aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/devfreq
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/devfreq')
-rw-r--r--drivers/devfreq/devfreq.c31
1 files changed, 20 insertions, 11 deletions
diff --git a/drivers/devfreq/devfreq.c b/drivers/devfreq/devfreq.c
index a0b2f7e0eedb..2042ec3656ba 100644
--- a/drivers/devfreq/devfreq.c
+++ b/drivers/devfreq/devfreq.c
@@ -91,26 +91,35 @@ static int devfreq_get_freq_level(struct devfreq *devfreq, unsigned long freq)
91 */ 91 */
92static int devfreq_update_status(struct devfreq *devfreq, unsigned long freq) 92static int devfreq_update_status(struct devfreq *devfreq, unsigned long freq)
93{ 93{
94 int lev, prev_lev; 94 int lev, prev_lev, ret = 0;
95 unsigned long cur_time; 95 unsigned long cur_time;
96 96
97 lev = devfreq_get_freq_level(devfreq, freq);
98 if (lev < 0)
99 return lev;
100
101 cur_time = jiffies; 97 cur_time = jiffies;
102 devfreq->time_in_state[lev] += 98
99 prev_lev = devfreq_get_freq_level(devfreq, devfreq->previous_freq);
100 if (prev_lev < 0) {
101 ret = prev_lev;
102 goto out;
103 }
104
105 devfreq->time_in_state[prev_lev] +=
103 cur_time - devfreq->last_stat_updated; 106 cur_time - devfreq->last_stat_updated;
104 if (freq != devfreq->previous_freq) { 107
105 prev_lev = devfreq_get_freq_level(devfreq, 108 lev = devfreq_get_freq_level(devfreq, freq);
106 devfreq->previous_freq); 109 if (lev < 0) {
110 ret = lev;
111 goto out;
112 }
113
114 if (lev != prev_lev) {
107 devfreq->trans_table[(prev_lev * 115 devfreq->trans_table[(prev_lev *
108 devfreq->profile->max_state) + lev]++; 116 devfreq->profile->max_state) + lev]++;
109 devfreq->total_trans++; 117 devfreq->total_trans++;
110 } 118 }
111 devfreq->last_stat_updated = cur_time;
112 119
113 return 0; 120out:
121 devfreq->last_stat_updated = cur_time;
122 return ret;
114} 123}
115 124
116/** 125/**