public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Andre Przywara <andre.przywara@arm.com>
To: Samuel Holland <samuel@sholland.org>
Cc: Jagan Teki <jagan@amarulasolutions.com>,
	Michael Trimarchi <michael@amarulasolutions.com>,
	Dario Binacchi <dario.binacchi@amarulasolutions.com>,
	Hans de Goede <hdegoede@redhat.com>,
	Lukasz Majewski <lukma@denx.de>,
	Sean Anderson <seanga2@gmail.com>, Simon Glass <sjg@chromium.org>,
	u-boot@lists.denx.de
Subject: Re: [PATCH v2 6/6] mtd: nand: sunxi: Pass the device to the init function
Date: Fri, 14 Apr 2023 11:23:08 +0100	[thread overview]
Message-ID: <20230414112308.15fc398c@donnerap.cambridge.arm.com> (raw)
In-Reply-To: <20230122220637.41496-7-samuel@sholland.org>

On Sun, 22 Jan 2023 16:06:36 -0600
Samuel Holland <samuel@sholland.org> wrote:

> This more closely matches the U-Boot driver to the Linux version.
> 
> Signed-off-by: Samuel Holland <samuel@sholland.org>

Reviewed-by: Andre Przywara <andre.przywara@arm.com>

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;


  reply	other threads:[~2023-04-14 10:23 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-22 22:06 [PATCH v2 0/6] mtd: nand: sunxi: Convert to devicetree and the driver model Samuel Holland
2023-01-22 22:06 ` [PATCH v2 1/6] clk: sunxi: Add NAND clocks and resets Samuel Holland
2023-01-27 22:59   ` Andre Przywara
2023-02-12 17:55   ` Sean Anderson
2023-01-22 22:06 ` [PATCH v2 2/6] pinctrl: sunxi: Add NAND pinmuxes Samuel Holland
2023-01-22 22:06 ` [PATCH v2 3/6] mtd: nand: sunxi: Remove an unnecessary check Samuel Holland
2023-01-22 22:06 ` [PATCH v2 4/6] mtd: nand: sunxi: Convert from fdtdec to ofnode Samuel Holland
2023-04-14  9:56   ` Andre Przywara
2023-01-22 22:06 ` [PATCH v2 5/6] mtd: nand: sunxi: Convert to the driver model Samuel Holland
2023-01-22 22:06 ` [PATCH v2 6/6] mtd: nand: sunxi: Pass the device to the init function Samuel Holland
2023-04-14 10:23   ` Andre Przywara [this message]
2023-04-14 10:46     ` Michael Nazzareno Trimarchi
2023-04-14 10:25 ` [PATCH v2 0/6] mtd: nand: sunxi: Convert to devicetree and the driver model Andre Przywara

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230414112308.15fc398c@donnerap.cambridge.arm.com \
    --to=andre.przywara@arm.com \
    --cc=dario.binacchi@amarulasolutions.com \
    --cc=hdegoede@redhat.com \
    --cc=jagan@amarulasolutions.com \
    --cc=lukma@denx.de \
    --cc=michael@amarulasolutions.com \
    --cc=samuel@sholland.org \
    --cc=seanga2@gmail.com \
    --cc=sjg@chromium.org \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox