Skip to content

Commit c034b02

Browse files
Dirk Brandewierafaeljw
authored andcommitted
cpufreq: expose scaling_cur_freq sysfs file for set_policy() drivers
Currently the core does not expose scaling_cur_freq for set_policy() drivers this breaks some userspace monitoring tools. Change the core to expose this file for all drivers and if the set_policy() driver supports the get() callback use it to retrieve the current frequency. Link: https://bugzilla.kernel.org/show_bug.cgi?id=73741 Cc: All applicable <stable@vger.kernel.org> Signed-off-by: Dirk Brandewie <dirk.j.brandewie@intel.com> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
1 parent 36b4bed commit c034b02

1 file changed

Lines changed: 17 additions & 6 deletions

File tree

‎drivers/cpufreq/cpufreq.c‎

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -512,7 +512,18 @@ show_one(cpuinfo_max_freq, cpuinfo.max_freq);
512512
show_one(cpuinfo_transition_latency, cpuinfo.transition_latency);
513513
show_one(scaling_min_freq, min);
514514
show_one(scaling_max_freq, max);
515-
show_one(scaling_cur_freq, cur);
515+
516+
static ssize_t show_scaling_cur_freq(
517+
struct cpufreq_policy *policy, char *buf)
518+
{
519+
ssize_t ret;
520+
521+
if (cpufreq_driver && cpufreq_driver->setpolicy && cpufreq_driver->get)
522+
ret = sprintf(buf, "%u\n", cpufreq_driver->get(policy->cpu));
523+
else
524+
ret = sprintf(buf, "%u\n", policy->cur);
525+
return ret;
526+
}
516527

517528
static int cpufreq_set_policy(struct cpufreq_policy *policy,
518529
struct cpufreq_policy *new_policy);
@@ -906,11 +917,11 @@ static int cpufreq_add_dev_interface(struct cpufreq_policy *policy,
906917
if (ret)
907918
goto err_out_kobj_put;
908919
}
909-
if (has_target()) {
910-
ret = sysfs_create_file(&policy->kobj, &scaling_cur_freq.attr);
911-
if (ret)
912-
goto err_out_kobj_put;
913-
}
920+
921+
ret = sysfs_create_file(&policy->kobj, &scaling_cur_freq.attr);
922+
if (ret)
923+
goto err_out_kobj_put;
924+
914925
if (cpufreq_driver->bios_limit) {
915926
ret = sysfs_create_file(&policy->kobj, &bios_limit.attr);
916927
if (ret)

0 commit comments

Comments
 (0)