aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/devfreq/governor_simpleondemand.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/devfreq/governor_simpleondemand.c')
-rw-r--r--drivers/devfreq/governor_simpleondemand.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/drivers/devfreq/governor_simpleondemand.c b/drivers/devfreq/governor_simpleondemand.c
index efad8dcf9028..a2e3eae79011 100644
--- a/drivers/devfreq/governor_simpleondemand.c
+++ b/drivers/devfreq/governor_simpleondemand.c
@@ -25,6 +25,7 @@ static int devfreq_simple_ondemand_func(struct devfreq *df,
25 unsigned int dfso_upthreshold = DFSO_UPTHRESHOLD; 25 unsigned int dfso_upthreshold = DFSO_UPTHRESHOLD;
26 unsigned int dfso_downdifferential = DFSO_DOWNDIFFERENCTIAL; 26 unsigned int dfso_downdifferential = DFSO_DOWNDIFFERENCTIAL;
27 struct devfreq_simple_ondemand_data *data = df->data; 27 struct devfreq_simple_ondemand_data *data = df->data;
28 unsigned long max = (df->max_freq) ? df->max_freq : UINT_MAX;
28 29
29 if (err) 30 if (err)
30 return err; 31 return err;
@@ -41,7 +42,7 @@ static int devfreq_simple_ondemand_func(struct devfreq *df,
41 42
42 /* Assume MAX if it is going to be divided by zero */ 43 /* Assume MAX if it is going to be divided by zero */
43 if (stat.total_time == 0) { 44 if (stat.total_time == 0) {
44 *freq = UINT_MAX; 45 *freq = max;
45 return 0; 46 return 0;
46 } 47 }
47 48
@@ -54,13 +55,13 @@ static int devfreq_simple_ondemand_func(struct devfreq *df,
54 /* Set MAX if it's busy enough */ 55 /* Set MAX if it's busy enough */
55 if (stat.busy_time * 100 > 56 if (stat.busy_time * 100 >
56 stat.total_time * dfso_upthreshold) { 57 stat.total_time * dfso_upthreshold) {
57 *freq = UINT_MAX; 58 *freq = max;
58 return 0; 59 return 0;
59 } 60 }
60 61
61 /* Set MAX if we do not know the initial frequency */ 62 /* Set MAX if we do not know the initial frequency */
62 if (stat.current_frequency == 0) { 63 if (stat.current_frequency == 0) {
63 *freq = UINT_MAX; 64 *freq = max;
64 return 0; 65 return 0;
65 } 66 }
66 67
@@ -79,6 +80,11 @@ static int devfreq_simple_ondemand_func(struct devfreq *df,
79 b = div_u64(b, (dfso_upthreshold - dfso_downdifferential / 2)); 80 b = div_u64(b, (dfso_upthreshold - dfso_downdifferential / 2));
80 *freq = (unsigned long) b; 81 *freq = (unsigned long) b;
81 82
83 if (df->min_freq && *freq < df->min_freq)
84 *freq = df->min_freq;
85 if (df->max_freq && *freq > df->max_freq)
86 *freq = df->max_freq;
87
82 return 0; 88 return 0;
83} 89}
84 90