Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1398836

[patch V4 20/31] mtd: use parity functions in inftlcore

From zengzhaoxiu@163.com
Newsgroups linux.kernel
Subject [patch V4 20/31] mtd: use parity functions in inftlcore
Date 2016-05-11 11:30 +0200
Message-ID <rxyCS-5ns-13@gated-at.bofh.it> (permalink)
References <rxxGP-4ls-49@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


From: Zhaoxiu Zeng <zhaoxiu.zeng@gmail.com>

Signed-off-by: Zhaoxiu Zeng <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..8c9457b 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.7.4

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[patch V4 00/31] bitops: add parity functions zengzhaoxiu@163.com - 2016-05-11 10:30 +0200
  [patch V4 01/31] bitops: add parity functions zengzhaoxiu@163.com - 2016-05-11 11:10 +0200
    Re: [patch V4 01/31] bitops: add parity functions Martin Kepplinger <martink@posteo.de> - 2016-05-11 16:40 +0200
  [patch V4 02/31] bitops: Include generic parity.h in some architectures' bitops.h zengzhaoxiu@163.com - 2016-05-11 11:20 +0200
    Re: [patch V4 02/31] bitops: Include generic parity.h in some  architectures' bitops.h Jesper Nilsson <jesper.nilsson@axis.com> - 2016-05-11 12:10 +0200
    Re: [patch V4 02/31] bitops: Include generic parity.h in some  architectures' bitops.h Catalin Marinas <catalin.marinas@arm.com> - 2016-05-11 12:50 +0200
    Re: [patch V4 02/31] bitops: Include generic parity.h in some  architectures' bitops.h Vineet Gupta <Vineet.Gupta1@synopsys.com> - 2016-05-11 16:00 +0200
    Re: [patch V4 02/31] bitops: Include generic parity.h in some  architectures' bitops.h Mark Salter <msalter@redhat.com> - 2016-05-11 17:30 +0200
  [patch V4 09/31] bitops: Add x86-specific parity functions zengzhaoxiu@163.com - 2016-05-11 11:20 +0200
    Re: [patch V4 09/31] bitops: Add x86-specific parity functions Peter Zijlstra <peterz@infradead.org> - 2016-05-11 11:40 +0200
      Re: [patch V4 09/31] bitops: Add x86-specific parity functions Borislav Petkov <bp@suse.de> - 2016-05-11 12:00 +0200
  [patch V4 06/31] bitops: Tile and MIPS (if has usable __builtin_popcount) use popcount parity functions zengzhaoxiu@163.com - 2016-05-11 11:20 +0200
  [patch V4 12/31] lib: bch: use parity32 zengzhaoxiu@163.com - 2016-05-11 11:20 +0200
  [patch V4 03/31] bitops: Add alpha-specific parity functions zengzhaoxiu@163.com - 2016-05-11 11:20 +0200
  [patch V4 05/31] bitops: Add ia-specific parity functions zengzhaoxiu@163.com - 2016-05-11 11:20 +0200
  [patch V4 11/31] mips: use parity functions in cerr-sb1.c zengzhaoxiu@163.com - 2016-05-11 11:20 +0200
  [patch V4 08/31] bitops: Add sparc-specific parity functions zengzhaoxiu@163.com - 2016-05-11 11:20 +0200
    Re: [patch V4 08/31] bitops: Add sparc-specific parity functions David Miller <davem@davemloft.net> - 2016-05-12 02:00 +0200
  [patch V4 10/31] sunrpc: use parity8 zengzhaoxiu@163.com - 2016-05-11 11:20 +0200
  [patch V4 07/31] bitops: Add powerpc-specific parity functions zengzhaoxiu@163.com - 2016-05-11 11:20 +0200
  [patch V4 04/31] bitops: Add blackfin-specific parity functions zengzhaoxiu@163.com - 2016-05-11 11:20 +0200
  [patch V4 28/31] input: use parity8 in elantech zengzhaoxiu@163.com - 2016-05-11 11:30 +0200
  [patch V4 19/31] mtd: use parity16 in ssfdc zengzhaoxiu@163.com - 2016-05-11 11:30 +0200
  [patch V4 23/31] ethernet: use parity8 in sun/niu.c zengzhaoxiu@163.com - 2016-05-11 11:30 +0200
    Re: [patch V4 23/31] ethernet: use parity8 in sun/niu.c David Miller <davem@davemloft.net> - 2016-05-12 02:10 +0200
  [patch V4 20/31] mtd: use parity functions in inftlcore zengzhaoxiu@163.com - 2016-05-11 11:30 +0200
  [patch V4 14/31] media: use parity functions in saa7115 zengzhaoxiu@163.com - 2016-05-11 11:30 +0200
  [patch V4 31/31] edac: use parity8 in amd64_edac.c zengzhaoxiu@163.com - 2016-05-11 11:30 +0200
  [patch V4 29/31] ethernet: use parity8 in broadcom/tg3.c zengzhaoxiu@163.com - 2016-05-11 11:30 +0200
    Re: [patch V4 29/31] ethernet: use parity8 in broadcom/tg3.c David Miller <davem@davemloft.net> - 2016-05-12 02:00 +0200
  [patch V4 18/31] scsi: use parity32 in isci's phy zengzhaoxiu@163.com - 2016-05-11 11:30 +0200
  [patch V4 21/31] crypto: use parity functions in qat_hal zengzhaoxiu@163.com - 2016-05-11 11:30 +0200
  [patch V4 15/31] input: use parity32 in grip_mp zengzhaoxiu@163.com - 2016-05-11 11:30 +0200
  [patch V4 30/31] crypto: use parity_long is sahara.c zengzhaoxiu@163.com - 2016-05-11 11:30 +0200
  [patch V4 22/31] mtd: use parity16 in sm_ftl zengzhaoxiu@163.com - 2016-05-11 11:30 +0200
  [patch V4 25/31] input: use parity8 in sa1111ps2 zengzhaoxiu@163.com - 2016-05-11 11:30 +0200
  [patch V4 16/31] input: use parity64 in sidewinder zengzhaoxiu@163.com - 2016-05-11 11:30 +0200
  [patch V4 27/31] serial: use parity32 in max3100 zengzhaoxiu@163.com - 2016-05-11 11:30 +0200
  [patch V4 24/31] input: use parity8 in pcips2 zengzhaoxiu@163.com - 2016-05-11 11:30 +0200
  [patch V4 26/31] iio: use parity32 in adxrs450 zengzhaoxiu@163.com - 2016-05-11 11:30 +0200
  [patch V4 17/31] input: use parity16 in ams_delta_serio zengzhaoxiu@163.com - 2016-05-11 11:30 +0200
  [patch V4 13/31] media: use parity8 in vivid-vbi-gen.c zengzhaoxiu@163.com - 2016-05-11 11:30 +0200

csiph-web