[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20240803121734.25f0863b@jic23-huawei>
Date: Sat, 3 Aug 2024 12:17:34 +0100
From: Jonathan Cameron <jic23@...nel.org>
To: Javier Carrasco <javier.carrasco.cruz@...il.com>
Cc: Suzuki K Poulose <suzuki.poulose@....com>, Mike Leach
<mike.leach@...aro.org>, James Clark <james.clark@...aro.org>, Alexander
Shishkin <alexander.shishkin@...ux.intel.com>, Michael Hennerich
<Michael.Hennerich@...log.com>, Lars-Peter Clausen <lars@...afoo.de>, Anand
Ashok Dumbre <anand.ashok.dumbre@...inx.com>, Michal Simek
<michal.simek@....com>, Sakari Ailus <sakari.ailus@...ux.intel.com>, Pavel
Machek <pavel@....cz>, Lee Jones <lee@...nel.org>,
coresight@...ts.linaro.org, linux-arm-kernel@...ts.infradead.org,
linux-kernel@...r.kernel.org, linux-iio@...r.kernel.org,
linux-leds@...r.kernel.org
Subject: Re: [PATCH 3/4] iio: adc: xilinx-ams: use device_* to iterate over
device child nodes
On Thu, 01 Aug 2024 08:13:52 +0200
Javier Carrasco <javier.carrasco.cruz@...il.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@...il.com>
> ---
> drivers/iio/adc/xilinx-ams.c | 7 ++-----
> 1 file changed, 2 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/iio/adc/xilinx-ams.c b/drivers/iio/adc/xilinx-ams.c
> index f051358d6b50..27d5e4a6f9d6 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,13 +1296,11 @@ static int ams_parse_firmware(struct iio_dev *indio_dev)
> num_channels += ret;
> }
>
> - fwnode_for_each_child_node(fwnode, child) {
> + device_for_each_child_node_scoped(dev, child) {
> if (fwnode_device_is_available(child)) {
This is fun. should have been fwnode_for_each_available_child_node()
in the first place rather than iterating over all nodes, and only
doing stuff for the available ones.
Can use the device_for_each_child_node_scoped() but that only includes
available nodes anyway, so my understanding is that we can also drop
this if statement as it will always be true.
> ret = ams_init_module(indio_dev, child, ams_channels + num_channels);
> - if (ret < 0) {
> - fwnode_handle_put(child);
> + if (ret < 0)
> return ret;
> - }
>
> num_channels += ret;
> }
>
Powered by blists - more mailing lists