diff options
author | Chanwoo Choi <cw00.choi@samsung.com> | 2017-10-22 21:32:10 -0400 |
---|---|---|
committer | MyungJoo Ham <myungjoo.ham@samsung.com> | 2017-10-26 04:08:40 -0400 |
commit | 416b46a2627ae8de1466f90787dede6f9c5a1bfa (patch) | |
tree | afe1701ce9bc7b57af453c924e450fbc84acf23b | |
parent | ea572f816032bef9ff2641a439a45651a20eab73 (diff) |
PM / devfreq: Show the all available frequencies
The commit a76caf55e5b35 ("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>
-rw-r--r-- | drivers/devfreq/devfreq.c | 16 | ||||
-rw-r--r-- | include/linux/devfreq.h | 5 |
2 files changed, 8 insertions, 13 deletions
diff --git a/drivers/devfreq/devfreq.c b/drivers/devfreq/devfreq.c index b2920cd2b78e..381f92e5e794 100644 --- a/drivers/devfreq/devfreq.c +++ b/drivers/devfreq/devfreq.c | |||
@@ -1194,22 +1194,16 @@ static ssize_t available_frequencies_show(struct device *d, | |||
1194 | char *buf) | 1194 | char *buf) |
1195 | { | 1195 | { |
1196 | struct devfreq *df = to_devfreq(d); | 1196 | struct devfreq *df = to_devfreq(d); |
1197 | struct device *dev = df->dev.parent; | ||
1198 | struct dev_pm_opp *opp; | ||
1199 | ssize_t count = 0; | 1197 | ssize_t count = 0; |
1200 | unsigned long freq = 0; | 1198 | int i; |
1201 | 1199 | ||
1202 | do { | 1200 | mutex_lock(&df->lock); |
1203 | opp = dev_pm_opp_find_freq_ceil(dev, &freq); | ||
1204 | if (IS_ERR(opp)) | ||
1205 | break; | ||
1206 | 1201 | ||
1207 | dev_pm_opp_put(opp); | 1202 | for (i = 0; i < df->profile->max_state; i++) |
1208 | count += scnprintf(&buf[count], (PAGE_SIZE - count - 2), | 1203 | count += scnprintf(&buf[count], (PAGE_SIZE - count - 2), |
1209 | "%lu ", freq); | 1204 | "%lu ", df->profile->freq_table[i]); |
1210 | freq++; | ||
1211 | } while (1); | ||
1212 | 1205 | ||
1206 | mutex_unlock(&df->lock); | ||
1213 | /* Truncate the trailing space */ | 1207 | /* Truncate the trailing space */ |
1214 | if (count) | 1208 | if (count) |
1215 | count--; | 1209 | count--; |
diff --git a/include/linux/devfreq.h b/include/linux/devfreq.h index 997a9eb34191..19520625ea94 100644 --- a/include/linux/devfreq.h +++ b/include/linux/devfreq.h | |||
@@ -84,8 +84,9 @@ struct devfreq_dev_status { | |||
84 | * from devfreq_remove_device() call. If the user | 84 | * from devfreq_remove_device() call. If the user |
85 | * has registered devfreq->nb at a notifier-head, | 85 | * has registered devfreq->nb at a notifier-head, |
86 | * this is the time to unregister it. | 86 | * this is the time to unregister it. |
87 | * @freq_table: Optional list of frequencies to support statistics. | 87 | * @freq_table: Optional list of frequencies to support statistics |
88 | * @max_state: The size of freq_table. | 88 | * and freq_table must be generated in ascending order. |
89 | * @max_state: The size of freq_table. | ||
89 | */ | 90 | */ |
90 | struct devfreq_dev_profile { | 91 | struct devfreq_dev_profile { |
91 | unsigned long initial_freq; | 92 | unsigned long initial_freq; |