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

Input: gpio_keys_polled - use device_for_each_child_node_scoped()

Switch to the _scoped() version introduced in commit 365130fd47af
("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.

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-4-dbad1bc7ea84@gmail.com
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>

authored by

Javier Carrasco and committed by
Dmitry Torokhov
1102db75 c90a8519

+1 -3
+1 -3
drivers/input/keyboard/gpio_keys_polled.c
··· 144 144 { 145 145 struct gpio_keys_platform_data *pdata; 146 146 struct gpio_keys_button *button; 147 - struct fwnode_handle *child; 148 147 int nbuttons; 149 148 150 149 nbuttons = device_get_child_node_count(dev); ··· 165 166 166 167 device_property_read_string(dev, "label", &pdata->name); 167 168 168 - device_for_each_child_node(dev, child) { 169 + device_for_each_child_node_scoped(dev, child) { 169 170 if (fwnode_property_read_u32(child, "linux,code", 170 171 &button->code)) { 171 172 dev_err(dev, "button without keycode\n"); 172 - fwnode_handle_put(child); 173 173 return ERR_PTR(-EINVAL); 174 174 } 175 175