MLK-13793-1 cpufreq: imx6q: Return regulator error in probe
authorIrina Tirdea <irina.tirdea@nxp.com>
Thu, 2 Feb 2017 13:24:59 +0000 (15:24 +0200)
committerNitin Garg <nitin.garg@nxp.com>
Mon, 19 Mar 2018 19:58:08 +0000 (14:58 -0500)
If there are any errors in getting the cpu0 regulators, the driver returns
-ENOENT. In case the regulators are not yet available, the devm_regulator_get
calls will return -EPROBE_DEFER, so that the driver can be probed later.
If we return -ENOENT, the driver will fail its initialization and will
not try to probe again (when the regulators become available).

Return the actual error received from regulator_get in probe. Print a
differentiated message in case we need to probe the device later and
in case we actually failed. Also add a message to inform when the
driver has been successfully registered.

Signed-off-by: Irina Tirdea <irina.tirdea@nxp.com>
drivers/cpufreq/imx6q-cpufreq.c

index 3c2a30f..006e6e2 100644 (file)
@@ -359,8 +359,11 @@ static int imx6q_cpufreq_probe(struct platform_device *pdev)
        pu_reg = devm_regulator_get_optional(cpu_dev, "pu");
        soc_reg = devm_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;
+               ret = IS_ERR(arm_reg)?PTR_ERR(arm_reg):PTR_ERR(soc_reg);
+               if (ret == -EPROBE_DEFER)
+                       dev_warn(cpu_dev, "regulators not ready, retry\n");
+               else
+                       dev_err(cpu_dev, "failed to get regulators: %d\n", ret);
                goto put_node;
        }
 
@@ -517,6 +520,7 @@ soc_opp_out:
        register_pm_notifier(&imx6_cpufreq_pm_notifier);
 
        of_node_put(np);
+       dev_info(cpu_dev, "Registered imx6q-cpufreq\n");
        return 0;
 
 free_freq_table: