[PATCH] iio: adc: xilinx-ams: Use device_for_each_child_node_scoped()
Marcelo Schmitt
marcelo.schmitt1 at gmail.com
Sat Apr 27 02:13:01 PDT 2024
Hi Pedro, Roberto,
Patch looks overall good except for the _scoped() function name and arguments,
must have been miss-typed or miss-copied somehow.
Comment inline.
Regards,
Marcelo
On 04/24, Pedro Mariano wrote:
> Using device_for_each_child_node_scoped instead of
> device_for_each_child_node automatically releases the handle on early exit
> which reduces the chance of bugs that cause resource leaks.
>
> Co-developed-by: Roberto Bolgheroni <robertobolgheroni at usp.br>
> Signed-off-by: Roberto Bolgheroni <robertobolgheroni at usp.br>
> Signed-off-by: Pedro Mariano <pedro.mariano at usp.br>
> ---
> 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 f0b71a122..7f5571d9d 100644
> --- a/drivers/iio/adc/xilinx-ams.c
> +++ b/drivers/iio/adc/xilinx-ams.c
> @@ -1261,7 +1261,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;
> @@ -1283,13 +1282,11 @@ static int ams_parse_firmware(struct iio_dev *indio_dev)
> num_channels += ret;
> }
>
> - fwnode_for_each_child_node(fwnode, child) {
> + fwnode_for_each_child_node_scoped(fwnode, child) {
should be
device_for_each_child_node_scoped(dev, 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);
> + if (ret < 0)
> return ret;
> - }
>
> num_channels += ret;
> }
> --
> 2.44.0
>
>
More information about the linux-arm-kernel
mailing list