Skip to contentSkip to conversation

phy: amlogic: phy-meson-axg-mipi-pcie-analog: Hold reference returned by of_get_parent()

PATCH Superseded Liang He 4 participants 7 messages Jul 5, 2022 – Sep 13, 2022

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Liang He

author
#0 lore raw

PATCH 1/1 phy: amlogic: phy-meson-axg-mipi-pcie-analog: Hold reference returned by of_get_parent()

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")
---
 drivers/phy/amlogic/phy-meson-axg-mipi-pcie-analog.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/phy/amlogic/phy-meson-axg-mipi-pcie-analog.c +4 -2
index 1027ece6ca12..a3e1108b736d 100644
@@ -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");
Signature · 7 lines
2.25.1


-- 
linux-phy mailing list
[email protected]
https://lists.infradead.org/mailman/listinfo/linux-phy
#1 lore raw

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

Quoted 33 lines · Liang He

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")
---
  drivers/phy/amlogic/phy-meson-axg-mipi-pcie-analog.c | 6 ++++--
  1 file changed, 4 insertions(+), 2 deletions(-)
drivers/phy/amlogic/phy-meson-axg-mipi-pcie-analog.c +4 -2
index 1027ece6ca12..a3e1108b736d 100644
@@ -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");
Signature · 3 lines
linux-phy mailing list
[email protected]
https://lists.infradead.org/mailman/listinfo/linux-phy
reviewer Acked-by on v1 1/1
#2 lore raw
In reply to Liang He
Quoted 6 lines · Liang He

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")
Signature · 3 lines
linux-phy mailing list
[email protected]
https://lists.infradead.org/mailman/listinfo/linux-phy
maintainer
#3 lore raw
In reply to Liang He
Quoted 2 lines · Liang He

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?

Quoted 39 lines
Fixes 8eff8b4e22d9 ("phy: amlogic: phy-meson-axg-mipi-pcie-analog: add support for MIPI DSI analog")
---
 drivers/phy/amlogic/phy-meson-axg-mipi-pcie-analog.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/phy/amlogic/phy-meson-axg-mipi-pcie-analog.c +4 -2
index 1027ece6ca12..a3e1108b736d 100644
@@ -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");
Signature · 7 lines
2.25.1


-- 
linux-phy mailing list
[email protected]
https://lists.infradead.org/mailman/listinfo/linux-phy
Signature · 6 lines
~Vinod

-- 
linux-phy mailing list
[email protected]
https://lists.infradead.org/mailman/listinfo/linux-phy
author
#4 lore raw
Quoted 7 lines · Vinod Koul
Quoted 2 lines · Liang He

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

Quoted 42 lines
Quoted 39 lines
Fixes 8eff8b4e22d9 ("phy: amlogic: phy-meson-axg-mipi-pcie-analog: add support for MIPI DSI analog")
---
 drivers/phy/amlogic/phy-meson-axg-mipi-pcie-analog.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/phy/amlogic/phy-meson-axg-mipi-pcie-analog.c +4 -2
index 1027ece6ca12..a3e1108b736d 100644
@@ -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");
Signature · 7 lines
2.25.1


-- 
linux-phy mailing list
[email protected]
https://lists.infradead.org/mailman/listinfo/linux-phy
Signature · 1 line
~Vinod
Signature · 3 lines
linux-phy mailing list
[email protected]
https://lists.infradead.org/mailman/listinfo/linux-phy
maintainer
#5 lore raw
Quoted 11 lines · Liang He
Quoted 7 lines · Vinod Koul
Quoted 2 lines · Liang He

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?

Quoted 8 lines

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

Quoted 3 lines

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

Signature · 6 lines
~Vinod

-- 
linux-phy mailing list
[email protected]
https://lists.infradead.org/mailman/listinfo/linux-phy
author
#6 lore raw
Quoted 21 lines · Vinod Koul
Quoted 11 lines · Liang He
Quoted 7 lines · Vinod Koul
Quoted 2 lines · Liang He

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?

Quoted 8 lines

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.

Quoted 9 lines

Right, that is correct explanation

Quoted 3 lines

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.

Quoted 2 lines
Signature · 1 line
~Vinod
Signature · 3 lines
linux-phy mailing list
[email protected]
https://lists.infradead.org/mailman/listinfo/linux-phy