Skip to content

Commit d164888

Browse files
Lincoln-Yujijic23
authored andcommitted
iio: adc: ti-ads1015: use device_for_each_child_node_scoped()
This loop definition removes the need for manual releasing of the fwnode_handle in early exit paths (here an error path) allow simplification of the code and reducing the chance of future modifications not releasing fwnode_handle correctly. Co-developed-by: Luiza Soezima <lbrsoezima@usp.br> Signed-off-by: Luiza Soezima <lbrsoezima@usp.br> Co-developed-by: Sabrina Araujo <sabrinaaraujo@usp.br> Signed-off-by: Sabrina Araujo <sabrinaaraujo@usp.br> Signed-off-by: Lincoln Yuji <lincolnyuji@usp.br> Reviewed-by: Marcelo Schmitt <marcelo.schmitt1@gmail.com> Link: https://lore.kernel.org/r/20240429132233.6266-1-lincolnyuji@usp.br Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
1 parent 80f87d6 commit d164888

1 file changed

Lines changed: 1 addition & 4 deletions

File tree

drivers/iio/adc/ti-ads1015.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -902,10 +902,9 @@ static int ads1015_client_get_channels_config(struct i2c_client *client)
902902
struct iio_dev *indio_dev = i2c_get_clientdata(client);
903903
struct ads1015_data *data = iio_priv(indio_dev);
904904
struct device *dev = &client->dev;
905-
struct fwnode_handle *node;
906905
int i = -1;
907906

908-
device_for_each_child_node(dev, node) {
907+
device_for_each_child_node_scoped(dev, node) {
909908
u32 pval;
910909
unsigned int channel;
911910
unsigned int pga = ADS1015_DEFAULT_PGA;
@@ -927,7 +926,6 @@ static int ads1015_client_get_channels_config(struct i2c_client *client)
927926
pga = pval;
928927
if (pga > 5) {
929928
dev_err(dev, "invalid gain on %pfw\n", node);
930-
fwnode_handle_put(node);
931929
return -EINVAL;
932930
}
933931
}
@@ -936,7 +934,6 @@ static int ads1015_client_get_channels_config(struct i2c_client *client)
936934
data_rate = pval;
937935
if (data_rate > 7) {
938936
dev_err(dev, "invalid data_rate on %pfw\n", node);
939-
fwnode_handle_put(node);
940937
return -EINVAL;
941938
}
942939
}

0 commit comments

Comments
 (0)