Commit 77b2b475 authored by Javier Carrasco's avatar Javier Carrasco Committed by Lee Jones

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: default avatarJavier Carrasco <javier.carrasco.cruz@gmail.com>
Acked-by: default avatarSakari Ailus <sakari.ailus@linux.intel.com>
Link: https://lore.kernel.org/r/20240820-device_child_node_access-v3-2-1ee09bdedb9e@gmail.comSigned-off-by: default avatarLee Jones <lee@kernel.org>
parent 9557b437
...@@ -478,14 +478,12 @@ static int as3645a_detect(struct as3645a *flash) ...@@ -478,14 +478,12 @@ static int as3645a_detect(struct as3645a *flash)
return as3645a_write(flash, AS_BOOST_REG, AS_BOOST_CURRENT_DISABLE); return as3645a_write(flash, AS_BOOST_REG, AS_BOOST_CURRENT_DISABLE);
} }
static int as3645a_parse_node(struct as3645a *flash, static int as3645a_parse_node(struct device *dev, struct as3645a *flash)
struct fwnode_handle *fwnode)
{ {
struct as3645a_config *cfg = &flash->cfg; struct as3645a_config *cfg = &flash->cfg;
struct fwnode_handle *child;
int rval; int rval;
fwnode_for_each_child_node(fwnode, child) { device_for_each_child_node_scoped(dev, child) {
u32 id = 0; u32 id = 0;
fwnode_property_read_u32(child, "reg", &id); fwnode_property_read_u32(child, "reg", &id);
...@@ -686,7 +684,7 @@ static int as3645a_probe(struct i2c_client *client) ...@@ -686,7 +684,7 @@ static int as3645a_probe(struct i2c_client *client)
flash->client = client; flash->client = client;
rval = as3645a_parse_node(flash, dev_fwnode(&client->dev)); rval = as3645a_parse_node(&client->dev, flash);
if (rval < 0) if (rval < 0)
return rval; return rval;
......
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