mirror of
git://git.yoctoproject.org/linux-yocto.git
synced 2025-07-05 13:25:20 +02:00
hwmon: (ina3221): Simplify with scoped for each OF child loop
Use scoped for_each_child_of_node_scoped() when iterating over device nodes to make code a bit simpler. Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com> Message-ID: <20240822062956.3490387-4-ruanjinjie@huawei.com> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
This commit is contained in:
parent
d5733a9387
commit
3fd38c6434
|
@ -813,7 +813,6 @@ static int ina3221_probe_child_from_dt(struct device *dev,
|
||||||
static int ina3221_probe_from_dt(struct device *dev, struct ina3221_data *ina)
|
static int ina3221_probe_from_dt(struct device *dev, struct ina3221_data *ina)
|
||||||
{
|
{
|
||||||
const struct device_node *np = dev->of_node;
|
const struct device_node *np = dev->of_node;
|
||||||
struct device_node *child;
|
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
/* Compatible with non-DT platforms */
|
/* Compatible with non-DT platforms */
|
||||||
|
@ -822,12 +821,10 @@ static int ina3221_probe_from_dt(struct device *dev, struct ina3221_data *ina)
|
||||||
|
|
||||||
ina->single_shot = of_property_read_bool(np, "ti,single-shot");
|
ina->single_shot = of_property_read_bool(np, "ti,single-shot");
|
||||||
|
|
||||||
for_each_child_of_node(np, child) {
|
for_each_child_of_node_scoped(np, child) {
|
||||||
ret = ina3221_probe_child_from_dt(dev, child, ina);
|
ret = ina3221_probe_child_from_dt(dev, child, ina);
|
||||||
if (ret) {
|
if (ret)
|
||||||
of_node_put(child);
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user