From patchwork Wed Jun 13 09:02:36 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Abhishek Sahu X-Patchwork-Id: 10461909 X-Patchwork-Delegate: agross@codeaurora.org Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 8E30E60329 for ; Wed, 13 Jun 2018 09:02:50 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 934E8289EB for ; Wed, 13 Jun 2018 09:02:50 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 87AFC289F3; Wed, 13 Jun 2018 09:02:50 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 302EF289EB for ; Wed, 13 Jun 2018 09:02:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754487AbeFMJCs (ORCPT ); Wed, 13 Jun 2018 05:02:48 -0400 Received: from smtp.codeaurora.org ([198.145.29.96]:39644 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750922AbeFMJCq (ORCPT ); Wed, 13 Jun 2018 05:02:46 -0400 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 4E5EC607A4; Wed, 13 Jun 2018 09:02:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1528880566; bh=fl6gQW5SIy21oP3dRmfZs3JwXPRdmjmKR+fZnpIVOuY=; h=From:To:Cc:Subject:Date:From; b=F7uh66Rf4i1eWn0tAzAvlZKN4orHtggqJI1eA9amGTvBsov+w+ifhUgni9sSBmVKI 81xQ+jbFAKdAt5sOBodRQOZXFZx2VTcHZij2R695Pw6HTQOZ+ru0UUZeoixULiQLqV PPYl2vYQVqP1b8ON3nJBcDP+gw3vhTuyKlHcehHs= Received: from absahu-linux.qualcomm.com (blr-c-bdr-fw-01_globalnat_allzones-outside.qualcomm.com [103.229.19.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: absahu@smtp.codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id A2EFB606DB; Wed, 13 Jun 2018 09:02:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1528880564; bh=fl6gQW5SIy21oP3dRmfZs3JwXPRdmjmKR+fZnpIVOuY=; h=From:To:Cc:Subject:Date:From; b=VdvW0VbYD4pI6bLeUuJwiDfLy0JCGxYKT/6iFMM/+79J5pGSC/3CSd6KRwsFt3o0H CwOkoHQaKGGlwERH/0VOrj5SXS58b83OXyrm5s9c0gIP31Zpck1KJFm0u2Z7fYvFUu xfYBPn7rvUdPDNbW8eJC28Sgl1mFj3ODoYLPwj3U= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org A2EFB606DB Authentication-Results: pdx-caf-mail.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: pdx-caf-mail.web.codeaurora.org; spf=none smtp.mailfrom=absahu@codeaurora.org From: Abhishek Sahu To: Boris Brezillon Cc: David Woodhouse , Brian Norris , Marek Vasut , Richard Weinberger , Miquel Raynal , linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mtd@lists.infradead.org, Abhishek Sahu , Subject: [PATCH] mtd: rawnand: fix return value check for bad block status Date: Wed, 13 Jun 2018 14:32:36 +0530 Message-Id: <1528880556-20348-1-git-send-email-absahu@codeaurora.org> X-Mailer: git-send-email 1.9.1 Sender: linux-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Positive return value from read_oob() is making false BAD blocks. For some of the NAND controllers, OOB bytes will be protected with ECC and read_oob() will return number of bitflips. If there is any bitflip in ECC protected OOB bytes for BAD block status page, then that block is getting treated as BAD. Fixes: c120e75e0e7d ("mtd: nand: use read_oob() instead of cmdfunc() for bad block check") Cc: Signed-off-by: Abhishek Sahu Reviewed-by: Miquel Raynal --- drivers/mtd/nand/raw/nand_base.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/mtd/nand/raw/nand_base.c b/drivers/mtd/nand/raw/nand_base.c index f28c3a5..4a73f73 100644 --- a/drivers/mtd/nand/raw/nand_base.c +++ b/drivers/mtd/nand/raw/nand_base.c @@ -440,7 +440,7 @@ static int nand_block_bad(struct mtd_info *mtd, loff_t ofs) for (; page < page_end; page++) { res = chip->ecc.read_oob(mtd, chip, page); - if (res) + if (res < 0) return res; bad = chip->oob_poi[chip->badblockpos];