* [PATCH 21/31] mtd: use parity16 in ssfdc.c
[not found] <1458788612-4367-1-git-send-email-zhaoxiu.zeng@gmail.com>
@ 2016-03-27 7:24 ` zhaoxiu.zeng
2016-04-01 23:48 ` Brian Norris
2016-03-27 7:27 ` [PATCH 22/31] mtd: use parity functions in inftlcore.c zhaoxiu.zeng
2016-03-27 7:33 ` [PATCH 24/31] mtd: use parity16 in sm_ftl.c zhaoxiu.zeng
2 siblings, 1 reply; 4+ messages in thread
From: zhaoxiu.zeng @ 2016-03-27 7:24 UTC (permalink / raw)
To: David Woodhouse, Brian Norris; +Cc: linux-kernel, linux-mtd
From: Zeng Zhaoxiu <zhaoxiu.zeng@gmail.com>
Signed-off-by: Zeng Zhaoxiu <zhaoxiu.zeng@gmail.com>
---
drivers/mtd/ssfdc.c | 20 ++------------------
1 file changed, 2 insertions(+), 18 deletions(-)
diff --git a/drivers/mtd/ssfdc.c b/drivers/mtd/ssfdc.c
index daf82ba..b4d9144 100644
--- a/drivers/mtd/ssfdc.c
+++ b/drivers/mtd/ssfdc.c
@@ -182,24 +182,10 @@ 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)
{
- int block_address, parity;
+ int block_address;
int offset[2] = {6, 11}; /* offset of the 2 address fields within OOB */
int j;
int ok = 0;
@@ -215,11 +201,9 @@ static int get_logical_address(uint8_t *oob_buf)
/* Check for the signature bits in the address field (MSBits) */
if ((block_address & ~0x7FF) == 0x1000) {
- parity = block_address & 0x01;
block_address &= 0x7FF;
- block_address >>= 1;
- if (get_parity(block_address, 10) != parity) {
+ if (!parity16(block_address)) {
pr_debug("SSFDC_RO: logical address field%d"
"parity error(0x%04X)\n", j+1,
block_address);
--
2.5.5
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 22/31] mtd: use parity functions in inftlcore.c
[not found] <1458788612-4367-1-git-send-email-zhaoxiu.zeng@gmail.com>
2016-03-27 7:24 ` [PATCH 21/31] mtd: use parity16 in ssfdc.c zhaoxiu.zeng
@ 2016-03-27 7:27 ` zhaoxiu.zeng
2016-03-27 7:33 ` [PATCH 24/31] mtd: use parity16 in sm_ftl.c zhaoxiu.zeng
2 siblings, 0 replies; 4+ messages in thread
From: zhaoxiu.zeng @ 2016-03-27 7:27 UTC (permalink / raw)
To: David Woodhouse, Brian Norris; +Cc: linux-kernel, linux-mtd
From: Zeng Zhaoxiu <zhaoxiu.zeng@gmail.com>
Signed-off-by: Zeng Zhaoxiu <zhaoxiu.zeng@gmail.com>
---
drivers/mtd/inftlcore.c | 17 ++++-------------
1 file changed, 4 insertions(+), 13 deletions(-)
diff --git a/drivers/mtd/inftlcore.c b/drivers/mtd/inftlcore.c
index b66b541..29567bb 100644
--- a/drivers/mtd/inftlcore.c
+++ b/drivers/mtd/inftlcore.c
@@ -457,15 +457,6 @@ static u16 INFTL_makefreeblock(struct INFTLrecord *inftl, unsigned pendingblock)
return INFTL_foldchain(inftl, LongestChain, pendingblock);
}
-static int nrbits(unsigned int val, int bitcount)
-{
- int i, total = 0;
-
- for (i = 0; (i < bitcount); i++)
- total += (((0x1 << i) & val) ? 1 : 0);
- return total;
-}
-
/*
* INFTL_findwriteunit: Return the unit number into which we can write
* for this block. Make it available if it isn't already.
@@ -593,10 +584,10 @@ hitused:
if (prev_block < inftl->nb_blocks)
prev_block -= inftl->firstEUN;
- parity = (nrbits(thisVUC, 16) & 0x1) ? 0x1 : 0;
- parity |= (nrbits(prev_block, 16) & 0x1) ? 0x2 : 0;
- parity |= (nrbits(anac, 8) & 0x1) ? 0x4 : 0;
- parity |= (nrbits(nacs, 8) & 0x1) ? 0x8 : 0;
+ parity = parity16(thisVUC);
+ parity |= parity16(prev_block) << 1;
+ parity |= parity8(anac) << 2;
+ parity |= parity8(nacs) << 3;
oob.u.a.virtualUnitNo = cpu_to_le16(thisVUC);
oob.u.a.prevUnitNo = cpu_to_le16(prev_block);
--
2.5.5
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 24/31] mtd: use parity16 in sm_ftl.c
[not found] <1458788612-4367-1-git-send-email-zhaoxiu.zeng@gmail.com>
2016-03-27 7:24 ` [PATCH 21/31] mtd: use parity16 in ssfdc.c zhaoxiu.zeng
2016-03-27 7:27 ` [PATCH 22/31] mtd: use parity functions in inftlcore.c zhaoxiu.zeng
@ 2016-03-27 7:33 ` zhaoxiu.zeng
2 siblings, 0 replies; 4+ messages in thread
From: zhaoxiu.zeng @ 2016-03-27 7:33 UTC (permalink / raw)
To: David Woodhouse, Brian Norris; +Cc: linux-kernel, linux-mtd
From: Zeng Zhaoxiu <zhaoxiu.zeng@gmail.com>
Signed-off-by: Zeng Zhaoxiu <zhaoxiu.zeng@gmail.com>
---
drivers/mtd/sm_ftl.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/mtd/sm_ftl.c b/drivers/mtd/sm_ftl.c
index b096f8b..2244588 100644
--- a/drivers/mtd/sm_ftl.c
+++ b/drivers/mtd/sm_ftl.c
@@ -136,7 +136,7 @@ static int sm_get_lba(uint8_t *lba)
return -2;
/* check parity - endianness doesn't matter */
- if (hweight16(*(uint16_t *)lba) & 1)
+ if (parity16(*(uint16_t *)lba))
return -2;
return (lba[1] >> 1) | ((lba[0] & 0x07) << 7);
@@ -183,7 +183,7 @@ static void sm_write_lba(struct sm_oob *oob, uint16_t lba)
tmp[0] = 0x10 | ((lba >> 7) & 0x07);
tmp[1] = (lba << 1) & 0xFF;
- if (hweight16(*(uint16_t *)tmp) & 0x01)
+ if (parity16(*(uint16_t *)tmp))
tmp[1] |= 1;
oob->lba_copy1[0] = oob->lba_copy2[0] = tmp[0];
--
2.5.5
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH 21/31] mtd: use parity16 in ssfdc.c
2016-03-27 7:24 ` [PATCH 21/31] mtd: use parity16 in ssfdc.c zhaoxiu.zeng
@ 2016-04-01 23:48 ` Brian Norris
0 siblings, 0 replies; 4+ messages in thread
From: Brian Norris @ 2016-04-01 23:48 UTC (permalink / raw)
To: zhaoxiu.zeng; +Cc: David Woodhouse, linux-kernel, linux-mtd
On Sun, Mar 27, 2016 at 03:24:59PM +0800, zhaoxiu.zeng wrote:
> From: Zeng Zhaoxiu <zhaoxiu.zeng@gmail.com>
>
> Signed-off-by: Zeng Zhaoxiu <zhaoxiu.zeng@gmail.com>
I'm not CC'd on the rest of this series, where you defined parity16().
And I doubt you've tested this. So I'm not applying.
Brian
> drivers/mtd/ssfdc.c | 20 ++------------------
> 1 file changed, 2 insertions(+), 18 deletions(-)
>
> diff --git a/drivers/mtd/ssfdc.c b/drivers/mtd/ssfdc.c
> index daf82ba..b4d9144 100644
> --- a/drivers/mtd/ssfdc.c
> +++ b/drivers/mtd/ssfdc.c
> @@ -182,24 +182,10 @@ 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)
> {
> - int block_address, parity;
> + int block_address;
> int offset[2] = {6, 11}; /* offset of the 2 address fields within OOB */
> int j;
> int ok = 0;
> @@ -215,11 +201,9 @@ static int get_logical_address(uint8_t *oob_buf)
>
> /* Check for the signature bits in the address field (MSBits) */
> if ((block_address & ~0x7FF) == 0x1000) {
> - parity = block_address & 0x01;
> block_address &= 0x7FF;
> - block_address >>= 1;
>
> - if (get_parity(block_address, 10) != parity) {
> + if (!parity16(block_address)) {
> pr_debug("SSFDC_RO: logical address field%d"
> "parity error(0x%04X)\n", j+1,
> block_address);
> --
> 2.5.5
>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2016-04-01 23:49 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <1458788612-4367-1-git-send-email-zhaoxiu.zeng@gmail.com>
2016-03-27 7:24 ` [PATCH 21/31] mtd: use parity16 in ssfdc.c zhaoxiu.zeng
2016-04-01 23:48 ` Brian Norris
2016-03-27 7:27 ` [PATCH 22/31] mtd: use parity functions in inftlcore.c zhaoxiu.zeng
2016-03-27 7:33 ` [PATCH 24/31] mtd: use parity16 in sm_ftl.c zhaoxiu.zeng
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).