Skip to content

Commit d13df21

Browse files
javiercarrascocruzdtor
authored andcommitted
Input: adc-joystick - use device_for_each_child_node_scoped()
Switch to the _scoped() version introduced in commit 365130f ("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: Javier Carrasco <javier.carrasco.cruz@gmail.com> Link: https://lore.kernel.org/r/20240412-input_device_for_each_child_node_scoped-v1-6-dbad1bc7ea84@gmail.com Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
1 parent 44f9c7c commit d13df21

File tree

1 file changed

+5
-11
lines changed

1 file changed

+5
-11
lines changed

drivers/input/joystick/adc-joystick.c

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,6 @@ static void adc_joystick_cleanup(void *data)
132132
static int adc_joystick_set_axes(struct device *dev, struct adc_joystick *joy)
133133
{
134134
struct adc_joystick_axis *axes = joy->axes;
135-
struct fwnode_handle *child;
136135
s32 range[2], fuzz, flat;
137136
unsigned int num_axes;
138137
int error, i;
@@ -149,31 +148,30 @@ static int adc_joystick_set_axes(struct device *dev, struct adc_joystick *joy)
149148
return -EINVAL;
150149
}
151150

152-
device_for_each_child_node(dev, child) {
151+
device_for_each_child_node_scoped(dev, child) {
153152
error = fwnode_property_read_u32(child, "reg", &i);
154153
if (error) {
155154
dev_err(dev, "reg invalid or missing\n");
156-
goto err_fwnode_put;
155+
return error;
157156
}
158157

159158
if (i >= num_axes) {
160-
error = -EINVAL;
161159
dev_err(dev, "No matching axis for reg %d\n", i);
162-
goto err_fwnode_put;
160+
return -EINVAL;
163161
}
164162

165163
error = fwnode_property_read_u32(child, "linux,code",
166164
&axes[i].code);
167165
if (error) {
168166
dev_err(dev, "linux,code invalid or missing\n");
169-
goto err_fwnode_put;
167+
return error;
170168
}
171169

172170
error = fwnode_property_read_u32_array(child, "abs-range",
173171
range, 2);
174172
if (error) {
175173
dev_err(dev, "abs-range invalid or missing\n");
176-
goto err_fwnode_put;
174+
return error;
177175
}
178176

179177
if (range[0] > range[1]) {
@@ -190,10 +188,6 @@ static int adc_joystick_set_axes(struct device *dev, struct adc_joystick *joy)
190188
}
191189

192190
return 0;
193-
194-
err_fwnode_put:
195-
fwnode_handle_put(child);
196-
return error;
197191
}
198192

199193

0 commit comments

Comments
 (0)