regulator: max14577: Fix invalid return value on DT parse success
Subsystems (2)
PATCH 1/1 regulator: max14577: Fix invalid return value on DT parse success
This fixes bug introduced in 667a6b7a (regulator: max14577: Add missing of_node_put). The DTS parsing function returned number of matched regulators as success status which then was compared against 0 in probe.
Result was a probe fail after successful parsing the DTS:
max14577-regulator: probe of max14577-regulator failed with error 2
--- drivers/regulator/max14577.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/regulator/max14577.c +3 -1
@@ -168,11 +168,13 @@ static int max14577_regulator_dt_parse_pdata(struct platform_device *pdev) MAX14577_REG_MAX);if (ret <0 ) {dev_err (&pdev->dev,"Error parsing regulator init data: %d\n" , ret); +of_node_put (np); +return ret; }of_node_put (np); -return ret; +return 0 ; }static inline struct regulator_init_data *match_init_data (int index)
Signature · 1 line
1.7.9.5
Hi Krzysztof,
Quoted 19 lines · Krzysztof Kozlowski
This fixes bug introduced in
667a6b7a(regulator: max14577: Add missingof_node_put). The DTS parsing function returned number of matched regulators as success status which then was compared against 0 in probe.Result was a probe fail after successful parsing the DTS:
max14577-regulator: probe of max14577-regulator failed with error 2Signed-off-by Krzysztof Kozlowski <[email protected]>--- drivers/regulator/max14577.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)drivers/regulator/max14577.c +0
-0@@ -168,11 +168,13 @@ static int max14577_regulator_dt_parse_pdata(struct platform_device *pdev) MAX14577_REG_MAX);if (ret <0 ) {
drivers/regulator/max14577.c static int max14577_regulator_dt_parse_pdata(struct platform_device *pdev) · line 178
Quoted 10 lines
drivers/regulator/max14577.c +3
-1dev_err (&pdev->dev,"Error parsing regulator init data: %d\n" , ret); +of_node_put (np); +return ret; }of_node_put (np); -return ret; +return 0 ; }
Instead of so many changes here, you could simply make the following change in the max14577_regulator_probe function.
ret = max14577_regulator_dt_parse_pdata(pdev);
if (ret < 0)
return ret;
Signature · 2 lines
With warm regards, Sachin
Quoted 36 lines · Sachin Kamat
Hi Krzysztof,
Quoted 19 lines · Krzysztof Kozlowski
This fixes bug introduced in
667a6b7a(regulator: max14577: Add missingof_node_put). The DTS parsing function returned number of matched regulators as success status which then was compared against 0 in probe.Result was a probe fail after successful parsing the DTS:
max14577-regulator: probe of max14577-regulator failed with error 2Signed-off-by Krzysztof Kozlowski <[email protected]>--- drivers/regulator/max14577.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)drivers/regulator/max14577.c +0
-0@@ -168,11 +168,13 @@ static int max14577_regulator_dt_parse_pdata(struct platform_device *pdev) MAX14577_REG_MAX);if (ret <0 ) {drivers/regulator/max14577.c static int max14577_regulator_dt_parse_pdata(struct platform_device *pdev) · line 178
Quoted 10 lines
drivers/regulator/max14577.c +3
-1dev_err (&pdev->dev,"Error parsing regulator init data: %d\n" , ret); +of_node_put (np); +return ret; }of_node_put (np); -return ret; +return 0 ; }Instead of so many changes here, you could simply make the following change in the
max14577_regulator_probefunction.
Quoted 3 lines
ret =
max14577_regulator_dt_parse_pdata(pdev);
if (ret < 0)return ret;
That still wouldn't be sufficient because later in probe() the 'ret' is not reassigned (if devm_regulator_register succeeds) and it is directly returned at the probe() end. So still the number of matched regulators would be returned as probe result.
Best regards,
Krzysztof
Quoted 37 lines · Krzysztof Kozlowski
Quoted 36 lines · Sachin Kamat
Hi Krzysztof,
Quoted 19 lines · Krzysztof Kozlowski
This fixes bug introduced in
667a6b7a(regulator: max14577: Add missingof_node_put). The DTS parsing function returned number of matched regulators as success status which then was compared against 0 in probe.Result was a probe fail after successful parsing the DTS:
max14577-regulator: probe of max14577-regulator failed with error 2Signed-off-by Krzysztof Kozlowski <[email protected]>--- drivers/regulator/max14577.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)drivers/regulator/max14577.c +0
-0@@ -168,11 +168,13 @@ static int max14577_regulator_dt_parse_pdata(struct platform_device *pdev) MAX14577_REG_MAX);if (ret <0 ) {drivers/regulator/max14577.c static int max14577_regulator_dt_parse_pdata(struct platform_device *pdev) · line 178
Quoted 10 lines
drivers/regulator/max14577.c +3
-1dev_err (&pdev->dev,"Error parsing regulator init data: %d\n" , ret); +of_node_put (np); +return ret; }of_node_put (np); -return ret; +return 0 ; }Instead of so many changes here, you could simply make the following change in the
max14577_regulator_probefunction.
Quoted 8 lines
Quoted 3 lines
ret =
max14577_regulator_dt_parse_pdata(pdev);
if (ret < 0)return ret;That still wouldn't be sufficient because later in
probe()the 'ret' is not reassigned (ifdevm_regulator_registersucceeds) and it is directly returned at theprobe()end. So still the number of matched regulators would be returned as probe result.
Ah, you are right. In that case how about the following:
- if (ret < 0) {
+ if (ret < 0)
dev_err(&pdev->dev, "Error parsing regulator init data: %d\n", ret);
- }
+ else
+ ret = 0;
I am just trying to see if we can avoid any code duplication.
Signature · 2 lines
With warm regards, Sachin
Quoted 56 lines · Sachin Kamat
Quoted 37 lines · Krzysztof Kozlowski
Quoted 36 lines · Sachin Kamat
Hi Krzysztof,
Quoted 19 lines · Krzysztof Kozlowski
This fixes bug introduced in
667a6b7a(regulator: max14577: Add missingof_node_put). The DTS parsing function returned number of matched regulators as success status which then was compared against 0 in probe.Result was a probe fail after successful parsing the DTS:
max14577-regulator: probe of max14577-regulator failed with error 2Signed-off-by Krzysztof Kozlowski <[email protected]>--- drivers/regulator/max14577.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)drivers/regulator/max14577.c +0
-0@@ -168,11 +168,13 @@ static int max14577_regulator_dt_parse_pdata(struct platform_device *pdev) MAX14577_REG_MAX);if (ret <0 ) {drivers/regulator/max14577.c static int max14577_regulator_dt_parse_pdata(struct platform_device *pdev) · line 178
Quoted 10 lines
drivers/regulator/max14577.c +3
-1dev_err (&pdev->dev,"Error parsing regulator init data: %d\n" , ret); +of_node_put (np); +return ret; }of_node_put (np); -return ret; +return 0 ; }Instead of so many changes here, you could simply make the following change in the
max14577_regulator_probefunction.Quoted 8 lines
Quoted 3 lines
ret =
max14577_regulator_dt_parse_pdata(pdev);
if (ret < 0)return ret;That still wouldn't be sufficient because later in
probe()the 'ret' is not reassigned (ifdevm_regulator_registersucceeds) and it is directly returned at theprobe()end. So still the number of matched regulators would be returned as probe result.Ah, you are right. In that case how about the following:
(quoted diff) +3
-2- if (ret < 0) { + if (ret < 0) dev_err(&pdev->dev, "Error parsing regulator init data: %d\n", ret); - } + else + ret = 0;
Quoted 1 line
I am just trying to see if we can avoid any code duplication.
Looks good. Thanks for idea, I'll send v2.
Best regards,
Krzysztof