Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

iio: adc: qcom-spmi-adc5: Use device_for_each_child_node_scoped()

Switching to the _scoped() version removes the need for manual
calling of fwnode_handle_put() in the paths where the code
exits the loop early. In this case that's all in error paths.

A slightly less convincing usecase than many as all the failure paths
are wrapped up in a call to a per fwnode_handle utility function.
The complexity in that function is sufficient that it makes sense to
factor it out even if it this new auto cleanup would enable simpler
returns if the code was inline at the call site. Hence I've left it alone.

Cc: Marijn Suijten <marijn.suijten@somainline.org>
Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
Link: https://lore.kernel.org/r/20240330185305.1319844-3-jic23@kernel.org
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>

+2 -5
+2 -5
drivers/iio/adc/qcom-spmi-adc5.c
··· 825 825 const struct adc5_channels *adc_chan; 826 826 struct iio_chan_spec *iio_chan; 827 827 struct adc5_channel_prop prop, *chan_props; 828 - struct fwnode_handle *child; 829 828 unsigned int index = 0; 830 829 int ret; 831 830 ··· 848 849 if (!adc->data) 849 850 adc->data = &adc5_data_pmic; 850 851 851 - device_for_each_child_node(adc->dev, child) { 852 + device_for_each_child_node_scoped(adc->dev, child) { 852 853 ret = adc5_get_fw_channel_data(adc, &prop, child, adc->data); 853 - if (ret) { 854 - fwnode_handle_put(child); 854 + if (ret) 855 855 return ret; 856 - } 857 856 858 857 prop.scale_fn_type = 859 858 adc->data->adc_chans[prop.channel].scale_fn_type;