Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp4024880imm; Sat, 21 Jul 2018 08:24:31 -0700 (PDT) X-Google-Smtp-Source: AAOMgpcGJOKj6ayMxfI/u9L6w9TB/bXylROSoUpmcWb/vvbG48s1B207NoRj0zNNwvp3wpTpx2cm X-Received: by 2002:a65:64c8:: with SMTP id t8-v6mr5998541pgv.110.1532186671252; Sat, 21 Jul 2018 08:24:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532186671; cv=none; d=google.com; s=arc-20160816; b=F5EgDlyKLcL7qBw71JF4wUbTzso5Qo7+ZqNR3uPpgoU4SKGgEvbFfNv0mKUEEHFXcw Iqpu4Jx1gWSTnPdDvmE3cCaH6+Wwi+dXmaB5btrwL7FoYCwyWWblu8/j4pfeNnxXhIO1 dGturXGkxucOs5Uo6dAU3lmiFZicwXTY8dIDPh2tUsAv5iZI3dMZTsz+qapFvrmrxXqu J9K3aIAfqOzdQRCG3Iy6wmBGXCcY8i5pVl+tQHz06EijW37ljx6oxfgy6KimwHDr9EGt cU4mGo0BdT3UEBl1aSUvNawPZgivvGPd0gRAwaGGIQOP4ociCMzc8RqpP13SE4zkuXwO 0NJQ== 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=2DTqPG0gdFB0jEEr2haAd48cd32SIbiS96Lnj/qW6tI=; b=lcNFFYysKu58qepZ+Jrn88hcdgC9SonNC7DpThKgyZbXbEiRu2cQEKTBu5rPuimnap IglAS5V+5ZaNmAGbL7m4A0FSCbFul+tnTJwl/W9cLiyggkX5PoztmLWgTykEm1jwPzQs 4FvsHKwJ40+g+8xs0QcycXPwG75KCtPUOGk2VRqf8mnW3vIim4Y+ftUxUAuTc7TlXbsW DgUujz57mW1GDMVEJw2EFi8ho5ewh7DqgZkq1q7txbHC0j7c6kGWrezt0mrmqMdF9mm9 xEhbLVNWeAYCPA8leC7I4Yim1oHTCVz+0SGpMau8I9jrnuKSP4xLDJI5mrH2wypEnHDZ aZdg== 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 c10-v6si3913505pla.98.2018.07.21.08.24.16; Sat, 21 Jul 2018 08:24:31 -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 S1728068AbeGUQQc (ORCPT + 99 others); Sat, 21 Jul 2018 12:16:32 -0400 Received: from mail.bootlin.com ([62.4.15.54]:47787 "EHLO mail.bootlin.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727759AbeGUQQc (ORCPT ); Sat, 21 Jul 2018 12:16:32 -0400 Received: by mail.bootlin.com (Postfix, from userid 110) id 31BC22072F; Sat, 21 Jul 2018 17:23:24 +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 shortcircuit=ham autolearn=disabled version=3.4.0 Received: from bbrezillon (unknown [37.173.79.60]) by mail.bootlin.com (Postfix) with ESMTPSA id E51E8206A6; Sat, 21 Jul 2018 17:23:21 +0200 (CEST) Date: Sat, 21 Jul 2018 17:23:19 +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 10/35] mtd: rawnand: jz4780: convert driver to nand_scan() Message-ID: <20180721172250.723b4fd2@bbrezillon> In-Reply-To: <20180720151527.16038-11-miquel.raynal@bootlin.com> References: <20180720151527.16038-1-miquel.raynal@bootlin.com> <20180720151527.16038-11-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:02 +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 > Acked-by: Harvey Hunt Reviewed-by: Boris Brezillon > --- > drivers/mtd/nand/raw/jz4780_nand.c | 34 ++++++++++++++++------------------ > 1 file changed, 16 insertions(+), 18 deletions(-) > > diff --git a/drivers/mtd/nand/raw/jz4780_nand.c b/drivers/mtd/nand/raw/jz4780_nand.c > index 49841dad347c..db4fa60bd52a 100644 > --- a/drivers/mtd/nand/raw/jz4780_nand.c > +++ b/drivers/mtd/nand/raw/jz4780_nand.c > @@ -158,9 +158,8 @@ static int jz4780_nand_ecc_correct(struct mtd_info *mtd, u8 *dat, > return jz4780_bch_correct(nfc->bch, ¶ms, dat, read_ecc); > } > > -static int jz4780_nand_init_ecc(struct jz4780_nand_chip *nand, struct device *dev) > +static int jz4780_nand_attach_chip(struct nand_chip *chip) > { > - struct nand_chip *chip = &nand->chip; > struct mtd_info *mtd = nand_to_mtd(chip); > struct jz4780_nand_controller *nfc = to_jz4780_nand_controller(chip->controller); > int eccbytes; > @@ -171,7 +170,8 @@ static int jz4780_nand_init_ecc(struct jz4780_nand_chip *nand, struct device *de > switch (chip->ecc.mode) { > case NAND_ECC_HW: > if (!nfc->bch) { > - dev_err(dev, "HW BCH selected, but BCH controller not found\n"); > + dev_err(nfc->dev, > + "HW BCH selected, but BCH controller not found\n"); > return -ENODEV; > } > > @@ -180,15 +180,16 @@ static int jz4780_nand_init_ecc(struct jz4780_nand_chip *nand, struct device *de > chip->ecc.correct = jz4780_nand_ecc_correct; > /* fall through */ > case NAND_ECC_SOFT: > - dev_info(dev, "using %s (strength %d, size %d, bytes %d)\n", > - (nfc->bch) ? "hardware BCH" : "software ECC", > - chip->ecc.strength, chip->ecc.size, chip->ecc.bytes); > + dev_info(nfc->dev, "using %s (strength %d, size %d, bytes %d)\n", > + (nfc->bch) ? "hardware BCH" : "software ECC", > + chip->ecc.strength, chip->ecc.size, chip->ecc.bytes); > break; > case NAND_ECC_NONE: > - dev_info(dev, "not using ECC\n"); > + dev_info(nfc->dev, "not using ECC\n"); > break; > default: > - dev_err(dev, "ECC mode %d not supported\n", chip->ecc.mode); > + dev_err(nfc->dev, "ECC mode %d not supported\n", > + chip->ecc.mode); > return -EINVAL; > } > > @@ -200,7 +201,7 @@ static int jz4780_nand_init_ecc(struct jz4780_nand_chip *nand, struct device *de > eccbytes = mtd->writesize / chip->ecc.size * chip->ecc.bytes; > > if (eccbytes > mtd->oobsize - 2) { > - dev_err(dev, > + dev_err(nfc->dev, > "invalid ECC config: required %d ECC bytes, but only %d are available", > eccbytes, mtd->oobsize - 2); > return -EINVAL; > @@ -211,6 +212,10 @@ static int jz4780_nand_init_ecc(struct jz4780_nand_chip *nand, struct device *de > return 0; > } > > +static const struct nand_controller_ops jz4780_nand_controller_ops = { > + .attach_chip = jz4780_nand_attach_chip, > +}; > + > static int jz4780_nand_init_chip(struct platform_device *pdev, > struct jz4780_nand_controller *nfc, > struct device_node *np, > @@ -280,15 +285,8 @@ static int jz4780_nand_init_chip(struct platform_device *pdev, > chip->controller = &nfc->controller; > nand_set_flash_node(chip, np); > > - ret = nand_scan_ident(mtd, 1, NULL); > - if (ret) > - return ret; > - > - ret = jz4780_nand_init_ecc(nand, dev); > - if (ret) > - return ret; > - > - ret = nand_scan_tail(mtd); > + chip->controller->ops = &jz4780_nand_controller_ops; > + ret = nand_scan(mtd, 1); > if (ret) > return ret; >