* [PATCH] soc: dove: pmu: Simplify with scoped for each OF child loop
@ 2026-01-02 12:48 Krzysztof Kozlowski
2026-01-05 14:04 ` Gregory CLEMENT
0 siblings, 1 reply; 2+ messages in thread
From: Krzysztof Kozlowski @ 2026-01-02 12:48 UTC (permalink / raw)
To: Andrew Lunn, Sebastian Hesselbarth, Gregory Clement,
linux-arm-kernel, linux-kernel
Cc: Krzysztof Kozlowski
Use scoped for-each loop when iterating over device nodes to make code a
bit simpler.
Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@oss.qualcomm.com>
---
drivers/soc/dove/pmu.c | 9 +++------
1 file changed, 3 insertions(+), 6 deletions(-)
diff --git a/drivers/soc/dove/pmu.c b/drivers/soc/dove/pmu.c
index 7bbd3f940e4d..dd8ade8e9ee8 100644
--- a/drivers/soc/dove/pmu.c
+++ b/drivers/soc/dove/pmu.c
@@ -371,7 +371,7 @@ int __init dove_init_pmu_legacy(const struct dove_pmu_initdata *initdata)
*/
int __init dove_init_pmu(void)
{
- struct device_node *np_pmu, *domains_node, *np;
+ struct device_node *np_pmu, *domains_node;
struct pmu_data *pmu;
int ret, parent_irq;
@@ -404,21 +404,18 @@ int __init dove_init_pmu(void)
pmu_reset_init(pmu);
- for_each_available_child_of_node(domains_node, np) {
+ for_each_available_child_of_node_scoped(domains_node, np) {
struct of_phandle_args args;
struct pmu_domain *domain;
domain = kzalloc(sizeof(*domain), GFP_KERNEL);
- if (!domain) {
- of_node_put(np);
+ if (!domain)
break;
- }
domain->pmu = pmu;
domain->base.name = kasprintf(GFP_KERNEL, "%pOFn", np);
if (!domain->base.name) {
kfree(domain);
- of_node_put(np);
break;
}
--
2.51.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] soc: dove: pmu: Simplify with scoped for each OF child loop
2026-01-02 12:48 [PATCH] soc: dove: pmu: Simplify with scoped for each OF child loop Krzysztof Kozlowski
@ 2026-01-05 14:04 ` Gregory CLEMENT
0 siblings, 0 replies; 2+ messages in thread
From: Gregory CLEMENT @ 2026-01-05 14:04 UTC (permalink / raw)
To: Krzysztof Kozlowski, Andrew Lunn, Sebastian Hesselbarth,
linux-arm-kernel, linux-kernel
Cc: Krzysztof Kozlowski
Krzysztof Kozlowski <krzysztof.kozlowski@oss.qualcomm.com> writes:
> Use scoped for-each loop when iterating over device nodes to make code a
> bit simpler.
>
> Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@oss.qualcomm.com>
Applied on mvebu/arm
Thanks,
Gregory
> ---
> drivers/soc/dove/pmu.c | 9 +++------
> 1 file changed, 3 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/soc/dove/pmu.c b/drivers/soc/dove/pmu.c
> index 7bbd3f940e4d..dd8ade8e9ee8 100644
> --- a/drivers/soc/dove/pmu.c
> +++ b/drivers/soc/dove/pmu.c
> @@ -371,7 +371,7 @@ int __init dove_init_pmu_legacy(const struct dove_pmu_initdata *initdata)
> */
> int __init dove_init_pmu(void)
> {
> - struct device_node *np_pmu, *domains_node, *np;
> + struct device_node *np_pmu, *domains_node;
> struct pmu_data *pmu;
> int ret, parent_irq;
>
> @@ -404,21 +404,18 @@ int __init dove_init_pmu(void)
>
> pmu_reset_init(pmu);
>
> - for_each_available_child_of_node(domains_node, np) {
> + for_each_available_child_of_node_scoped(domains_node, np) {
> struct of_phandle_args args;
> struct pmu_domain *domain;
>
> domain = kzalloc(sizeof(*domain), GFP_KERNEL);
> - if (!domain) {
> - of_node_put(np);
> + if (!domain)
> break;
> - }
>
> domain->pmu = pmu;
> domain->base.name = kasprintf(GFP_KERNEL, "%pOFn", np);
> if (!domain->base.name) {
> kfree(domain);
> - of_node_put(np);
> break;
> }
>
> --
> 2.51.0
>
--
Grégory CLEMENT, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-01-05 14:04 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-01-02 12:48 [PATCH] soc: dove: pmu: Simplify with scoped for each OF child loop Krzysztof Kozlowski
2026-01-05 14:04 ` Gregory CLEMENT
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).