From patchwork Wed Apr 6 10:05:47 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhaoxiu Zeng X-Patchwork-Id: 606920 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3qg1d73zHLz9s9Y for ; Wed, 6 Apr 2016 20:08:11 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=163.com header.i=@163.com header.b=K/eW7zS/; dkim-atps=neutral Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1ankMN-0004rV-Ag; Wed, 06 Apr 2016 10:06:51 +0000 Received: from m50-134.163.com ([123.125.50.134]) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1ankMJ-0004kb-NH for linux-mtd@lists.infradead.org; Wed, 06 Apr 2016 10:06:49 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=From:Subject:Date:Message-Id; bh=15VLrEL/D2qna7WptP hajx+DSBj87o0xsL9or7Gnkb8=; b=K/eW7zS/aJ0eSmWZEQjIoworaCwCKahp++ fThMOW3aal8VAtjeK8rbaoNwreYKbKytodmEEvja/3pDp/cCw8wShyyj7gqemtCV e2bE7AGumPmrzTbDKUvYn6xcTUOkG55SAW316YGFLCpUfTcOpkaxCSQix/eLSVyr f7oYPis08= Received: from zhaoxiuzeng-VirtualBox.spreadtrum.com (unknown [112.95.225.98]) by smtp4 (Coremail) with SMTP id DtGowACHhz963wRXyfYKAA--.1137S2; Wed, 06 Apr 2016 18:05:52 +0800 (CST) From: zengzhaoxiu@163.com To: dwmw2@infradead.org, computersforpeace@gmail.com Subject: [PATCH v2 23/30] mtd: use parity16 in sm_ftl Date: Wed, 6 Apr 2016 18:05:47 +0800 Message-Id: <1459937147-8173-1-git-send-email-zengzhaoxiu@163.com> X-Mailer: git-send-email 2.5.0 In-Reply-To: <57031D9D.801@gmail.com> References: <57031D9D.801@gmail.com> X-CM-TRANSID: DtGowACHhz963wRXyfYKAA--.1137S2 X-Coremail-Antispam: 1Uf129KBjvdXoWrtr4fKr13Gr13Cry7Aw1fZwb_yoWftFX_Kr 13G3ZFgrW7C3Wjkw1kAr1a9F92vanY9w18W3Wvqa93Gay5Zw18XryDZr95Jw1kZF40kasx Aws8ua40yFW3WjkaLaAFLSUrUUUUUb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUvcSsGvfC2KfnxnUUI43ZEXa7IU0fMa5UUUUU== X-Originating-IP: [112.95.225.98] X-CM-SenderInfo: p2hqw6xkdr5xrx6rljoofrz/1tbiNRZDgFSIM66kDQABsJ X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160406_030648_569444_024D2BE2 X-CRM114-Status: UNSURE ( 6.99 ) X-CRM114-Notice: Please train this message. X-Spam-Score: -3.0 (---) X-Spam-Report: SpamAssassin version 3.4.0 on bombadil.infradead.org summary: Content analysis details: (-3.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (zengzhaoxiu[at]163.com) -1.0 RP_MATCHES_RCVD Envelope sender domain matches handover relay domain -0.0 SPF_PASS SPF: sender matches SPF record -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-mtd@lists.infradead.org, linux-kernel@vger.kernel.org, Zhaoxiu Zeng MIME-Version: 1.0 Sender: "linux-mtd" Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org From: Zhaoxiu Zeng Signed-off-by: Zhaoxiu Zeng --- drivers/mtd/sm_ftl.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/mtd/sm_ftl.c b/drivers/mtd/sm_ftl.c index b096f8b..345ff1a 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,8 +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) - tmp[1] |= 1; + tmp[1] |= parity16(*(uint16_t *)tmp); oob->lba_copy1[0] = oob->lba_copy2[0] = tmp[0]; oob->lba_copy1[1] = oob->lba_copy2[1] = tmp[1];