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

regulator: qcom-rpmh: 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://patch.msgid.link/20240814-cleanup-h-of-node-put-regulator-v1-5-87151088b883@linaro.org
Signed-off-by: Mark Brown <broonie@kernel.org>

authored by

Krzysztof Kozlowski and committed by
Mark Brown
17636d44 34a3f959

+3 -8
+3 -8
drivers/regulator/qcom-rpmh-regulator.c
··· 1537 1537 { 1538 1538 struct device *dev = &pdev->dev; 1539 1539 const struct rpmh_vreg_init_data *vreg_data; 1540 - struct device_node *node; 1541 1540 struct rpmh_vreg *vreg; 1542 1541 const char *pmic_id; 1543 1542 int ret; ··· 1551 1552 return ret; 1552 1553 } 1553 1554 1554 - for_each_available_child_of_node(dev->of_node, node) { 1555 + for_each_available_child_of_node_scoped(dev->of_node, node) { 1555 1556 vreg = devm_kzalloc(dev, sizeof(*vreg), GFP_KERNEL); 1556 - if (!vreg) { 1557 - of_node_put(node); 1557 + if (!vreg) 1558 1558 return -ENOMEM; 1559 - } 1560 1559 1561 1560 ret = rpmh_regulator_init_vreg(vreg, dev, node, pmic_id, 1562 1561 vreg_data); 1563 - if (ret < 0) { 1564 - of_node_put(node); 1562 + if (ret < 0) 1565 1563 return ret; 1566 - } 1567 1564 } 1568 1565 1569 1566 return 0;