From patchwork Mon Jan 6 09:27:20 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wolfram Sang X-Patchwork-Id: 13927099 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 496A9E7719D for ; Mon, 6 Jan 2025 09:27:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=NKebGb7XyGq/ylEOUSUcUsKdeDVW4xUI5cdXeYUzk7g=; b=sfN9cd2oBN33iT Vp0iM2OOFJ+n/6S6+Y2olh30DOa74VVbxMjwhdU3mP7Sqim0yNCDHCoTrYDPYFhKFWPTqtO5g/JeC Aw45f5RttJZZq5dx0CgUeJhSihRrK9XkuNF5Fja+QTPCj9H55AGkjrGkTHRVFLlvO4OCjV8wy5q/q nZ+Q7iTWSAEyNdcEoYKAOCW6X2bioSO/zSwYcgcJjgqYu+v2Ayg+RcjGbquZuSIMTjLSZgV4ZiIEL 7v5JG9FQ6gG6I7NtyQ8qCZ3A4Y8pwxsDSOfKBnBl5wv2xXcBTOqBZczvaz7MeFLK78qHP6UD9Lsdp 93t4biH/R5J6HwKS48og==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tUjOf-00000000gLE-0Ck7; Mon, 06 Jan 2025 09:27:41 +0000 Received: from zeus03.de ([194.117.254.33] helo=mail.zeus03.de) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1tUjOT-00000000gGv-3hLn for linux-i3c@lists.infradead.org; Mon, 06 Jan 2025 09:27:33 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= sang-engineering.com; h=from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; s=k1; bh=3esdoiFUb3AEevKBNMcpAJ6KfgvtuQ7LV32gNwqiGFg=; b=TPWk4N fPZcFA8m1Gjf3bWSln46VsZOp5vMeZKXNGqo+2aLWg5gfieLCa+BfBNX3ty3Ls7N E7GWKLWrww3BOUql2/X00NYG6maKN6aHoPkf64myWHYMdRgJBU1oFw1vJYxRdram XhLhz/Sx+LYpnzkxaySdxU6Fpn298bvr6wwxz0WIzu1EE84CpVdLjiS29QeRHxHg iugPAFkwqrAPQb5uIxAGNQJqoeDbPR+LxlNcD8VMOi8elZJ+VWtR0pYftGhS9PdK UQzmQ2hvi8ZH7RAGv61mzSOTG/Gs0VE/rbXkmQi89evDat94dqkWVdpmlmh1dRki a+M0i0qKYqzqgi+w== Received: (qmail 1727852 invoked from network); 6 Jan 2025 10:27:27 +0100 Received: by mail.zeus03.de with ESMTPSA (TLS_AES_256_GCM_SHA384 encrypted, authenticated); 6 Jan 2025 10:27:27 +0100 X-UD-Smtp-Session: l3s3148p1@/zGjPAYr4JsgAwDPXw20AOMQ2KO98fSH From: Wolfram Sang To: linux-i3c@lists.infradead.org Cc: linux-kernel@vger.kernel.org, linux-renesas-soc@vger.kernel.org, Wolfram Sang , Guenter Roeck , Geert Uytterhoeven , Kuan-Wei Chiu , Jean Delvare , linux-hwmon@vger.kernel.org Subject: [PATCH v3 2/5] hwmon: (spd5118) Use generic parity calculation Date: Mon, 6 Jan 2025 10:27:20 +0100 Message-ID: <20250106092725.22869-3-wsa+renesas@sang-engineering.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20250106092725.22869-1-wsa+renesas@sang-engineering.com> References: <20250106092725.22869-1-wsa+renesas@sang-engineering.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20250106_012730_809667_D8C9D97E X-CRM114-Status: UNSURE ( 8.37 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-i3c@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-i3c" Errors-To: linux-i3c-bounces+linux-i3c=archiver.kernel.org@lists.infradead.org Make use of the new generic helper for calculating the parity. Signed-off-by: Wolfram Sang Tested-by: Guenter Roeck Acked-by: Guenter Roeck Reviewed-by: Geert Uytterhoeven Reviewed-by: Kuan-Wei Chiu --- drivers/hwmon/spd5118.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/drivers/hwmon/spd5118.c b/drivers/hwmon/spd5118.c index 6cee48a3e5c3..358152868d96 100644 --- a/drivers/hwmon/spd5118.c +++ b/drivers/hwmon/spd5118.c @@ -291,12 +291,6 @@ static umode_t spd5118_is_visible(const void *_data, enum hwmon_sensor_types typ } } -static inline bool spd5118_parity8(u8 w) -{ - w ^= w >> 4; - return (0x6996 >> (w & 0xf)) & 1; -} - /* * Bank and vendor id are 8-bit fields with seven data bits and odd parity. * Vendor IDs 0 and 0x7f are invalid. @@ -304,7 +298,7 @@ static inline bool spd5118_parity8(u8 w) */ static bool spd5118_vendor_valid(u8 bank, u8 id) { - if (!spd5118_parity8(bank) || !spd5118_parity8(id)) + if (parity8(bank) == 0 || parity8(id) == 0) return false; id &= 0x7f;