linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Paweł Chmiel" <pawel.mikolaj.chmiel@gmail.com>
To: kgene@kernel.org
Cc: krzk@kernel.org, robh+dt@kernel.org, mark.rutland@arm.com,
	linux@armlinux.org.uk, viresh.kumar@linaro.org,
	rjw@rjwysocki.net, linux-arm-kernel@lists.infradead.org,
	linux-samsung-soc@vger.kernel.org, devicetree@vger.kernel.org,
	linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org,
	"Paweł Chmiel" <pawel.mikolaj.chmiel@gmail.com>
Subject: [PATCH v2 3/4] cpufreq: s5pv210: Defer probe if getting regulators fail
Date: Thu, 10 Jan 2019 21:52:14 +0100	[thread overview]
Message-ID: <20190110205215.22030-4-pawel.mikolaj.chmiel@gmail.com> (raw)
In-Reply-To: <20190110205215.22030-1-pawel.mikolaj.chmiel@gmail.com>

There is possibility, that when probing driver, regulators are not yet
initialized. In this case we should return EPROBE_DEFER and wait till
they're initialized, since they're required currently for cpufreq driver
to work. Also move regulator initialization code at beginning of probe,
so we can defer as fast as posibble.

Signed-off-by: Paweł Chmiel <pawel.mikolaj.chmiel@gmail.com>
---
Changes from v1:
  - Fix compilation error
  - Reorganize code so it's smaller
---
 drivers/cpufreq/s5pv210-cpufreq.c | 32 ++++++++++++++++++-------------
 1 file changed, 19 insertions(+), 13 deletions(-)

diff --git a/drivers/cpufreq/s5pv210-cpufreq.c b/drivers/cpufreq/s5pv210-cpufreq.c
index f51697f1e0b3..6df95941ba96 100644
--- a/drivers/cpufreq/s5pv210-cpufreq.c
+++ b/drivers/cpufreq/s5pv210-cpufreq.c
@@ -594,6 +594,25 @@ static int s5pv210_cpufreq_probe(struct platform_device *pdev)
 	 * this whole driver as soon as S5PV210 gets migrated to use
 	 * cpufreq-dt driver.
 	 */
+	arm_regulator = regulator_get(NULL, "vddarm");
+	if (IS_ERR(arm_regulator)) {
+		if (PTR_ERR(arm_regulator) == -EPROBE_DEFER)
+			pr_debug("vddarm regulator not ready, defer\n");
+		else
+			pr_err("failed to get regulator vddarm\n");
+		return PTR_ERR(arm_regulator);
+	}
+
+	int_regulator = regulator_get(NULL, "vddint");
+	if (IS_ERR(int_regulator)) {
+		if (PTR_ERR(int_regulator) == -EPROBE_DEFER)
+			pr_debug("vddint regulator not ready, defer\n");
+		else
+			pr_err("failed to get regulator vddint\n");
+		regulator_put(arm_regulator);
+		return PTR_ERR(int_regulator);
+	}
+
 	np = of_find_compatible_node(NULL, NULL, "samsung,s5pv210-clock");
 	if (!np) {
 		pr_err("%s: failed to find clock controller DT node\n",
@@ -633,19 +652,6 @@ static int s5pv210_cpufreq_probe(struct platform_device *pdev)
 		}
 	}
 
-	arm_regulator = regulator_get(NULL, "vddarm");
-	if (IS_ERR(arm_regulator)) {
-		pr_err("failed to get regulator vddarm\n");
-		return PTR_ERR(arm_regulator);
-	}
-
-	int_regulator = regulator_get(NULL, "vddint");
-	if (IS_ERR(int_regulator)) {
-		pr_err("failed to get regulator vddint\n");
-		regulator_put(arm_regulator);
-		return PTR_ERR(int_regulator);
-	}
-
 	register_reboot_notifier(&s5pv210_cpufreq_reboot_notifier);
 
 	return cpufreq_register_driver(&s5pv210_driver);
-- 
2.17.1


  parent reply	other threads:[~2019-01-10 20:53 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-01-10 20:52 [PATCH v2 0/4] ARM: dts: s5pv210: Enable cpufreq support Paweł Chmiel
2019-01-10 20:52 ` [PATCH v2 1/4] ARM: dts: s5pv210: Add dmc nodes Paweł Chmiel
2019-01-11  8:32   ` Krzysztof Kozlowski
2019-01-11  9:41     ` Viresh Kumar
2019-01-11  9:47       ` Krzysztof Kozlowski
2019-01-10 20:52 ` [PATCH v2 2/4] cpufreq: s5pv210: Don't flood kernel log after cpufreq change Paweł Chmiel
2019-01-10 20:52 ` Paweł Chmiel [this message]
2019-01-11  9:46   ` [PATCH v2 3/4] cpufreq: s5pv210: Defer probe if getting regulators fail Krzysztof Kozlowski
2019-01-11  9:53     ` Paweł Chmiel
2019-01-10 20:52 ` [PATCH v2 4/4] ARM: defconfig: s5pv210: Add cpufreq support Paweł Chmiel
2019-01-13  9:34   ` Krzysztof Kozlowski

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190110205215.22030-4-pawel.mikolaj.chmiel@gmail.com \
    --to=pawel.mikolaj.chmiel@gmail.com \
    --cc=devicetree@vger.kernel.org \
    --cc=kgene@kernel.org \
    --cc=krzk@kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=linux-samsung-soc@vger.kernel.org \
    --cc=linux@armlinux.org.uk \
    --cc=mark.rutland@arm.com \
    --cc=rjw@rjwysocki.net \
    --cc=robh+dt@kernel.org \
    --cc=viresh.kumar@linaro.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).