Skip to content

Commit

Permalink
PM / devfreq: Show the all available frequencies
Browse files Browse the repository at this point in the history
The commit a76caf5 ("thermal: Add devfreq cooling") allows
the devfreq device to use the cooling device. When the cooling down
are required, the devfreq_cooling.c disables the OPP entry with
the dev_pm_opp_disable(). In result, 'available_frequencies'[1]
sysfs node never came to show the all available frequencies.
[1] /sys/class/devfreq/.../available_frequencies

So, this patch uses the 'freq_table' in the 'struct devfreq_dev_profile'
in order to show the all available frequencies.
- If 'freq_table' is NULL, devfreq core initializes them by using OPP values.
- If 'freq_table' is initialized, devfreq core just uses the 'freq_table'.

And this patch adds some comment about the sort way of 'freq_table'.

Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
Signed-off-by: MyungJoo Ham <myungjoo.ham@samsung.com>
  • Loading branch information
Chanwoo Choi authored and MyungJoo Ham committed Oct 26, 2017
1 parent ea572f8 commit 416b46a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 13 deletions.
16 changes: 5 additions & 11 deletions drivers/devfreq/devfreq.c
Original file line number Diff line number Diff line change
Expand Up @@ -1194,22 +1194,16 @@ static ssize_t available_frequencies_show(struct device *d,
char *buf)
{
struct devfreq *df = to_devfreq(d);
struct device *dev = df->dev.parent;
struct dev_pm_opp *opp;
ssize_t count = 0;
unsigned long freq = 0;
int i;

do {
opp = dev_pm_opp_find_freq_ceil(dev, &freq);
if (IS_ERR(opp))
break;
mutex_lock(&df->lock);

dev_pm_opp_put(opp);
for (i = 0; i < df->profile->max_state; i++)
count += scnprintf(&buf[count], (PAGE_SIZE - count - 2),
"%lu ", freq);
freq++;
} while (1);
"%lu ", df->profile->freq_table[i]);

mutex_unlock(&df->lock);
/* Truncate the trailing space */
if (count)
count--;
Expand Down
5 changes: 3 additions & 2 deletions include/linux/devfreq.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,9 @@ struct devfreq_dev_status {
* from devfreq_remove_device() call. If the user
* has registered devfreq->nb at a notifier-head,
* this is the time to unregister it.
* @freq_table: Optional list of frequencies to support statistics.
* @max_state: The size of freq_table.
* @freq_table: Optional list of frequencies to support statistics
* and freq_table must be generated in ascending order.
* @max_state: The size of freq_table.
*/
struct devfreq_dev_profile {
unsigned long initial_freq;
Expand Down

0 comments on commit 416b46a

Please sign in to comment.