]> www.infradead.org Git - linux.git/commitdiff
iio: adc: xilinx-ams: use device_* to iterate over device child nodes
authorJavier Carrasco <javier.carrasco.cruz@gmail.com>
Tue, 20 Aug 2024 19:02:26 +0000 (21:02 +0200)
committerJonathan Cameron <Jonathan.Cameron@huawei.com>
Tue, 3 Sep 2024 17:49:44 +0000 (18:49 +0100)
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>
Reviewed-by: Mike Leach <mike.leach@linaro.org>
Link: https://patch.msgid.link/20240820-device_child_node_access-v3-1-1ee09bdedb9e@gmail.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
drivers/iio/adc/xilinx-ams.c

index f051358d6b50b2eafa3e47b42ee9fbe5a52ddbaf..ebc583b07e0c00bd08c3219f595edd8df26a8378 100644 (file)
@@ -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++) {