Linux-ARM-Kernel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Jonathan Cameron <jic23@kernel.org>
To: Javier Carrasco <javier.carrasco.cruz@gmail.com>
Cc: Suzuki K Poulose <suzuki.poulose@arm.com>,
	Mike Leach <mike.leach@linaro.org>,
	James Clark <james.clark@linaro.org>,
	Alexander Shishkin <alexander.shishkin@linux.intel.com>,
	Michael Hennerich <Michael.Hennerich@analog.com>,
	Lars-Peter Clausen <lars@metafoo.de>,
	Anand Ashok Dumbre <anand.ashok.dumbre@xilinx.com>,
	Michal Simek <michal.simek@amd.com>,
	Sakari Ailus <sakari.ailus@linux.intel.com>,
	Pavel Machek <pavel@ucw.cz>, Lee Jones <lee@kernel.org>,
	coresight@lists.linaro.org, linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org, linux-iio@vger.kernel.org,
	linux-leds@vger.kernel.org
Subject: Re: [PATCH v3 1/2] iio: adc: xilinx-ams: use device_* to iterate over device child nodes
Date: Mon, 26 Aug 2024 11:52:26 +0100	[thread overview]
Message-ID: <20240826115226.43027f1b@jic23-huawei> (raw)
In-Reply-To: <20240820-device_child_node_access-v3-1-1ee09bdedb9e@gmail.com>

On Tue, 20 Aug 2024 21:02:26 +0200
Javier Carrasco <javier.carrasco.cruz@gmail.com> wrote:

> Use `device_for_each_child_node_scoped()` in `ams_parse_firmware()`
> to explicitly state device child node access, and simplify the child
> node handling as it is not required outside the loop.
> 
> Signed-off-by: Javier Carrasco <javier.carrasco.cruz@gmail.com>
Applied, but I would ideally still like one of the xilinx folk
others familiar with this driver to take a look.  It'll be a
few days before this ends up in next anyway as I need to rebase
after Greg (hopefully) takes the pull request from last week.

It would be lovely to get rid of the direct fwnode usage
in here but I'm not 100% sure if there is a path that will land
on a disabled fwnode.

Thanks,

Jonathan

> ---
>  drivers/iio/adc/xilinx-ams.c | 15 +++++----------
>  1 file changed, 5 insertions(+), 10 deletions(-)
> 
> diff --git a/drivers/iio/adc/xilinx-ams.c b/drivers/iio/adc/xilinx-ams.c
> index f051358d6b50..ebc583b07e0c 100644
> --- a/drivers/iio/adc/xilinx-ams.c
> +++ b/drivers/iio/adc/xilinx-ams.c
> @@ -1275,7 +1275,6 @@ static int ams_parse_firmware(struct iio_dev *indio_dev)
>  	struct ams *ams = iio_priv(indio_dev);
>  	struct iio_chan_spec *ams_channels, *dev_channels;
>  	struct device *dev = indio_dev->dev.parent;
> -	struct fwnode_handle *child = NULL;
>  	struct fwnode_handle *fwnode = dev_fwnode(dev);
>  	size_t ams_size;
>  	int ret, ch_cnt = 0, i, rising_off, falling_off;
> @@ -1297,16 +1296,12 @@ static int ams_parse_firmware(struct iio_dev *indio_dev)
>  		num_channels += ret;
>  	}
>  
> -	fwnode_for_each_child_node(fwnode, child) {
> -		if (fwnode_device_is_available(child)) {
> -			ret = ams_init_module(indio_dev, child, ams_channels + num_channels);
> -			if (ret < 0) {
> -				fwnode_handle_put(child);
> -				return ret;
> -			}
> +	device_for_each_child_node_scoped(dev, child) {
> +		ret = ams_init_module(indio_dev, child, ams_channels + num_channels);
> +		if (ret < 0)
> +			return ret;
>  
> -			num_channels += ret;
> -		}
> +		num_channels += ret;
>  	}
>  
>  	for (i = 0; i < num_channels; i++) {
> 



  reply	other threads:[~2024-08-26 11:05 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-08-20 19:02 [PATCH v3 0/2] use device_for_each_child_node_scoped to access device child nodes Javier Carrasco
2024-08-20 19:02 ` [PATCH v3 1/2] iio: adc: xilinx-ams: use device_* to iterate over " Javier Carrasco
2024-08-26 10:52   ` Jonathan Cameron [this message]
2024-08-26 11:15     ` Michal Simek
2024-08-20 19:02 ` [PATCH v3 2/2] leds: as3645a: " Javier Carrasco
2024-08-22 13:36   ` (subset) " Lee Jones

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=20240826115226.43027f1b@jic23-huawei \
    --to=jic23@kernel.org \
    --cc=Michael.Hennerich@analog.com \
    --cc=alexander.shishkin@linux.intel.com \
    --cc=anand.ashok.dumbre@xilinx.com \
    --cc=coresight@lists.linaro.org \
    --cc=james.clark@linaro.org \
    --cc=javier.carrasco.cruz@gmail.com \
    --cc=lars@metafoo.de \
    --cc=lee@kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-leds@vger.kernel.org \
    --cc=michal.simek@amd.com \
    --cc=mike.leach@linaro.org \
    --cc=pavel@ucw.cz \
    --cc=sakari.ailus@linux.intel.com \
    --cc=suzuki.poulose@arm.com \
    /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