Skip to contentSkip to conversation

regulator: fix OF node imbalance on reuse

PATCH In review Johan Hovold 3 participants 7 messages Apr 7 – Apr 8

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

cover regulator: fix OF node imbalance on reuse

These drivers reuse the OF node of their parent multi-function device but fail to take another reference to balance the one dropped by the platform bus code when unbinding the MFD and deregistering the child devices.

Fix this by using the intended helper for reusing OF nodes.

Note that this may cause a trivial conflict with Doug's series adding accessor functions for struct device flags:

	https://lore.kernel.org/r/[email protected]

Johan

Johan Hovold (2):
regulator: bq257xx: fix OF node reference imbalance
regulator: rk808: fix OF node reference imbalance

 drivers/regulator/bq257xx-regulator.c | 3 +--
 drivers/regulator/rk808-regulator.c   | 3 +--
 2 files changed, 2 insertions(+), 4 deletions(-)
Signature · 1 line
2.52.0
#1 lore raw

PATCH 1/2 regulator: bq257xx: fix OF node reference imbalance

The driver reuses the OF node of the parent multi-function device but fails to take another reference to balance the one dropped by the platform bus code when unbinding the MFD and deregistering the child devices.

Fix this by using the intended helper for reusing OF nodes.

Fixes 981dd162b635 ("regulator: bq257xx: Add bq257xx boost regulator driver")
Cc Chris Morgan <[email protected]>
---
 drivers/regulator/bq257xx-regulator.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/regulator/bq257xx-regulator.c +1 -2
index dab8f1ab4450..711dbe045383 100644
@@ -142,8 +142,7 @@ static int bq257xx_regulator_probe(struct platform_device *pdev)
 	struct device_node *np = dev->of_node;
 	struct regulator_config cfg = {};
 
-	pdev->dev.of_node = pdev->dev.parent->of_node;
-	pdev->dev.of_node_reused = true;
+	device_set_of_node_from_dev(&pdev->dev, pdev->dev.parent);
 
 	pdata = devm_kzalloc(&pdev->dev, sizeof(struct bq257xx_reg_data), GFP_KERNEL);
 	if (!pdata)
Signature · 1 line
2.52.0
Reviewed-by on v1 1/2
#2 lore raw

Re: [PATCH 1/2] regulator: bq257xx: fix OF node reference imbalance

Hi,

Quoted 8 lines · Johan Hovold

The driver reuses the OF node of the parent multi-function device but fails to take another reference to balance the one dropped by the platform bus code when unbinding the MFD and deregistering the child devices.

Fix this by using the intended helper for reusing OF nodes.

Quoted 7 lines
Fixes 981dd162b635 ("regulator: bq257xx: Add bq257xx boost regulator driver")
Cc Chris Morgan <[email protected]>
---
 drivers/regulator/bq257xx-regulator.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
#3 lore raw

PATCH 2/2 regulator: rk808: fix OF node reference imbalance

In reply to Johan Hovold

The driver reuses the OF node of the parent multi-function device but fails to take another reference to balance the one dropped by the platform bus code when unbinding the MFD and deregistering the child devices.

Fix this by using the intended helper for reusing OF nodes.

Fixes 5111c931f36c ("regulator: rk808: cleanup parent device usage")
Cc Sebastian Reichel <[email protected]>
---
 drivers/regulator/rk808-regulator.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/regulator/rk808-regulator.c +1 -2
index e66408f23bb6..1e956153427e 100644
@@ -2114,8 +2114,7 @@ static int rk808_regulator_probe(struct platform_device *pdev)
 	struct regmap *regmap;
 	int ret, i, nregulators;
 
-	pdev->dev.of_node = pdev->dev.parent->of_node;
-	pdev->dev.of_node_reused = true;
+	device_set_of_node_from_dev(&pdev->dev, pdev->dev.parent);
 
 	regmap = dev_get_regmap(pdev->dev.parent, NULL);
 	if (!regmap)
Signature · 1 line
2.52.0
Reviewed-by on v1 2/2
#4 lore raw

Re: [PATCH 2/2] regulator: rk808: fix OF node reference imbalance

Hi,

Quoted 5 lines · Johan Hovold

The driver reuses the OF node of the parent multi-function device but fails to take another reference to balance the one dropped by the platform bus code when unbinding the MFD and deregistering the child devices.

Quoted 7 lines

Fix this by using the intended helper for reusing OF nodes.

Fixes 5111c931f36c ("regulator: rk808: cleanup parent device usage")
Cc Sebastian Reichel <[email protected]>

---

-- Sebastian

Quoted 20 lines
 drivers/regulator/rk808-regulator.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/regulator/rk808-regulator.c +1 -2
index e66408f23bb6..1e956153427e 100644
@@ -2114,8 +2114,7 @@ static int rk808_regulator_probe(struct platform_device *pdev)
 	struct regmap *regmap;
 	int ret, i, nregulators;
 
-	pdev->dev.of_node = pdev->dev.parent->of_node;
-	pdev->dev.of_node_reused = true;
+	device_set_of_node_from_dev(&pdev->dev, pdev->dev.parent);
 
 	regmap = dev_get_regmap(pdev->dev.parent, NULL);
 	if (!regmap)
Signature · 1 line
2.52.0
Reviewed-by on v1 2/2
#5 lore raw

Re: [PATCH 2/2] regulator: rk808: fix OF node reference imbalance

In reply to Johan Hovold

Hi,

Quoted 9 lines · Johan Hovold

The driver reuses the OF node of the parent multi-function device but fails to take another reference to balance the one dropped by the platform bus code when unbinding the MFD and deregistering the child devices.

Fix this by using the intended helper for reusing OF nodes.

Fixes 5111c931f36c ("regulator: rk808: cleanup parent device usage")

I don't think this is quite the right "Fixes". Even before that commit, the driver copied the parent's "of_node" and still set "of_node_reused".

The first place I see the parent's "of_node" being copied is actually commit 647e57351f8e ("regulator: rk808: reduce 'struct rk808' usage"). "of_node_reused" is first set in commit 1b9e86d445a0 ("regulator:
rk808: fix asynchronous probing"), but really that should have been set in the beginning anyway...

Other than that:

#6 lore raw

Re: [PATCH 2/2] regulator: rk808: fix OF node reference imbalance

Quoted 15 lines · Doug Anderson
Quoted 9 lines · Johan Hovold

The driver reuses the OF node of the parent multi-function device but fails to take another reference to balance the one dropped by the platform bus code when unbinding the MFD and deregistering the child devices.

Fix this by using the intended helper for reusing OF nodes.

Fixes 5111c931f36c ("regulator: rk808: cleanup parent device usage")

I don't think this is quite the right "Fixes". Even before that commit, the driver copied the parent's "of_node" and still set "of_node_reused".

Quoted 5 lines

The first place I see the parent's "of_node" being copied is actually commit 647e57351f8e ("regulator: rk808: reduce 'struct rk808' usage"). "of_node_reused" is first set in commit 1b9e86d445a0 ("regulator:
rk808: fix asynchronous probing"), but really that should have been set in the beginning anyway...

Indeed, thanks for catching that. I've just sent a v2 of the series with the correct tag and that includes all of the regulator fixes that unfortunately ended up being being spread over three series.

Johan