1 From 05723e71234b60a1a47313ea1a889797ec648f1c Mon Sep 17 00:00:00 2001
2 From: Chanwoo Choi <cw00.choi@samsung.com>
3 Date: Tue, 2 Mar 2021 17:22:50 +0900
4 Subject: [PATCH 3/5] PM / devfreq: passive: Reduce duplicate code when
7 In order to keep the consistent coding style between passive_devfreq
8 and passive_cpufreq, use common code for handling required opp property.
9 Also remove the unneed conditional statement and unify the comment
10 of both passive_devfreq and passive_cpufreq when getting the target frequency.
12 Tested-by: Chen-Yu Tsai <wenst@chromium.org>
13 Tested-by: Johnson Wang <johnson.wang@mediatek.com>
14 Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
16 drivers/devfreq/governor_passive.c | 66 ++++--------------------------
17 1 file changed, 8 insertions(+), 58 deletions(-)
19 --- a/drivers/devfreq/governor_passive.c
20 +++ b/drivers/devfreq/governor_passive.c
21 @@ -93,65 +93,16 @@ static int get_target_freq_with_devfreq(
22 = (struct devfreq_passive_data *)devfreq->data;
23 struct devfreq *parent_devfreq = (struct devfreq *)p_data->parent;
24 unsigned long child_freq = ULONG_MAX;
25 - struct dev_pm_opp *opp, *p_opp;
29 - * If the devfreq device with passive governor has the specific method
30 - * to determine the next frequency, should use the get_target_freq()
31 - * of struct devfreq_passive_data.
33 - if (p_data->get_target_freq)
34 - return p_data->get_target_freq(devfreq, freq);
37 - * If the parent and passive devfreq device uses the OPP table,
38 - * get the next frequency by using the OPP table.
42 - * - parent devfreq device uses the governors except for passive.
43 - * - passive devfreq device uses the passive governor.
45 - * Each devfreq has the OPP table. After deciding the new frequency
46 - * from the governor of parent devfreq device, the passive governor
47 - * need to get the index of new frequency on OPP table of parent
48 - * device. And then the index is used for getting the suitable
49 - * new frequency for passive devfreq device.
51 - if (!devfreq->profile || !devfreq->profile->freq_table
52 - || devfreq->profile->max_state <= 0)
56 - * The passive governor have to get the correct frequency from OPP
57 - * list of parent device. Because in this case, *freq is temporary
58 - * value which is decided by ondemand governor.
60 - if (devfreq->opp_table && parent_devfreq->opp_table) {
61 - p_opp = devfreq_recommended_opp(parent_devfreq->dev.parent,
64 - return PTR_ERR(p_opp);
66 - opp = dev_pm_opp_xlate_required_opp(parent_devfreq->opp_table,
67 - devfreq->opp_table, p_opp);
68 - dev_pm_opp_put(p_opp);
71 - goto no_required_opp;
73 - *freq = dev_pm_opp_get_freq(opp);
74 - dev_pm_opp_put(opp);
78 + /* Get target freq via required opps */
79 + child_freq = get_target_freq_by_required_opp(parent_devfreq->dev.parent,
80 + parent_devfreq->opp_table,
81 + devfreq->opp_table, freq);
87 - * Get the OPP table's index of decided frequency by governor
90 + /* Use interpolation if required opps is not available */
91 for (i = 0; i < parent_devfreq->profile->max_state; i++)
92 if (parent_devfreq->profile->freq_table[i] == *freq)
94 @@ -159,7 +110,6 @@ no_required_opp:
95 if (i == parent_devfreq->profile->max_state)
98 - /* Get the suitable frequency by using index of parent device. */
99 if (i < devfreq->profile->max_state) {
100 child_freq = devfreq->profile->freq_table[i];
102 @@ -167,7 +117,7 @@ no_required_opp:
103 child_freq = devfreq->profile->freq_table[count - 1];
106 - /* Return the suitable frequency for passive device. */