From patchwork Thu Sep 6 12:05:34 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Boris Brezillon X-Patchwork-Id: 10590549 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 CC72B1669 for ; Thu, 6 Sep 2018 12:40:30 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B19A62A839 for ; Thu, 6 Sep 2018 12:40:30 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A50E72A849; Thu, 6 Sep 2018 12:40:30 +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 21A452A839 for ; Thu, 6 Sep 2018 12:40:30 +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=aoNdiofOcMWKDlH8ah1VWWGIak/0JzQnCEboOm2jG3o=; b=b8Cv1v3tljLQgwY8kdFgdIZL24 uZ8P0KILyJiWmcIWOFyaBcza9ixJmw/0sbayuSUFlN7Np+q1v28ggZhjVtO0S6Uh/yVtYRelI67CN d4nJm81XXnq+z2gvHopyOizwYX07R3Ky20eZwNL4WyKIHXoLqERsV5Fq/agaok6UF13OX3xFVzBfV TJnUZkrHjGJc5VvCuucWB4RjewdcqGMVdN/fj9Z5U5BwgsxLJDPkBrTkZEesL2R5GGJ6pAUaL2dJu lAPlUVOPo0NxkYB5JCVvpfIaByENKCernLvXgN/M42Gjva/uqifMUHJo1/YEu9sovHRPiRSgLYgcc 0PIItx2Q==; 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 1fxtaE-000528-7B for patchwork-linux-mediatek@patchwork.kernel.org; Thu, 06 Sep 2018 12:40:26 +0000 Received: from casper.infradead.org ([2001:8b0:10b:1236::1]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fxtXV-0002zB-Nh; Thu, 06 Sep 2018 12:37:38 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=References:In-Reply-To:Message-Id:Date: Subject:Cc:To:From:Sender:Reply-To:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=olIZPpFRkCVIn1/dp8uDv+vJF3Sq2xuFj+r6lhN7nA8=; b=V9Z+Njzv31rvT/FZ7+4RaHsWe ahVlyjKC5cj73kInHdrM31p4e+EVVfoZt7ahDUbqSjLbWxbMTo7QQ1oKm/E9eKVMFb2Qe3wQn8uB3 jy7OxARWVxmFSuLVPQzjQOBv07Xr6MgVlYXEI+/2ZSoq2R+gmoQtbncr829UKymZk9chEL3q9v6Z8 2by5z++hwH2NFXmLIdSFgpsxDWt97ofWoyHOZ849I9EueWFiOY9Omuh1+7960iXucjrwu3XicCZwM CW/zMHrmBl7yJN//1VoOpUBD+87SUPGnyec4/AB9ue08kEhshPlO7AdYS2M9QavvI9sjP5DICCUx6 v16gQsvlg==; Received: from mail.bootlin.com ([62.4.15.54]) by casper.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1fxt3O-0008AM-78; Thu, 06 Sep 2018 12:06:35 +0000 Received: by mail.bootlin.com (Postfix, from userid 110) id CDF7022A49; Thu, 6 Sep 2018 14:06:12 +0200 (CEST) Received: from localhost.localdomain (AAubervilliers-681-1-30-219.w90-88.abo.wanadoo.fr [90.88.15.219]) by mail.bootlin.com (Postfix) with ESMTPSA id C114122AF1; Thu, 6 Sep 2018 14:06:01 +0200 (CEST) From: Boris Brezillon To: Boris Brezillon , Richard Weinberger , Miquel Raynal , linux-mtd@lists.infradead.org Subject: [PATCH v2 22/23] mtd: rawnand: Pass a nand_chip object to all nand_xxx_bbt() helpers Date: Thu, 6 Sep 2018 14:05:34 +0200 Message-Id: <20180906120535.21255-23-boris.brezillon@bootlin.com> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20180906120535.21255-1-boris.brezillon@bootlin.com> References: <20180906120535.21255-1-boris.brezillon@bootlin.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180906_130630_446211_508E0F91 X-CRM114-Status: GOOD ( 22.06 ) 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_xxx_bbt() helpers. Signed-off-by: Boris Brezillon --- drivers/mtd/nand/raw/nand_base.c | 6 +++--- drivers/mtd/nand/raw/nand_bbt.c | 16 +++++++--------- include/linux/mtd/rawnand.h | 6 +++--- 3 files changed, 13 insertions(+), 15 deletions(-) diff --git a/drivers/mtd/nand/raw/nand_base.c b/drivers/mtd/nand/raw/nand_base.c index 0a89ab663728..074de0c8c9dc 100644 --- a/drivers/mtd/nand/raw/nand_base.c +++ b/drivers/mtd/nand/raw/nand_base.c @@ -515,7 +515,7 @@ static int nand_block_markbad_lowlevel(struct mtd_info *mtd, loff_t ofs) /* Mark block bad in BBT */ if (chip->bbt) { - res = nand_markbad_bbt(mtd, ofs); + res = nand_markbad_bbt(chip, ofs); if (!ret) ret = res; } @@ -565,7 +565,7 @@ static int nand_block_isreserved(struct mtd_info *mtd, loff_t ofs) if (!chip->bbt) return 0; /* Return info from the table */ - return nand_isreserved_bbt(mtd, ofs); + return nand_isreserved_bbt(chip, ofs); } /** @@ -585,7 +585,7 @@ static int nand_block_checkbad(struct mtd_info *mtd, loff_t ofs, int allowbbt) return chip->block_bad(chip, ofs); /* Return info from the table */ - return nand_isbad_bbt(mtd, ofs, allowbbt); + return nand_isbad_bbt(chip, ofs, allowbbt); } /** diff --git a/drivers/mtd/nand/raw/nand_bbt.c b/drivers/mtd/nand/raw/nand_bbt.c index 76849a441518..7424be0547f8 100644 --- a/drivers/mtd/nand/raw/nand_bbt.c +++ b/drivers/mtd/nand/raw/nand_bbt.c @@ -1387,12 +1387,11 @@ EXPORT_SYMBOL(nand_create_bbt); /** * nand_isreserved_bbt - [NAND Interface] Check if a block is reserved - * @mtd: MTD device structure + * @this: NAND chip object * @offs: offset in the device */ -int nand_isreserved_bbt(struct mtd_info *mtd, loff_t offs) +int nand_isreserved_bbt(struct nand_chip *this, loff_t offs) { - struct nand_chip *this = mtd_to_nand(mtd); int block; block = (int)(offs >> this->bbt_erase_shift); @@ -1401,13 +1400,12 @@ int nand_isreserved_bbt(struct mtd_info *mtd, loff_t offs) /** * nand_isbad_bbt - [NAND Interface] Check if a block is bad - * @mtd: MTD device structure + * @this: NAND chip object * @offs: offset in the device * @allowbbt: allow access to bad block table region */ -int nand_isbad_bbt(struct mtd_info *mtd, loff_t offs, int allowbbt) +int nand_isbad_bbt(struct nand_chip *this, loff_t offs, int allowbbt) { - struct nand_chip *this = mtd_to_nand(mtd); int block, res; block = (int)(offs >> this->bbt_erase_shift); @@ -1429,12 +1427,12 @@ int nand_isbad_bbt(struct mtd_info *mtd, loff_t offs, int allowbbt) /** * nand_markbad_bbt - [NAND Interface] Mark a block bad in the BBT - * @mtd: MTD device structure + * @this: NAND chip object * @offs: offset of the bad block */ -int nand_markbad_bbt(struct mtd_info *mtd, loff_t offs) +int nand_markbad_bbt(struct nand_chip *this, loff_t offs) { - struct nand_chip *this = mtd_to_nand(mtd); + struct mtd_info *mtd = nand_to_mtd(this); int block, ret = 0; block = (int)(offs >> this->bbt_erase_shift); diff --git a/include/linux/mtd/rawnand.h b/include/linux/mtd/rawnand.h index 5bfb9d543a8a..e0d98ca7cb45 100644 --- a/include/linux/mtd/rawnand.h +++ b/include/linux/mtd/rawnand.h @@ -1545,9 +1545,9 @@ extern const struct nand_manufacturer_ops amd_nand_manuf_ops; extern const struct nand_manufacturer_ops macronix_nand_manuf_ops; int nand_create_bbt(struct nand_chip *chip); -int nand_markbad_bbt(struct mtd_info *mtd, loff_t offs); -int nand_isreserved_bbt(struct mtd_info *mtd, loff_t offs); -int nand_isbad_bbt(struct mtd_info *mtd, loff_t offs, int allowbbt); +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 allowbbt);