* [PATCH 1/2] cpufreq: No need to verify cpufreq_driver in show_scaling_cur_freq()
@ 2020-08-27 5:24 Viresh Kumar
2020-08-27 5:24 ` [PATCH 2/2] cpufreq: Do WARN() for invalid relation Viresh Kumar
2020-08-27 10:54 ` [PATCH 1/2] cpufreq: No need to verify cpufreq_driver in show_scaling_cur_freq() Rafael J. Wysocki
0 siblings, 2 replies; 3+ messages in thread
From: Viresh Kumar @ 2020-08-27 5:24 UTC (permalink / raw)
To: Rafael Wysocki, Viresh Kumar; +Cc: linux-pm, Vincent Guittot, linux-kernel
"cpufreq_driver" is guaranteed to be valid here, no need to check it
here.
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
---
drivers/cpufreq/cpufreq.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
index 02ab56b2a0d8..47aa90f9a7c2 100644
--- a/drivers/cpufreq/cpufreq.c
+++ b/drivers/cpufreq/cpufreq.c
@@ -703,8 +703,7 @@ static ssize_t show_scaling_cur_freq(struct cpufreq_policy *policy, char *buf)
freq = arch_freq_get_on_cpu(policy->cpu);
if (freq)
ret = sprintf(buf, "%u\n", freq);
- else if (cpufreq_driver && cpufreq_driver->setpolicy &&
- cpufreq_driver->get)
+ else if (cpufreq_driver->setpolicy && cpufreq_driver->get)
ret = sprintf(buf, "%u\n", cpufreq_driver->get(policy->cpu));
else
ret = sprintf(buf, "%u\n", policy->cur);
--
2.25.0.rc1.19.g042ed3e048af
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH 2/2] cpufreq: Do WARN() for invalid relation
2020-08-27 5:24 [PATCH 1/2] cpufreq: No need to verify cpufreq_driver in show_scaling_cur_freq() Viresh Kumar
@ 2020-08-27 5:24 ` Viresh Kumar
2020-08-27 10:54 ` [PATCH 1/2] cpufreq: No need to verify cpufreq_driver in show_scaling_cur_freq() Rafael J. Wysocki
1 sibling, 0 replies; 3+ messages in thread
From: Viresh Kumar @ 2020-08-27 5:24 UTC (permalink / raw)
To: Rafael Wysocki, Viresh Kumar; +Cc: linux-pm, Vincent Guittot, linux-kernel
The relation can't be invalid here, if it is just WARN() and return 0.
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
---
include/linux/cpufreq.h | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/include/linux/cpufreq.h b/include/linux/cpufreq.h
index 8f141d4c859c..a911e5d06845 100644
--- a/include/linux/cpufreq.h
+++ b/include/linux/cpufreq.h
@@ -956,8 +956,8 @@ static inline int cpufreq_frequency_table_target(struct cpufreq_policy *policy,
case CPUFREQ_RELATION_C:
return cpufreq_table_find_index_c(policy, target_freq);
default:
- pr_err("%s: Invalid relation: %d\n", __func__, relation);
- return -EINVAL;
+ WARN_ON_ONCE(1);
+ return 0;
}
}
--
2.25.0.rc1.19.g042ed3e048af
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH 1/2] cpufreq: No need to verify cpufreq_driver in show_scaling_cur_freq()
2020-08-27 5:24 [PATCH 1/2] cpufreq: No need to verify cpufreq_driver in show_scaling_cur_freq() Viresh Kumar
2020-08-27 5:24 ` [PATCH 2/2] cpufreq: Do WARN() for invalid relation Viresh Kumar
@ 2020-08-27 10:54 ` Rafael J. Wysocki
1 sibling, 0 replies; 3+ messages in thread
From: Rafael J. Wysocki @ 2020-08-27 10:54 UTC (permalink / raw)
To: Viresh Kumar
Cc: Rafael Wysocki, Linux PM, Vincent Guittot, Linux Kernel Mailing List
On Thu, Aug 27, 2020 at 7:24 AM Viresh Kumar <viresh.kumar@linaro.org> wrote:
>
> "cpufreq_driver" is guaranteed to be valid here, no need to check it
> here.
>
> Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
> ---
> drivers/cpufreq/cpufreq.c | 3 +--
> 1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
> index 02ab56b2a0d8..47aa90f9a7c2 100644
> --- a/drivers/cpufreq/cpufreq.c
> +++ b/drivers/cpufreq/cpufreq.c
> @@ -703,8 +703,7 @@ static ssize_t show_scaling_cur_freq(struct cpufreq_policy *policy, char *buf)
> freq = arch_freq_get_on_cpu(policy->cpu);
> if (freq)
> ret = sprintf(buf, "%u\n", freq);
> - else if (cpufreq_driver && cpufreq_driver->setpolicy &&
> - cpufreq_driver->get)
> + else if (cpufreq_driver->setpolicy && cpufreq_driver->get)
> ret = sprintf(buf, "%u\n", cpufreq_driver->get(policy->cpu));
> else
> ret = sprintf(buf, "%u\n", policy->cur);
> --
This and the [2/2] applied, the latter with some minor edits in the
subject/changelog.
Thanks!
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2020-08-27 12:28 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-27 5:24 [PATCH 1/2] cpufreq: No need to verify cpufreq_driver in show_scaling_cur_freq() Viresh Kumar
2020-08-27 5:24 ` [PATCH 2/2] cpufreq: Do WARN() for invalid relation Viresh Kumar
2020-08-27 10:54 ` [PATCH 1/2] cpufreq: No need to verify cpufreq_driver in show_scaling_cur_freq() Rafael J. Wysocki
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).