Skip to contentSkip to conversation

cpufreq: imx: fix regulator_get error handling

PATCH In review Heiner Kallweit 2 participants 4 messages Oct 18, 2015

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

PATCH 1/2 cpufreq: imx: fix regulator_get error handling

With CONFIG_DELAY_DEVICE_PROBES being set I get the following error:

cpu cpu0: failed to get regulators
imx6q-cpufreq: probe of imx6q-cpufreq.0 failed with error -2

Fix the error handling of regulator_get to properly deal with -EPROBE_DEFER.

---
 drivers/cpufreq/imx6q-cpufreq.c | 15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)
drivers/cpufreq/imx6q-cpufreq.c +12 -3
index 380a90d..0bb33dc 100644
@@ -187,11 +187,20 @@ static int imx6q_cpufreq_probe(struct platform_device *pdev)
 	}
 
 	arm_reg = regulator_get(cpu_dev, "arm");
+	if (IS_ERR(arm_reg)) {
+		ret = PTR_ERR(arm_reg);
+		if (ret != -EPROBE_DEFER)
+			dev_err(cpu_dev, "failed to get regulator arm\n");
+		goto put_reg;
+	}
+
 	pu_reg = regulator_get_optional(cpu_dev, "pu");
+
 	soc_reg = regulator_get(cpu_dev, "soc");
-	if (IS_ERR(arm_reg) || IS_ERR(soc_reg)) {
-		dev_err(cpu_dev, "failed to get regulators\n");
-		ret = -ENOENT;
+	if (IS_ERR(soc_reg)) {
+		ret = PTR_ERR(soc_reg);
+		if (ret != -EPROBE_DEFER)
+			dev_err(cpu_dev, "failed to get regulator soc\n");
 		goto put_reg;
 	}
 
Signature · 1 line
2.6.1
maintainer
#1 lore raw

drivers/cpufreq/imx6q-cpufreq.c static int imx6q_cpufreq_probe(struct platform_device *pdev) · line 194

Quoted 6 lines · Heiner Kallweit
drivers/cpufreq/imx6q-cpufreq.c +5 -0
 	arm_reg = regulator_get(cpu_dev, "arm");
+	if (IS_ERR(arm_reg)) {
+		ret = PTR_ERR(arm_reg);
+		if (ret != -EPROBE_DEFER)
+			dev_err(cpu_dev, "failed to get regulator arm\n");
+		goto put_reg;

So you will error out even for other errors, but that wasn't the case earlier. Are you sure this is what you want?

drivers/cpufreq/imx6q-cpufreq.c static int imx6q_cpufreq_probe(struct platform_device *pdev) · line 197

Quoted 3 lines
drivers/cpufreq/imx6q-cpufreq.c +2 -0
+	}
+
 	pu_reg = regulator_get_optional(cpu_dev, "pu");

Why don't we do error checking for this as well ?

Quoted 14 lines
drivers/cpufreq/imx6q-cpufreq.c +5 -3
+
 	soc_reg = regulator_get(cpu_dev, "soc");
-	if (IS_ERR(arm_reg) || IS_ERR(soc_reg)) {
-		dev_err(cpu_dev, "failed to get regulators\n");
-		ret = -ENOENT;
+	if (IS_ERR(soc_reg)) {
+		ret = PTR_ERR(soc_reg);
+		if (ret != -EPROBE_DEFER)
+			dev_err(cpu_dev, "failed to get regulator soc\n");
 		goto put_reg;
 	}
Signature · 2 lines
-- 
2.6.1
Signature · 1 line
viresh
#2 lore raw

Am 18.10.2015 um 17:55 schrieb Viresh Kumar:

Quoted 11 lines · Heiner Kallweit

drivers/cpufreq/imx6q-cpufreq.c static int imx6q_cpufreq_probe(struct platform_device *pdev) · line 194

Quoted 6 lines
drivers/cpufreq/imx6q-cpufreq.c +5 -0
 	arm_reg = regulator_get(cpu_dev, "arm");
+	if (IS_ERR(arm_reg)) {
+		ret = PTR_ERR(arm_reg);
+		if (ret != -EPROBE_DEFER)
+			dev_err(cpu_dev, "failed to get regulator arm\n");
+		goto put_reg;

So you will error out even for other errors, but that wasn't the case earlier. Are you sure this is what you want?

This was the case before as well (just the error handling for arm-reg and soc_reg was combined).
The only difference is that before all errors were mapped to -ENOENT and now the actual error code is forwarded.

Quoted 6 lines

drivers/cpufreq/imx6q-cpufreq.c static int imx6q_cpufreq_probe(struct platform_device *pdev) · line 197

Quoted 3 lines
drivers/cpufreq/imx6q-cpufreq.c +2 -0
+	}
+
 	pu_reg = regulator_get_optional(cpu_dev, "pu");

Why don't we do error checking for this as well ?

Please see patch 2/2. I separated it because it doeas a little bit more than handling -EPROBE_DEFER.

Quoted 15 lines
Quoted 14 lines
drivers/cpufreq/imx6q-cpufreq.c +5 -3
+
 	soc_reg = regulator_get(cpu_dev, "soc");
-	if (IS_ERR(arm_reg) || IS_ERR(soc_reg)) {
-		dev_err(cpu_dev, "failed to get regulators\n");
-		ret = -ENOENT;
+	if (IS_ERR(soc_reg)) {
+		ret = PTR_ERR(soc_reg);
+		if (ret != -EPROBE_DEFER)
+			dev_err(cpu_dev, "failed to get regulator soc\n");
 		goto put_reg;
 	}
Signature · 2 lines
-- 
2.6.1
maintainer Acked-by on v1 1/2
#3 lore raw
In reply to Heiner Kallweit
Quoted 5 lines · Heiner Kallweit

With CONFIG_DELAY_DEVICE_PROBES being set I get the following error:

cpu cpu0: failed to get regulators
imx6q-cpufreq: probe of imx6q-cpufreq.0 failed with error -2

Quoted 7 lines

Fix the error handling of regulator_get to properly deal with -EPROBE_DEFER.

---
 drivers/cpufreq/imx6q-cpufreq.c | 15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)

For both patches.

Signature · 1 line
viresh