0442105d87f73cf3a67300df7d58410ae85f905e
[openwrt/staging/blocktrron.git] /
1 From 713472e53e6e53c985e283782b0fd76b8ecfd47e Mon Sep 17 00:00:00 2001
2 From: Chanwoo Choi <cw00.choi@samsung.com>
3 Date: Mon, 1 Mar 2021 02:07:29 +0900
4 Subject: [PATCH 1/5] PM / devfreq: Export devfreq_get_freq_range symbol within
5 devfreq
6
7 In order to get frequency range within devfreq governors,
8 export devfreq_get_freq_range symbol within devfreq.
9
10 Reviewed-by: Matthias Kaehlcke <mka@chromium.org>
11 Tested-by: Chen-Yu Tsai <wenst@chromium.org>
12 Tested-by: Johnson Wang <johnson.wang@mediatek.com>
13 Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
14 ---
15 drivers/devfreq/devfreq.c | 20 ++++++++++++--------
16 drivers/devfreq/governor.h | 2 ++
17 2 files changed, 14 insertions(+), 8 deletions(-)
18
19 --- a/drivers/devfreq/devfreq.c
20 +++ b/drivers/devfreq/devfreq.c
21 @@ -112,16 +112,16 @@ static unsigned long find_available_max_
22 }
23
24 /**
25 - * get_freq_range() - Get the current freq range
26 + * devfreq_get_freq_range() - Get the current freq range
27 * @devfreq: the devfreq instance
28 * @min_freq: the min frequency
29 * @max_freq: the max frequency
30 *
31 * This takes into consideration all constraints.
32 */
33 -static void get_freq_range(struct devfreq *devfreq,
34 - unsigned long *min_freq,
35 - unsigned long *max_freq)
36 +void devfreq_get_freq_range(struct devfreq *devfreq,
37 + unsigned long *min_freq,
38 + unsigned long *max_freq)
39 {
40 unsigned long *freq_table = devfreq->profile->freq_table;
41 s32 qos_min_freq, qos_max_freq;
42 @@ -158,6 +158,7 @@ static void get_freq_range(struct devfre
43 if (*min_freq > *max_freq)
44 *min_freq = *max_freq;
45 }
46 +EXPORT_SYMBOL(devfreq_get_freq_range);
47
48 /**
49 * devfreq_get_freq_level() - Lookup freq_table for the frequency
50 @@ -418,7 +419,7 @@ int devfreq_update_target(struct devfreq
51 err = devfreq->governor->get_target_freq(devfreq, &freq);
52 if (err)
53 return err;
54 - get_freq_range(devfreq, &min_freq, &max_freq);
55 + devfreq_get_freq_range(devfreq, &min_freq, &max_freq);
56
57 if (freq < min_freq) {
58 freq = min_freq;
59 @@ -785,6 +786,7 @@ struct devfreq *devfreq_add_device(struc
60 {
61 struct devfreq *devfreq;
62 struct devfreq_governor *governor;
63 + unsigned long min_freq, max_freq;
64 int err = 0;
65
66 if (!dev || !profile || !governor_name) {
67 @@ -849,6 +851,8 @@ struct devfreq *devfreq_add_device(struc
68 goto err_dev;
69 }
70
71 + devfreq_get_freq_range(devfreq, &min_freq, &max_freq);
72 +
73 devfreq->suspend_freq = dev_pm_opp_get_suspend_opp_freq(dev);
74 devfreq->opp_table = dev_pm_opp_get_opp_table(dev);
75 if (IS_ERR(devfreq->opp_table))
76 @@ -1561,7 +1565,7 @@ static ssize_t min_freq_show(struct devi
77 unsigned long min_freq, max_freq;
78
79 mutex_lock(&df->lock);
80 - get_freq_range(df, &min_freq, &max_freq);
81 + devfreq_get_freq_range(df, &min_freq, &max_freq);
82 mutex_unlock(&df->lock);
83
84 return sprintf(buf, "%lu\n", min_freq);
85 @@ -1615,7 +1619,7 @@ static ssize_t max_freq_show(struct devi
86 unsigned long min_freq, max_freq;
87
88 mutex_lock(&df->lock);
89 - get_freq_range(df, &min_freq, &max_freq);
90 + devfreq_get_freq_range(df, &min_freq, &max_freq);
91 mutex_unlock(&df->lock);
92
93 return sprintf(buf, "%lu\n", max_freq);
94 @@ -1929,7 +1933,7 @@ static int devfreq_summary_show(struct s
95
96 mutex_lock(&devfreq->lock);
97 cur_freq = devfreq->previous_freq;
98 - get_freq_range(devfreq, &min_freq, &max_freq);
99 + devfreq_get_freq_range(devfreq, &min_freq, &max_freq);
100 timer = devfreq->profile->timer;
101
102 if (IS_SUPPORTED_ATTR(devfreq->governor->attrs, POLLING_INTERVAL))
103 --- a/drivers/devfreq/governor.h
104 +++ b/drivers/devfreq/governor.h
105 @@ -86,6 +86,8 @@ int devfreq_remove_governor(struct devfr
106
107 int devfreq_update_status(struct devfreq *devfreq, unsigned long freq);
108 int devfreq_update_target(struct devfreq *devfreq, unsigned long freq);
109 +void devfreq_get_freq_range(struct devfreq *devfreq, unsigned long *min_freq,
110 + unsigned long *max_freq);
111
112 static inline int devfreq_update_stats(struct devfreq *df)
113 {