OPP: ti: Fix ti_opp_supply_probe wrong return values
PATCH 1/1 OPP: ti: Fix ti_opp_supply_probe wrong return values
Function ti_opp_supply_probe() since commit 6baee034cb55 ("OPP: ti:
Migrate to dev_pm_opp_set_config_regulators()") returns wrong values when all goes well and hence driver probing eventually fails.
--- drivers/opp/ti-opp-supply.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/opp/ti-opp-supply.c +4 -2
@@ -393,10 +393,12 @@ static int ti_opp_supply_probe(struct platform_device *pdev) } ret =dev_pm_opp_set_config_regulators (cpu_dev, ti_opp_config_regulators); -if (ret <0 ) +if (ret <0 ) {_free_optimized_voltages (dev, &opp_data); +return ret; + } -return ret; +return 0 ; }static struct platform_driver ti_opp_supply_driver = {
Signature · 1 line
2.25.1
Quoted 19 lines · Primoz Fiser
Function
ti_opp_supply_probe()since commit6baee034cb55("OPP: ti:
Migrate todev_pm_opp_set_config_regulators()") returns wrong values when all goes well and hence driver probing eventually fails.Fixes 6baee034cb55 ("OPP: ti: Migrate to dev_pm_opp_set_config_regulators()")Signed-off-by Primoz Fiser <[email protected]>--- drivers/opp/ti-opp-supply.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)drivers/opp/ti-opp-supply.c +0
-1@@ -393,10 +393,12 @@ static int ti_opp_supply_probe(struct platform_device *pdev) } ret =dev_pm_opp_set_config_regulators (cpu_dev, ti_opp_config_regulators); -if (ret <0 )
drivers/opp/ti-opp-supply.c static int ti_opp_supply_probe(struct platform_device *pdev) · line 404
Quoted 10 lines
drivers/opp/ti-opp-supply.c +4
-1+if (ret <0 ) {_free_optimized_voltages (dev, &opp_data); +return ret; + } -return ret; +return 0 ; }static struct platform_driver ti_opp_supply_driver = {
Not sure I understand the problem here. Can you please explain with an example ?
Signature · 1 line
viresh
Hi Viresh,
Quoted 25 lines · Viresh Kumar
Quoted 24 lines · Primoz Fiser
Function
ti_opp_supply_probe()since commit6baee034cb55("OPP: ti:
Migrate todev_pm_opp_set_config_regulators()") returns wrong values when all goes well and hence driver probing eventually fails.Fixes 6baee034cb55 ("OPP: ti: Migrate to dev_pm_opp_set_config_regulators()")Signed-off-by Primoz Fiser <[email protected]>--- drivers/opp/ti-opp-supply.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)drivers/opp/ti-opp-supply.c +3
-1@@ -393,10 +393,12 @@ static int ti_opp_supply_probe(struct platform_device *pdev) } ret =dev_pm_opp_set_config_regulators (cpu_dev, ti_opp_config_regulators); -if (ret <0 ) +if (ret <0 ) {_free_optimized_voltages (dev, &opp_data); +return ret; + }
Quoted 8 lines
drivers/opp/ti-opp-supply.c static int ti_opp_supply_probe(struct platform_device *pdev) · line 404
Quoted 5 lines
drivers/opp/ti-opp-supply.c +1
-1-return ret; +return 0 ; }static struct platform_driver ti_opp_supply_driver = {Not sure I understand the problem here. Can you please explain with an example ?
ti_opp_supply_probe
-> dev_pm_opp_set_config_regulators
-> dev_pm_opp_set_config (returns negative if error, otherwise >= 1)
Lets assume dev_pm_opp_set_config returns 1 (SUCCESS):
so now, without my patch:ti_opp_supply_probe returns 1 -> FAILURE and hence error:
ti_opp_supply 4a003b20.opp-supply: probe with driver ti_opp_supply failed with error 1
with my patch:ti_opp_supply_probe returns 0 -> SUCCESS
BR,
Primoz
Quoted 3 lines · Primoz Fiser
ti_opp_supply_probe
->dev_pm_opp_set_config_regulators
->dev_pm_opp_set_config(returns negative if error, otherwise >= 1)
Ah, I forgot about the token that is returned here. I think the driver should be fixed properly once and for all here.
The token must be used to clean the module removal part. Else if you try to insert this module, remove it, insert again, you will get some errors as the resources aren't cleaned well.
So either provide a remove() callback to the driver, or use devm_pm_opp_set_config() here.
Signature · 1 line
viresh
Hi Viresh,
Quoted 8 lines · Viresh Kumar
Quoted 3 lines · Primoz Fiser
ti_opp_supply_probe
->dev_pm_opp_set_config_regulators
->dev_pm_opp_set_config(returns negative if error, otherwise >= 1)Ah, I forgot about the token that is returned here. I think the driver should be fixed properly once and for all here.
Quoted 7 lines
The token must be used to clean the module removal part. Else if you try to insert this module, remove it, insert again, you will get some errors as the resources aren't cleaned well.
So either provide a
remove()callback to the driver, or usedevm_pm_opp_set_config()here.
So basically, you want v2 with:
Quoted 24 lines
drivers/opp/ti-opp-supply.c +1
-1@@ -392,7 +392,7 @@ static int ti_opp_supply_probe(struct platform_device *pdev)return ret; } - ret =dev_pm_opp_set_config_regulators (cpu_dev, ti_opp_config_regulators); + ret =devm_pm_opp_set_config_regulators (cpu_dev, ti_opp_config_regulators);if (ret <0 )_free_optimized_voltages (dev, &opp_data);include/linux/pm_opp.h +1
-1@@ -654,14 +654,14 @@ static inline int devm_pm_opp_set_clkname(struct device *dev, const char *name) }/* config-regulators helpers */ -static inline int dev_pm_opp_set_config_regulators (struct device *dev, +static inline int devm_pm_opp_set_config_regulators (struct device *dev,config_regulators_t helper)
include/linux/pm_opp.h static inline int devm_pm_opp_set_clkname(struct device *dev, const char *name) · line 667
Quoted 10 lines
include/linux/pm_opp.h +1
-1{struct dev_pm_opp_config config = { .config_regulators = helper, }; -return dev_pm_opp_set_config (dev, &config); +return devm_pm_opp_set_config (dev, &config); }static inline void dev_pm_opp_put_config_regulators (int token)
Right?
BR,
Primoz
Quoted 33 lines · Primoz Fiser
Quoted 10 lines
Ah, I forgot about the token that is returned here. I think the driver should be fixed properly once and for all here.
The token must be used to clean the module removal part. Else if you try to insert this module, remove it, insert again, you will get some errors as the resources aren't cleaned well.
So either provide a
remove()callback to the driver, or usedevm_pm_opp_set_config()here.So basically, you want v2 with:
Quoted 20 lines
drivers/opp/ti-opp-supply.c +1
-1@@ -392,7 +392,7 @@ static int ti_opp_supply_probe(struct platform_device *pdev)return ret; } - ret =dev_pm_opp_set_config_regulators (cpu_dev, ti_opp_config_regulators); + ret =devm_pm_opp_set_config_regulators (cpu_dev, ti_opp_config_regulators);if (ret <0 )_free_optimized_voltages (dev, &opp_data);include/linux/pm_opp.h +0
-0@@ -654,14 +654,14 @@ static inline int devm_pm_opp_set_clkname(struct device *dev, const char *name) }
Quoted 2 lines
include/linux/pm_opp.h static inline int devm_pm_opp_set_clkname(struct device *dev, const char *name) · line 657
Quoted 2 lines
include/linux/pm_opp.h +0
-1/* config-regulators helpers */ -static inline int dev_pm_opp_set_config_regulators(struct device *dev,
Don't remove this, add a new devm_ counterpart.
Quoted 10 lines
Quoted 10 lines
include/linux/pm_opp.h +2
-1+static inline int devm_pm_opp_set_config_regulators (struct device *dev,config_regulators_t helper) {struct dev_pm_opp_config config = { .config_regulators = helper, }; -return dev_pm_opp_set_config (dev, &config); +return devm_pm_opp_set_config (dev, &config); }
Signature · 1 line
viresh
Hi,
sent new series instead of v2.
Link:
https://lore.kernel.org/linux-pm/[email protected]/
BR,
Primoz
Quoted 50 lines · Viresh Kumar
Quoted 33 lines · Primoz Fiser
Quoted 10 lines
Ah, I forgot about the token that is returned here. I think the driver should be fixed properly once and for all here.
The token must be used to clean the module removal part. Else if you try to insert this module, remove it, insert again, you will get some errors as the resources aren't cleaned well.
So either provide a
remove()callback to the driver, or usedevm_pm_opp_set_config()here.So basically, you want v2 with:
Quoted 20 lines
drivers/opp/ti-opp-supply.c +1
-1@@ -392,7 +392,7 @@ static int ti_opp_supply_probe(struct platform_device *pdev)return ret; } - ret =dev_pm_opp_set_config_regulators (cpu_dev, ti_opp_config_regulators); + ret =devm_pm_opp_set_config_regulators (cpu_dev, ti_opp_config_regulators);if (ret <0 )_free_optimized_voltages (dev, &opp_data);include/linux/pm_opp.h +0
-0@@ -654,14 +654,14 @@ static inline int devm_pm_opp_set_clkname(struct device *dev, const char *name) }Quoted 2 lines
include/linux/pm_opp.h static inline int devm_pm_opp_set_clkname(struct device *dev, const char *name) · line 657
Quoted 2 lines
include/linux/pm_opp.h +0
-1/* config-regulators helpers */ -static inline int dev_pm_opp_set_config_regulators(struct device *dev,Don't remove this, add a new
devm_counterpart.Quoted 10 lines
Quoted 10 lines
include/linux/pm_opp.h +2
-1+static inline int devm_pm_opp_set_config_regulators (struct device *dev,config_regulators_t helper) {struct dev_pm_opp_config config = { .config_regulators = helper, }; -return dev_pm_opp_set_config (dev, &config); +return devm_pm_opp_set_config (dev, &config); }
Signature · 9 lines
Primoz Fiser | phone: +386-41-390-545 <tel:+386-41-390-545> | ---------------------------------------------------------| Norik systems d.o.o. | https://www.norik.com <https://www.norik.com> | Your embedded software partner | email: [email protected] <mailto:[email protected]> | Slovenia, EU | phone: +386-41-540-545 <tel:+386-41-540-545> |
Viresh Kumar
AppliedQuoted 17 lines · Primoz Fiser
Function
ti_opp_supply_probe()since commit6baee034cb55("OPP: ti:
Migrate todev_pm_opp_set_config_regulators()") returns wrong values when all goes well and hence driver probing eventually fails.Fixes 6baee034cb55 ("OPP: ti: Migrate to dev_pm_opp_set_config_regulators()")Signed-off-by Primoz Fiser <[email protected]>--- drivers/opp/ti-opp-supply.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)drivers/opp/ti-opp-supply.c +0
-0@@ -393,10 +393,12 @@ static int ti_opp_supply_probe(struct platform_device *pdev) }
drivers/opp/ti-opp-supply.c static int ti_opp_supply_probe(struct platform_device *pdev) · line 402
Quoted 10 lines
drivers/opp/ti-opp-supply.c +4
-2ret =dev_pm_opp_set_config_regulators (cpu_dev, ti_opp_config_regulators); -if (ret <0 ) +if (ret <0 ) {_free_optimized_voltages (dev, &opp_data); +return ret; + } -return ret; +return 0 ; }
Applied. Thanks.
Signature · 1 line
viresh