diff mbox series

soc: ti: Use for_each_node_with_property() simplify code logic

Message ID 20230818070149.23103-1-zhangzekun11@huawei.com
State Accepted
Commit 5e536362f6ab97f709c07bfda962a7bb036c2563
Headers show
Series soc: ti: Use for_each_node_with_property() simplify code logic | expand

Commit Message

Zhang Zekun Aug. 18, 2023, 7:01 a.m. UTC
Introduct for_each_node_with_property() to iterate through the
nodes, this can simplify the code logic a bit, no functional
change here.

Signed-off-by: Zhang Zekun <zhangzekun11@huawei.com>
---
 drivers/genpd/ti/ti_sci_pm_domains.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)

Comments

Nishanth Menon Aug. 24, 2023, 7:14 p.m. UTC | #1
On 11:10-20230818, Ulf Hansson wrote:
> On Fri, 18 Aug 2023 at 09:10, Zhang Zekun <zhangzekun11@huawei.com> wrote:
> >
> > Introduct for_each_node_with_property() to iterate through the
> > nodes, this can simplify the code logic a bit, no functional
> > change here.
> 
> I would prefer if we can start using the prefix "genpd: ti*" for the
> commit message header.
> 
> >
> > Signed-off-by: Zhang Zekun <zhangzekun11@huawei.com>
> 
> This looks good to me and I can pick it up, but awaiting and ack from
> the soc maintainers too.

Acked-by: Nishanth Menon <nm@ti.com>

Did some sanity tests around it as well.. I didn't see any obvious
breakage that I related to this.

> 
> Kind regards
> Uffe
> 
> > ---
> >  drivers/genpd/ti/ti_sci_pm_domains.c | 8 ++------
> >  1 file changed, 2 insertions(+), 6 deletions(-)
> >
> > diff --git a/drivers/genpd/ti/ti_sci_pm_domains.c b/drivers/genpd/ti/ti_sci_pm_domains.c
> > index a33ec7eaf23d..34645104fe45 100644
> > --- a/drivers/genpd/ti/ti_sci_pm_domains.c
> > +++ b/drivers/genpd/ti/ti_sci_pm_domains.c
> > @@ -119,7 +119,7 @@ static int ti_sci_pm_domain_probe(struct platform_device *pdev)
> >         struct device *dev = &pdev->dev;
> >         struct ti_sci_genpd_provider *pd_provider;
> >         struct ti_sci_pm_domain *pd;
> > -       struct device_node *np = NULL;
> > +       struct device_node *np;
> >         struct of_phandle_args args;
> >         int ret;
> >         u32 max_id = 0;
> > @@ -138,11 +138,7 @@ static int ti_sci_pm_domain_probe(struct platform_device *pdev)
> >         INIT_LIST_HEAD(&pd_provider->pd_list);
> >
> >         /* Find highest device ID used for power domains */
> > -       while (1) {
> > -               np = of_find_node_with_property(np, "power-domains");
> > -               if (!np)
> > -                       break;
> > -
> > +       for_each_node_with_property(np, "power-domains") {
> >                 index = 0;
> >
> >                 while (1) {
> > --
> > 2.17.1
> >
Ulf Hansson Aug. 25, 2023, 10:07 a.m. UTC | #2
On Fri, 18 Aug 2023 at 11:10, Ulf Hansson <ulf.hansson@linaro.org> wrote:
>
> On Fri, 18 Aug 2023 at 09:10, Zhang Zekun <zhangzekun11@huawei.com> wrote:
> >
> > Introduct for_each_node_with_property() to iterate through the
> > nodes, this can simplify the code logic a bit, no functional
> > change here.
>
> I would prefer if we can start using the prefix "genpd: ti*" for the
> commit message header.
>
> >
> > Signed-off-by: Zhang Zekun <zhangzekun11@huawei.com>
>
> This looks good to me and I can pick it up, but awaiting and ack from
> the soc maintainers too.

Applied for next and by amending the commit msg header, thanks!

Kind regards
Uffe


>
> Kind regards
> Uffe
>
> > ---
> >  drivers/genpd/ti/ti_sci_pm_domains.c | 8 ++------
> >  1 file changed, 2 insertions(+), 6 deletions(-)
> >
> > diff --git a/drivers/genpd/ti/ti_sci_pm_domains.c b/drivers/genpd/ti/ti_sci_pm_domains.c
> > index a33ec7eaf23d..34645104fe45 100644
> > --- a/drivers/genpd/ti/ti_sci_pm_domains.c
> > +++ b/drivers/genpd/ti/ti_sci_pm_domains.c
> > @@ -119,7 +119,7 @@ static int ti_sci_pm_domain_probe(struct platform_device *pdev)
> >         struct device *dev = &pdev->dev;
> >         struct ti_sci_genpd_provider *pd_provider;
> >         struct ti_sci_pm_domain *pd;
> > -       struct device_node *np = NULL;
> > +       struct device_node *np;
> >         struct of_phandle_args args;
> >         int ret;
> >         u32 max_id = 0;
> > @@ -138,11 +138,7 @@ static int ti_sci_pm_domain_probe(struct platform_device *pdev)
> >         INIT_LIST_HEAD(&pd_provider->pd_list);
> >
> >         /* Find highest device ID used for power domains */
> > -       while (1) {
> > -               np = of_find_node_with_property(np, "power-domains");
> > -               if (!np)
> > -                       break;
> > -
> > +       for_each_node_with_property(np, "power-domains") {
> >                 index = 0;
> >
> >                 while (1) {
> > --
> > 2.17.1
> >
diff mbox series

Patch

diff --git a/drivers/genpd/ti/ti_sci_pm_domains.c b/drivers/genpd/ti/ti_sci_pm_domains.c
index a33ec7eaf23d..34645104fe45 100644
--- a/drivers/genpd/ti/ti_sci_pm_domains.c
+++ b/drivers/genpd/ti/ti_sci_pm_domains.c
@@ -119,7 +119,7 @@  static int ti_sci_pm_domain_probe(struct platform_device *pdev)
 	struct device *dev = &pdev->dev;
 	struct ti_sci_genpd_provider *pd_provider;
 	struct ti_sci_pm_domain *pd;
-	struct device_node *np = NULL;
+	struct device_node *np;
 	struct of_phandle_args args;
 	int ret;
 	u32 max_id = 0;
@@ -138,11 +138,7 @@  static int ti_sci_pm_domain_probe(struct platform_device *pdev)
 	INIT_LIST_HEAD(&pd_provider->pd_list);
 
 	/* Find highest device ID used for power domains */
-	while (1) {
-		np = of_find_node_with_property(np, "power-domains");
-		if (!np)
-			break;
-
+	for_each_node_with_property(np, "power-domains") {
 		index = 0;
 
 		while (1) {