From patchwork Fri Dec 20 11:29:55 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wolfram Sang X-Patchwork-Id: 13916628 X-Patchwork-Delegate: geert@linux-m68k.org Received: from mail.zeus03.de (zeus03.de [194.117.254.33]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C11991C5F22 for ; Fri, 20 Dec 2024 11:30:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=194.117.254.33 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734694233; cv=none; b=uApbtw79xrqUOGhPUx5cdprXnPLoR6uFcye2QcY5NKsJPEGwYQdh5gQuswncdLXErGdQ+Itdh4Y5BDg7CFKK8gUORdbv4dPSQH5a/1NZ115M0Ejb1AcCPrruewjIYK6qjjzehQe0uhHgZCqYery3C2/vfz2kVH+6AEbG1SXRkvM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734694233; c=relaxed/simple; bh=eqGHK14hiiHm06pTZF2RCIe0dz2FSZkRJZ81635i/Kg=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=WlNa09h9gac6sSO+dw0RXGmDfXfuUtintwY6bNDkJRxaIWUPims+5RMYNx9988s5wFca41qz4T+wBKSwLOV2I7YNQjq5D7VEVgOb5oVkisw5X87trECNNkbCg2hqvx87/K0IfAWlxopx0c/et2HOu9uSlbLO8UxY/DqnGoU9S+o= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=sang-engineering.com; spf=pass smtp.mailfrom=sang-engineering.com; dkim=pass (2048-bit key) header.d=sang-engineering.com header.i=@sang-engineering.com header.b=HG7IkTzX; arc=none smtp.client-ip=194.117.254.33 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=sang-engineering.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=sang-engineering.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=sang-engineering.com header.i=@sang-engineering.com header.b="HG7IkTzX" 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=uWx7Khj94+L0maCjBS9mNDc9rvpKoRkC0PwJFVrpB/4=; b=HG7IkT zXozOs/ChC8zGZ+i12XO18fIY3hnQc8eyHLWrtufHdJ8zDz5jSjdQKViFekG2KKX 8nSG5kAVJSsHUyGu4JeV2cWv+JPmWxYvvuAxz9GuhvzoL2hBwpEstwi9Fv4kzSj4 cB2HgfKUbEF0IZ6r2uFfJsIwau6C5y4Q4nTqq0QGNgZFy8MWAUvAMxPZga8+UMMs G4LEpc6XPAGuB+3sgDDL9ayg2VRX2p5K2vDMNhB4WZFCUk/C8stxEz3B0xzuEkyI oNtxyrEKJyOWRZrNx4noAY2RlKn5rSf4EEiD5rZv8BL8Vfw3RwNqybvtcwDPvMO2 v3MXz4+ubhLSbreA== Received: (qmail 989678 invoked from network); 20 Dec 2024 12:30:19 +0100 Received: by mail.zeus03.de with ESMTPSA (TLS_AES_256_GCM_SHA384 encrypted, authenticated); 20 Dec 2024 12:30:19 +0100 X-UD-Smtp-Session: l3s3148p1@bi+9+LEpXpAujnsY From: Wolfram Sang To: linux-renesas-soc@vger.kernel.org Cc: Yury Norov , Wolfram Sang , Guenter Roeck , Geert Uytterhoeven , Kuan-Wei Chiu , Rasmus Villemoes Subject: [PATCH RFT 1/5] bitops: add generic parity calculation for u8 Date: Fri, 20 Dec 2024 12:29:55 +0100 Message-Id: <20241220113000.17537-2-wsa+renesas@sang-engineering.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20241220113000.17537-1-wsa+renesas@sang-engineering.com> References: <20241220113000.17537-1-wsa+renesas@sang-engineering.com> Precedence: bulk X-Mailing-List: linux-renesas-soc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 There are multiple open coded implementations for getting the parity of a byte in the kernel, even using different approaches. Take the pretty efficient version from SPD5118 driver and make it generally available by putting it into the bitops header. As long as there is just one parity calculation helper, the creation of a distinct 'parity.h' header was discarded. Also, the usage of hweight8() for architectures having a popcnt instruction is postponed until a use case within hot paths is desired. The motivation for this patch is the frequent use of odd parity in the I3C specification and to simplify drivers there. Changes compared to the original SPD5118 version are the addition of kernel documentation, switching the return type from bool to int, and renaming the argument of the function. Signed-off-by: Wolfram Sang Tested-by: Guenter Roeck Reviewed-by: Geert Uytterhoeven Acked-by: Yury Norov Reviewed-by: Kuan-Wei Chiu Tested-by: Kuan-Wei Chiu --- include/linux/bitops.h | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/include/linux/bitops.h b/include/linux/bitops.h index ba35bbf07798..4ed430934ffc 100644 --- a/include/linux/bitops.h +++ b/include/linux/bitops.h @@ -229,6 +229,37 @@ static inline int get_count_order_long(unsigned long l) return (int)fls_long(--l); } +/** + * get_parity8 - get the parity of an u8 value + * @value: the value to be examined + * + * Determine the parity of the u8 argument. + * + * Returns: + * 0 for even parity, 1 for odd parity + * + * Note: This function informs you about the current parity. Example to bail + * out when parity is odd: + * + * if (get_parity8(val) == 1) + * return -EBADMSG; + * + * If you need to calculate a parity bit, you need to draw the conclusion from + * this result yourself. Example to enforce odd parity, parity bit is bit 7: + * + * if (get_parity8(val) == 0) + * val |= BIT(7); + */ +static inline int get_parity8(u8 val) +{ + /* + * One explanation of this algorithm: + * https://funloop.org/codex/problem/parity/README.html + */ + val ^= val >> 4; + return (0x6996 >> (val & 0xf)) & 1; +} + /** * __ffs64 - find first set bit in a 64 bit word * @word: The 64 bit word From patchwork Fri Dec 20 11:29:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wolfram Sang X-Patchwork-Id: 13916626 X-Patchwork-Delegate: geert@linux-m68k.org Received: from mail.zeus03.de (zeus03.de [194.117.254.33]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C10B81C5F12 for ; Fri, 20 Dec 2024 11:30:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=194.117.254.33 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734694231; cv=none; b=pvmzwFJ+OK3lkjGLiEk/S/paHeWz4Uxum00ZcfFYQX37C0zrpCOCe55PMSjp06kyMwtZkWwuWH7+yOk8xaLSRXyfefe0gh/38uYYA6J6se3IRWqwUB7vuRmnf6g68/6jmrEbWZoODz/k1vYn1Ga5bKL9vgTnMeznzDLpsNPBvzQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734694231; c=relaxed/simple; bh=wLie45FQJjevoqTvATT1Bwc7/Ik+763kNu0o5MBnW6o=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=tNEYX63tYQnV0OoKEi1AzU74rKit4CxwNxNILa+8E2d3Ye28b1/jjCWLhrnKJFlizPHc6mkvrN0ABi6RUpB/0scQ4iWozktHxSQR/HYw5qahL7GPMR+cJYMO3WRoywHoOYjIf9/6J3Vtjm1fc6smYy+GPOVvehcMnPH/KG3NzFc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=sang-engineering.com; spf=pass smtp.mailfrom=sang-engineering.com; dkim=pass (2048-bit key) header.d=sang-engineering.com header.i=@sang-engineering.com header.b=asJFXhRs; arc=none smtp.client-ip=194.117.254.33 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=sang-engineering.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=sang-engineering.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=sang-engineering.com header.i=@sang-engineering.com header.b="asJFXhRs" 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=7urdFe4hc0mW5T0rNDU1jZWJ1H72Kr3Yh3vXW+VAdRs=; b=asJFXh RsolHAL7/ixEyPnyfszqd0gs0UyZhTnTcglfgwvcuOwri5BhHiK5oyKANkkZ5qL7 Ufot87xiJQbhl6J6bQMOSGCsmGw9IjIGq3tETtLd9Ko6xVrCVAQHuH3CTjbH9l/I 4rsuZHkIzhsWwZ5gdO98vxSJG4qZMlMOLWZLz8RTFbs4elg3EE6eeRpULXvnv4GV GDWOulYA3jOF1v9pyr4e26ab4KbaoK9NSBI/TlO6Rpepg3e0L1ia1U5kzDP4nZkQ mXEhzLkYySRAxnQMUSzzy0eLHY7jhn9mhZ0BECit4OsPmiQwTaPPtDPR1aaDfpb5 4d3Bp1UMlJpIR/QQ== Received: (qmail 989714 invoked from network); 20 Dec 2024 12:30:20 +0100 Received: by mail.zeus03.de with ESMTPSA (TLS_AES_256_GCM_SHA384 encrypted, authenticated); 20 Dec 2024 12:30:20 +0100 X-UD-Smtp-Session: l3s3148p1@YFHG+LEpCJ8ujnsY From: Wolfram Sang To: linux-renesas-soc@vger.kernel.org Cc: Yury Norov , Wolfram Sang , Guenter Roeck , Geert Uytterhoeven , Kuan-Wei Chiu , Jean Delvare , linux-hwmon@vger.kernel.org Subject: [PATCH RFT 2/5] hwmon: (spd5118) Use generic parity calculation Date: Fri, 20 Dec 2024 12:29:56 +0100 Message-Id: <20241220113000.17537-3-wsa+renesas@sang-engineering.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20241220113000.17537-1-wsa+renesas@sang-engineering.com> References: <20241220113000.17537-1-wsa+renesas@sang-engineering.com> Precedence: bulk X-Mailing-List: linux-renesas-soc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Make use of the new generic helper for calculating the parity. Signed-off-by: Wolfram Sang Tested-by: Guenter Roeck Reviewed-by: Geert Uytterhoeven Reviewed-by: Kuan-Wei Chiu Acked-by: Guenter Roeck --- 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..07ab3a47b00c 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 (get_parity8(bank) == 0 || get_parity8(id) == 0) return false; id &= 0x7f; From patchwork Fri Dec 20 11:29:57 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wolfram Sang X-Patchwork-Id: 13916625 X-Patchwork-Delegate: geert@linux-m68k.org Received: from mail.zeus03.de (zeus03.de [194.117.254.33]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 817ED1C5F03 for ; Fri, 20 Dec 2024 11:30:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=194.117.254.33 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734694231; cv=none; b=ub26slQMZtq1iRhU3DYLKnS4opHpv4ENPAl9M4g3wrU6Yopp4OPete3hq5EDVI/HBpvLHgWNstgVu7iSdf350UyXOwh9BahjSc75/s0vIJaPlKS/es6bmrXPqOkOlQgbJgE0l4FCq8eUnp6aan1CIo4f/PofCoTUvbjSZG76NmI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734694231; c=relaxed/simple; bh=+r130rckWcX6jYdn+Ln3jDvzy6JOxhEl+3WKkuSt1qw=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=n/lJXNIRgBQJexpAZC7tB39rFXXEnRrNg5MiWEbyjkeVNFwXgOjRKTdCfzATIPUPPbKSoHs1VYnrwtF1g7hlaC2NpMwuk+NFsfzS2KwyJ4tOqsiu9w9krgrDvusfPoUDNWjGHkqqahAxZkbu6TTCyvdhrtAxtXV+5voo9zY0tFA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=sang-engineering.com; spf=pass smtp.mailfrom=sang-engineering.com; dkim=pass (2048-bit key) header.d=sang-engineering.com header.i=@sang-engineering.com header.b=kwlhKMAN; arc=none smtp.client-ip=194.117.254.33 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=sang-engineering.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=sang-engineering.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=sang-engineering.com header.i=@sang-engineering.com header.b="kwlhKMAN" 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=JTVYffu7bObqCnm7BryRbyhmBYXN9UAwW1f5OWePOno=; b=kwlhKM AN3DbBvDjh703OIGKen6f2vvMi0WWJR+pV3xIf5N3tjLc9GN9hrflnww6AKhLtR3 tuhnlxFnb0DP2HEe/ikJMnYxuSCZNYnpEZiro5fm1+goDLf7Lqt8xypxv08XWBeD b1XMWwe/3ktGrHppyVnBW+MI0ysPYkJ43l68koEe2dJkHfqzV0d/hO93Rtsa3AaW GSWPE23CNwgiLT/F33nTB4oSTuuWRnr/PEJmFN+ZXjwfixpXwobiOi+RjVEDyGrL voVKiW2CXx1KRcO7AmEzxkqOScfV9Gr/xipmdPj9nQB3PLk7mWknVJQ+j7QzVrA2 pKn7FyPtdx3tf85g== Received: (qmail 989755 invoked from network); 20 Dec 2024 12:30:20 +0100 Received: by mail.zeus03.de with ESMTPSA (TLS_AES_256_GCM_SHA384 encrypted, authenticated); 20 Dec 2024 12:30:20 +0100 X-UD-Smtp-Session: l3s3148p1@NOjP+LEpDJ8ujnsY From: Wolfram Sang To: linux-renesas-soc@vger.kernel.org Cc: Yury Norov , Wolfram Sang , Alexandre Belloni , linux-i3c@lists.infradead.org Subject: [PATCH RFT 3/5] i3c: dw: use get_parity8 helper instead of open coding it Date: Fri, 20 Dec 2024 12:29:57 +0100 Message-Id: <20241220113000.17537-4-wsa+renesas@sang-engineering.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20241220113000.17537-1-wsa+renesas@sang-engineering.com> References: <20241220113000.17537-1-wsa+renesas@sang-engineering.com> Precedence: bulk X-Mailing-List: linux-renesas-soc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 The kernel has now a generic helper for getting parity with easier to understand semantics. Make use of it. Signed-off-by: Wolfram Sang --- drivers/i3c/master/dw-i3c-master.c | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/drivers/i3c/master/dw-i3c-master.c b/drivers/i3c/master/dw-i3c-master.c index d4b80eb8cecd..a6d7fade5007 100644 --- a/drivers/i3c/master/dw-i3c-master.c +++ b/drivers/i3c/master/dw-i3c-master.c @@ -251,14 +251,6 @@ struct dw_i3c_i2c_dev_data { struct i3c_generic_ibi_pool *ibi_pool; }; -static u8 even_parity(u8 p) -{ - p ^= p >> 4; - p &= 0xf; - - return (0x9669 >> p) & 1; -} - static bool dw_i3c_master_supports_ccc_cmd(struct i3c_master_controller *m, const struct i3c_ccc_cmd *cmd) { @@ -848,7 +840,7 @@ static int dw_i3c_master_daa(struct i3c_master_controller *m) struct dw_i3c_xfer *xfer; struct dw_i3c_cmd *cmd; u32 olddevs, newdevs; - u8 p, last_addr = 0; + u8 last_addr = 0; int ret, pos; ret = pm_runtime_resume_and_get(master->dev); @@ -873,9 +865,9 @@ static int dw_i3c_master_daa(struct i3c_master_controller *m) } master->devs[pos].addr = ret; - p = even_parity(ret); last_addr = ret; - ret |= (p << 7); + + ret |= get_parity8(ret) ? 0 : BIT(7); writel(DEV_ADDR_TABLE_DYNAMIC_ADDR(ret), master->regs + From patchwork Fri Dec 20 11:29:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wolfram Sang X-Patchwork-Id: 13916623 X-Patchwork-Delegate: geert@linux-m68k.org Received: from mail.zeus03.de (zeus03.de [194.117.254.33]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 818411C5F04 for ; Fri, 20 Dec 2024 11:30:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=194.117.254.33 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734694231; cv=none; b=B2KWZvkrCuWJz3ByK33zsD0ckgJG0/UIj5vzzAz1TKg8JitNIw1e/WO1iR6VdFS7gP5+T1En62RV0i1tgq1PeIkIxFr0a/jKU9a61cAWZCzxRidFfnqqFB8pzMsT93+5dMZOTDHmdT9qzQ31s7KTXmMammBNde+aQ0hV9o01m5c= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734694231; c=relaxed/simple; bh=gpNBkc6doeMy4/aCPzNDJIb9seFsCsIEDoGkRZbmb8I=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=M/L82hSOdFam6H6lPWykdoeBh6V8Oc17RuKQPJ1O0pRLMANIPhZxsJKNanGQJdwspfQCyX+K99UWlzCC05i8XOoZwlz20O/W47qJEgWGNrI+9xncA+PzrAc/Ephdb6+hnSz6aNWnbIxExLdB2HxhsoxWe8s9OA+HxRllywtMDkk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=sang-engineering.com; spf=pass smtp.mailfrom=sang-engineering.com; dkim=pass (2048-bit key) header.d=sang-engineering.com header.i=@sang-engineering.com header.b=JOr2yzBe; arc=none smtp.client-ip=194.117.254.33 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=sang-engineering.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=sang-engineering.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=sang-engineering.com header.i=@sang-engineering.com header.b="JOr2yzBe" 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=Xle8vB4tioG0noyMlph488LEaOgkNcMUcx711tLKtDQ=; b=JOr2yz Bexm47v5wzeQCPJkhwFqqlSDLpwbGjsiluD1HliWQfq2s3ASnD3OrtYNFs9TYOfK 1AbIdgV7i7LYE1beaRVYp01FMENsAoub5s3Ra5NY5uvqSt1cGKxAougsbP3imU4W 7SIvCceCuOixvH/Iq8i3rnzoe3gMdHdQI6ScogMnh29/7pQ4aPvtOab/LtnrT7eN 6i1p5ZoZGgbNoGNSg3xEOy2OXsfr1V+/jHjgcc7QVXOvDO6RREIphnOaljWOA+SI eheErQwvQ2M853ESFoJcU72+OuJnMsTJw0tz1IIpS4RXoPiAt2nkIyfxUl9SXeC+ FxtEtIqFhfIwUNLA== Received: (qmail 989787 invoked from network); 20 Dec 2024 12:30:21 +0100 Received: by mail.zeus03.de with ESMTPSA (TLS_AES_256_GCM_SHA384 encrypted, authenticated); 20 Dec 2024 12:30:21 +0100 X-UD-Smtp-Session: l3s3148p1@cA/Z+LEpEJ8ujnsY From: Wolfram Sang To: linux-renesas-soc@vger.kernel.org Cc: Yury Norov , Wolfram Sang , Alexandre Belloni , linux-i3c@lists.infradead.org Subject: [PATCH RFT 4/5] i3c: mipi-i3c-hci: use get_parity8 helper instead of open coding it Date: Fri, 20 Dec 2024 12:29:58 +0100 Message-Id: <20241220113000.17537-5-wsa+renesas@sang-engineering.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20241220113000.17537-1-wsa+renesas@sang-engineering.com> References: <20241220113000.17537-1-wsa+renesas@sang-engineering.com> Precedence: bulk X-Mailing-List: linux-renesas-soc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 The kernel has now a generic helper for getting parity with easier to understand semantics. Make use of it. Signed-off-by: Wolfram Sang --- drivers/i3c/master/mipi-i3c-hci/dat_v1.c | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/drivers/i3c/master/mipi-i3c-hci/dat_v1.c b/drivers/i3c/master/mipi-i3c-hci/dat_v1.c index 47b9b4d4ed3f..ac67016932b0 100644 --- a/drivers/i3c/master/mipi-i3c-hci/dat_v1.c +++ b/drivers/i3c/master/mipi-i3c-hci/dat_v1.c @@ -40,15 +40,6 @@ #define dat_w0_write(i, v) writel(v, hci->DAT_regs + (i) * 8) #define dat_w1_write(i, v) writel(v, hci->DAT_regs + (i) * 8 + 4) -static inline bool dynaddr_parity(unsigned int addr) -{ - addr |= 1 << 7; - addr += addr >> 4; - addr += addr >> 2; - addr += addr >> 1; - return (addr & 1); -} - static int hci_dat_v1_init(struct i3c_hci *hci) { unsigned int dat_idx; @@ -123,7 +114,7 @@ static void hci_dat_v1_set_dynamic_addr(struct i3c_hci *hci, dat_w0 = dat_w0_read(dat_idx); dat_w0 &= ~(DAT_0_DYNAMIC_ADDRESS | DAT_0_DYNADDR_PARITY); dat_w0 |= FIELD_PREP(DAT_0_DYNAMIC_ADDRESS, address) | - (dynaddr_parity(address) ? DAT_0_DYNADDR_PARITY : 0); + (get_parity8(address) ? 0 : DAT_0_DYNADDR_PARITY); dat_w0_write(dat_idx, dat_w0); } From patchwork Fri Dec 20 11:29:59 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wolfram Sang X-Patchwork-Id: 13916624 X-Patchwork-Delegate: geert@linux-m68k.org Received: from mail.zeus03.de (zeus03.de [194.117.254.33]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8EC6E1C5CDC for ; Fri, 20 Dec 2024 11:30:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=194.117.254.33 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734694231; cv=none; b=fhSwl25KPcZf1A2skszb4HPd2LPRSVv8TcLJP2VlnJhAIdQb9SMYmpRjZqTc94KlIVthetqYeP8P3fdNSLN0PBnb2wHXoJCbaw3hFkU7ZxtE8/nLXBovusLNNHOM2FcJenQacipZaiuAPF3Tcp4BzacbBGkCYTfwrQj8W/gd3Z8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734694231; c=relaxed/simple; bh=nuc0RZ7/2GFIN6GG8WZzbZFnq0y+SsYQBbRS2ZzaVq4=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Wf6UaK8i3vXStU9JiP/zlUba6Axs6OIZORwjG1P9hujkuUXhWa95J+VFj2k/XSHQcTkiTPTJ+gxxD5Ew1b7D3XUbCNiwF2x4sZzAK6nHx4fO9aIV7lAVzaHov5XqbGDURlWS8CFyECkQtJcI4Zdrf2ySY1BnRFUn1xneB/ZIQBE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=sang-engineering.com; spf=pass smtp.mailfrom=sang-engineering.com; dkim=pass (2048-bit key) header.d=sang-engineering.com header.i=@sang-engineering.com header.b=Rfb4poHg; arc=none smtp.client-ip=194.117.254.33 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=sang-engineering.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=sang-engineering.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=sang-engineering.com header.i=@sang-engineering.com header.b="Rfb4poHg" 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=rsDE8URaHTqtvoHB8Si3sxcYn73y38+s7yQFTYbHb2I=; b=Rfb4po HgqpyesKVuDDivS2ZFzUzRwZK7+gL8A5R6A6xlwpQ6wO5eid5OpOVKmeuteAdAl3 Sg9fLQ+khYWj8Q3wWPByxRFDBN5B3Npg7pAo+KTFkxgjFY5fmJXfXx72bPPVG/Kg T+d8/T4ORf2/PtY+mNYgA2oHQ38RpqjBxrBT03witTgpNw4y2xJRENMuDv5Wky3E spD/IaJAr/j0iLFYkle6O7IVQiJJIFcYL+Etv/YZEhREjqjTEq4ktJ8p3LgphRkJ 2WY4UP07xLe/3PG9Dkdx7rTNxaOm6ROoB5wJK80/exqzLJsWfFU4JHXKvW+uOYPh iIO6DsADxkxy5T3g== Received: (qmail 989817 invoked from network); 20 Dec 2024 12:30:22 +0100 Received: by mail.zeus03.de with ESMTPSA (TLS_AES_256_GCM_SHA384 encrypted, authenticated); 20 Dec 2024 12:30:22 +0100 X-UD-Smtp-Session: l3s3148p1@I5Pi+LEpFp8ujnsY From: Wolfram Sang To: linux-renesas-soc@vger.kernel.org Cc: Yury Norov , Wolfram Sang , =?utf-8?q?Przemys=C5=82aw_?= =?utf-8?q?Gaj?= , Alexandre Belloni , linux-i3c@lists.infradead.org Subject: [PATCH RFT 5/5] i3c: cdns: use get_parity8 helper instead of open coding it Date: Fri, 20 Dec 2024 12:29:59 +0100 Message-Id: <20241220113000.17537-6-wsa+renesas@sang-engineering.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20241220113000.17537-1-wsa+renesas@sang-engineering.com> References: <20241220113000.17537-1-wsa+renesas@sang-engineering.com> Precedence: bulk X-Mailing-List: linux-renesas-soc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 The kernel has now a generic helper for getting parity with easier to understand semantics. Make use of it. Signed-off-by: Wolfram Sang --- Can't the '& 0x7f' be left out here? drivers/i3c/master/i3c-master-cdns.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/i3c/master/i3c-master-cdns.c b/drivers/i3c/master/i3c-master-cdns.c index 06c0592487d3..abeef6f70b53 100644 --- a/drivers/i3c/master/i3c-master-cdns.c +++ b/drivers/i3c/master/i3c-master-cdns.c @@ -889,8 +889,7 @@ static u32 prepare_rr0_dev_address(u32 addr) ret |= (addr & GENMASK(9, 7)) << 6; /* RR0[0] = ~XOR(addr[6:0]) */ - if (!(hweight8(addr & 0x7f) & 1)) - ret |= 1; + ret |= get_parity8(addr & 0x7f) ? 0 : BIT(0); return ret; }