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

leds: as3645a: Use device_* to iterate over device child nodes

Drop the manual access to the fwnode of the device to iterate over its
child nodes. `device_for_each_child_node` macro provides direct access
to the child nodes, and given that the `child` variable is only required
within the loop, the scoped variant of the macro can be used.

Use the `device_for_each_child_node_scoped` macro to iterate over the
direct child nodes of the device.

Signed-off-by: Javier Carrasco <javier.carrasco.cruz@gmail.com>
Acked-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Link: https://lore.kernel.org/r/20240820-device_child_node_access-v3-2-1ee09bdedb9e@gmail.com
Signed-off-by: Lee Jones <lee@kernel.org>

authored by

Javier Carrasco and committed by
Lee Jones
77b2b475 9557b437

+3 -5
+3 -5
drivers/leds/flash/leds-as3645a.c
··· 478 478 return as3645a_write(flash, AS_BOOST_REG, AS_BOOST_CURRENT_DISABLE); 479 479 } 480 480 481 - static int as3645a_parse_node(struct as3645a *flash, 482 - struct fwnode_handle *fwnode) 481 + static int as3645a_parse_node(struct device *dev, struct as3645a *flash) 483 482 { 484 483 struct as3645a_config *cfg = &flash->cfg; 485 - struct fwnode_handle *child; 486 484 int rval; 487 485 488 - fwnode_for_each_child_node(fwnode, child) { 486 + device_for_each_child_node_scoped(dev, child) { 489 487 u32 id = 0; 490 488 491 489 fwnode_property_read_u32(child, "reg", &id); ··· 684 686 685 687 flash->client = client; 686 688 687 - rval = as3645a_parse_node(flash, dev_fwnode(&client->dev)); 689 + rval = as3645a_parse_node(&client->dev, flash); 688 690 if (rval < 0) 689 691 return rval; 690 692