From patchwork Fri Aug 17 16:09:22 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Boris Brezillon X-Patchwork-Id: 10569187 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 4A404109C for ; Fri, 17 Aug 2018 16:25:16 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3C4D12B169 for ; Fri, 17 Aug 2018 16:25:16 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2F6392B188; Fri, 17 Aug 2018 16:25:16 +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=-2.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.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 BD1082B169 for ; Fri, 17 Aug 2018 16:25:15 +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=365RMq8qTVr3Qa6/mcrKbyrtH+ozHusdlG+mN+Tw0SA=; b=CCI7j/XWQJYsBi31aW9RTpWAFb HHymIwp8Z7BOq1LWz8M2R04ycE+5+zUikKI5M24mZH8Wopt1EroRbXWhDwlZgjFUmIGqbpmZd6ibJ JeMcQMraYxBt4mA6KeRQx+cLsNINGfRqpNp2wdnen0EfHI+oJtQ2K6N73EH4k0w3ci7QJwaRhbwWS sPMblacmH+0AnsAiM9d2vI3A69UimuBx0bkHEMDx4HEs9VpiJyWVdF5lRPL4q+GYI8/ZeYj+6VAw4 HVhkV8Q0pZIJfHP8ZKBNXRIo+mW+QXKPxojxC8IAxoZclBlvg3jJqf3514e5W7RdvFph9sfCwLG2P h4IR0HhA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1fqhYn-00076V-QJ; Fri, 17 Aug 2018 16:25:13 +0000 Received: from mail.bootlin.com ([62.4.15.54]) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1fqhKX-0005XG-MK; Fri, 17 Aug 2018 16:10:56 +0000 Received: by mail.bootlin.com (Postfix, from userid 110) id 9FF27215E4; Fri, 17 Aug 2018 18:10:14 +0200 (CEST) Received: from localhost.localdomain (91-160-177-164.subs.proxad.net [91.160.177.164]) by mail.bootlin.com (Postfix) with ESMTPSA id 3716A215DD; Fri, 17 Aug 2018 18:09:57 +0200 (CEST) From: Boris Brezillon To: Boris Brezillon , Richard Weinberger , Miquel Raynal , linux-mtd@lists.infradead.org Subject: [PATCH 23/23] mtd: rawnand: Pass a nand_chip object nand_erase_nand() Date: Fri, 17 Aug 2018 18:09:22 +0200 Message-Id: <20180817160922.6224-24-boris.brezillon@bootlin.com> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20180817160922.6224-1-boris.brezillon@bootlin.com> References: <20180817160922.6224-1-boris.brezillon@bootlin.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180817_091030_488521_57F53477 X-CRM114-Status: GOOD ( 17.13 ) X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Andrew Lunn , Alexandre Belloni , Rich Felker , linux-doc@vger.kernel.org, Tony Lindgren , linux-mips@linux-mips.org, Stefan Agner , Masahiro Yamada , Mans Rullgard , Robert Jarzmik , Jason Cooper , devel@driverdev.osuosl.org, Maxime Ripard , Maxim Levitsky , Yoshinori Sato , Aaro Koskinen , Gregory Clement , linux-sh@vger.kernel.org, Lukasz Majewski , Neil Armstrong , Marek Vasut , Chen-Yu Tsai , NXP Linux Team , Sylvain Lemieux , Sebastian Hesselbarth , Alexander Clouter , Wan ZongShun , Marc Gonzalez , Sascha Hauer , Haojian Zhuang , Vladimir Zapolskiy , Harvey Hunt , Krzysztof Halasa , Kamal Dasu , Matthias Brugger , Han Xu , Xiaolei Li , linux-omap@vger.kernel.org, Alexander Sverdlin , linux-arm-kernel@lists.infradead.org, Brian Norris , David Woodhouse , Jonathan Corbet , Nicolas Ferre , Ralf Baechle , Hartley Sweeten , Pengutronix Kernel Team , Greg Kroah-Hartman , Fabio Estevam , linux-mediatek@lists.infradead.org, Imre Kaloz , Shawn Guo , Daniel Mack MIME-Version: 1.0 Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+patchwork-linux-mediatek=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Let's make the raw NAND API consistent by patching all helpers and hooks to take a nand_chip object instead of an mtd_info one or remove the mtd_info object when both are passed. Let's tackle the nand_erase_nand() helper. Signed-off-by: Boris Brezillon --- drivers/mtd/nand/raw/nand_base.c | 10 +++++----- drivers/mtd/nand/raw/nand_bbt.c | 2 +- include/linux/mtd/rawnand.h | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/mtd/nand/raw/nand_base.c b/drivers/mtd/nand/raw/nand_base.c index 074de0c8c9dc..ef4d90ed896d 100644 --- a/drivers/mtd/nand/raw/nand_base.c +++ b/drivers/mtd/nand/raw/nand_base.c @@ -505,7 +505,7 @@ static int nand_block_markbad_lowlevel(struct mtd_info *mtd, loff_t ofs) memset(&einfo, 0, sizeof(einfo)); einfo.addr = ofs; einfo.len = 1ULL << chip->phys_erase_shift; - nand_erase_nand(mtd, &einfo, 0); + nand_erase_nand(chip, &einfo, 0); /* Write bad block marker to OOB */ nand_get_device(mtd, FL_WRITING); @@ -4638,22 +4638,22 @@ static int single_erase(struct nand_chip *chip, int page) */ static int nand_erase(struct mtd_info *mtd, struct erase_info *instr) { - return nand_erase_nand(mtd, instr, 0); + return nand_erase_nand(mtd_to_nand(mtd), instr, 0); } /** * nand_erase_nand - [INTERN] erase block(s) - * @mtd: MTD device structure + * @chip: NAND chip object * @instr: erase instruction * @allowbbt: allow erasing the bbt area * * Erase one ore more blocks. */ -int nand_erase_nand(struct mtd_info *mtd, struct erase_info *instr, +int nand_erase_nand(struct nand_chip *chip, struct erase_info *instr, int allowbbt) { + struct mtd_info *mtd = nand_to_mtd(chip); int page, status, pages_per_block, ret, chipnr; - struct nand_chip *chip = mtd_to_nand(mtd); loff_t len; pr_debug("%s: start = 0x%012llx, len = %llu\n", diff --git a/drivers/mtd/nand/raw/nand_bbt.c b/drivers/mtd/nand/raw/nand_bbt.c index 7424be0547f8..9d73e086c5de 100644 --- a/drivers/mtd/nand/raw/nand_bbt.c +++ b/drivers/mtd/nand/raw/nand_bbt.c @@ -853,7 +853,7 @@ static int write_bbt(struct mtd_info *mtd, uint8_t *buf, memset(&einfo, 0, sizeof(einfo)); einfo.addr = to; einfo.len = 1 << this->bbt_erase_shift; - res = nand_erase_nand(mtd, &einfo, 1); + res = nand_erase_nand(this, &einfo, 1); if (res < 0) { pr_warn("nand_bbt: error while erasing BBT block %d\n", res); diff --git a/include/linux/mtd/rawnand.h b/include/linux/mtd/rawnand.h index eaf3d48032ed..5339f5c8307d 100644 --- a/include/linux/mtd/rawnand.h +++ b/include/linux/mtd/rawnand.h @@ -1548,7 +1548,7 @@ int nand_create_bbt(struct nand_chip *chip); int nand_markbad_bbt(struct nand_chip *chip, loff_t offs); int nand_isreserved_bbt(struct nand_chip *chip, loff_t offs); int nand_isbad_bbt(struct nand_chip *chip, loff_t offs, int allowbbt); -int nand_erase_nand(struct mtd_info *mtd, struct erase_info *instr, +int nand_erase_nand(struct nand_chip *chip, struct erase_info *instr, int allowbbt); /**