From patchwork Fri Aug 17 16:09:19 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Boris Brezillon X-Patchwork-Id: 10569225 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 7AD1914BD for ; Fri, 17 Aug 2018 16:55:00 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6B7F22ACE1 for ; Fri, 17 Aug 2018 16:55:00 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5CDD42B37E; Fri, 17 Aug 2018 16:55:00 +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 DBF632ACDF for ; Fri, 17 Aug 2018 16:54:59 +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=uZ9y9tvTGaskWMCXIb/fLS4NtuW/SGZ6qVXZAQYREvc=; b=WL/r/qwfTvBpK2qSJFZ9jvFLyX NikU4BSHVAHmZ4dWedzCzVy64ZpP8EeX46u41fjH0s2VXfOCR/A0PCsY/daq6JiTri6PcDOF0mR5w 8LPQbF3tm/el0/RazyTa4kIBUZ9K/02PS8m19+BlxosvIMigKmyfW4dolD9lwCmqoaecwsVqQHEf9 UYgW6TvZGHVUk96P1PvDge6KPSm+PIDcy1lkcIIeHEyvkZSAtzaz4Lyq/JLQySCItzvLwBD/lZb+r x7l7N4foXKCxle2B8Fl6JqoPjB0Gt85TH7hwXO2KTB+jySHrQMrPVpdtXS6ciDE4JXpJB8pCyHBjT lsKg8/xQ==; 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 1fqi1b-000316-IC for patchwork-linux-mediatek@patchwork.kernel.org; Fri, 17 Aug 2018 16:54:59 +0000 Received: from merlin.infradead.org ([2001:8b0:10b:1231::1]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fqhzu-0001uP-DO; Fri, 17 Aug 2018 16:53:14 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.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=oicbX5oeZfznt38cBcCDNUXn6iEnwjhNw2VpgKENsJQ=; b=CnO2Ls6PEjwTUW3kYwQ5PBis4 5r8mP0pP9Y2vBCNjvplB5Q4NhsRUCR8nSyAjywGXQy61fk/ZmW3md/pQK1LAq04vO3VoetX9RtI5K pmaG9BSxBduJ+5ShGajwRPM9aQsNlRhwiCdaLKrVr5kat4b/v6EyYg08VbpRo0my+91hLmI8lj8Fp hYa7eY9qLq6U+ooY8baSOGwMGzHcl5tA8y3wo6PjLLFvsVIlWVuuXCauZvxV8zA3KNJT9b52S5Duw 7LKAOdPRsIJU5fIvDO8jRuLW9eHa14TxkOfjhEXoBwc9csW8aRgGwQuTMplduSYRpXVfycylMVbm+ qESeQnFtQ==; Received: from mail.bootlin.com ([62.4.15.54]) by merlin.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1fqhKM-0001yE-0U; Fri, 17 Aug 2018 16:10:19 +0000 Received: by mail.bootlin.com (Postfix, from userid 110) id 872A0215D4; Fri, 17 Aug 2018 18:09:49 +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 0346B212F4; Fri, 17 Aug 2018 18:09:47 +0200 (CEST) From: Boris Brezillon To: Boris Brezillon , Richard Weinberger , Miquel Raynal , linux-mtd@lists.infradead.org Subject: [PATCH 20/23] mtd: rawnand: Pass a nand_chip object to chip->setup_read_retry() Date: Fri, 17 Aug 2018 18:09:19 +0200 Message-Id: <20180817160922.6224-21-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_121018_259275_E8C7CF9C X-CRM114-Status: GOOD ( 20.38 ) 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 chip->setup_read_retry() hook. Signed-off-by: Boris Brezillon --- drivers/mtd/nand/raw/nand_base.c | 12 +++++------- drivers/mtd/nand/raw/nand_hynix.c | 3 +-- drivers/mtd/nand/raw/nand_micron.c | 3 +-- include/linux/mtd/rawnand.h | 2 +- 4 files changed, 8 insertions(+), 12 deletions(-) diff --git a/drivers/mtd/nand/raw/nand_base.c b/drivers/mtd/nand/raw/nand_base.c index 0ae597ced5b4..a7575aa68c48 100644 --- a/drivers/mtd/nand/raw/nand_base.c +++ b/drivers/mtd/nand/raw/nand_base.c @@ -3475,17 +3475,15 @@ static uint8_t *nand_transfer_oob(struct mtd_info *mtd, uint8_t *oob, /** * nand_setup_read_retry - [INTERN] Set the READ RETRY mode - * @mtd: MTD device structure + * @chip: NAND chip object * @retry_mode: the retry mode to use * * Some vendors supply a special command to shift the Vt threshold, to be used * when there are too many bitflips in a page (i.e., ECC error). After setting * a new threshold, the host should retry reading the page. */ -static int nand_setup_read_retry(struct mtd_info *mtd, int retry_mode) +static int nand_setup_read_retry(struct nand_chip *chip, int retry_mode) { - struct nand_chip *chip = mtd_to_nand(mtd); - pr_debug("setting READ RETRY mode %d\n", retry_mode); if (retry_mode >= chip->read_retries) @@ -3494,7 +3492,7 @@ static int nand_setup_read_retry(struct mtd_info *mtd, int retry_mode) if (!chip->setup_read_retry) return -EOPNOTSUPP; - return chip->setup_read_retry(mtd, retry_mode); + return chip->setup_read_retry(chip, retry_mode); } static void nand_wait_readrdy(struct nand_chip *chip) @@ -3619,7 +3617,7 @@ static int nand_do_read_ops(struct mtd_info *mtd, loff_t from, if (mtd->ecc_stats.failed - ecc_failures) { if (retry_mode + 1 < chip->read_retries) { retry_mode++; - ret = nand_setup_read_retry(mtd, + ret = nand_setup_read_retry(chip, retry_mode); if (ret < 0) break; @@ -3646,7 +3644,7 @@ static int nand_do_read_ops(struct mtd_info *mtd, loff_t from, /* Reset to retry mode 0 */ if (retry_mode) { - ret = nand_setup_read_retry(mtd, 0); + ret = nand_setup_read_retry(chip, 0); if (ret < 0) break; retry_mode = 0; diff --git a/drivers/mtd/nand/raw/nand_hynix.c b/drivers/mtd/nand/raw/nand_hynix.c index fa873e517131..bb1c4f8ce785 100644 --- a/drivers/mtd/nand/raw/nand_hynix.c +++ b/drivers/mtd/nand/raw/nand_hynix.c @@ -113,9 +113,8 @@ static int hynix_nand_reg_write_op(struct nand_chip *chip, u8 addr, u8 val) return 0; } -static int hynix_nand_setup_read_retry(struct mtd_info *mtd, int retry_mode) +static int hynix_nand_setup_read_retry(struct nand_chip *chip, int retry_mode) { - struct nand_chip *chip = mtd_to_nand(mtd); struct hynix_nand *hynix = nand_get_manufacturer_data(chip); const u8 *values; int i, ret; diff --git a/drivers/mtd/nand/raw/nand_micron.c b/drivers/mtd/nand/raw/nand_micron.c index 2f26dbeb5428..1a5505ccbe54 100644 --- a/drivers/mtd/nand/raw/nand_micron.c +++ b/drivers/mtd/nand/raw/nand_micron.c @@ -74,9 +74,8 @@ struct micron_nand { struct micron_on_die_ecc ecc; }; -static int micron_nand_setup_read_retry(struct mtd_info *mtd, int retry_mode) +static int micron_nand_setup_read_retry(struct nand_chip *chip, int retry_mode) { - struct nand_chip *chip = mtd_to_nand(mtd); u8 feature[ONFI_SUBFEATURE_PARAM_LEN] = {retry_mode}; return nand_set_features(chip, ONFI_FEATURE_ADDR_READ_RETRY, feature); diff --git a/include/linux/mtd/rawnand.h b/include/linux/mtd/rawnand.h index 471ad78d27a5..6f5e7ea36dab 100644 --- a/include/linux/mtd/rawnand.h +++ b/include/linux/mtd/rawnand.h @@ -1303,7 +1303,7 @@ struct nand_chip { uint8_t *subfeature_para); int (*get_features)(struct nand_chip *chip, int feature_addr, uint8_t *subfeature_para); - int (*setup_read_retry)(struct mtd_info *mtd, int retry_mode); + int (*setup_read_retry)(struct nand_chip *chip, int retry_mode); int (*setup_data_interface)(struct mtd_info *mtd, int chipnr, const struct nand_data_interface *conf);