From patchwork Sun Dec 29 10:12:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wolfram Sang X-Patchwork-Id: 13922640 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 692F986346 for ; Sun, 29 Dec 2024 10:12:43 +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=1735467169; cv=none; b=bFqhzWo2C4CjM9VbuNhsE1cuwxzzrL9kdJYsJ6AiPb7bO345kjkyXKhgL1eZQ+YI9GDHDgLEcGOOdQgrr1Uk1F66vE1vlGMJZ9/+PGk+u/6r1FLNK3cw3T2RpukLA4LuY55VLqaKCaBodGArfWkiGX2zM2BB9bJmnmn/e3yK50k= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735467169; c=relaxed/simple; bh=O9CYMB0lO17RuiwpnK2GfLz07nkd/+OcaZhmBRSW0S0=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=ZUMKpdOwe4ql2trU3B5L9Ge55sGiZ3Ntw+vthungk998PZZonjVyeP4yEgsUqH5m1GO8r/c/cMdu+MmqWEOkzVgLg21j18r9PBHlgQuE3V2d6afqeSjiBQEQ4ZDfK3FsBcId117KZYE5h3AEjMwYGns/GbUawPg63Riyir4UFeY= 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=dijRjoAD; 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="dijRjoAD" 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=plWvPVApWRSIQ2OhiRlGaz0MEdpViJLDsoLZ/6lDlDA=; b=dijRjo ADdThNVTeq3XMcZlByKGXwrUpaKcK4vencvoye8hwie4arvk6Yi5b2AtUjpo9Q+T 0070rb8XEYsy1mx+5EMMtMzhHFKVF8dfJQlTqh4p8S1w+IDDKyz3J6a0g8Uk7WEf qmkVK5ebgrZhBhalI68fBxs1hw4/fJp9H+o27AUiF1aCA2rOrQxhZEJ31WZGZRG9 P3uoBNZcaYAzrp1bMRzrcMAfSGl4MPcK1qoHEuKUiXFSllf+CKJB7J5BesJ6lsIE Me9IV4OWNsVjDoLex9+u+IKvaEBUIiuEyJJ7DRGxCYQ5WNSAa27/ovtC6m6Z+yYI 1GYe0d/HUwLdy/Cg== Received: (qmail 3656632 invoked from network); 29 Dec 2024 11:12:36 +0100 Received: by mail.zeus03.de with ESMTPSA (TLS_AES_256_GCM_SHA384 encrypted, authenticated); 29 Dec 2024 11:12:36 +0100 X-UD-Smtp-Session: l3s3148p1@T5td72UqgrEujnsY From: Wolfram Sang To: linux-i3c@lists.infradead.org Cc: linux-kernel@vger.kernel.org, linux-renesas-soc@vger.kernel.org, Rasmus Villemoes , Wolfram Sang , Guenter Roeck , Geert Uytterhoeven , Yury Norov , Kuan-Wei Chiu Subject: [PATCH RFT v2 1/5] bitops: add generic parity calculation for u8 Date: Sun, 29 Dec 2024 11:12:29 +0100 Message-Id: <20241229101234.2896-2-wsa+renesas@sang-engineering.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20241229101234.2896-1-wsa+renesas@sang-engineering.com> References: <20241229101234.2896-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 --- Changes since v1: * renamed from 'get_parity8' to 'parity8' * use XOR instead of OR in the kdoc example (Thanks, Rasmus, for both) * rebased to 6.13-rc4 include/linux/bitops.h | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/include/linux/bitops.h b/include/linux/bitops.h index ba35bbf07798..c1cb53cf2f0f 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); } +/** + * 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 (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 (parity8(val) == 0) + * val ^= BIT(7); + */ +static inline int 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 Sun Dec 29 10:12:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wolfram Sang X-Patchwork-Id: 13922637 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 BE9AA86355 for ; Sun, 29 Dec 2024 10:12:44 +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=1735467168; cv=none; b=TEGKKDz4dDaxLv7lV3DMAuo5lofUslD3ltjv/vdLrUcIyrRV54kMML/4nuOlB9tDyT/TGXl0yYeecg1iTTfv3/oUb6IFqjpzY81vfswLz0KlgEH3pl51WU2Wc7Yt3KatnwWZLwP/GLe2kNdG+cJAtE/zQAUZrenMwAsxzMKZZG4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735467168; c=relaxed/simple; bh=v22f0loiNwAuiMzdHCIr0vy7Rq85k5BvrrfF+boD7Xg=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=G7j5B9dBzNLRKhdS9iwoyAuwI04z2gbjEpksyAEtZGghYyShWMoBe0FL+yn5MNFtgxb5k58fFrBVpwOJ9NOvDI1qFXtwDqvGpAKh7i5aM0kHJ41DSu8O55oRdmEfOPKTcCVtdapqdMTREYPCgsBzIXAzWaOONVR3fiEjxatAGws= 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=XigPu+vK; 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="XigPu+vK" 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=G6kjFPdUe1j2cdg63XDSQh38HU3Hz3YIpXujxIBwTkE=; b=XigPu+ vK9Pm9D6f0m9k8kozSFU3T5K5XAAUzC26cxSpb0c9t7dELQR+obbJ9Huf/vJW8NW I3+YlWioX3ABGVClKJxu6LL7xg60LDdXCCVJ/E69ntTLxRt4IzP1qIySBModBGBC 3makzX9s5MFOgLEF83OnKWydHy+6rkN8g7Opp+Y7LiivI5/D1kImYNqFVwlgwG/L jgPgL7N2Kmy3kBfjbUlvOZodrMv+0+mioaEMYqUNbw7UUJs5hIImJk9vcIOX3d4N hP1Vhf5EC2kuhig2S3aOKQBJwtJzpOoQDjypLMZZoYL+hgBLQ6f7NOo4bGUxV1nM EGZbPEUxgk1VTGUA== Received: (qmail 3656676 invoked from network); 29 Dec 2024 11:12:37 +0100 Received: by mail.zeus03.de with ESMTPSA (TLS_AES_256_GCM_SHA384 encrypted, authenticated); 29 Dec 2024 11:12:37 +0100 X-UD-Smtp-Session: l3s3148p1@qSNn72UqjLEujnsY From: Wolfram Sang To: linux-i3c@lists.infradead.org Cc: linux-kernel@vger.kernel.org, linux-renesas-soc@vger.kernel.org, Rasmus Villemoes , Wolfram Sang , Guenter Roeck , Geert Uytterhoeven , Kuan-Wei Chiu , Jean Delvare , linux-hwmon@vger.kernel.org Subject: [PATCH RFT v2 2/5] hwmon: (spd5118) Use generic parity calculation Date: Sun, 29 Dec 2024 11:12:30 +0100 Message-Id: <20241229101234.2896-3-wsa+renesas@sang-engineering.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20241229101234.2896-1-wsa+renesas@sang-engineering.com> References: <20241229101234.2896-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 Acked-by: Guenter Roeck Reviewed-by: Geert Uytterhoeven Reviewed-by: Kuan-Wei Chiu --- Changes since v1: * renamed from 'get_parity8' to 'parity8' * added tag from Guenter (thanks!) * rebased to 6.13-rc4 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; From patchwork Sun Dec 29 10:12:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wolfram Sang X-Patchwork-Id: 13922639 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 989D412DD8A for ; Sun, 29 Dec 2024 10:12:45 +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=1735467169; cv=none; b=hrVLMAbR/1mz6aNN9AiJpR/UK28m8Het2P6AHnCD1MuNEt1bjaZ0gSVUHP/1rGFgjWGzaqiSOmBlzZl8QV0mSyatsCEE5HMPxCOpTPX5FUrl87iaDLiEPZDS/iglG8QA1kNuonkakmLNjecQ4/pLm72yEWy3wpywpTtnux5BqVc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735467169; c=relaxed/simple; bh=mIeRqhDuiwHFKlnukfjGYt2UKBf196i9hF58Gak8iD4=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=NfGHpw6TYsnYY9hvxBrsmrlitXFeOBBeHJrFinAb7E9ydLEafjZXH4n4Q7JZOOBeNFoVY5X98rGMhZLU17fn+YGTMU2vJUwyKxPKufBt3tvdhQ0MEiO5V2WBUmX/60o3Bf/F9BCE6qxwrf1EkLAz+p58NMRu2dvegXuUHQpp+tU= 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=M6oPC6Gt; 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="M6oPC6Gt" 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=HcEn4SC6k8TM3B5gnzbEg5duKt2BAHa6/yH+isc0eiY=; b=M6oPC6 GtxOju2Rp23MsXuWEpjI0wp0wTTuPQ8qVd4iki1LoP4TYeSG65Uirmt7AIxPR/rj VSr/nmQ6eEb3ry3J0ztf97z5zXzdfdqvaSE7r/R9YSQA+bElRNGH3lNUdKZllN2G SAHEdZWO/UcY48+JMliB+JeGnl99jUx/BEV19sjS+jLQPYdzw5te4egVqD5Zc9ED cSFRerfJCulX/HdSNceXyOIfeaB4aC1ecLaUDkga7kTD4gdYkkVM7SOwrOHvL1jI bc6z653Vpr3iKaj8XnrTiotj99+DRn+QJNJr9513R8nxpb4I/rGh7vDveTPX7Ivy JoSK/ce3JKSCqqzQ== Received: (qmail 3656724 invoked from network); 29 Dec 2024 11:12:37 +0100 Received: by mail.zeus03.de with ESMTPSA (TLS_AES_256_GCM_SHA384 encrypted, authenticated); 29 Dec 2024 11:12:37 +0100 X-UD-Smtp-Session: l3s3148p1@mkFx72UqmLEujnsY From: Wolfram Sang To: linux-i3c@lists.infradead.org Cc: linux-kernel@vger.kernel.org, linux-renesas-soc@vger.kernel.org, Rasmus Villemoes , Wolfram Sang , Alexandre Belloni Subject: [PATCH RFT v2 3/5] i3c: dw: use get_parity8 helper instead of open coding it Date: Sun, 29 Dec 2024 11:12:31 +0100 Message-Id: <20241229101234.2896-4-wsa+renesas@sang-engineering.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20241229101234.2896-1-wsa+renesas@sang-engineering.com> References: <20241229101234.2896-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 --- Changes since v1: * renamed from 'get_parity8' to 'parity8' * rebased to 6.13-rc4 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..0d4d44458c11 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 |= parity8(ret) ? 0 : BIT(7); writel(DEV_ADDR_TABLE_DYNAMIC_ADDR(ret), master->regs + From patchwork Sun Dec 29 10:12:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wolfram Sang X-Patchwork-Id: 13922642 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 3C3DE137932 for ; Sun, 29 Dec 2024 10:12:46 +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=1735467170; cv=none; b=bsIz62RwNeB2hfBz8srbX5pfKSxlww1ESWNu4KA7efF/lZZYhDIZQY0PpfvcrmmxXBtpwafOuhco0d+HTeR5rwoS+1XRBl6nyo39hUymHsovtXGmun3FJ8UocrSUT5t9Uvv/3hHOW8STvHiWPiTtpXu9b09zBQA/mrlbhwGgDkE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735467170; c=relaxed/simple; bh=Y3Cc22NIQeBiPQ/ptXbRKHRxI+NhYF4Z9JcoAKhf2NA=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=S1hm3c/Ql27UNdd2G/fsVJu1uxYdvs6Wotqugt/uHCbEW5iB1ZAm/sMgchBcBA7LFftd8b4wKzoAzGEo98cSP43T6Gjd5aKiv/wa/PWsyzU36Tr1Z5f574SrQ+oqYkT2q6gY0zgFVtITZ7ydo3Sp49ZeqJDKSdFJku63wv/Finc= 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=enQzPRR3; 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="enQzPRR3" 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=3dWsyI2fhnNRuJtDWw143uSamr17n+7uryQ9yHPh310=; b=enQzPR R3ZWxa4oEBsfz1GK0QIsytd1MqCogF1CFBGcGfKaZSfeAcBj6GjkryWe8fJyXyAs kpkxlj7qPNIwuXeaYKNCpQjkhmn+arykPWPRIzpz7Gw8kQRo3Vlib9WUmndFvflT FTodw9v3HaSxfvuwzwI6e1Kr2B827k/vxUak5iuBW6UwsIqa3kEzDyCYoR50OYsB oNQZZWY2b8jGp0ak13g4VqGIobTudlOLH9KKKFcmEtRCM+9LTVcGApqb//yn7v/r vgkcNpWVOMj/RekqjCPGyxPDnYiEwCki/qS1or0fdfDQqwSfqiZd+CFC/DecenSG mmBijsEU8fxWDVhg== Received: (qmail 3656752 invoked from network); 29 Dec 2024 11:12:38 +0100 Received: by mail.zeus03.de with ESMTPSA (TLS_AES_256_GCM_SHA384 encrypted, authenticated); 29 Dec 2024 11:12:38 +0100 X-UD-Smtp-Session: l3s3148p1@ilN772UqqLEujnsY From: Wolfram Sang To: linux-i3c@lists.infradead.org Cc: linux-kernel@vger.kernel.org, linux-renesas-soc@vger.kernel.org, Rasmus Villemoes , Wolfram Sang , Alexandre Belloni Subject: [PATCH RFT v2 4/5] i3c: mipi-i3c-hci: use get_parity8 helper instead of open coding it Date: Sun, 29 Dec 2024 11:12:32 +0100 Message-Id: <20241229101234.2896-5-wsa+renesas@sang-engineering.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20241229101234.2896-1-wsa+renesas@sang-engineering.com> References: <20241229101234.2896-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 Tested-by: Jarkko Nikula --- Changes since v1: * renamed from 'get_parity8' to 'parity8' * rebased to 6.13-rc4 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..85c4916972e4 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); + (parity8(address) ? 0 : DAT_0_DYNADDR_PARITY); dat_w0_write(dat_idx, dat_w0); } From patchwork Sun Dec 29 10:12:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wolfram Sang X-Patchwork-Id: 13922641 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 6FA8C13C914 for ; Sun, 29 Dec 2024 10:12:48 +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=1735467170; cv=none; b=OOpkNcVThlCswbCjdQ7pOKITN1SZh7sYqfoWjDspAvIYL6YdX5iejdWhKzFjnmujIKhNiTyirfWB6CIIVqKstBvw5Dt83RPci6gCl3qeWERytFTwHfo81bOfBuz04qRMjXwTg+Hw6B3Vcemd+C0JyBqNJy4hSbX85MQz0tGqpHQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735467170; c=relaxed/simple; bh=UJO9Wig/mq0HYbVQ/7InT45fcHvTZoo1GM3kp2C6elw=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=dE2aZGdlQ4tpMTtClRRf3xplMic3A1uRrwx+Qva9FPrnHW+z4vecn60hEGg7K0ucOT69jiBhEEpbAGGeiXbF0kgqTUwE1AeiESkqZOhh7C6g7tfAMe0CQskBkQFBhMPp/cXFfnXQWK/+SwWh89lX1PDfDVXLgckrNt+oF0oCaac= 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=j+NbuKnH; 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="j+NbuKnH" 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=2KA7hCNfCHGJ3bQ72rfcY2S2+sqyqP8iXHnm5KhmB1w=; b=j+NbuK nHFFnXj2Buk7ny77kDCnyJr4CiJIVLlIJTJECcVPJx3yxjP9uqYymNSEWjgMvHZ9 wfSRch8zu9CDPWWyFbo6eSZdJ8s3no+8RNMGYMCsjO7nBDA6nw2fZJt/6c1hqDWR L/oPBkXlLCH/8z6So+iyDcukcmqW4ZxEUvOfedJHnVfpqurlKgJb2+6mb936azst shgdQOyhlJJ74qx76hVu4eF5YWA6W70eSxCdv4fNg3cDOrzYiEkJ+oRIL2WAWp4h 1cRxW59DjtuaBB0PnhjYBBgQN1IItAZAOIewsgXNFCxCTJDKFGz+DqjIxMwSCtdv nAL71FubWrdxWwrA== Received: (qmail 3656777 invoked from network); 29 Dec 2024 11:12:38 +0100 Received: by mail.zeus03.de with ESMTPSA (TLS_AES_256_GCM_SHA384 encrypted, authenticated); 29 Dec 2024 11:12:38 +0100 X-UD-Smtp-Session: l3s3148p1@e8CD72Uqle8ujnsY From: Wolfram Sang To: linux-i3c@lists.infradead.org Cc: linux-kernel@vger.kernel.org, linux-renesas-soc@vger.kernel.org, Rasmus Villemoes , Wolfram Sang , =?utf-8?q?Przemys=C5=82aw_?= =?utf-8?q?Gaj?= , Alexandre Belloni Subject: [PATCH RFT v2 5/5] i3c: cdns: use get_parity8 helper instead of open coding it Date: Sun, 29 Dec 2024 11:12:33 +0100 Message-Id: <20241229101234.2896-6-wsa+renesas@sang-engineering.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20241229101234.2896-1-wsa+renesas@sang-engineering.com> References: <20241229101234.2896-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 --- Changes since v1: * renamed from 'get_parity8' to 'parity8' * rebased to 6.13-rc4 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..fedbe6624a1c 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 |= parity8(addr & 0x7f) ? 0 : BIT(0); return ret; }