Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp4130475imm; Sat, 21 Jul 2018 10:51:58 -0700 (PDT) X-Google-Smtp-Source: AAOMgpcwCLK32izW6QcIvliV4qZJsi9cSLJIjPns2cUdtb4U9vym7Gb3HHeCZCrGord9a6yIlFdt X-Received: by 2002:a65:560a:: with SMTP id l10-v6mr6497779pgs.130.1532195518143; Sat, 21 Jul 2018 10:51:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532195518; cv=none; d=google.com; s=arc-20160816; b=RaKRXVJBMG4HyUzQuJntZrBAWer0VmTirTuaJ18NXDuiA9k3ztd9kgQqBChmSixxRY gPJTbREtAsyJNU1qI8QIeRFtl9ugdfFCC4GOcQJ2VbABO2CnQ244EjU7QyY7d3sKCGBq qgPj3bxzW334VTORguiKWce6CC6JHZ6e9J/J8vi6FaZ99PA8JCH9CeIF6z2O/m+MYueH J6B7GkA+qXIAs/7Tx11CyJezysWt7gfYtabEp+0j/ggcIFlBVH2LcCFedWq5l19iWzBN 387kPYYIquMsKhepdGSnx5UolxmV9bya9NKahEKEynkyDYp3biSSXmAfMrHziH8Beahs 7BAg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :arc-authentication-results; bh=iMBn0ieohU/qGGlOwTKM5mHn8/KP/cdFp5mGQ1Ay5X0=; b=uKb+gESJlV4uuoN3RoU+aBXljks4rLCF/hHwtuM6HcpceJGkuHxDM9Rz5JmW4R/9r/ Srzdld5JD7II2VkrtB8YHY2xX4shNEsEuBu7GdNemRVuaTogoZqwH2GDqa/CHy8sTBNt VDdjeWcMQG1xXGjpn6zbuLWCljA9D2w2UDoA9rbiDywRE4ZKtLvdML/Q94Sz2OYFcyDH xvfZNEfFsx8t5vAOkLYYC+KUHSvIdqMbapTpgNkbQrR6wie224cE9JmS8kZU9Gn585Mm ObONEJrEVnWZYQeAJIpDkkIN7GnD5GupPfMAqIhSMW2mMgqlQ2kzkTeFXVKZ0QV5iLCA maVQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l128-v6si4423858pfc.129.2018.07.21.10.51.43; Sat, 21 Jul 2018 10:51:58 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728314AbeGUSoS (ORCPT + 99 others); Sat, 21 Jul 2018 14:44:18 -0400 Received: from mail.bootlin.com ([62.4.15.54]:50109 "EHLO mail.bootlin.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727854AbeGUSoS (ORCPT ); Sat, 21 Jul 2018 14:44:18 -0400 Received: by mail.bootlin.com (Postfix, from userid 110) id 913112093C; Sat, 21 Jul 2018 19:50:44 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on mail.bootlin.com X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=ALL_TRUSTED,SHORTCIRCUIT, URIBL_BLOCKED shortcircuit=ham autolearn=disabled version=3.4.0 Received: from bbrezillon (unknown [37.173.79.60]) by mail.bootlin.com (Postfix) with ESMTPSA id 460FF206F3; Sat, 21 Jul 2018 19:50:32 +0200 (CEST) Date: Sat, 21 Jul 2018 19:50:30 +0200 From: Boris Brezillon To: Miquel Raynal Cc: Wenyou Yang , Josh Wu , Tudor Ambarus , Richard Weinberger , David Woodhouse , Brian Norris , Marek Vasut , Nicolas Ferre , Alexandre Belloni , Kamal Dasu , Masahiro Yamada , Han Xu , Harvey Hunt , Vladimir Zapolskiy , Sylvain Lemieux , Xiaolei Li , Matthias Brugger , Maxime Ripard , Chen-Yu Tsai , Marc Gonzalez , Mans Rullgard , Stefan Agner , linux-mtd@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, bcm-kernel-feedback-list@broadcom.com, linux-mediatek@lists.infradead.org Subject: Re: [PATCH v4 21/35] mtd: rawnand: sunxi: convert driver to nand_scan() Message-ID: <20180721195030.62264dd9@bbrezillon> In-Reply-To: <20180720151527.16038-22-miquel.raynal@bootlin.com> References: <20180720151527.16038-1-miquel.raynal@bootlin.com> <20180720151527.16038-22-miquel.raynal@bootlin.com> X-Mailer: Claws Mail 3.15.0-dirty (GTK+ 2.24.31; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 20 Jul 2018 17:15:13 +0200 Miquel Raynal wrote: > Two helpers have been added to the core to make ECC-related > configuration between the detection phase and the final NAND scan. Use > these hooks and convert the driver to just use nand_scan() instead of > both nand_scan_ident() and nand_scan_tail(). > > Signed-off-by: Miquel Raynal Reviewed-by: Boris Brezillon > --- > drivers/mtd/nand/raw/sunxi_nand.c | 43 +++++++++++++++++---------------------- > 1 file changed, 19 insertions(+), 24 deletions(-) > > diff --git a/drivers/mtd/nand/raw/sunxi_nand.c b/drivers/mtd/nand/raw/sunxi_nand.c > index 07f3ff9a28f2..a4d23381003d 100644 > --- a/drivers/mtd/nand/raw/sunxi_nand.c > +++ b/drivers/mtd/nand/raw/sunxi_nand.c > @@ -1816,12 +1816,21 @@ static void sunxi_nand_ecc_cleanup(struct nand_ecc_ctrl *ecc) > } > } > > -static int sunxi_nand_ecc_init(struct mtd_info *mtd, struct nand_ecc_ctrl *ecc, > - struct device_node *np) > +static int sunxi_nand_attach_chip(struct nand_chip *nand) > { > - struct nand_chip *nand = mtd_to_nand(mtd); > + struct mtd_info *mtd = nand_to_mtd(nand); > + struct nand_ecc_ctrl *ecc = &nand->ecc; > + struct device_node *np = nand_get_flash_node(nand); > int ret; > > + if (nand->bbt_options & NAND_BBT_USE_FLASH) > + nand->bbt_options |= NAND_BBT_NO_OOB; > + > + if (nand->options & NAND_NEED_SCRAMBLING) > + nand->options |= NAND_NO_SUBPAGE_WRITE; > + > + nand->options |= NAND_SUBPAGE_READ; > + > if (!ecc->size) { > ecc->size = nand->ecc_step_ds; > ecc->strength = nand->ecc_strength_ds; > @@ -1846,6 +1855,10 @@ static int sunxi_nand_ecc_init(struct mtd_info *mtd, struct nand_ecc_ctrl *ecc, > return 0; > } > > +static const struct nand_controller_ops sunxi_nand_controller_ops = { > + .attach_chip = sunxi_nand_attach_chip, > +}; > + > static int sunxi_nand_chip_init(struct device *dev, struct sunxi_nfc *nfc, > struct device_node *np) > { > @@ -1911,6 +1924,8 @@ static int sunxi_nand_chip_init(struct device *dev, struct sunxi_nfc *nfc, > /* Default tR value specified in the ONFI spec (chapter 4.15.1) */ > nand->chip_delay = 200; > nand->controller = &nfc->controller; > + nand->controller->ops = &sunxi_nand_controller_ops; > + > /* > * Set the ECC mode to the default value in case nothing is specified > * in the DT. > @@ -1927,30 +1942,10 @@ static int sunxi_nand_chip_init(struct device *dev, struct sunxi_nfc *nfc, > mtd = nand_to_mtd(nand); > mtd->dev.parent = dev; > > - ret = nand_scan_ident(mtd, nsels, NULL); > + ret = nand_scan(mtd, nsels); > if (ret) > return ret; > > - if (nand->bbt_options & NAND_BBT_USE_FLASH) > - nand->bbt_options |= NAND_BBT_NO_OOB; > - > - if (nand->options & NAND_NEED_SCRAMBLING) > - nand->options |= NAND_NO_SUBPAGE_WRITE; > - > - nand->options |= NAND_SUBPAGE_READ; > - > - ret = sunxi_nand_ecc_init(mtd, &nand->ecc, np); > - if (ret) { > - dev_err(dev, "ECC init failed: %d\n", ret); > - return ret; > - } > - > - ret = nand_scan_tail(mtd); > - if (ret) { > - dev_err(dev, "nand_scan_tail failed: %d\n", ret); > - return ret; > - } > - > ret = mtd_device_register(mtd, NULL, 0); > if (ret) { > dev_err(dev, "failed to register mtd device: %d\n", ret);