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

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

authored by

Javier Carrasco and committed by
Dmitry Torokhov
c90a8519 4f210af5

+1 -3
+1 -3
drivers/input/keyboard/gpio_keys.c
··· 768 768 { 769 769 struct gpio_keys_platform_data *pdata; 770 770 struct gpio_keys_button *button; 771 - struct fwnode_handle *child; 772 771 int nbuttons, irq; 773 772 774 773 nbuttons = device_get_child_node_count(dev); ··· 789 790 790 791 device_property_read_string(dev, "label", &pdata->name); 791 792 792 - device_for_each_child_node(dev, child) { 793 + device_for_each_child_node_scoped(dev, child) { 793 794 if (is_of_node(child)) { 794 795 irq = of_irq_get_byname(to_of_node(child), "irq"); 795 796 if (irq > 0) ··· 807 808 if (fwnode_property_read_u32(child, "linux,code", 808 809 &button->code)) { 809 810 dev_err(dev, "Button without keycode\n"); 810 - fwnode_handle_put(child); 811 811 return ERR_PTR(-EINVAL); 812 812 } 813 813