Commit d13df21d authored by Javier Carrasco's avatar Javier Carrasco Committed by Dmitry Torokhov

Input: adc-joystick - use device_for_each_child_node_scoped()

Switch to the _scoped() version introduced in commit 365130fd
("device property: Introduce device_for_each_child_node_scoped()")
to remove the need for manual calling of fwnode_handle_put() in the
paths where the code exits the loop early.

In this case the err_fwnode_put label was no longer necessary and the
error code is returned directly.
Signed-off-by: default avatarJavier Carrasco <javier.carrasco.cruz@gmail.com>
Link: https://lore.kernel.org/r/20240412-input_device_for_each_child_node_scoped-v1-6-dbad1bc7ea84@gmail.comSigned-off-by: default avatarDmitry Torokhov <dmitry.torokhov@gmail.com>
parent 44f9c7c5
...@@ -132,7 +132,6 @@ static void adc_joystick_cleanup(void *data) ...@@ -132,7 +132,6 @@ static void adc_joystick_cleanup(void *data)
static int adc_joystick_set_axes(struct device *dev, struct adc_joystick *joy) static int adc_joystick_set_axes(struct device *dev, struct adc_joystick *joy)
{ {
struct adc_joystick_axis *axes = joy->axes; struct adc_joystick_axis *axes = joy->axes;
struct fwnode_handle *child;
s32 range[2], fuzz, flat; s32 range[2], fuzz, flat;
unsigned int num_axes; unsigned int num_axes;
int error, i; int error, i;
...@@ -149,31 +148,30 @@ static int adc_joystick_set_axes(struct device *dev, struct adc_joystick *joy) ...@@ -149,31 +148,30 @@ static int adc_joystick_set_axes(struct device *dev, struct adc_joystick *joy)
return -EINVAL; return -EINVAL;
} }
device_for_each_child_node(dev, child) { device_for_each_child_node_scoped(dev, child) {
error = fwnode_property_read_u32(child, "reg", &i); error = fwnode_property_read_u32(child, "reg", &i);
if (error) { if (error) {
dev_err(dev, "reg invalid or missing\n"); dev_err(dev, "reg invalid or missing\n");
goto err_fwnode_put; return error;
} }
if (i >= num_axes) { if (i >= num_axes) {
error = -EINVAL;
dev_err(dev, "No matching axis for reg %d\n", i); dev_err(dev, "No matching axis for reg %d\n", i);
goto err_fwnode_put; return -EINVAL;
} }
error = fwnode_property_read_u32(child, "linux,code", error = fwnode_property_read_u32(child, "linux,code",
&axes[i].code); &axes[i].code);
if (error) { if (error) {
dev_err(dev, "linux,code invalid or missing\n"); dev_err(dev, "linux,code invalid or missing\n");
goto err_fwnode_put; return error;
} }
error = fwnode_property_read_u32_array(child, "abs-range", error = fwnode_property_read_u32_array(child, "abs-range",
range, 2); range, 2);
if (error) { if (error) {
dev_err(dev, "abs-range invalid or missing\n"); dev_err(dev, "abs-range invalid or missing\n");
goto err_fwnode_put; return error;
} }
if (range[0] > range[1]) { if (range[0] > range[1]) {
...@@ -190,10 +188,6 @@ static int adc_joystick_set_axes(struct device *dev, struct adc_joystick *joy) ...@@ -190,10 +188,6 @@ static int adc_joystick_set_axes(struct device *dev, struct adc_joystick *joy)
} }
return 0; return 0;
err_fwnode_put:
fwnode_handle_put(child);
return error;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment