From patchwork Thu Nov 30 17:01:28 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miquel Raynal X-Patchwork-Id: 10085375 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 DF24760311 for ; Thu, 30 Nov 2017 17:03:10 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CCA761FE8D for ; Thu, 30 Nov 2017 17:03:10 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C0DDB2A22F; Thu, 30 Nov 2017 17:03:10 +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=-4.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id EBFE41FE8D for ; Thu, 30 Nov 2017 17:03:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=8tn5EJQ5uW+7Ow/sITh3wAPS/P842QvHH5KuGOf7oIY=; b=SJ0RqnGZkEwbx7TZ5YzXBL7nuC h7euNc2hlRzFGRxwbWpdhV5FREHD9kHJ5UP62RVDY58KAXBG/eyxIp1fAP145zld5Gulm6XtoUZUs 8DhpEUVQYD+3fvGp19sCHzZyexVN9tYatJbUD6gYfdV34ImFTZF3/aRA+us6tdAFPdlI08i73SVgY PKvqfBcGZaNzzEd2wtE1Omk16KpHEMjRwppQ/1Xf+e1ToJ5pJe6GtbBsQ0EeQzkD1uwMIk8IoTYoE L3wGj4tVclFv/JHV/cpgdo9z+8HxUi3y3Fh9pDXGzk4rkyGXZ4OLF13rPCmmQ3+Y7pVPb7cOxNu5G zmomBwzQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1eKSEt-0005iF-5V; Thu, 30 Nov 2017 17:03:07 +0000 Received: from mail.free-electrons.com ([62.4.15.54]) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1eKSDo-00051k-1W; Thu, 30 Nov 2017 17:02:12 +0000 Received: by mail.free-electrons.com (Postfix, from userid 110) id 651CD20709; Thu, 30 Nov 2017 18:01:40 +0100 (CET) Received: from localhost.localdomain (unknown [91.224.148.103]) by mail.free-electrons.com (Postfix) with ESMTPSA id CA90120374; Thu, 30 Nov 2017 18:01:38 +0100 (CET) From: Miquel Raynal To: Boris Brezillon , Richard Weinberger , David Woodhouse , Brian Norris , Marek Vasut , Cyrille Pitchen Subject: [PATCH 1/5] mtd: nand: use usual return values for the ->erase() hook Date: Thu, 30 Nov 2017 18:01:28 +0100 Message-Id: <20171130170132.27522-2-miquel.raynal@free-electrons.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20171130170132.27522-1-miquel.raynal@free-electrons.com> References: <20171130170132.27522-1-miquel.raynal@free-electrons.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20171130_090200_453389_DA972D7A X-CRM114-Status: GOOD ( 12.14 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Hanna Hawa , Stefan Agner , Nadav Haklai , Masahiro Yamada , Alexandre Belloni , Gregory Clement , devel@driverdev.osuosl.org, Maxim Levitsky , Kamal Dasu , Chen-Yu Tsai , bcm-kernel-feedback-list@broadcom.com, Ezequiel Garcia , Sylvain Lemieux , Marc Gonzalez , Vladimir Zapolskiy , linux-mediatek@lists.infradead.org, Miquel Raynal , Matthias Brugger , Han Xu , Ofer Heifetz , linux-arm-kernel@lists.infradead.org, Thomas Petazzoni , Greg Kroah-Hartman , Antoine Tenart , Wenyou Yang , linux-mtd@lists.infradead.org, Maxime Ripard MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Avoid using specific defined values for checking returned status of the ->erase() hook. Instead, use usual negative error values on failure, zero otherwise. Signed-off-by: Miquel Raynal Acked-by: Masahiro Yamada --- drivers/mtd/nand/denali.c | 2 +- drivers/mtd/nand/docg4.c | 7 ++++++- drivers/mtd/nand/nand_base.c | 2 +- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/drivers/mtd/nand/denali.c b/drivers/mtd/nand/denali.c index 34008a02ddb0..3e19861a46c6 100644 --- a/drivers/mtd/nand/denali.c +++ b/drivers/mtd/nand/denali.c @@ -951,7 +951,7 @@ static int denali_erase(struct mtd_info *mtd, int page) irq_status = denali_wait_for_irq(denali, INTR__ERASE_COMP | INTR__ERASE_FAIL); - return irq_status & INTR__ERASE_COMP ? 0 : NAND_STATUS_FAIL; + return irq_status & INTR__ERASE_COMP ? 0 : -EIO; } static int denali_setup_data_interface(struct mtd_info *mtd, int chipnr, diff --git a/drivers/mtd/nand/docg4.c b/drivers/mtd/nand/docg4.c index 2436cbc71662..45c01b4b34c7 100644 --- a/drivers/mtd/nand/docg4.c +++ b/drivers/mtd/nand/docg4.c @@ -900,6 +900,7 @@ static int docg4_erase_block(struct mtd_info *mtd, int page) struct docg4_priv *doc = nand_get_controller_data(nand); void __iomem *docptr = doc->virtadr; uint16_t g4_page; + int status; dev_dbg(doc->dev, "%s: page %04x\n", __func__, page); @@ -939,7 +940,11 @@ static int docg4_erase_block(struct mtd_info *mtd, int page) poll_status(doc); write_nop(docptr); - return nand->waitfunc(mtd, nand); + status = nand->waitfunc(mtd, nand); + if (status < 0) + return status; + + return status & NAND_STATUS_FAIL ? -EIO : 0; } static int write_page(struct mtd_info *mtd, struct nand_chip *nand, diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c index 630048f5abdc..4d1f2bda6095 100644 --- a/drivers/mtd/nand/nand_base.c +++ b/drivers/mtd/nand/nand_base.c @@ -3077,7 +3077,7 @@ int nand_erase_nand(struct mtd_info *mtd, struct erase_info *instr, status = chip->erase(mtd, page & chip->pagemask); /* See if block erase succeeded */ - if (status & NAND_STATUS_FAIL) { + if (status) { pr_debug("%s: failed erase, page 0x%08x\n", __func__, page); instr->state = MTD_ERASE_FAILED;