diff mbox

[V4,2/8] opp: call of_node_{get|put}() from of_init_opp_table()

Message ID 4139797fe7501ba99adf63ec8e5cf9fa9b24c197.1401191054.git.viresh.kumar@linaro.org
State New
Headers show

Commit Message

Viresh Kumar May 27, 2014, 11:50 a.m. UTC
All callers of of_init_opp_table() are required to take reference of
dev->of_node, by initiating calls to of_node_{get|put}(), before and after
calling of_init_opp_table().

Its better to call these from within of_init_opp_table(), no fun adding
redundant code to every caller.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
---
 drivers/base/power/opp.c | 4 ++++
 1 file changed, 4 insertions(+)

Comments

Nishanth Menon May 29, 2014, 10:32 p.m. UTC | #1
On 05/27/2014 06:50 AM, Viresh Kumar wrote:
> All callers of of_init_opp_table() are required to take reference of
> dev->of_node, by initiating calls to of_node_{get|put}(), before and after
> calling of_init_opp_table().
> 
> Its better to call these from within of_init_opp_table(), no fun adding
> redundant code to every caller.
> 
> Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
> ---
>  drivers/base/power/opp.c | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/drivers/base/power/opp.c b/drivers/base/power/opp.c
> index faae9cf..2b615b9 100644
> --- a/drivers/base/power/opp.c
> +++ b/drivers/base/power/opp.c
> @@ -622,6 +622,9 @@ int of_init_opp_table(struct device *dev)
>  	const __be32 *val;
>  	int nr;
>  
> +	if (!of_node_get(dev->of_node))
> +		return -ENODEV;
> +
>  	prop = of_find_property(dev->of_node, "operating-points", NULL);
>  	if (!prop)
>  		return -ENODEV;
> @@ -649,6 +652,7 @@ int of_init_opp_table(struct device *dev)
>  		nr -= 2;
>  	}
>  
> +	of_node_put(dev->of_node);
>  	return 0;
>  }
>  EXPORT_SYMBOL_GPL(of_init_opp_table);
> 
With the same $subject comment as patch #1:
Acked-by: Nishanth Menon <nm@ti.com>
Sachin Kamat May 30, 2014, 6:33 a.m. UTC | #2
Hi Viresh,

On 27 May 2014 17:20, Viresh Kumar <viresh.kumar@linaro.org> wrote:
> All callers of of_init_opp_table() are required to take reference of
> dev->of_node, by initiating calls to of_node_{get|put}(), before and after
> calling of_init_opp_table().
>
> Its better to call these from within of_init_opp_table(), no fun adding
> redundant code to every caller.
>
> Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
> ---
>  drivers/base/power/opp.c | 4 ++++
>  1 file changed, 4 insertions(+)
>
> diff --git a/drivers/base/power/opp.c b/drivers/base/power/opp.c
> index faae9cf..2b615b9 100644
> --- a/drivers/base/power/opp.c
> +++ b/drivers/base/power/opp.c
> @@ -622,6 +622,9 @@ int of_init_opp_table(struct device *dev)
>         const __be32 *val;
>         int nr;
>
> +       if (!of_node_get(dev->of_node))
> +               return -ENODEV;
> +
>         prop = of_find_property(dev->of_node, "operating-points", NULL);
>         if (!prop)
>                 return -ENODEV;

What about of_node_put before returning here and other places in this function?
Rafael J. Wysocki May 30, 2014, 12:22 p.m. UTC | #3
On Friday, May 30, 2014 12:03:08 PM Sachin Kamat wrote:
> Hi Viresh,
> 
> On 27 May 2014 17:20, Viresh Kumar <viresh.kumar@linaro.org> wrote:
> > All callers of of_init_opp_table() are required to take reference of
> > dev->of_node, by initiating calls to of_node_{get|put}(), before and after
> > calling of_init_opp_table().
> >
> > Its better to call these from within of_init_opp_table(), no fun adding
> > redundant code to every caller.
> >
> > Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
> > ---
> >  drivers/base/power/opp.c | 4 ++++
> >  1 file changed, 4 insertions(+)
> >
> > diff --git a/drivers/base/power/opp.c b/drivers/base/power/opp.c
> > index faae9cf..2b615b9 100644
> > --- a/drivers/base/power/opp.c
> > +++ b/drivers/base/power/opp.c
> > @@ -622,6 +622,9 @@ int of_init_opp_table(struct device *dev)
> >         const __be32 *val;
> >         int nr;
> >
> > +       if (!of_node_get(dev->of_node))
> > +               return -ENODEV;
> > +
> >         prop = of_find_property(dev->of_node, "operating-points", NULL);
> >         if (!prop)
> >                 return -ENODEV;
> 
> What about of_node_put before returning here and other places in this function?

Yeah, that needs to be fixed.

The rest of the series looks good to me, so Viresh, please fix this one ASAP and
send an update (of this particular patch only).

Thanks!
diff mbox

Patch

diff --git a/drivers/base/power/opp.c b/drivers/base/power/opp.c
index faae9cf..2b615b9 100644
--- a/drivers/base/power/opp.c
+++ b/drivers/base/power/opp.c
@@ -622,6 +622,9 @@  int of_init_opp_table(struct device *dev)
 	const __be32 *val;
 	int nr;
 
+	if (!of_node_get(dev->of_node))
+		return -ENODEV;
+
 	prop = of_find_property(dev->of_node, "operating-points", NULL);
 	if (!prop)
 		return -ENODEV;
@@ -649,6 +652,7 @@  int of_init_opp_table(struct device *dev)
 		nr -= 2;
 	}
 
+	of_node_put(dev->of_node);
 	return 0;
 }
 EXPORT_SYMBOL_GPL(of_init_opp_table);