From: Viresh Kumar <viresh.kumar@linaro.org>
To: Pi-Cheng Chen <pi-cheng.chen@linaro.org>
Cc: Matthias Brugger <matthias.bgg@gmail.com>,
Daniel Kurtz <djkurtz@chromium.org>,
linux-mediatek@lists.infradead.org,
linaro-kernel@lists.linaro.org,
linux-arm-kernel@lists.infradead.org, linux-pm@vger.kernel.org
Subject: Re: [PATCH 3/4] cpufreq: mt8173: check return value of regulator_get_voltage() call
Date: Mon, 30 Nov 2015 10:57:51 +0530 [thread overview]
Message-ID: <20151130052751.GK3373@ubuntu> (raw)
In-Reply-To: <1448785898-17838-3-git-send-email-pi-cheng.chen@linaro.org>
On 29-11-15, 16:31, Pi-Cheng Chen wrote:
> Sometimes regulator_get_voltage() call returns negative values for
> reasons(e.g. underlying I2C bus timeout). Add check for the return
> values and fail out early.
>
> Signed-off-by: Pi-Cheng Chen <pi-cheng.chen@linaro.org>
> ---
> drivers/cpufreq/mt8173-cpufreq.c | 28 ++++++++++++++++++++++++++++
> 1 file changed, 28 insertions(+)
>
> diff --git a/drivers/cpufreq/mt8173-cpufreq.c b/drivers/cpufreq/mt8173-cpufreq.c
> index 750cda7..9d0fe37 100644
> --- a/drivers/cpufreq/mt8173-cpufreq.c
> +++ b/drivers/cpufreq/mt8173-cpufreq.c
> @@ -59,6 +59,10 @@ static int mtk_cpufreq_voltage_tracking(struct mtk_cpu_dvfs_info *info,
> int old_vproc, old_vsram, new_vsram, vsram, vproc, ret;
>
> old_vproc = regulator_get_voltage(proc_reg);
> + if (old_vproc < 0) {
> + pr_err("%s: invalid Vproc value: %d\n", __func__, old_vproc);
> + return old_vproc;
> + }
> /* Vsram should not exceed the maximum allowed voltage of SoC. */
> new_vsram = min(new_vproc + MIN_VOLT_SHIFT, MAX_VOLT_LIMIT);
>
> @@ -71,7 +75,17 @@ static int mtk_cpufreq_voltage_tracking(struct mtk_cpu_dvfs_info *info,
> */
> do {
> old_vsram = regulator_get_voltage(sram_reg);
> + if (old_vsram < 0) {
> + pr_err("%s: invalid Vsram value: %d\n",
> + __func__, old_vsram);
> + return old_vsram;
> + }
> old_vproc = regulator_get_voltage(proc_reg);
> + if (old_vproc < 0) {
> + pr_err("%s: invalid Vproc value: %d\n",
> + __func__, old_vproc);
> + return old_vproc;
> + }
>
> vsram = min(new_vsram, old_vproc + MAX_VOLT_SHIFT);
>
> @@ -116,7 +130,17 @@ static int mtk_cpufreq_voltage_tracking(struct mtk_cpu_dvfs_info *info,
> */
> do {
> old_vproc = regulator_get_voltage(proc_reg);
> + if (old_vproc < 0) {
> + pr_err("%s: invalid Vproc value: %d\n",
> + __func__, old_vproc);
> + return old_vproc;
> + }
> old_vsram = regulator_get_voltage(sram_reg);
> + if (old_vsram < 0) {
> + pr_err("%s: invalid Vsram value: %d\n",
> + __func__, old_vsram);
> + return old_vsram;
> + }
>
> vproc = max(new_vproc, old_vsram - MAX_VOLT_SHIFT);
> ret = regulator_set_voltage(proc_reg, vproc,
> @@ -184,6 +208,10 @@ static int mtk_cpufreq_set_target(struct cpufreq_policy *policy,
>
> old_freq_hz = clk_get_rate(cpu_clk);
> old_vproc = regulator_get_voltage(info->proc_reg);
> + if (old_vproc < 0) {
> + pr_err("%s: invalid Vproc value: %d\n", __func__, old_vproc);
> + return old_vproc;
> + }
>
> freq_hz = freq_table[index].frequency * 1000;
Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
--
viresh
WARNING: multiple messages have this Message-ID (diff)
From: viresh.kumar@linaro.org (Viresh Kumar)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 3/4] cpufreq: mt8173: check return value of regulator_get_voltage() call
Date: Mon, 30 Nov 2015 10:57:51 +0530 [thread overview]
Message-ID: <20151130052751.GK3373@ubuntu> (raw)
In-Reply-To: <1448785898-17838-3-git-send-email-pi-cheng.chen@linaro.org>
On 29-11-15, 16:31, Pi-Cheng Chen wrote:
> Sometimes regulator_get_voltage() call returns negative values for
> reasons(e.g. underlying I2C bus timeout). Add check for the return
> values and fail out early.
>
> Signed-off-by: Pi-Cheng Chen <pi-cheng.chen@linaro.org>
> ---
> drivers/cpufreq/mt8173-cpufreq.c | 28 ++++++++++++++++++++++++++++
> 1 file changed, 28 insertions(+)
>
> diff --git a/drivers/cpufreq/mt8173-cpufreq.c b/drivers/cpufreq/mt8173-cpufreq.c
> index 750cda7..9d0fe37 100644
> --- a/drivers/cpufreq/mt8173-cpufreq.c
> +++ b/drivers/cpufreq/mt8173-cpufreq.c
> @@ -59,6 +59,10 @@ static int mtk_cpufreq_voltage_tracking(struct mtk_cpu_dvfs_info *info,
> int old_vproc, old_vsram, new_vsram, vsram, vproc, ret;
>
> old_vproc = regulator_get_voltage(proc_reg);
> + if (old_vproc < 0) {
> + pr_err("%s: invalid Vproc value: %d\n", __func__, old_vproc);
> + return old_vproc;
> + }
> /* Vsram should not exceed the maximum allowed voltage of SoC. */
> new_vsram = min(new_vproc + MIN_VOLT_SHIFT, MAX_VOLT_LIMIT);
>
> @@ -71,7 +75,17 @@ static int mtk_cpufreq_voltage_tracking(struct mtk_cpu_dvfs_info *info,
> */
> do {
> old_vsram = regulator_get_voltage(sram_reg);
> + if (old_vsram < 0) {
> + pr_err("%s: invalid Vsram value: %d\n",
> + __func__, old_vsram);
> + return old_vsram;
> + }
> old_vproc = regulator_get_voltage(proc_reg);
> + if (old_vproc < 0) {
> + pr_err("%s: invalid Vproc value: %d\n",
> + __func__, old_vproc);
> + return old_vproc;
> + }
>
> vsram = min(new_vsram, old_vproc + MAX_VOLT_SHIFT);
>
> @@ -116,7 +130,17 @@ static int mtk_cpufreq_voltage_tracking(struct mtk_cpu_dvfs_info *info,
> */
> do {
> old_vproc = regulator_get_voltage(proc_reg);
> + if (old_vproc < 0) {
> + pr_err("%s: invalid Vproc value: %d\n",
> + __func__, old_vproc);
> + return old_vproc;
> + }
> old_vsram = regulator_get_voltage(sram_reg);
> + if (old_vsram < 0) {
> + pr_err("%s: invalid Vsram value: %d\n",
> + __func__, old_vsram);
> + return old_vsram;
> + }
>
> vproc = max(new_vproc, old_vsram - MAX_VOLT_SHIFT);
> ret = regulator_set_voltage(proc_reg, vproc,
> @@ -184,6 +208,10 @@ static int mtk_cpufreq_set_target(struct cpufreq_policy *policy,
>
> old_freq_hz = clk_get_rate(cpu_clk);
> old_vproc = regulator_get_voltage(info->proc_reg);
> + if (old_vproc < 0) {
> + pr_err("%s: invalid Vproc value: %d\n", __func__, old_vproc);
> + return old_vproc;
> + }
>
> freq_hz = freq_table[index].frequency * 1000;
Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
--
viresh
next prev parent reply other threads:[~2015-11-30 5:27 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-11-29 8:31 [PATCH 1/4] cpufreq: mt8173: add CPUFREQ_HAVE_GOVERNOR_PER_POLICY flag Pi-Cheng Chen
2015-11-29 8:31 ` Pi-Cheng Chen
2015-11-29 8:31 ` [PATCH 2/4] cpufreq: mt8173: remove redundant regulator_get_voltage() call Pi-Cheng Chen
2015-11-29 8:31 ` Pi-Cheng Chen
2015-11-30 5:23 ` Viresh Kumar
2015-11-30 5:23 ` Viresh Kumar
2015-11-29 8:31 ` [PATCH 3/4] cpufreq: mt8173: check return value of " Pi-Cheng Chen
2015-11-29 8:31 ` Pi-Cheng Chen
2015-11-30 5:27 ` Viresh Kumar [this message]
2015-11-30 5:27 ` Viresh Kumar
2015-11-29 8:31 ` [PATCH 4/4] cpufreq: mt8173: move resources allocation into ->probe() Pi-Cheng Chen
2015-11-29 8:31 ` Pi-Cheng Chen
2015-12-05 6:01 ` [PATCH v2] " Pi-Cheng Chen
2015-12-05 6:01 ` Pi-Cheng Chen
2015-12-06 2:24 ` Viresh Kumar
2015-12-06 2:24 ` Viresh Kumar
2015-12-07 2:44 ` Daniel Kurtz
2015-12-07 2:44 ` Daniel Kurtz
2015-12-07 12:42 ` Pi-Cheng Chen
2015-12-07 12:42 ` Pi-Cheng Chen
2015-12-07 16:03 ` Viresh Kumar
2015-12-07 16:03 ` Viresh Kumar
2015-12-09 23:53 ` Rafael J. Wysocki
2015-12-09 23:53 ` Rafael J. Wysocki
2015-12-10 3:48 ` [PATCH v3] " Pi-Cheng Chen
2015-12-10 3:48 ` Pi-Cheng Chen
2015-12-14 23:59 ` Rafael J. Wysocki
2015-12-14 23:59 ` Rafael J. Wysocki
2015-11-30 5:20 ` [PATCH 1/4] cpufreq: mt8173: add CPUFREQ_HAVE_GOVERNOR_PER_POLICY flag Viresh Kumar
2015-11-30 5:20 ` Viresh Kumar
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=20151130052751.GK3373@ubuntu \
--to=viresh.kumar@linaro.org \
--cc=djkurtz@chromium.org \
--cc=linaro-kernel@lists.linaro.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-mediatek@lists.infradead.org \
--cc=linux-pm@vger.kernel.org \
--cc=matthias.bgg@gmail.com \
--cc=pi-cheng.chen@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.