linux-amlogic.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] soc: amlogic: meson-pwrc: Hold reference returned by  of_get_parent()
@ 2022-07-26  7:38 Liang He
  2022-07-26 21:12 ` Martin Blumenstingl
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Liang He @ 2022-07-26  7:38 UTC (permalink / raw)
  To: narmstrong, khilman, jbrunet, martin.blumenstingl, p.zabel,
	linux-arm-kernel, linux-amlogic, windhl

We should hold the reference returned by of_get_parent() and use
it to call of_node_put() for refcount balance.

Signed-off-by: Liang He <windhl@126.com>
---
 drivers/soc/amlogic/meson-ee-pwrc.c     | 5 ++++-
 drivers/soc/amlogic/meson-gx-pwrc-vpu.c | 5 ++++-
 2 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/drivers/soc/amlogic/meson-ee-pwrc.c b/drivers/soc/amlogic/meson-ee-pwrc.c
index 2be3afe6c2e3..dd5f2a13ceb5 100644
--- a/drivers/soc/amlogic/meson-ee-pwrc.c
+++ b/drivers/soc/amlogic/meson-ee-pwrc.c
@@ -469,6 +469,7 @@ static int meson_ee_pwrc_probe(struct platform_device *pdev)
 {
 	const struct meson_ee_pwrc_domain_data *match;
 	struct regmap *regmap_ao, *regmap_hhi;
+	struct device_node *parent_np;
 	struct meson_ee_pwrc *pwrc;
 	int i, ret;
 
@@ -495,7 +496,9 @@ static int meson_ee_pwrc_probe(struct platform_device *pdev)
 
 	pwrc->xlate.num_domains = match->count;
 
-	regmap_hhi = syscon_node_to_regmap(of_get_parent(pdev->dev.of_node));
+	parent_np = of_get_parent(pdev->dev.of_node);
+	regmap_hhi = syscon_node_to_regmap(parent_np);
+	of_node_put(parent_np);
 	if (IS_ERR(regmap_hhi)) {
 		dev_err(&pdev->dev, "failed to get HHI regmap\n");
 		return PTR_ERR(regmap_hhi);
diff --git a/drivers/soc/amlogic/meson-gx-pwrc-vpu.c b/drivers/soc/amlogic/meson-gx-pwrc-vpu.c
index b4615b288625..312fd9afccb0 100644
--- a/drivers/soc/amlogic/meson-gx-pwrc-vpu.c
+++ b/drivers/soc/amlogic/meson-gx-pwrc-vpu.c
@@ -273,6 +273,7 @@ static int meson_gx_pwrc_vpu_probe(struct platform_device *pdev)
 	const struct meson_gx_pwrc_vpu *vpu_pd_match;
 	struct regmap *regmap_ao, *regmap_hhi;
 	struct meson_gx_pwrc_vpu *vpu_pd;
+	struct device_node *parent_np;
 	struct reset_control *rstc;
 	struct clk *vpu_clk;
 	struct clk *vapb_clk;
@@ -291,7 +292,9 @@ static int meson_gx_pwrc_vpu_probe(struct platform_device *pdev)
 
 	memcpy(vpu_pd, vpu_pd_match, sizeof(*vpu_pd));
 
-	regmap_ao = syscon_node_to_regmap(of_get_parent(pdev->dev.of_node));
+	parent_np = of_get_parent(pdev->dev.of_node);
+	regmap_ao = syscon_node_to_regmap(parent_np);
+	of_node_put(parent_np);
 	if (IS_ERR(regmap_ao)) {
 		dev_err(&pdev->dev, "failed to get regmap\n");
 		return PTR_ERR(regmap_ao);
-- 
2.25.1


_______________________________________________
linux-amlogic mailing list
linux-amlogic@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-amlogic

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

* Re: [PATCH v2] soc: amlogic: meson-pwrc: Hold reference returned by of_get_parent()
  2022-07-26  7:38 [PATCH v2] soc: amlogic: meson-pwrc: Hold reference returned by of_get_parent() Liang He
@ 2022-07-26 21:12 ` Martin Blumenstingl
  2022-08-08  8:07 ` Neil Armstrong
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Martin Blumenstingl @ 2022-07-26 21:12 UTC (permalink / raw)
  To: Liang He
  Cc: Neil Armstrong, khilman, jbrunet, p.zabel, linux-arm-kernel,
	linux-amlogic

On Tue, Jul 26, 2022 at 9:39 AM Liang He <windhl@126.com> wrote:
>
> We should hold the reference returned by of_get_parent() and use
> it to call of_node_put() for refcount balance.
>
> Signed-off-by: Liang He <windhl@126.com>
Thank you for the update in v2! This now gets my:
Reviewed-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com>

_______________________________________________
linux-amlogic mailing list
linux-amlogic@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-amlogic

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

* Re: [PATCH v2] soc: amlogic: meson-pwrc: Hold reference returned by of_get_parent()
  2022-07-26  7:38 [PATCH v2] soc: amlogic: meson-pwrc: Hold reference returned by of_get_parent() Liang He
  2022-07-26 21:12 ` Martin Blumenstingl
@ 2022-08-08  8:07 ` Neil Armstrong
  2022-08-12  8:23 ` Jerome Brunet
  2022-09-05  7:24 ` Neil Armstrong
  3 siblings, 0 replies; 5+ messages in thread
From: Neil Armstrong @ 2022-08-08  8:07 UTC (permalink / raw)
  To: Liang He, khilman, jbrunet, martin.blumenstingl, p.zabel,
	linux-arm-kernel, linux-amlogic

On 26/07/2022 09:38, Liang He wrote:
> We should hold the reference returned by of_get_parent() and use
> it to call of_node_put() for refcount balance.
> 
> Signed-off-by: Liang He <windhl@126.com>
> ---
>   drivers/soc/amlogic/meson-ee-pwrc.c     | 5 ++++-
>   drivers/soc/amlogic/meson-gx-pwrc-vpu.c | 5 ++++-
>   2 files changed, 8 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/soc/amlogic/meson-ee-pwrc.c b/drivers/soc/amlogic/meson-ee-pwrc.c
> index 2be3afe6c2e3..dd5f2a13ceb5 100644
> --- a/drivers/soc/amlogic/meson-ee-pwrc.c
> +++ b/drivers/soc/amlogic/meson-ee-pwrc.c
> @@ -469,6 +469,7 @@ static int meson_ee_pwrc_probe(struct platform_device *pdev)
>   {
>   	const struct meson_ee_pwrc_domain_data *match;
>   	struct regmap *regmap_ao, *regmap_hhi;
> +	struct device_node *parent_np;
>   	struct meson_ee_pwrc *pwrc;
>   	int i, ret;
>   
> @@ -495,7 +496,9 @@ static int meson_ee_pwrc_probe(struct platform_device *pdev)
>   
>   	pwrc->xlate.num_domains = match->count;
>   
> -	regmap_hhi = syscon_node_to_regmap(of_get_parent(pdev->dev.of_node));
> +	parent_np = of_get_parent(pdev->dev.of_node);
> +	regmap_hhi = syscon_node_to_regmap(parent_np);
> +	of_node_put(parent_np);
>   	if (IS_ERR(regmap_hhi)) {
>   		dev_err(&pdev->dev, "failed to get HHI regmap\n");
>   		return PTR_ERR(regmap_hhi);
> diff --git a/drivers/soc/amlogic/meson-gx-pwrc-vpu.c b/drivers/soc/amlogic/meson-gx-pwrc-vpu.c
> index b4615b288625..312fd9afccb0 100644
> --- a/drivers/soc/amlogic/meson-gx-pwrc-vpu.c
> +++ b/drivers/soc/amlogic/meson-gx-pwrc-vpu.c
> @@ -273,6 +273,7 @@ static int meson_gx_pwrc_vpu_probe(struct platform_device *pdev)
>   	const struct meson_gx_pwrc_vpu *vpu_pd_match;
>   	struct regmap *regmap_ao, *regmap_hhi;
>   	struct meson_gx_pwrc_vpu *vpu_pd;
> +	struct device_node *parent_np;
>   	struct reset_control *rstc;
>   	struct clk *vpu_clk;
>   	struct clk *vapb_clk;
> @@ -291,7 +292,9 @@ static int meson_gx_pwrc_vpu_probe(struct platform_device *pdev)
>   
>   	memcpy(vpu_pd, vpu_pd_match, sizeof(*vpu_pd));
>   
> -	regmap_ao = syscon_node_to_regmap(of_get_parent(pdev->dev.of_node));
> +	parent_np = of_get_parent(pdev->dev.of_node);
> +	regmap_ao = syscon_node_to_regmap(parent_np);
> +	of_node_put(parent_np);
>   	if (IS_ERR(regmap_ao)) {
>   		dev_err(&pdev->dev, "failed to get regmap\n");
>   		return PTR_ERR(regmap_ao);

Reviewed-by: Neil Armstrong <narmstrong@baylibre.com>

_______________________________________________
linux-amlogic mailing list
linux-amlogic@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-amlogic

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

* Re: [PATCH v2] soc: amlogic: meson-pwrc: Hold reference returned by of_get_parent()
  2022-07-26  7:38 [PATCH v2] soc: amlogic: meson-pwrc: Hold reference returned by of_get_parent() Liang He
  2022-07-26 21:12 ` Martin Blumenstingl
  2022-08-08  8:07 ` Neil Armstrong
@ 2022-08-12  8:23 ` Jerome Brunet
  2022-09-05  7:24 ` Neil Armstrong
  3 siblings, 0 replies; 5+ messages in thread
From: Jerome Brunet @ 2022-08-12  8:23 UTC (permalink / raw)
  To: narmstrong, khilman, martin.blumenstingl, p.zabel,
	linux-arm-kernel, linux-amlogic, windhl


On Tue 26 Jul 2022 at 15:38, Liang He <windhl@126.com> wrote:

> We should hold the reference returned by of_get_parent() and use
> it to call of_node_put() for refcount balance.

Considering you are making this type of changes more or less everywhere
in the tree it would be good to propose an helper function instead of
repeating the of_get_parent(), syscon_node_to_regmap(), of_node_put()
pattern.

A coccinelle script would be nice too.

Thx

>
> Signed-off-by: Liang He <windhl@126.com>
> ---
>  drivers/soc/amlogic/meson-ee-pwrc.c     | 5 ++++-
>  drivers/soc/amlogic/meson-gx-pwrc-vpu.c | 5 ++++-
>  2 files changed, 8 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/soc/amlogic/meson-ee-pwrc.c b/drivers/soc/amlogic/meson-ee-pwrc.c
> index 2be3afe6c2e3..dd5f2a13ceb5 100644
> --- a/drivers/soc/amlogic/meson-ee-pwrc.c
> +++ b/drivers/soc/amlogic/meson-ee-pwrc.c
> @@ -469,6 +469,7 @@ static int meson_ee_pwrc_probe(struct platform_device *pdev)
>  {
>  	const struct meson_ee_pwrc_domain_data *match;
>  	struct regmap *regmap_ao, *regmap_hhi;
> +	struct device_node *parent_np;
>  	struct meson_ee_pwrc *pwrc;
>  	int i, ret;
>  
> @@ -495,7 +496,9 @@ static int meson_ee_pwrc_probe(struct platform_device *pdev)
>  
>  	pwrc->xlate.num_domains = match->count;
>  
> -	regmap_hhi = syscon_node_to_regmap(of_get_parent(pdev->dev.of_node));
> +	parent_np = of_get_parent(pdev->dev.of_node);
> +	regmap_hhi = syscon_node_to_regmap(parent_np);
> +	of_node_put(parent_np);
>  	if (IS_ERR(regmap_hhi)) {
>  		dev_err(&pdev->dev, "failed to get HHI regmap\n");
>  		return PTR_ERR(regmap_hhi);
> diff --git a/drivers/soc/amlogic/meson-gx-pwrc-vpu.c b/drivers/soc/amlogic/meson-gx-pwrc-vpu.c
> index b4615b288625..312fd9afccb0 100644
> --- a/drivers/soc/amlogic/meson-gx-pwrc-vpu.c
> +++ b/drivers/soc/amlogic/meson-gx-pwrc-vpu.c
> @@ -273,6 +273,7 @@ static int meson_gx_pwrc_vpu_probe(struct platform_device *pdev)
>  	const struct meson_gx_pwrc_vpu *vpu_pd_match;
>  	struct regmap *regmap_ao, *regmap_hhi;
>  	struct meson_gx_pwrc_vpu *vpu_pd;
> +	struct device_node *parent_np;
>  	struct reset_control *rstc;
>  	struct clk *vpu_clk;
>  	struct clk *vapb_clk;
> @@ -291,7 +292,9 @@ static int meson_gx_pwrc_vpu_probe(struct platform_device *pdev)
>  
>  	memcpy(vpu_pd, vpu_pd_match, sizeof(*vpu_pd));
>  
> -	regmap_ao = syscon_node_to_regmap(of_get_parent(pdev->dev.of_node));
> +	parent_np = of_get_parent(pdev->dev.of_node);
> +	regmap_ao = syscon_node_to_regmap(parent_np);
> +	of_node_put(parent_np);
>  	if (IS_ERR(regmap_ao)) {
>  		dev_err(&pdev->dev, "failed to get regmap\n");
>  		return PTR_ERR(regmap_ao);


_______________________________________________
linux-amlogic mailing list
linux-amlogic@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-amlogic

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

* Re: [PATCH v2] soc: amlogic: meson-pwrc: Hold reference returned by of_get_parent()
  2022-07-26  7:38 [PATCH v2] soc: amlogic: meson-pwrc: Hold reference returned by of_get_parent() Liang He
                   ` (2 preceding siblings ...)
  2022-08-12  8:23 ` Jerome Brunet
@ 2022-09-05  7:24 ` Neil Armstrong
  3 siblings, 0 replies; 5+ messages in thread
From: Neil Armstrong @ 2022-09-05  7:24 UTC (permalink / raw)
  To: martin.blumenstingl, p.zabel, linux-amlogic, Liang He,
	linux-arm-kernel, jbrunet, khilman
  Cc: Neil Armstrong

Hi,

On Tue, 26 Jul 2022 15:38:41 +0800, Liang He wrote:
> We should hold the reference returned by of_get_parent() and use
> it to call of_node_put() for refcount balance.
> 
> 

Thanks, Applied to https://git.kernel.org/pub/scm/linux/kernel/git/amlogic/linux.git (v6.1/drivers)

[1/1] soc: amlogic: meson-pwrc: Hold reference returned by of_get_parent()
      https://git.kernel.org/amlogic/c/9491cff16a4996aee578adf9f41acfb1bc483df9

These changes has been applied on the intermediate git tree [1].

The v6.1/drivers branch will then be sent via a formal Pull Request to the Linux SoC maintainers
for inclusion in their intermediate git branches in order to be sent to Linus during
the next merge window, or sooner if it's a set of fixes.

In the cases of fixes, those will be merged in the current release candidate
kernel and as soon they appear on the Linux master branch they will be
backported to the previous Stable and Long-Stable kernels [2].

The intermediate git branches are merged daily in the linux-next tree [3],
people are encouraged testing these pre-release kernels and report issues on the
relevant mailing-lists.

If problems are discovered on those changes, please submit a signed-off-by revert
patch followed by a corrective changeset.

[1] https://git.kernel.org/pub/scm/linux/kernel/git/amlogic/linux.git
[2] https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
[3] https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git

-- 
Neil

_______________________________________________
linux-amlogic mailing list
linux-amlogic@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-amlogic

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

end of thread, other threads:[~2022-09-05  8:16 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-26  7:38 [PATCH v2] soc: amlogic: meson-pwrc: Hold reference returned by of_get_parent() Liang He
2022-07-26 21:12 ` Martin Blumenstingl
2022-08-08  8:07 ` Neil Armstrong
2022-08-12  8:23 ` Jerome Brunet
2022-09-05  7:24 ` Neil Armstrong

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