[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20250223164217.2139331-14-visitorckw@gmail.com>
Date: Mon, 24 Feb 2025 00:42:13 +0800
From: Kuan-Wei Chiu <visitorckw@...il.com>
To: tglx@...utronix.de,
mingo@...hat.com,
bp@...en8.de,
dave.hansen@...ux.intel.com,
x86@...nel.org,
jk@...abs.org,
joel@....id.au,
eajames@...ux.ibm.com,
andrzej.hajda@...el.com,
neil.armstrong@...aro.org,
rfoss@...nel.org,
maarten.lankhorst@...ux.intel.com,
mripard@...nel.org,
tzimmermann@...e.de,
airlied@...il.com,
simona@...ll.ch,
dmitry.torokhov@...il.com,
mchehab@...nel.org,
awalls@...metrocast.net,
hverkuil@...all.nl,
miquel.raynal@...tlin.com,
richard@....at,
vigneshr@...com,
louis.peens@...igine.com,
andrew+netdev@...n.ch,
davem@...emloft.net,
edumazet@...gle.com,
pabeni@...hat.com,
parthiban.veerasooran@...rochip.com,
arend.vanspriel@...adcom.com,
johannes@...solutions.net,
gregkh@...uxfoundation.org,
jirislaby@...nel.org,
yury.norov@...il.com,
akpm@...ux-foundation.org
Cc: hpa@...or.com,
alistair@...ple.id.au,
linux@...musvillemoes.dk,
Laurent.pinchart@...asonboard.com,
jonas@...boo.se,
jernej.skrabec@...il.com,
kuba@...nel.org,
linux-kernel@...r.kernel.org,
linux-fsi@...ts.ozlabs.org,
dri-devel@...ts.freedesktop.org,
linux-input@...r.kernel.org,
linux-media@...r.kernel.org,
linux-mtd@...ts.infradead.org,
oss-drivers@...igine.com,
netdev@...r.kernel.org,
linux-wireless@...r.kernel.org,
brcm80211@...ts.linux.dev,
brcm80211-dev-list.pdl@...adcom.com,
linux-serial@...r.kernel.org,
bpf@...r.kernel.org,
jserv@...s.ncku.edu.tw,
Kuan-Wei Chiu <visitorckw@...il.com>,
Yu-Chun Lin <eleanor15x@...il.com>
Subject: [PATCH 13/17] mtd: ssfdc: Replace open-coded parity calculation with parity32()
Refactor parity calculations to use the standard parity32() helper.
This change eliminates redundant implementations and improves code
efficiency.
Co-developed-by: Yu-Chun Lin <eleanor15x@...il.com>
Signed-off-by: Yu-Chun Lin <eleanor15x@...il.com>
Signed-off-by: Kuan-Wei Chiu <visitorckw@...il.com>
---
drivers/mtd/ssfdc.c | 17 ++---------------
1 file changed, 2 insertions(+), 15 deletions(-)
diff --git a/drivers/mtd/ssfdc.c b/drivers/mtd/ssfdc.c
index 46c01fa2ec46..e7f9e73da644 100644
--- a/drivers/mtd/ssfdc.c
+++ b/drivers/mtd/ssfdc.c
@@ -7,6 +7,7 @@
* Based on NTFL and MTDBLOCK_RO drivers
*/
+#include <linux/bitops.h>
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/init.h>
@@ -178,20 +179,6 @@ static int read_raw_oob(struct mtd_info *mtd, loff_t offs, uint8_t *buf)
return 0;
}
-/* Parity calculator on a word of n bit size */
-static int get_parity(int number, int size)
-{
- int k;
- int parity;
-
- parity = 1;
- for (k = 0; k < size; k++) {
- parity += (number >> k);
- parity &= 1;
- }
- return parity;
-}
-
/* Read and validate the logical block address field stored in the OOB */
static int get_logical_address(uint8_t *oob_buf)
{
@@ -215,7 +202,7 @@ static int get_logical_address(uint8_t *oob_buf)
block_address &= 0x7FF;
block_address >>= 1;
- if (get_parity(block_address, 10) != parity) {
+ if (parity32(block_address & 0x3ff) == parity) {
pr_debug("SSFDC_RO: logical address field%d"
"parity error(0x%04X)\n", j+1,
block_address);
--
2.34.1
Powered by blists - more mailing lists