Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp4139810imm; Sat, 21 Jul 2018 11:05:22 -0700 (PDT) X-Google-Smtp-Source: AAOMgpeWFkRz4Ixq2ptSN2CKy+SK2DWR3CWvdifPlH4M3ZovqimnKKavjQ+rf/aiHmcSqUDUUEea X-Received: by 2002:a65:53cb:: with SMTP id z11-v6mr6339889pgr.218.1532196322082; Sat, 21 Jul 2018 11:05:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532196322; cv=none; d=google.com; s=arc-20160816; b=cegyhbm1gV61fcGQln9G8m6HljT17Jn2Zmy24wFuZfO5+J7pMqcm6S9gV/kyFAgHV4 H0lvvDtqxte18w2W+oK2369iR5dl15aAXqun+58c+GQYaJYwntsXhZTmXnb5nqnDul+j v+82pj3C65tujYTG2sotAzxYew138eWQV697OS3xG2uSZqHakPXTXdmJexa+P7YFDZai 7JaYTcNJmiuPQy19cytNP6DaYRE60Nnoipj9QZtFvJXJOYOVWneq/Q5VLEWq+ENNFvkH HtAODCBHTCGJqFwNqybggG7U9FlVZZg/36630lVRFq54waa0KiyX84AIFD3U4qVDUDV7 Fwig== 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=+hwpCOwCp3LlFf+PA1f17DNo2C2ysYmdUWCtBJR0Jjs=; b=DdrMTxTOf8WUwicv1xZ9F5Jr9zSSEreMLvyhZG3o1cbDsmRptDT93gGi0lioqNwAY9 V7w0yHJUQxwptJyf93E3xGpH/vSpGKDksl5BAyZzRBRIGCK8t+tgDrWUraBWlV0P6MXp H4yupVqZ6zNgp1Qlii4jznrBnWbqVL7l1hgPWpnTnCaYlMHVrklDI68SZpckOvolcOAB XY+ATrMqdIiVaj5IFS4fszhjxw/k17kESUOeyV9ljZXzOlDkbPYt+q3utoPZQT5xe7Wn e3FoB+Hhi8ZoiLzIYUcLQdXvpTG/KjuXh68OCnETyrgvICovrZAs6LGtOGWCH1ylLM1T W4yQ== 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 p17-v6si4640648pfd.76.2018.07.21.11.05.07; Sat, 21 Jul 2018 11:05:22 -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 S1728207AbeGUS5y (ORCPT + 99 others); Sat, 21 Jul 2018 14:57:54 -0400 Received: from mail.bootlin.com ([62.4.15.54]:50656 "EHLO mail.bootlin.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727458AbeGUS5x (ORCPT ); Sat, 21 Jul 2018 14:57:53 -0400 Received: by mail.bootlin.com (Postfix, from userid 110) id 52E2420717; Sat, 21 Jul 2018 20:04:17 +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 8F366203D9; Sat, 21 Jul 2018 20:04:05 +0200 (CEST) Date: Sat, 21 Jul 2018 20:04:04 +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 24/35] mtd: rawnand: txx9ndfmc: convert driver to nand_scan() Message-ID: <20180721200404.419fad90@bbrezillon> In-Reply-To: <20180720151527.16038-25-miquel.raynal@bootlin.com> References: <20180720151527.16038-1-miquel.raynal@bootlin.com> <20180720151527.16038-25-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:16 +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 > --- > drivers/mtd/nand/raw/txx9ndfmc.c | 29 +++++++++++++++-------------- > 1 file changed, 15 insertions(+), 14 deletions(-) > > diff --git a/drivers/mtd/nand/raw/txx9ndfmc.c b/drivers/mtd/nand/raw/txx9ndfmc.c > index 9019022774f7..0134beb1136d 100644 > --- a/drivers/mtd/nand/raw/txx9ndfmc.c > +++ b/drivers/mtd/nand/raw/txx9ndfmc.c > @@ -254,23 +254,23 @@ static void txx9ndfmc_initialize(struct platform_device *dev) > #define TXX9NDFMC_NS_TO_CYC(gbusclk, ns) \ > DIV_ROUND_UP((ns) * DIV_ROUND_UP(gbusclk, 1000), 1000000) > > -static int txx9ndfmc_nand_scan(struct mtd_info *mtd) > +static int txx9ndfmc_attach_chip(struct nand_chip *chip) > { > - struct nand_chip *chip = mtd_to_nand(mtd); > - int ret; > + struct mtd_info *mtd = nand_to_mtd(chip); > > - ret = nand_scan_ident(mtd, 1, NULL); > - if (!ret) { > - if (mtd->writesize >= 512) { > - /* Hardware ECC 6 byte ECC per 512 Byte data */ > - chip->ecc.size = 512; > - chip->ecc.bytes = 6; > - } > - ret = nand_scan_tail(mtd); > + if (mtd->writesize >= 512) { > + /* Hardware ECC 6 byte ECC per 512 Byte data */ > + chip->ecc.size = 512; > + chip->ecc.bytes = 6; > } > - return ret; > + > + return 0; > } > > +static const struct nand_controller_ops txx9ndfmc_controller_ops = { > + .attach_chip = txx9ndfmc_attach_chip, > +}; > + > static int __init txx9ndfmc_probe(struct platform_device *dev) > { > struct txx9ndfmc_platform_data *plat = dev_get_platdata(&dev->dev); > @@ -304,6 +304,7 @@ static int __init txx9ndfmc_probe(struct platform_device *dev) > (gbusclk + 500000) / 1000000, hold, spw); > > nand_controller_init(&drvdata->controller); > + drvdata->controller.ops = &txx9ndfmc_controller_ops; > > platform_set_drvdata(dev, drvdata); > txx9ndfmc_initialize(dev); > @@ -332,7 +333,7 @@ static int __init txx9ndfmc_probe(struct platform_device *dev) > chip->ecc.correct = txx9ndfmc_correct_data; > chip->ecc.hwctl = txx9ndfmc_enable_hwecc; > chip->ecc.mode = NAND_ECC_HW; > - /* txx9ndfmc_nand_scan will overwrite ecc.size and ecc.bytes */ > + /* nand_scan() will overwrite ecc.size and ecc.bytes */ > chip->ecc.size = 256; > chip->ecc.bytes = 3; I had a hard time understanding what was the point of assigning values that would later be overwritten. Actually the comment is inaccurate, it's only overwritten if mtd->writesize >= 512. Can you had a patch that moves this block in txx9ndfmc_nand_scan() before doing the ->attach_chip() conversion? > chip->ecc.strength = 1; > @@ -359,7 +360,7 @@ static int __init txx9ndfmc_probe(struct platform_device *dev) > if (plat->wide_mask & (1 << i)) > chip->options |= NAND_BUSWIDTH_16; > > - if (txx9ndfmc_nand_scan(mtd)) { > + if (nand_scan(mtd, 1)) { > kfree(txx9_priv->mtdname); > kfree(txx9_priv); > continue;