mirror of
git://git.yoctoproject.org/linux-yocto.git
synced 2025-10-23 07:23:12 +02:00
leds: is31fl32xx: Simplify with scoped for each OF child loop
Use scoped for_each_available_child_of_node_scoped() when iterating over device nodes to make code a bit simpler. Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org> Link: https://lore.kernel.org/r/20240816-cleanup-h-of-node-put-var-v1-9-1d0292802470@linaro.org Signed-off-by: Lee Jones <lee@kernel.org>
This commit is contained in:
parent
c57ba40ea1
commit
2c37529ee9
|
@ -363,10 +363,9 @@ static struct is31fl32xx_led_data *is31fl32xx_find_led_data(
|
||||||
static int is31fl32xx_parse_dt(struct device *dev,
|
static int is31fl32xx_parse_dt(struct device *dev,
|
||||||
struct is31fl32xx_priv *priv)
|
struct is31fl32xx_priv *priv)
|
||||||
{
|
{
|
||||||
struct device_node *child;
|
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
||||||
for_each_available_child_of_node(dev_of_node(dev), child) {
|
for_each_available_child_of_node_scoped(dev_of_node(dev), child) {
|
||||||
struct led_init_data init_data = {};
|
struct led_init_data init_data = {};
|
||||||
struct is31fl32xx_led_data *led_data =
|
struct is31fl32xx_led_data *led_data =
|
||||||
&priv->leds[priv->num_leds];
|
&priv->leds[priv->num_leds];
|
||||||
|
@ -376,7 +375,7 @@ static int is31fl32xx_parse_dt(struct device *dev,
|
||||||
|
|
||||||
ret = is31fl32xx_parse_child_dt(dev, child, led_data);
|
ret = is31fl32xx_parse_child_dt(dev, child, led_data);
|
||||||
if (ret)
|
if (ret)
|
||||||
goto err;
|
return ret;
|
||||||
|
|
||||||
/* Detect if channel is already in use by another child */
|
/* Detect if channel is already in use by another child */
|
||||||
other_led_data = is31fl32xx_find_led_data(priv,
|
other_led_data = is31fl32xx_find_led_data(priv,
|
||||||
|
@ -385,8 +384,7 @@ static int is31fl32xx_parse_dt(struct device *dev,
|
||||||
dev_err(dev,
|
dev_err(dev,
|
||||||
"Node %pOF 'reg' conflicts with another LED\n",
|
"Node %pOF 'reg' conflicts with another LED\n",
|
||||||
child);
|
child);
|
||||||
ret = -EINVAL;
|
return -EINVAL;
|
||||||
goto err;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
init_data.fwnode = of_fwnode_handle(child);
|
init_data.fwnode = of_fwnode_handle(child);
|
||||||
|
@ -396,17 +394,13 @@ static int is31fl32xx_parse_dt(struct device *dev,
|
||||||
if (ret) {
|
if (ret) {
|
||||||
dev_err(dev, "Failed to register LED for %pOF: %d\n",
|
dev_err(dev, "Failed to register LED for %pOF: %d\n",
|
||||||
child, ret);
|
child, ret);
|
||||||
goto err;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
priv->num_leds++;
|
priv->num_leds++;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
err:
|
|
||||||
of_node_put(child);
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static const struct of_device_id of_is31fl32xx_match[] = {
|
static const struct of_device_id of_is31fl32xx_match[] = {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user