regulator: fix OF node imbalance on reuse
Subsystems (2)
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
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.
--- drivers/regulator/bq257xx-regulator.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/regulator/bq257xx-regulator.c +1 -2
@@ -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
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 [email protected] # 6.18Cc Chris Morgan <[email protected]>Signed-off-by Johan Hovold <[email protected]>--- drivers/regulator/bq257xx-regulator.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
PATCH 2/2 regulator: rk808: fix OF node reference imbalance
In reply to Johan HovoldThe 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.
--- drivers/regulator/rk808-regulator.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/regulator/rk808-regulator.c +1 -2
@@ -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
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 [email protected] # 6.5Cc Sebastian Reichel <[email protected]>Signed-off-by Johan Hovold <[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@@ -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
Re: [PATCH 2/2] regulator: rk808: fix OF node reference imbalance
In reply to Johan HovoldHi,
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:
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 commit647e57351f8e("regulator: rk808: reduce 'struct rk808' usage"). "of_node_reused" is first set in commit1b9e86d445a0("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