linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH V2] thermal: imx: Add missing of_node_put()
@ 2020-03-26 14:29 Anson Huang
  2020-04-28 20:28 ` Amit Kucheria
  0 siblings, 1 reply; 3+ messages in thread
From: Anson Huang @ 2020-03-26 14:29 UTC (permalink / raw)
  To: rui.zhang, daniel.lezcano, amit.kucheria, shawnguo, s.hauer,
	kernel, festevam, linux-pm, linux-arm-kernel, linux-kernel
  Cc: Linux-imx

After finishing using cpu node got from of_get_cpu_node(), of_node_put()
needs to be called.

Signed-off-by: Anson Huang <Anson.Huang@nxp.com>
---
Changes since V1:
	- improve the logic, no need to use got.
---
 drivers/thermal/imx_thermal.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/thermal/imx_thermal.c b/drivers/thermal/imx_thermal.c
index e761c9b..1b84ea6 100644
--- a/drivers/thermal/imx_thermal.c
+++ b/drivers/thermal/imx_thermal.c
@@ -649,7 +649,7 @@ MODULE_DEVICE_TABLE(of, of_imx_thermal_match);
 static int imx_thermal_register_legacy_cooling(struct imx_thermal_data *data)
 {
 	struct device_node *np;
-	int ret;
+	int ret = 0;
 
 	data->policy = cpufreq_cpu_get(0);
 	if (!data->policy) {
@@ -664,11 +664,12 @@ static int imx_thermal_register_legacy_cooling(struct imx_thermal_data *data)
 		if (IS_ERR(data->cdev)) {
 			ret = PTR_ERR(data->cdev);
 			cpufreq_cpu_put(data->policy);
-			return ret;
 		}
 	}
 
-	return 0;
+	of_node_put(np);
+
+	return ret;
 }
 
 static void imx_thermal_unregister_legacy_cooling(struct imx_thermal_data *data)
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH V2] thermal: imx: Add missing of_node_put()
  2020-03-26 14:29 [PATCH V2] thermal: imx: Add missing of_node_put() Anson Huang
@ 2020-04-28 20:28 ` Amit Kucheria
  2020-04-29  2:00   ` Anson Huang
  0 siblings, 1 reply; 3+ messages in thread
From: Amit Kucheria @ 2020-04-28 20:28 UTC (permalink / raw)
  To: Anson Huang
  Cc: Zhang Rui, Daniel Lezcano, Shawn Guo, Sascha Hauer, kernel,
	Fabio Estevam, Linux PM list, lakml, LKML, dl-linux-imx

On Thu, Mar 26, 2020 at 8:06 PM Anson Huang <Anson.Huang@nxp.com> wrote:
>
> After finishing using cpu node got from of_get_cpu_node(), of_node_put()
> needs to be called.
>
> Signed-off-by: Anson Huang <Anson.Huang@nxp.com>
> ---
> Changes since V1:
>         - improve the logic, no need to use got.
> ---
>  drivers/thermal/imx_thermal.c | 7 ++++---
>  1 file changed, 4 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/thermal/imx_thermal.c b/drivers/thermal/imx_thermal.c
> index e761c9b..1b84ea6 100644
> --- a/drivers/thermal/imx_thermal.c
> +++ b/drivers/thermal/imx_thermal.c
> @@ -649,7 +649,7 @@ MODULE_DEVICE_TABLE(of, of_imx_thermal_match);
>  static int imx_thermal_register_legacy_cooling(struct imx_thermal_data *data)
>  {
>         struct device_node *np;
> -       int ret;
> +       int ret = 0;
>
>         data->policy = cpufreq_cpu_get(0);
>         if (!data->policy) {
> @@ -664,11 +664,12 @@ static int imx_thermal_register_legacy_cooling(struct imx_thermal_data *data)
>                 if (IS_ERR(data->cdev)) {
>                         ret = PTR_ERR(data->cdev);
>                         cpufreq_cpu_put(data->policy);

You could move this policy release outside the if block too, no?

> -                       return ret;
>                 }
>         }
>
> -       return 0;
> +       of_node_put(np);
> +
> +       return ret;
>  }
>
>  static void imx_thermal_unregister_legacy_cooling(struct imx_thermal_data *data)
> --
> 2.7.4
>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* RE: [PATCH V2] thermal: imx: Add missing of_node_put()
  2020-04-28 20:28 ` Amit Kucheria
@ 2020-04-29  2:00   ` Anson Huang
  0 siblings, 0 replies; 3+ messages in thread
From: Anson Huang @ 2020-04-29  2:00 UTC (permalink / raw)
  To: Amit Kucheria
  Cc: Zhang Rui, Daniel Lezcano, Shawn Guo, Sascha Hauer, kernel,
	Fabio Estevam, Linux PM list, lakml, LKML, dl-linux-imx

Hi, Amit


> Subject: Re: [PATCH V2] thermal: imx: Add missing of_node_put()
> 
> On Thu, Mar 26, 2020 at 8:06 PM Anson Huang <Anson.Huang@nxp.com>
> wrote:
> >
> > After finishing using cpu node got from of_get_cpu_node(),
> > of_node_put() needs to be called.
> >
> > Signed-off-by: Anson Huang <Anson.Huang@nxp.com>
> > ---
> > Changes since V1:
> >         - improve the logic, no need to use got.
> > ---
> >  drivers/thermal/imx_thermal.c | 7 ++++---
> >  1 file changed, 4 insertions(+), 3 deletions(-)
> >
> > diff --git a/drivers/thermal/imx_thermal.c
> > b/drivers/thermal/imx_thermal.c index e761c9b..1b84ea6 100644
> > --- a/drivers/thermal/imx_thermal.c
> > +++ b/drivers/thermal/imx_thermal.c
> > @@ -649,7 +649,7 @@ MODULE_DEVICE_TABLE(of,
> of_imx_thermal_match);
> > static int imx_thermal_register_legacy_cooling(struct imx_thermal_data
> > *data)  {
> >         struct device_node *np;
> > -       int ret;
> > +       int ret = 0;
> >
> >         data->policy = cpufreq_cpu_get(0);
> >         if (!data->policy) {
> > @@ -664,11 +664,12 @@ static int
> imx_thermal_register_legacy_cooling(struct imx_thermal_data *data)
> >                 if (IS_ERR(data->cdev)) {
> >                         ret = PTR_ERR(data->cdev);
> >                         cpufreq_cpu_put(data->policy);
> 
> You could move this policy release outside the if block too, no?

Looks like yes, the policy can be put before function return anyway, I will do it in V3.

Thanks,
Anson

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-04-29  2:00 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-26 14:29 [PATCH V2] thermal: imx: Add missing of_node_put() Anson Huang
2020-04-28 20:28 ` Amit Kucheria
2020-04-29  2:00   ` Anson Huang

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).