Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753851AbcC0H0Y (ORCPT ); Sun, 27 Mar 2016 03:26:24 -0400 Received: from mail-pa0-f66.google.com ([209.85.220.66]:35274 "EHLO mail-pa0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752974AbcC0H0P (ORCPT ); Sun, 27 Mar 2016 03:26:15 -0400 Subject: [PATCH 21/31] mtd: use parity16 in ssfdc.c References: <1458788612-4367-1-git-send-email-zhaoxiu.zeng@gmail.com> Cc: linux-kernel@vger.kernel.org, linux-mtd@lists.infradead.org To: David Woodhouse , Brian Norris From: "zhaoxiu.zeng" Message-ID: <56F78ACB.1010402@gmail.com> Date: Sun, 27 Mar 2016 15:24:59 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.7.1 MIME-Version: 1.0 In-Reply-To: <1458788612-4367-1-git-send-email-zhaoxiu.zeng@gmail.com> Content-Type: text/plain; charset=gbk Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1444 Lines: 52 From: Zeng Zhaoxiu Signed-off-by: Zeng Zhaoxiu --- 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