From patchwork Fri Dec 20 11:33: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: 13916640 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 407AAE7718B for ; Fri, 20 Dec 2024 11:33: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=tw5h6rXmBE6DzwemmJ/aKA2rPmnVHj0Tqpck1dEzZMc=; b=PJJX0Af8TOOrRi 9u9HMbAdn6npxJWPDeMCfQnynNuN2FtB4f33LrGltwycSd9QWQswVNF/CtPWNgjzp/CU165YtV+pW 8bXyn7YpDyJNGwUQf5BO/me3x79D7R//d38xj9yIFmNN1lxiCDJsglCu9jAy4cvTfMuBvCyTP5iB1 w9os7Qcw6r1BtOIdEY+Tyj16Jv4Q0U0YhcfxreESctSYL9QUhLpzF3Amc5JBpvXlaUAcyJj5/Jqw6 y05efLKOafh2lOZr/n1B2pMNQInMYSQuGo/xnV+3TjlCS24/aCrdlZag/kXgg3yEScyUWjIQS9Z5g ju6zrR3bjsO2gAJ3HEyw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tObGH-00000004mwh-02K0; Fri, 20 Dec 2024 11:33: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 1tObGE-00000004mue-022b for linux-i3c@lists.infradead.org; Fri, 20 Dec 2024 11:33:39 +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=uWx7Khj94+L0maCjBS9mNDc9rvpKoRkC0PwJFVrpB/4=; b=Mk5lMc bBigG6RSFglZ1BJGbzzc1v4XUGxS3lCHnMfYERPbnXJ6Qoq2xaZmAXjDo/m/Ph4r EEi3DUP5uBH6cF1FjK9cslyAx6V4Uu3b9BvDjEHMTakEMF72MmkAjSnJ9QFUTvQO T7UJ+zlyRZZ8E+kLdLQwj2jxEL8TZNM6EEd0AdRYQ6t3xYpa+u+a50zwHmtrNyXA V2lPtbcc9w9k/9nx6tJqcKBlB/63FtLVPkfdMLl3UHqclIZDgvpfeJccCelkuL1/ gJiuZ3cU9lv8rZZVJY86eHLXXD8UdchTRVT6xK6Qa6QXxCdPazGKOEUk1DhWoDui o/o2UkWLM9hu2K8w== Received: (qmail 990887 invoked from network); 20 Dec 2024 12:33:36 +0100 Received: by mail.zeus03.de with ESMTPSA (TLS_AES_256_GCM_SHA384 encrypted, authenticated); 20 Dec 2024 12:33:36 +0100 X-UD-Smtp-Session: l3s3148p1@q194BLIptOIujnsY From: Wolfram Sang To: linux-renesas-soc@vger.kernel.org Cc: Yury Norov , linux-i3c@lists.infradead.org, Wolfram Sang , Guenter Roeck , Geert Uytterhoeven , Kuan-Wei Chiu , Rasmus Villemoes Subject: [PATCH RFT RESEND 1/5] bitops: add generic parity calculation for u8 Date: Fri, 20 Dec 2024 12:33:29 +0100 Message-Id: <20241220113335.17937-2-wsa+renesas@sang-engineering.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20241220113335.17937-1-wsa+renesas@sang-engineering.com> References: <20241220113335.17937-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-20241220_033338_319664_0615BE6B X-CRM114-Status: GOOD ( 14.47 ) 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 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:33: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: 13916641 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 805A4E7718A for ; Fri, 20 Dec 2024 11:33: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=4/EH0TyVEIYelGcWS8nHWNTKHPnJCHcvK+NnGIVBS8A=; b=OvS4LOdx2p5vO/ jH35cSBQ1GtWIjt+L6IcOAwIQpgh5lPp2zSEfH28jZtL8QO7S6y2+sKXxu/l1YGnoc5JQK/Qo/jyF CkPpnJEMUJtgMEc8j+3WxZ8B7u1wjlv3GLVjpRwxI6kSfWMPURnWBDmT+7WNFIkKwtr+4c4VJw6pY 7KrkBIdD+tuYaFW0B6A4mUK2K/5v3zMvvUGuZEL3RsWDjRUfjpUfB6HhjFRe8UOk9RD4mqLW/FKd8 4SnqLxP7bnQ8kmYz+zUJt8N7tavOpsjJozFE2u1a5otWqsnYlBC5EbAvPcZpmDnVGn9aUTdD8YLv1 Esci4N8m2rJvv4WXBq9g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tObGH-00000004mwy-1Esd; Fri, 20 Dec 2024 11:33: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 1tObGE-00000004mug-2SSV for linux-i3c@lists.infradead.org; Fri, 20 Dec 2024 11:33:40 +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=7urdFe4hc0mW5T0rNDU1jZWJ1H72Kr3Yh3vXW+VAdRs=; b=lyK7fU WY3LP/ZmSFIqdrAGFwbU+VBuO68kzOtCSXWYh8IgmhSjL1gUhq1UoeiZwLyi+aGa StU0DGU6eqc9XHJieuQx/HYGqTw30YAenMVgr4y+w8WjpMexbVj0R1tkYSYXLajW OHvceZow1AnYFnGmJqDcHHGTOwizPzgkKTlliKk1H9YbRIMLtVUI1t7THd0yjiiG NmwH19mnwOAQhHj/mFPsUPOHLGbX4a5CBHjjkEpYbQazx/l+9WKChyV9MlmImqVg Wl5cwOYfq/huo4RWE897Fi0KrNWfzCEU5pLA7IUjSnR5iw+wr7105cPcsUXvbQIJ HQ/FmSuNWZuTmtbA== Received: (qmail 990929 invoked from network); 20 Dec 2024 12:33:36 +0100 Received: by mail.zeus03.de with ESMTPSA (TLS_AES_256_GCM_SHA384 encrypted, authenticated); 20 Dec 2024 12:33:36 +0100 X-UD-Smtp-Session: l3s3148p1@fl+BBLIpvuIujnsY From: Wolfram Sang To: linux-renesas-soc@vger.kernel.org Cc: Yury Norov , linux-i3c@lists.infradead.org, Wolfram Sang , Guenter Roeck , Geert Uytterhoeven , Kuan-Wei Chiu , Jean Delvare , linux-hwmon@vger.kernel.org Subject: [PATCH RFT RESEND 2/5] hwmon: (spd5118) Use generic parity calculation Date: Fri, 20 Dec 2024 12:33:30 +0100 Message-Id: <20241220113335.17937-3-wsa+renesas@sang-engineering.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20241220113335.17937-1-wsa+renesas@sang-engineering.com> References: <20241220113335.17937-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-20241220_033338_896748_CF7B78BD X-CRM114-Status: UNSURE ( 7.08 ) 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 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:33: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: 13916642 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 CE4A3E7718C for ; Fri, 20 Dec 2024 11:33: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=vwYuorfmgiIIGHRYCi0+SEqtiZ94QtRlY6On2mSAlnI=; b=0mZMoVHIGtmrpg kxWUectxUOLq5rLYSZ4SS5QC54nbWStTGdxNtdwYikCSOrt154XIFYKMbSz1aZIiqxWJV2RHcux/i VwhgcgIH3fB2NlFHNJHW9wKb4UGV15hQwaOSo/SlYZWUgHpF0V3Q3jusVgb6qhSMdATMqq1HnlkRa oNGWczF+zo1UrTfpD8KGvsJxpAS5avW3Hv19/o8c9FVLoWm0JxQWMoIF2B6u65upyTynL998lSlJS 2GhS1SbDxTr8Dj/SIYA2qZJLZqp3LV6RLXpxc5XpYVotTDuX+xOdi7/xR45y9Y2gPd1R7PmRgGxjS llP1K14eGzTN6vk1BxbQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tObGH-00000004mxM-2U3y; Fri, 20 Dec 2024 11:33: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 1tObGF-00000004muv-0pj7 for linux-i3c@lists.infradead.org; Fri, 20 Dec 2024 11:33:40 +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=JTVYffu7bObqCnm7BryRbyhmBYXN9UAwW1f5OWePOno=; b=HOfd6r thrpQ4Z1iKg1lV10bbLXXLAv0bJjlmc2QLWt7mjWQHkd5X02kvj4KDMwL4SeUmKC VfzrSienSOqIBUQ9NGXvBNHIUDsTqbjoSzyLAMKNKY/t0S4i24n7GSg84jVU3LMd KqrZyxW/tZWCyp201EyiqOFjRpmmzx2Ux0Pk+Jjwk/fVfZAApYbpG3l7JZsfgJbZ i4vJ8ZuiV5JA1q9dlecFGLuYID6vaxI1mtCyUUun9NipB2tLFRwyBLh2TptG3EEc ijBtNqexA++R0K4Gn8XRuW6s9eymaTuU7CkIeEJg4UuWErHhvW+wQXbatkz5x1Is K2jLozDFsnoqHl3w== Received: (qmail 990974 invoked from network); 20 Dec 2024 12:33:37 +0100 Received: by mail.zeus03.de with ESMTPSA (TLS_AES_256_GCM_SHA384 encrypted, authenticated); 20 Dec 2024 12:33:37 +0100 X-UD-Smtp-Session: l3s3148p1@KYCKBLIpzuIujnsY From: Wolfram Sang To: linux-renesas-soc@vger.kernel.org Cc: Yury Norov , linux-i3c@lists.infradead.org, Wolfram Sang , Alexandre Belloni Subject: [PATCH RFT RESEND 3/5] i3c: dw: use get_parity8 helper instead of open coding it Date: Fri, 20 Dec 2024 12:33:31 +0100 Message-Id: <20241220113335.17937-4-wsa+renesas@sang-engineering.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20241220113335.17937-1-wsa+renesas@sang-engineering.com> References: <20241220113335.17937-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-20241220_033339_505572_6F0702A7 X-CRM114-Status: UNSURE ( 8.56 ) 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 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:33: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: 13916643 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 29602E7718D for ; Fri, 20 Dec 2024 11:33:42 +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=SxHpAPYyjQ8REbmK/2q3P9P/xwgyj+S5H+HAq9cvRco=; b=CVAmtQP6DK62tP +Zh4fkLL2iYmK1vkqfUek7V5R/SogrjV51ObEpVzuuOKrYrmrCyKB42+FEBWX9A9oImhcr2XPM/Qg p6GTCBzwEKymZHGtjJEYZYuGY2nry+Oux/E3qlRNY/hDYGfHeqxLtbkTssjxhaSrgBBwn9s/g/pgb 5nJnjnuHOl3VIYpYRdS/v4AaC+ALO2R0yhSObIL/xmbweGZeD26MyLZLTUNzp2UZe4YxgGKSeA5++ JjK5S3ORREPT6J7XkUnxS+Bb+SqyDPCNBfH8fw5XvnuSloKXbmXZM25VW5nsoQOsnLYlpgaVHjFJX PzAvApwZRFnlEPwwLbAg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tObGH-00000004mxu-3tBd; Fri, 20 Dec 2024 11:33: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 1tObGF-00000004mvB-3C1l for linux-i3c@lists.infradead.org; Fri, 20 Dec 2024 11:33:41 +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=Xle8vB4tioG0noyMlph488LEaOgkNcMUcx711tLKtDQ=; b=DvKXHZ E6sa8osmBPAmLZAxnYmUvqb4aaU5Dd18iLQNg3ISos1/vhTWDlQAYh2ypr3SpVyO cHRS7jTgpQR0XiIhcHAN5ZpEnBry5XOoMw6+KF4Dv828B9U1OAsTGZxZMJwYa24+ 3sfBxRo5ysuRPBIvd8TvmXVG+3zlOjbdphpwq0b5uDA6incMolKXEccKFjsnS+ph HaDHkrOLVAAcyXPeoQXBehaPSsqdtqK8ooEexrVqYpoOxL/o+KMgSq7kBfLzsZZt Fcu1peqThM1T06cUyZJZJ5v/vZqe2IAd9xbojbCWZSe+GZ+kbiDRD29/gDEQrisy LOci0rnhp89kcnvA== Received: (qmail 991002 invoked from network); 20 Dec 2024 12:33:38 +0100 Received: by mail.zeus03.de with ESMTPSA (TLS_AES_256_GCM_SHA384 encrypted, authenticated); 20 Dec 2024 12:33:38 +0100 X-UD-Smtp-Session: l3s3148p1@IZaTBLIp0uIujnsY From: Wolfram Sang To: linux-renesas-soc@vger.kernel.org Cc: Yury Norov , linux-i3c@lists.infradead.org, Wolfram Sang , Alexandre Belloni Subject: [PATCH RFT RESEND 4/5] i3c: mipi-i3c-hci: use get_parity8 helper instead of open coding it Date: Fri, 20 Dec 2024 12:33:32 +0100 Message-Id: <20241220113335.17937-5-wsa+renesas@sang-engineering.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20241220113335.17937-1-wsa+renesas@sang-engineering.com> References: <20241220113335.17937-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-20241220_033340_065601_0E86E766 X-CRM114-Status: UNSURE ( 7.35 ) 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 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:33: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: 13916644 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 B10FEE7718E for ; Fri, 20 Dec 2024 11:33:42 +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=DpMb0X70At118EpLCzJtJYYog+UBBjXmjtG3olXfJVA=; b=JUrVb6nYylBsjY xi+INPdDUtjyMnTfbqNSTYx1v7+5Gi3n0ZPnEuE5GI/1x/ondKtt9Rucz3mFZR6hzHywJ1bDrqY1E DJ65FZOmY75uRwY2VqrtUlQXR+eJ+nkLQtqa7iMyfPQLG2rnelZl5N0S7XrQU5oRS8heiUynDR0eW f7l3TPyS5w4JdqUpKwJwACH/8ej2GrPF8wm7iFE5+RDAm9yDV6W8KLV/Vp8VF8on8FSjKDZQukyey roB8JyNQGWjmnZg8NxhndPYCZIxtCJrjSWaVzQiMVDbZb/EJYEzTaSU7EhCFTfVWfutqp2PDxjf5h n/ZyBhYGvoiX70N7j1tg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tObGI-00000004myT-1zF2; Fri, 20 Dec 2024 11:33:42 +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 1tObGG-00000004mvW-1c8h for linux-i3c@lists.infradead.org; Fri, 20 Dec 2024 11:33:41 +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=rsDE8URaHTqtvoHB8Si3sxcYn73y38+s7yQFTYbHb2I=; b=EO5MSg yfoTmozbzfM4TSszr5SUnGJnfT+gYqAPQz9gKubm0iAh8efyTxEwJJMSqR25rk5C LFUdM0AdlVzSrV27Y5uFQZapXHcucaHNWZVDYJtFuwCf/2Y163Wu43ul5KIOd0DY GBWq/PROenKtq8uUpuwSfz1QUYnhXJ3NxR90D6+Vx2a1VVshNfdcwFWDBiSEZXky d2d1g+Lkw7eYyU+p6To8fF22etZxQZqsBrRJvAaN/lcNXtVze7jx1aVMVa0WNKie 8u3ZEXcn7jp+N6HHKvVfymGUo/FhLPo3xi2HccTH05em5jyV+Uzthoz2BRohWauk FZVS9J6r8oKLlmSg== Received: (qmail 991033 invoked from network); 20 Dec 2024 12:33:38 +0100 Received: by mail.zeus03.de with ESMTPSA (TLS_AES_256_GCM_SHA384 encrypted, authenticated); 20 Dec 2024 12:33:38 +0100 X-UD-Smtp-Session: l3s3148p1@C8CcBLIp1uIujnsY From: Wolfram Sang To: linux-renesas-soc@vger.kernel.org Cc: Yury Norov , linux-i3c@lists.infradead.org, Wolfram Sang , =?utf-8?q?Przemys=C5=82aw_?= =?utf-8?q?Gaj?= , Alexandre Belloni Subject: [PATCH RFT RESEND 5/5] i3c: cdns: use get_parity8 helper instead of open coding it Date: Fri, 20 Dec 2024 12:33:33 +0100 Message-Id: <20241220113335.17937-6-wsa+renesas@sang-engineering.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20241220113335.17937-1-wsa+renesas@sang-engineering.com> References: <20241220113335.17937-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-20241220_033340_689292_EB41C867 X-CRM114-Status: UNSURE ( 8.43 ) 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 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; }