Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 3A74AC77B6E for ; Fri, 14 Apr 2023 10:23:22 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 64AFE85CB1; Fri, 14 Apr 2023 12:23:20 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=fail (p=none dis=none) header.from=arm.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Received: by phobos.denx.de (Postfix, from userid 109) id 0FB5B85627; Fri, 14 Apr 2023 12:23:18 +0200 (CEST) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by phobos.denx.de (Postfix) with ESMTP id 15AE485CB1 for ; Fri, 14 Apr 2023 12:23:13 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=andre.przywara@arm.com Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 9DF5C2F4; Fri, 14 Apr 2023 03:23:56 -0700 (PDT) Received: from donnerap.cambridge.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.121.207.14]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id E29C13F587; Fri, 14 Apr 2023 03:23:10 -0700 (PDT) Date: Fri, 14 Apr 2023 11:23:08 +0100 From: Andre Przywara To: Samuel Holland Cc: Jagan Teki , Michael Trimarchi , Dario Binacchi , Hans de Goede , Lukasz Majewski , Sean Anderson , Simon Glass , u-boot@lists.denx.de Subject: Re: [PATCH v2 6/6] mtd: nand: sunxi: Pass the device to the init function Message-ID: <20230414112308.15fc398c@donnerap.cambridge.arm.com> In-Reply-To: <20230122220637.41496-7-samuel@sholland.org> References: <20230122220637.41496-1-samuel@sholland.org> <20230122220637.41496-7-samuel@sholland.org> Organization: ARM X-Mailer: Claws Mail 3.18.0 (GTK+ 2.24.32; aarch64-unknown-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean On Sun, 22 Jan 2023 16:06:36 -0600 Samuel Holland wrote: > This more closely matches the U-Boot driver to the Linux version. > > Signed-off-by: Samuel Holland Reviewed-by: Andre Przywara Thanks! Andre > --- > > (no changes since v1) > > drivers/mtd/nand/raw/sunxi_nand.c | 39 ++++++++++++++++--------------- > 1 file changed, 20 insertions(+), 19 deletions(-) > > diff --git a/drivers/mtd/nand/raw/sunxi_nand.c b/drivers/mtd/nand/raw/sunxi_nand.c > index dda51a39b0..c0fa1e310c 100644 > --- a/drivers/mtd/nand/raw/sunxi_nand.c > +++ b/drivers/mtd/nand/raw/sunxi_nand.c > @@ -1604,7 +1604,8 @@ static int sunxi_nand_ecc_init(struct mtd_info *mtd, struct nand_ecc_ctrl *ecc) > return 0; > } > > -static int sunxi_nand_chip_init(ofnode np, struct sunxi_nfc *nfc, int devnum) > +static int sunxi_nand_chip_init(struct udevice *dev, struct sunxi_nfc *nfc, > + ofnode np, int devnum) > { > const struct nand_sdr_timings *timings; > struct sunxi_nand_chip *chip; > @@ -1620,7 +1621,7 @@ static int sunxi_nand_chip_init(ofnode np, struct sunxi_nfc *nfc, int devnum) > > nsels /= sizeof(u32); > if (!nsels || nsels > 8) { > - dev_err(nfc->dev, "invalid reg property size\n"); > + dev_err(dev, "invalid reg property size\n"); > return -EINVAL; > } > > @@ -1628,7 +1629,7 @@ static int sunxi_nand_chip_init(ofnode np, struct sunxi_nfc *nfc, int devnum) > (nsels * sizeof(struct sunxi_nand_chip_sel)), > GFP_KERNEL); > if (!chip) { > - dev_err(nfc->dev, "could not allocate chip\n"); > + dev_err(dev, "could not allocate chip\n"); > return -ENOMEM; > } > > @@ -1638,19 +1639,19 @@ static int sunxi_nand_chip_init(ofnode np, struct sunxi_nfc *nfc, int devnum) > for (i = 0; i < nsels; i++) { > ret = ofnode_read_u32_index(np, "reg", i, &tmp); > if (ret) { > - dev_err(nfc->dev, "could not retrieve reg property: %d\n", > + dev_err(dev, "could not retrieve reg property: %d\n", > ret); > return ret; > } > > if (tmp > NFC_MAX_CS) { > - dev_err(nfc->dev, > + dev_err(dev, > "invalid reg value: %u (max CS = 7)\n", tmp); > return -EINVAL; > } > > if (test_and_set_bit(tmp, &nfc->assigned_cs)) { > - dev_err(nfc->dev, "CS %d already assigned\n", tmp); > + dev_err(dev, "CS %d already assigned\n", tmp); > return -EINVAL; > } > > @@ -1661,9 +1662,9 @@ static int sunxi_nand_chip_init(ofnode np, struct sunxi_nfc *nfc, int devnum) > chip->sels[i].rb.type = RB_NATIVE; > chip->sels[i].rb.info.nativeid = tmp; > } else { > - ret = gpio_request_by_name_nodev(np, "rb-gpios", i, > - &chip->sels[i].rb.info.gpio, > - GPIOD_IS_IN); > + ret = gpio_request_by_name(dev, "rb-gpios", i, > + &chip->sels[i].rb.info.gpio, > + GPIOD_IS_IN); > if (ret) > chip->sels[i].rb.type = RB_GPIO; > else > @@ -1674,7 +1675,7 @@ static int sunxi_nand_chip_init(ofnode np, struct sunxi_nfc *nfc, int devnum) > timings = onfi_async_timing_mode_to_sdr_timings(0); > if (IS_ERR(timings)) { > ret = PTR_ERR(timings); > - dev_err(nfc->dev, > + dev_err(dev, > "could not retrieve timings for ONFI mode 0: %d\n", > ret); > return ret; > @@ -1682,7 +1683,7 @@ static int sunxi_nand_chip_init(ofnode np, struct sunxi_nfc *nfc, int devnum) > > ret = sunxi_nand_chip_set_timings(nfc, chip, timings); > if (ret) { > - dev_err(nfc->dev, "could not configure chip timings: %d\n", ret); > + dev_err(dev, "could not configure chip timings: %d\n", ret); > return ret; > } > > @@ -1717,25 +1718,25 @@ static int sunxi_nand_chip_init(ofnode np, struct sunxi_nfc *nfc, int devnum) > > ret = sunxi_nand_chip_init_timings(nfc, chip); > if (ret) { > - dev_err(nfc->dev, "could not configure chip timings: %d\n", ret); > + dev_err(dev, "could not configure chip timings: %d\n", ret); > return ret; > } > > ret = sunxi_nand_ecc_init(mtd, &nand->ecc); > if (ret) { > - dev_err(nfc->dev, "ECC init failed: %d\n", ret); > + dev_err(dev, "ECC init failed: %d\n", ret); > return ret; > } > > ret = nand_scan_tail(mtd); > if (ret) { > - dev_err(nfc->dev, "nand_scan_tail failed: %d\n", ret); > + dev_err(dev, "nand_scan_tail failed: %d\n", ret); > return ret; > } > > ret = nand_register(devnum, mtd); > if (ret) { > - dev_err(nfc->dev, "failed to register mtd device: %d\n", ret); > + dev_err(dev, "failed to register mtd device: %d\n", ret); > return ret; > } > > @@ -1744,13 +1745,13 @@ static int sunxi_nand_chip_init(ofnode np, struct sunxi_nfc *nfc, int devnum) > return 0; > } > > -static int sunxi_nand_chips_init(ofnode node, struct sunxi_nfc *nfc) > +static int sunxi_nand_chips_init(struct udevice *dev, struct sunxi_nfc *nfc) > { > ofnode nand_np; > int ret, i = 0; > > - ofnode_for_each_subnode(nand_np, node) { > - ret = sunxi_nand_chip_init(nand_np, nfc, i++); > + dev_for_each_subnode(nand_np, dev) { > + ret = sunxi_nand_chip_init(dev, nfc, nand_np, i++); > if (ret) > return ret; > } > @@ -1802,7 +1803,7 @@ static int sunxi_nand_probe(struct udevice *dev) > if (ret) > return ret; > > - ret = sunxi_nand_chips_init(dev_ofnode(dev), nfc); > + ret = sunxi_nand_chips_init(dev, nfc); > if (ret) { > dev_err(dev, "failed to init nand chips\n"); > return ret;