aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/cpufreq
diff options
context:
space:
mode:
authorViresh Kumar <viresh.kumar@linaro.org>2015-01-06 10:39:07 -0500
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>2015-01-23 17:06:44 -0500
commit5094160786ede5c08a6901648787a5bf9b0dc2e1 (patch)
tree7a14921873422c680323f69461f7a26ac48b4f2d /drivers/cpufreq
parenta9aaf2915ee265735c28b764551d084e61a694e0 (diff)
cpufreq: stats: rename 'struct cpufreq_stats' objects as 'stats'
Currently we name objects of 'struct cpufreq_stats' as 'stat' and 'stats'. Use 'stats' to make it consistent. Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Diffstat (limited to 'drivers/cpufreq')
-rw-r--r--drivers/cpufreq/cpufreq_stats.c102
1 files changed, 51 insertions, 51 deletions
diff --git a/drivers/cpufreq/cpufreq_stats.c b/drivers/cpufreq/cpufreq_stats.c
index 3792b2e2f4a8..cdc5233cf0c4 100644
--- a/drivers/cpufreq/cpufreq_stats.c
+++ b/drivers/cpufreq/cpufreq_stats.c
@@ -31,15 +31,15 @@ struct cpufreq_stats {
31#endif 31#endif
32}; 32};
33 33
34static int cpufreq_stats_update(struct cpufreq_stats *stat) 34static int cpufreq_stats_update(struct cpufreq_stats *stats)
35{ 35{
36 unsigned long long cur_time = get_jiffies_64(); 36 unsigned long long cur_time = get_jiffies_64();
37 37
38 spin_lock(&cpufreq_stats_lock); 38 spin_lock(&cpufreq_stats_lock);
39 if (stat->time_in_state) 39 if (stats->time_in_state)
40 stat->time_in_state[stat->last_index] += 40 stats->time_in_state[stats->last_index] +=
41 cur_time - stat->last_time; 41 cur_time - stats->last_time;
42 stat->last_time = cur_time; 42 stats->last_time = cur_time;
43 spin_unlock(&cpufreq_stats_lock); 43 spin_unlock(&cpufreq_stats_lock);
44 return 0; 44 return 0;
45} 45}
@@ -51,15 +51,15 @@ static ssize_t show_total_trans(struct cpufreq_policy *policy, char *buf)
51 51
52static ssize_t show_time_in_state(struct cpufreq_policy *policy, char *buf) 52static ssize_t show_time_in_state(struct cpufreq_policy *policy, char *buf)
53{ 53{
54 struct cpufreq_stats *stat = policy->stats; 54 struct cpufreq_stats *stats = policy->stats;
55 ssize_t len = 0; 55 ssize_t len = 0;
56 int i; 56 int i;
57 57
58 cpufreq_stats_update(stat); 58 cpufreq_stats_update(stats);
59 for (i = 0; i < stat->state_num; i++) { 59 for (i = 0; i < stats->state_num; i++) {
60 len += sprintf(buf + len, "%u %llu\n", stat->freq_table[i], 60 len += sprintf(buf + len, "%u %llu\n", stats->freq_table[i],
61 (unsigned long long) 61 (unsigned long long)
62 jiffies_64_to_clock_t(stat->time_in_state[i])); 62 jiffies_64_to_clock_t(stats->time_in_state[i]));
63 } 63 }
64 return len; 64 return len;
65} 65}
@@ -67,36 +67,36 @@ static ssize_t show_time_in_state(struct cpufreq_policy *policy, char *buf)
67#ifdef CONFIG_CPU_FREQ_STAT_DETAILS 67#ifdef CONFIG_CPU_FREQ_STAT_DETAILS
68static ssize_t show_trans_table(struct cpufreq_policy *policy, char *buf) 68static ssize_t show_trans_table(struct cpufreq_policy *policy, char *buf)
69{ 69{
70 struct cpufreq_stats *stat = policy->stats; 70 struct cpufreq_stats *stats = policy->stats;
71 ssize_t len = 0; 71 ssize_t len = 0;
72 int i, j; 72 int i, j;
73 73
74 cpufreq_stats_update(stat); 74 cpufreq_stats_update(stats);
75 len += snprintf(buf + len, PAGE_SIZE - len, " From : To\n"); 75 len += snprintf(buf + len, PAGE_SIZE - len, " From : To\n");
76 len += snprintf(buf + len, PAGE_SIZE - len, " : "); 76 len += snprintf(buf + len, PAGE_SIZE - len, " : ");
77 for (i = 0; i < stat->state_num; i++) { 77 for (i = 0; i < stats->state_num; i++) {
78 if (len >= PAGE_SIZE) 78 if (len >= PAGE_SIZE)
79 break; 79 break;
80 len += snprintf(buf + len, PAGE_SIZE - len, "%9u ", 80 len += snprintf(buf + len, PAGE_SIZE - len, "%9u ",
81 stat->freq_table[i]); 81 stats->freq_table[i]);
82 } 82 }
83 if (len >= PAGE_SIZE) 83 if (len >= PAGE_SIZE)
84 return PAGE_SIZE; 84 return PAGE_SIZE;
85 85
86 len += snprintf(buf + len, PAGE_SIZE - len, "\n"); 86 len += snprintf(buf + len, PAGE_SIZE - len, "\n");
87 87
88 for (i = 0; i < stat->state_num; i++) { 88 for (i = 0; i < stats->state_num; i++) {
89 if (len >= PAGE_SIZE) 89 if (len >= PAGE_SIZE)
90 break; 90 break;
91 91
92 len += snprintf(buf + len, PAGE_SIZE - len, "%9u: ", 92 len += snprintf(buf + len, PAGE_SIZE - len, "%9u: ",
93 stat->freq_table[i]); 93 stats->freq_table[i]);
94 94
95 for (j = 0; j < stat->state_num; j++) { 95 for (j = 0; j < stats->state_num; j++) {
96 if (len >= PAGE_SIZE) 96 if (len >= PAGE_SIZE)
97 break; 97 break;
98 len += snprintf(buf + len, PAGE_SIZE - len, "%9u ", 98 len += snprintf(buf + len, PAGE_SIZE - len, "%9u ",
99 stat->trans_table[i*stat->max_state+j]); 99 stats->trans_table[i*stats->max_state+j]);
100 } 100 }
101 if (len >= PAGE_SIZE) 101 if (len >= PAGE_SIZE)
102 break; 102 break;
@@ -125,28 +125,28 @@ static struct attribute_group stats_attr_group = {
125 .name = "stats" 125 .name = "stats"
126}; 126};
127 127
128static int freq_table_get_index(struct cpufreq_stats *stat, unsigned int freq) 128static int freq_table_get_index(struct cpufreq_stats *stats, unsigned int freq)
129{ 129{
130 int index; 130 int index;
131 for (index = 0; index < stat->max_state; index++) 131 for (index = 0; index < stats->max_state; index++)
132 if (stat->freq_table[index] == freq) 132 if (stats->freq_table[index] == freq)
133 return index; 133 return index;
134 return -1; 134 return -1;
135} 135}
136 136
137static void __cpufreq_stats_free_table(struct cpufreq_policy *policy) 137static void __cpufreq_stats_free_table(struct cpufreq_policy *policy)
138{ 138{
139 struct cpufreq_stats *stat = policy->stats; 139 struct cpufreq_stats *stats = policy->stats;
140 140
141 /* Already freed */ 141 /* Already freed */
142 if (!stat) 142 if (!stats)
143 return; 143 return;
144 144
145 pr_debug("%s: Free stat table\n", __func__); 145 pr_debug("%s: Free stats table\n", __func__);
146 146
147 sysfs_remove_group(&policy->kobj, &stats_attr_group); 147 sysfs_remove_group(&policy->kobj, &stats_attr_group);
148 kfree(stat->time_in_state); 148 kfree(stats->time_in_state);
149 kfree(stat); 149 kfree(stats);
150 policy->stats = NULL; 150 policy->stats = NULL;
151} 151}
152 152
@@ -166,7 +166,7 @@ static void cpufreq_stats_free_table(unsigned int cpu)
166static int __cpufreq_stats_create_table(struct cpufreq_policy *policy) 166static int __cpufreq_stats_create_table(struct cpufreq_policy *policy)
167{ 167{
168 unsigned int i, count = 0, ret = 0; 168 unsigned int i, count = 0, ret = 0;
169 struct cpufreq_stats *stat; 169 struct cpufreq_stats *stats;
170 unsigned int alloc_size; 170 unsigned int alloc_size;
171 unsigned int cpu = policy->cpu; 171 unsigned int cpu = policy->cpu;
172 struct cpufreq_frequency_table *pos, *table; 172 struct cpufreq_frequency_table *pos, *table;
@@ -179,16 +179,16 @@ static int __cpufreq_stats_create_table(struct cpufreq_policy *policy)
179 if (policy->stats) 179 if (policy->stats)
180 return -EEXIST; 180 return -EEXIST;
181 181
182 stat = kzalloc(sizeof(*stat), GFP_KERNEL); 182 stats = kzalloc(sizeof(*stats), GFP_KERNEL);
183 if ((stat) == NULL) 183 if ((stats) == NULL)
184 return -ENOMEM; 184 return -ENOMEM;
185 185
186 ret = sysfs_create_group(&policy->kobj, &stats_attr_group); 186 ret = sysfs_create_group(&policy->kobj, &stats_attr_group);
187 if (ret) 187 if (ret)
188 goto error_out; 188 goto error_out;
189 189
190 stat->cpu = cpu; 190 stats->cpu = cpu;
191 policy->stats = stat; 191 policy->stats = stats;
192 192
193 cpufreq_for_each_valid_entry(pos, table) 193 cpufreq_for_each_valid_entry(pos, table)
194 count++; 194 count++;
@@ -198,31 +198,31 @@ static int __cpufreq_stats_create_table(struct cpufreq_policy *policy)
198#ifdef CONFIG_CPU_FREQ_STAT_DETAILS 198#ifdef CONFIG_CPU_FREQ_STAT_DETAILS
199 alloc_size += count * count * sizeof(int); 199 alloc_size += count * count * sizeof(int);
200#endif 200#endif
201 stat->max_state = count; 201 stats->max_state = count;
202 stat->time_in_state = kzalloc(alloc_size, GFP_KERNEL); 202 stats->time_in_state = kzalloc(alloc_size, GFP_KERNEL);
203 if (!stat->time_in_state) { 203 if (!stats->time_in_state) {
204 ret = -ENOMEM; 204 ret = -ENOMEM;
205 goto error_alloc; 205 goto error_alloc;
206 } 206 }
207 stat->freq_table = (unsigned int *)(stat->time_in_state + count); 207 stats->freq_table = (unsigned int *)(stats->time_in_state + count);
208 208
209#ifdef CONFIG_CPU_FREQ_STAT_DETAILS 209#ifdef CONFIG_CPU_FREQ_STAT_DETAILS
210 stat->trans_table = stat->freq_table + count; 210 stats->trans_table = stats->freq_table + count;
211#endif 211#endif
212 i = 0; 212 i = 0;
213 cpufreq_for_each_valid_entry(pos, table) 213 cpufreq_for_each_valid_entry(pos, table)
214 if (freq_table_get_index(stat, pos->frequency) == -1) 214 if (freq_table_get_index(stats, pos->frequency) == -1)
215 stat->freq_table[i++] = pos->frequency; 215 stats->freq_table[i++] = pos->frequency;
216 stat->state_num = i; 216 stats->state_num = i;
217 spin_lock(&cpufreq_stats_lock); 217 spin_lock(&cpufreq_stats_lock);
218 stat->last_time = get_jiffies_64(); 218 stats->last_time = get_jiffies_64();
219 stat->last_index = freq_table_get_index(stat, policy->cur); 219 stats->last_index = freq_table_get_index(stats, policy->cur);
220 spin_unlock(&cpufreq_stats_lock); 220 spin_unlock(&cpufreq_stats_lock);
221 return 0; 221 return 0;
222error_alloc: 222error_alloc:
223 sysfs_remove_group(&policy->kobj, &stats_attr_group); 223 sysfs_remove_group(&policy->kobj, &stats_attr_group);
224error_out: 224error_out:
225 kfree(stat); 225 kfree(stats);
226 policy->stats = NULL; 226 policy->stats = NULL;
227 return ret; 227 return ret;
228} 228}
@@ -273,7 +273,7 @@ static int cpufreq_stat_notifier_trans(struct notifier_block *nb,
273{ 273{
274 struct cpufreq_freqs *freq = data; 274 struct cpufreq_freqs *freq = data;
275 struct cpufreq_policy *policy = cpufreq_cpu_get(freq->cpu); 275 struct cpufreq_policy *policy = cpufreq_cpu_get(freq->cpu);
276 struct cpufreq_stats *stat; 276 struct cpufreq_stats *stats;
277 int old_index, new_index; 277 int old_index, new_index;
278 278
279 if (!policy) { 279 if (!policy) {
@@ -289,26 +289,26 @@ static int cpufreq_stat_notifier_trans(struct notifier_block *nb,
289 goto put_policy; 289 goto put_policy;
290 } 290 }
291 291
292 stat = policy->stats; 292 stats = policy->stats;
293 293
294 old_index = stat->last_index; 294 old_index = stats->last_index;
295 new_index = freq_table_get_index(stat, freq->new); 295 new_index = freq_table_get_index(stats, freq->new);
296 296
297 /* We can't do stat->time_in_state[-1]= .. */ 297 /* We can't do stats->time_in_state[-1]= .. */
298 if (old_index == -1 || new_index == -1) 298 if (old_index == -1 || new_index == -1)
299 goto put_policy; 299 goto put_policy;
300 300
301 cpufreq_stats_update(stat); 301 cpufreq_stats_update(stats);
302 302
303 if (old_index == new_index) 303 if (old_index == new_index)
304 goto put_policy; 304 goto put_policy;
305 305
306 spin_lock(&cpufreq_stats_lock); 306 spin_lock(&cpufreq_stats_lock);
307 stat->last_index = new_index; 307 stats->last_index = new_index;
308#ifdef CONFIG_CPU_FREQ_STAT_DETAILS 308#ifdef CONFIG_CPU_FREQ_STAT_DETAILS
309 stat->trans_table[old_index * stat->max_state + new_index]++; 309 stats->trans_table[old_index * stats->max_state + new_index]++;
310#endif 310#endif
311 stat->total_trans++; 311 stats->total_trans++;
312 spin_unlock(&cpufreq_stats_lock); 312 spin_unlock(&cpufreq_stats_lock);
313 313
314put_policy: 314put_policy: