linux-phy.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] phy: amlogic: phy-meson-axg-mipi-pcie-analog: Hold reference returned by of_get_parent()
@ 2022-07-05  2:15 Liang He
  2022-07-05  7:21 ` Neil Armstrong
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Liang He @ 2022-07-05  2:15 UTC (permalink / raw)
  To: kishon, narmstrong, khilman, jbrunet, martin.blumenstingl, windhl,
	linux-phy

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

Fixes: 8eff8b4e22d9 ("phy: amlogic: phy-meson-axg-mipi-pcie-analog: add support for MIPI DSI analog")
Signed-off-by: Liang He <windhl@126.com>
---
 drivers/phy/amlogic/phy-meson-axg-mipi-pcie-analog.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/phy/amlogic/phy-meson-axg-mipi-pcie-analog.c b/drivers/phy/amlogic/phy-meson-axg-mipi-pcie-analog.c
index 1027ece6ca12..a3e1108b736d 100644
--- a/drivers/phy/amlogic/phy-meson-axg-mipi-pcie-analog.c
+++ b/drivers/phy/amlogic/phy-meson-axg-mipi-pcie-analog.c
@@ -197,7 +197,7 @@ static int phy_axg_mipi_pcie_analog_probe(struct platform_device *pdev)
 	struct phy_provider *phy;
 	struct device *dev = &pdev->dev;
 	struct phy_axg_mipi_pcie_analog_priv *priv;
-	struct device_node *np = dev->of_node;
+	struct device_node *np = dev->of_node, *parent_np;
 	struct regmap *map;
 	int ret;
 
@@ -206,7 +206,9 @@ static int phy_axg_mipi_pcie_analog_probe(struct platform_device *pdev)
 		return -ENOMEM;
 
 	/* Get the hhi system controller node */
-	map = syscon_node_to_regmap(of_get_parent(dev->of_node));
+	parent_np = of_get_parent(dev->of_node);
+	map = syscon_node_to_regmap(parent_np);
+	of_node_put(parent_np);
 	if (IS_ERR(map)) {
 		dev_err(dev,
 			"failed to get HHI regmap\n");
-- 
2.25.1


-- 
linux-phy mailing list
linux-phy@lists.infradead.org
https://lists.infradead.org/mailman/listinfo/linux-phy

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

* Re: [PATCH] phy: amlogic: phy-meson-axg-mipi-pcie-analog: Hold reference returned by of_get_parent()
  2022-07-05  2:15 [PATCH] phy: amlogic: phy-meson-axg-mipi-pcie-analog: Hold reference returned by of_get_parent() Liang He
@ 2022-07-05  7:21 ` Neil Armstrong
  2022-07-25 19:41 ` Martin Blumenstingl
  2022-09-02 15:41 ` Vinod Koul
  2 siblings, 0 replies; 7+ messages in thread
From: Neil Armstrong @ 2022-07-05  7:21 UTC (permalink / raw)
  To: Liang He, kishon, khilman, jbrunet, martin.blumenstingl,
	linux-phy
  Cc: open list:ARM/Amlogic Meson...,
	linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org

+ linux-amlogic, linux-arm-kernel, linux-kernel

On 05/07/2022 04:15, Liang He wrote:
> We should hold the reference returned by of_get_parent() and use it
> to call of_node_put() for reference balance.
> 
> Fixes: 8eff8b4e22d9 ("phy: amlogic: phy-meson-axg-mipi-pcie-analog: add support for MIPI DSI analog")
> Signed-off-by: Liang He <windhl@126.com>
> ---
>   drivers/phy/amlogic/phy-meson-axg-mipi-pcie-analog.c | 6 ++++--
>   1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/phy/amlogic/phy-meson-axg-mipi-pcie-analog.c b/drivers/phy/amlogic/phy-meson-axg-mipi-pcie-analog.c
> index 1027ece6ca12..a3e1108b736d 100644
> --- a/drivers/phy/amlogic/phy-meson-axg-mipi-pcie-analog.c
> +++ b/drivers/phy/amlogic/phy-meson-axg-mipi-pcie-analog.c
> @@ -197,7 +197,7 @@ static int phy_axg_mipi_pcie_analog_probe(struct platform_device *pdev)
>   	struct phy_provider *phy;
>   	struct device *dev = &pdev->dev;
>   	struct phy_axg_mipi_pcie_analog_priv *priv;
> -	struct device_node *np = dev->of_node;
> +	struct device_node *np = dev->of_node, *parent_np;
>   	struct regmap *map;
>   	int ret;
>   
> @@ -206,7 +206,9 @@ static int phy_axg_mipi_pcie_analog_probe(struct platform_device *pdev)
>   		return -ENOMEM;
>   
>   	/* Get the hhi system controller node */
> -	map = syscon_node_to_regmap(of_get_parent(dev->of_node));
> +	parent_np = of_get_parent(dev->of_node);
> +	map = syscon_node_to_regmap(parent_np);
> +	of_node_put(parent_np);
>   	if (IS_ERR(map)) {
>   		dev_err(dev,
>   			"failed to get HHI regmap\n");


-- 
linux-phy mailing list
linux-phy@lists.infradead.org
https://lists.infradead.org/mailman/listinfo/linux-phy

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

* Re: [PATCH] phy: amlogic: phy-meson-axg-mipi-pcie-analog: Hold reference returned by of_get_parent()
  2022-07-05  2:15 [PATCH] phy: amlogic: phy-meson-axg-mipi-pcie-analog: Hold reference returned by of_get_parent() Liang He
  2022-07-05  7:21 ` Neil Armstrong
@ 2022-07-25 19:41 ` Martin Blumenstingl
  2022-09-02 15:41 ` Vinod Koul
  2 siblings, 0 replies; 7+ messages in thread
From: Martin Blumenstingl @ 2022-07-25 19:41 UTC (permalink / raw)
  To: Liang He
  Cc: kishon, Neil Armstrong, khilman, jbrunet, linux-phy,
	linux-arm-kernel, linux-kernel, linux-amlogic

On Tue, Jul 5, 2022 at 4:15 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 reference balance.
>
> Fixes: 8eff8b4e22d9 ("phy: amlogic: phy-meson-axg-mipi-pcie-analog: add support for MIPI DSI analog")
> Signed-off-by: Liang He <windhl@126.com>
Acked-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com>

-- 
linux-phy mailing list
linux-phy@lists.infradead.org
https://lists.infradead.org/mailman/listinfo/linux-phy

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

* Re: [PATCH] phy: amlogic: phy-meson-axg-mipi-pcie-analog: Hold reference returned by of_get_parent()
  2022-07-05  2:15 [PATCH] phy: amlogic: phy-meson-axg-mipi-pcie-analog: Hold reference returned by of_get_parent() Liang He
  2022-07-05  7:21 ` Neil Armstrong
  2022-07-25 19:41 ` Martin Blumenstingl
@ 2022-09-02 15:41 ` Vinod Koul
  2022-09-05  7:21   ` Liang He
  2 siblings, 1 reply; 7+ messages in thread
From: Vinod Koul @ 2022-09-02 15:41 UTC (permalink / raw)
  To: Liang He
  Cc: kishon, narmstrong, khilman, jbrunet, martin.blumenstingl,
	linux-phy

On 05-07-22, 10:15, Liang He wrote:
> We should hold the reference returned by of_get_parent() and use it
> to call of_node_put() for reference balance.

And why should we hold and drop reference?

> 
> Fixes: 8eff8b4e22d9 ("phy: amlogic: phy-meson-axg-mipi-pcie-analog: add support for MIPI DSI analog")
> Signed-off-by: Liang He <windhl@126.com>
> ---
>  drivers/phy/amlogic/phy-meson-axg-mipi-pcie-analog.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/phy/amlogic/phy-meson-axg-mipi-pcie-analog.c b/drivers/phy/amlogic/phy-meson-axg-mipi-pcie-analog.c
> index 1027ece6ca12..a3e1108b736d 100644
> --- a/drivers/phy/amlogic/phy-meson-axg-mipi-pcie-analog.c
> +++ b/drivers/phy/amlogic/phy-meson-axg-mipi-pcie-analog.c
> @@ -197,7 +197,7 @@ static int phy_axg_mipi_pcie_analog_probe(struct platform_device *pdev)
>  	struct phy_provider *phy;
>  	struct device *dev = &pdev->dev;
>  	struct phy_axg_mipi_pcie_analog_priv *priv;
> -	struct device_node *np = dev->of_node;
> +	struct device_node *np = dev->of_node, *parent_np;
>  	struct regmap *map;
>  	int ret;
>  
> @@ -206,7 +206,9 @@ static int phy_axg_mipi_pcie_analog_probe(struct platform_device *pdev)
>  		return -ENOMEM;
>  
>  	/* Get the hhi system controller node */
> -	map = syscon_node_to_regmap(of_get_parent(dev->of_node));
> +	parent_np = of_get_parent(dev->of_node);
> +	map = syscon_node_to_regmap(parent_np);
> +	of_node_put(parent_np);
>  	if (IS_ERR(map)) {
>  		dev_err(dev,
>  			"failed to get HHI regmap\n");
> -- 
> 2.25.1
> 
> 
> -- 
> linux-phy mailing list
> linux-phy@lists.infradead.org
> https://lists.infradead.org/mailman/listinfo/linux-phy

-- 
~Vinod

-- 
linux-phy mailing list
linux-phy@lists.infradead.org
https://lists.infradead.org/mailman/listinfo/linux-phy

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

* Re:Re: [PATCH] phy: amlogic: phy-meson-axg-mipi-pcie-analog: Hold reference returned by of_get_parent()
  2022-09-02 15:41 ` Vinod Koul
@ 2022-09-05  7:21   ` Liang He
  2022-09-13 13:55     ` Vinod Koul
  0 siblings, 1 reply; 7+ messages in thread
From: Liang He @ 2022-09-05  7:21 UTC (permalink / raw)
  To: Vinod Koul
  Cc: kishon, narmstrong, khilman, jbrunet, martin.blumenstingl,
	linux-phy




At 2022-09-02 23:41:14, "Vinod Koul" <vkoul@kernel.org> wrote:
>On 05-07-22, 10:15, Liang He wrote:
>> We should hold the reference returned by of_get_parent() and use it
>> to call of_node_put() for reference balance.
>
>And why should we hold and drop reference?

>
Hi, Vinod Koul,


Thanks very much for your review.


As the of_get_parent() will increase the refcount of the node->parent  and the reference will be discarded 
so we should hold the reference , with which we can decrease the refcount.


If there is any misunderstanding about the of_get_parent() API, please correct me.


Thanks very much.


Liang

>> 
>> Fixes: 8eff8b4e22d9 ("phy: amlogic: phy-meson-axg-mipi-pcie-analog: add support for MIPI DSI analog")
>> Signed-off-by: Liang He <windhl@126.com>
>> ---
>>  drivers/phy/amlogic/phy-meson-axg-mipi-pcie-analog.c | 6 ++++--
>>  1 file changed, 4 insertions(+), 2 deletions(-)
>> 
>> diff --git a/drivers/phy/amlogic/phy-meson-axg-mipi-pcie-analog.c b/drivers/phy/amlogic/phy-meson-axg-mipi-pcie-analog.c
>> index 1027ece6ca12..a3e1108b736d 100644
>> --- a/drivers/phy/amlogic/phy-meson-axg-mipi-pcie-analog.c
>> +++ b/drivers/phy/amlogic/phy-meson-axg-mipi-pcie-analog.c
>> @@ -197,7 +197,7 @@ static int phy_axg_mipi_pcie_analog_probe(struct platform_device *pdev)
>>  	struct phy_provider *phy;
>>  	struct device *dev = &pdev->dev;
>>  	struct phy_axg_mipi_pcie_analog_priv *priv;
>> -	struct device_node *np = dev->of_node;
>> +	struct device_node *np = dev->of_node, *parent_np;
>>  	struct regmap *map;
>>  	int ret;
>>  
>> @@ -206,7 +206,9 @@ static int phy_axg_mipi_pcie_analog_probe(struct platform_device *pdev)
>>  		return -ENOMEM;
>>  
>>  	/* Get the hhi system controller node */
>> -	map = syscon_node_to_regmap(of_get_parent(dev->of_node));
>> +	parent_np = of_get_parent(dev->of_node);
>> +	map = syscon_node_to_regmap(parent_np);
>> +	of_node_put(parent_np);
>>  	if (IS_ERR(map)) {
>>  		dev_err(dev,
>>  			"failed to get HHI regmap\n");
>> -- 
>> 2.25.1
>> 
>> 
>> -- 
>> linux-phy mailing list
>> linux-phy@lists.infradead.org
>> https://lists.infradead.org/mailman/listinfo/linux-phy
>
>-- 
>~Vinod
-- 
linux-phy mailing list
linux-phy@lists.infradead.org
https://lists.infradead.org/mailman/listinfo/linux-phy

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

* Re: Re: [PATCH] phy: amlogic: phy-meson-axg-mipi-pcie-analog: Hold reference returned by of_get_parent()
  2022-09-05  7:21   ` Liang He
@ 2022-09-13 13:55     ` Vinod Koul
  2022-09-13 15:15       ` Liang He
  0 siblings, 1 reply; 7+ messages in thread
From: Vinod Koul @ 2022-09-13 13:55 UTC (permalink / raw)
  To: Liang He
  Cc: kishon, narmstrong, khilman, jbrunet, martin.blumenstingl,
	linux-phy

On 05-09-22, 15:21, Liang He wrote:
> 
> 
> 
> At 2022-09-02 23:41:14, "Vinod Koul" <vkoul@kernel.org> wrote:
> >On 05-07-22, 10:15, Liang He wrote:
> >> We should hold the reference returned by of_get_parent() and use it
> >> to call of_node_put() for reference balance.
> >
> >And why should we hold and drop reference?
> 
> >
> Hi, Vinod Koul,
> 
> 
> Thanks very much for your review.
> 
> 
> As the of_get_parent() will increase the refcount of the node->parent  and the reference will be discarded 
> so we should hold the reference , with which we can decrease the refcount.

Right, that is correct explanation
> 
> 
> If there is any misunderstanding about the of_get_parent() API, please correct me.

Nope, just that this explanation is missing from the log...

Please add...

-- 
~Vinod

-- 
linux-phy mailing list
linux-phy@lists.infradead.org
https://lists.infradead.org/mailman/listinfo/linux-phy

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

* Re:Re: Re: [PATCH] phy: amlogic: phy-meson-axg-mipi-pcie-analog: Hold reference returned by of_get_parent()
  2022-09-13 13:55     ` Vinod Koul
@ 2022-09-13 15:15       ` Liang He
  0 siblings, 0 replies; 7+ messages in thread
From: Liang He @ 2022-09-13 15:15 UTC (permalink / raw)
  To: Vinod Koul
  Cc: kishon, narmstrong, khilman, jbrunet, martin.blumenstingl,
	linux-phy



At 2022-09-13 21:55:53, "Vinod Koul" <vkoul@kernel.org> wrote:
>On 05-09-22, 15:21, Liang He wrote:
>> 
>> 
>> 
>> At 2022-09-02 23:41:14, "Vinod Koul" <vkoul@kernel.org> wrote:
>> >On 05-07-22, 10:15, Liang He wrote:
>> >> We should hold the reference returned by of_get_parent() and use it
>> >> to call of_node_put() for reference balance.
>> >
>> >And why should we hold and drop reference?
>> 
>> >
>> Hi, Vinod Koul,
>> 
>> 
>> Thanks very much for your review.
>> 
>> 
>> As the of_get_parent() will increase the refcount of the node->parent  and the reference will be discarded 
>> so we should hold the reference , with which we can decrease the refcount.
>
>Right, that is correct explanation
>> 
>> 
>> If there is any misunderstanding about the of_get_parent() API, please correct me.
>
>Nope, just that this explanation is missing from the log...
>
>Please add...
>
Thank you very much!
I will add it in new version.
>-- 
>~Vinod
-- 
linux-phy mailing list
linux-phy@lists.infradead.org
https://lists.infradead.org/mailman/listinfo/linux-phy

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

end of thread, other threads:[~2022-09-13 15:26 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-07-05  2:15 [PATCH] phy: amlogic: phy-meson-axg-mipi-pcie-analog: Hold reference returned by of_get_parent() Liang He
2022-07-05  7:21 ` Neil Armstrong
2022-07-25 19:41 ` Martin Blumenstingl
2022-09-02 15:41 ` Vinod Koul
2022-09-05  7:21   ` Liang He
2022-09-13 13:55     ` Vinod Koul
2022-09-13 15:15       ` Liang He

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