diff mbox

[1/2] cpufreq: imx: fix regulator_get error handling

Message ID 56237C1C.80109@gmail.com (mailing list archive)
State Changes Requested, archived
Headers show

Commit Message

Heiner Kallweit Oct. 18, 2015, 11:01 a.m. UTC
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.

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
---
 drivers/cpufreq/imx6q-cpufreq.c | 15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)

Comments

Viresh Kumar Oct. 18, 2015, 3:55 p.m. UTC | #1
On 18-10-15, 13:01, Heiner Kallweit wrote:
>  	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?

> +	}
> +
>  	pu_reg = regulator_get_optional(cpu_dev, "pu");

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

> +
>  	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;
>  	}
>  
> -- 
> 2.6.1
Heiner Kallweit Oct. 18, 2015, 4:40 p.m. UTC | #2
Am 18.10.2015 um 17:55 schrieb Viresh Kumar:
> On 18-10-15, 13:01, Heiner Kallweit wrote:
>>  	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.

>> +	}
>> +
>>  	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.

>> +
>>  	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;
>>  	}
>>  
>> -- 
>> 2.6.1
> 

--
To unsubscribe from this list: send the line "unsubscribe linux-pm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Viresh Kumar Oct. 18, 2015, 4:46 p.m. UTC | #3
On 18-10-15, 13:01, Heiner Kallweit wrote:
> 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.
> 
> Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
> ---
>  drivers/cpufreq/imx6q-cpufreq.c | 15 ++++++++++++---
>  1 file changed, 12 insertions(+), 3 deletions(-)

For both patches.

Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
diff mbox

Patch

diff --git a/drivers/cpufreq/imx6q-cpufreq.c b/drivers/cpufreq/imx6q-cpufreq.c
index 380a90d..0bb33dc 100644
--- a/drivers/cpufreq/imx6q-cpufreq.c
+++ b/drivers/cpufreq/imx6q-cpufreq.c
@@ -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;
 	}