aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/power
diff options
context:
space:
mode:
authorJean Pihet <j-pihet@ti.com>2011-08-25 09:35:12 -0400
committerRafael J. Wysocki <rjw@sisk.pl>2011-08-25 09:35:12 -0400
commitcc74998618a66d34651c784dd02412614c3e81cc (patch)
tree6ba8aba112a682039cae003f3bbcc027478ef08c /kernel/power
parente8db0be1245de16a6cc6365506abc392c3c212d4 (diff)
PM QoS: Minor clean-ups
- Misc fixes to improve code readability: * rename struct pm_qos_request_list to struct pm_qos_request, * rename pm_qos_req parameter to req in internal code, consistenly use req in the API parameters, * update the in-kernel API callers to the new parameters names, * rename of fields names (requests, list, node, constraints) Signed-off-by: Jean Pihet <j-pihet@ti.com> Acked-by: markgross <markgross@thegnar.org> Reviewed-by: Kevin Hilman <khilman@ti.com> Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
Diffstat (limited to 'kernel/power')
-rw-r--r--kernel/power/qos.c88
1 files changed, 44 insertions, 44 deletions
diff --git a/kernel/power/qos.c b/kernel/power/qos.c
index 61b47384329e..aa52c44e6080 100644
--- a/kernel/power/qos.c
+++ b/kernel/power/qos.c
@@ -45,7 +45,7 @@
45#include <linux/uaccess.h> 45#include <linux/uaccess.h>
46 46
47/* 47/*
48 * locking rule: all changes to requests or notifiers lists 48 * locking rule: all changes to constraints or notifiers lists
49 * or pm_qos_object list and pm_qos_objects need to happen with pm_qos_lock 49 * or pm_qos_object list and pm_qos_objects need to happen with pm_qos_lock
50 * held, taken with _irqsave. One lock to rule them all 50 * held, taken with _irqsave. One lock to rule them all
51 */ 51 */
@@ -60,7 +60,7 @@ enum pm_qos_type {
60 * types linux supports for 32 bit quantites 60 * types linux supports for 32 bit quantites
61 */ 61 */
62struct pm_qos_object { 62struct pm_qos_object {
63 struct plist_head requests; 63 struct plist_head constraints;
64 struct blocking_notifier_head *notifiers; 64 struct blocking_notifier_head *notifiers;
65 struct miscdevice pm_qos_power_miscdev; 65 struct miscdevice pm_qos_power_miscdev;
66 char *name; 66 char *name;
@@ -74,7 +74,7 @@ static DEFINE_SPINLOCK(pm_qos_lock);
74static struct pm_qos_object null_pm_qos; 74static struct pm_qos_object null_pm_qos;
75static BLOCKING_NOTIFIER_HEAD(cpu_dma_lat_notifier); 75static BLOCKING_NOTIFIER_HEAD(cpu_dma_lat_notifier);
76static struct pm_qos_object cpu_dma_pm_qos = { 76static struct pm_qos_object cpu_dma_pm_qos = {
77 .requests = PLIST_HEAD_INIT(cpu_dma_pm_qos.requests), 77 .constraints = PLIST_HEAD_INIT(cpu_dma_pm_qos.constraints),
78 .notifiers = &cpu_dma_lat_notifier, 78 .notifiers = &cpu_dma_lat_notifier,
79 .name = "cpu_dma_latency", 79 .name = "cpu_dma_latency",
80 .target_value = PM_QOS_CPU_DMA_LAT_DEFAULT_VALUE, 80 .target_value = PM_QOS_CPU_DMA_LAT_DEFAULT_VALUE,
@@ -84,7 +84,7 @@ static struct pm_qos_object cpu_dma_pm_qos = {
84 84
85static BLOCKING_NOTIFIER_HEAD(network_lat_notifier); 85static BLOCKING_NOTIFIER_HEAD(network_lat_notifier);
86static struct pm_qos_object network_lat_pm_qos = { 86static struct pm_qos_object network_lat_pm_qos = {
87 .requests = PLIST_HEAD_INIT(network_lat_pm_qos.requests), 87 .constraints = PLIST_HEAD_INIT(network_lat_pm_qos.constraints),
88 .notifiers = &network_lat_notifier, 88 .notifiers = &network_lat_notifier,
89 .name = "network_latency", 89 .name = "network_latency",
90 .target_value = PM_QOS_NETWORK_LAT_DEFAULT_VALUE, 90 .target_value = PM_QOS_NETWORK_LAT_DEFAULT_VALUE,
@@ -95,7 +95,7 @@ static struct pm_qos_object network_lat_pm_qos = {
95 95
96static BLOCKING_NOTIFIER_HEAD(network_throughput_notifier); 96static BLOCKING_NOTIFIER_HEAD(network_throughput_notifier);
97static struct pm_qos_object network_throughput_pm_qos = { 97static struct pm_qos_object network_throughput_pm_qos = {
98 .requests = PLIST_HEAD_INIT(network_throughput_pm_qos.requests), 98 .constraints = PLIST_HEAD_INIT(network_throughput_pm_qos.constraints),
99 .notifiers = &network_throughput_notifier, 99 .notifiers = &network_throughput_notifier,
100 .name = "network_throughput", 100 .name = "network_throughput",
101 .target_value = PM_QOS_NETWORK_THROUGHPUT_DEFAULT_VALUE, 101 .target_value = PM_QOS_NETWORK_THROUGHPUT_DEFAULT_VALUE,
@@ -129,15 +129,15 @@ static const struct file_operations pm_qos_power_fops = {
129/* unlocked internal variant */ 129/* unlocked internal variant */
130static inline int pm_qos_get_value(struct pm_qos_object *o) 130static inline int pm_qos_get_value(struct pm_qos_object *o)
131{ 131{
132 if (plist_head_empty(&o->requests)) 132 if (plist_head_empty(&o->constraints))
133 return o->default_value; 133 return o->default_value;
134 134
135 switch (o->type) { 135 switch (o->type) {
136 case PM_QOS_MIN: 136 case PM_QOS_MIN:
137 return plist_first(&o->requests)->prio; 137 return plist_first(&o->constraints)->prio;
138 138
139 case PM_QOS_MAX: 139 case PM_QOS_MAX:
140 return plist_last(&o->requests)->prio; 140 return plist_last(&o->constraints)->prio;
141 141
142 default: 142 default:
143 /* runtime check for not using enum */ 143 /* runtime check for not using enum */
@@ -170,13 +170,13 @@ static void update_target(struct pm_qos_object *o, struct plist_node *node,
170 * with new value and add, then see if the extremal 170 * with new value and add, then see if the extremal
171 * changed 171 * changed
172 */ 172 */
173 plist_del(node, &o->requests); 173 plist_del(node, &o->constraints);
174 plist_node_init(node, value); 174 plist_node_init(node, value);
175 plist_add(node, &o->requests); 175 plist_add(node, &o->constraints);
176 } else if (del) { 176 } else if (del) {
177 plist_del(node, &o->requests); 177 plist_del(node, &o->constraints);
178 } else { 178 } else {
179 plist_add(node, &o->requests); 179 plist_add(node, &o->constraints);
180 } 180 }
181 curr_value = pm_qos_get_value(o); 181 curr_value = pm_qos_get_value(o);
182 pm_qos_set_value(o, curr_value); 182 pm_qos_set_value(o, curr_value);
@@ -222,7 +222,7 @@ int pm_qos_request(int pm_qos_class)
222} 222}
223EXPORT_SYMBOL_GPL(pm_qos_request); 223EXPORT_SYMBOL_GPL(pm_qos_request);
224 224
225int pm_qos_request_active(struct pm_qos_request_list *req) 225int pm_qos_request_active(struct pm_qos_request *req)
226{ 226{
227 return req->pm_qos_class != 0; 227 return req->pm_qos_class != 0;
228} 228}
@@ -230,24 +230,24 @@ EXPORT_SYMBOL_GPL(pm_qos_request_active);
230 230
231/** 231/**
232 * pm_qos_add_request - inserts new qos request into the list 232 * pm_qos_add_request - inserts new qos request into the list
233 * @dep: pointer to a preallocated handle 233 * @req: pointer to a preallocated handle
234 * @pm_qos_class: identifies which list of qos request to use 234 * @pm_qos_class: identifies which list of qos request to use
235 * @value: defines the qos request 235 * @value: defines the qos request
236 * 236 *
237 * This function inserts a new entry in the pm_qos_class list of requested qos 237 * This function inserts a new entry in the pm_qos_class list of requested qos
238 * performance characteristics. It recomputes the aggregate QoS expectations 238 * performance characteristics. It recomputes the aggregate QoS expectations
239 * for the pm_qos_class of parameters and initializes the pm_qos_request_list 239 * for the pm_qos_class of parameters and initializes the pm_qos_request
240 * handle. Caller needs to save this handle for later use in updates and 240 * handle. Caller needs to save this handle for later use in updates and
241 * removal. 241 * removal.
242 */ 242 */
243 243
244void pm_qos_add_request(struct pm_qos_request_list *dep, 244void pm_qos_add_request(struct pm_qos_request *req,
245 int pm_qos_class, s32 value) 245 int pm_qos_class, s32 value)
246{ 246{
247 struct pm_qos_object *o = pm_qos_array[pm_qos_class]; 247 struct pm_qos_object *o = pm_qos_array[pm_qos_class];
248 int new_value; 248 int new_value;
249 249
250 if (pm_qos_request_active(dep)) { 250 if (pm_qos_request_active(req)) {
251 WARN(1, KERN_ERR "pm_qos_add_request() called for already added request\n"); 251 WARN(1, KERN_ERR "pm_qos_add_request() called for already added request\n");
252 return; 252 return;
253 } 253 }
@@ -255,15 +255,15 @@ void pm_qos_add_request(struct pm_qos_request_list *dep,
255 new_value = o->default_value; 255 new_value = o->default_value;
256 else 256 else
257 new_value = value; 257 new_value = value;
258 plist_node_init(&dep->list, new_value); 258 plist_node_init(&req->node, new_value);
259 dep->pm_qos_class = pm_qos_class; 259 req->pm_qos_class = pm_qos_class;
260 update_target(o, &dep->list, 0, PM_QOS_DEFAULT_VALUE); 260 update_target(o, &req->node, 0, PM_QOS_DEFAULT_VALUE);
261} 261}
262EXPORT_SYMBOL_GPL(pm_qos_add_request); 262EXPORT_SYMBOL_GPL(pm_qos_add_request);
263 263
264/** 264/**
265 * pm_qos_update_request - modifies an existing qos request 265 * pm_qos_update_request - modifies an existing qos request
266 * @pm_qos_req : handle to list element holding a pm_qos request to use 266 * @req : handle to list element holding a pm_qos request to use
267 * @value: defines the qos request 267 * @value: defines the qos request
268 * 268 *
269 * Updates an existing qos request for the pm_qos_class of parameters along 269 * Updates an existing qos request for the pm_qos_class of parameters along
@@ -271,56 +271,56 @@ EXPORT_SYMBOL_GPL(pm_qos_add_request);
271 * 271 *
272 * Attempts are made to make this code callable on hot code paths. 272 * Attempts are made to make this code callable on hot code paths.
273 */ 273 */
274void pm_qos_update_request(struct pm_qos_request_list *pm_qos_req, 274void pm_qos_update_request(struct pm_qos_request *req,
275 s32 new_value) 275 s32 new_value)
276{ 276{
277 s32 temp; 277 s32 temp;
278 struct pm_qos_object *o; 278 struct pm_qos_object *o;
279 279
280 if (!pm_qos_req) /*guard against callers passing in null */ 280 if (!req) /*guard against callers passing in null */
281 return; 281 return;
282 282
283 if (!pm_qos_request_active(pm_qos_req)) { 283 if (!pm_qos_request_active(req)) {
284 WARN(1, KERN_ERR "pm_qos_update_request() called for unknown object\n"); 284 WARN(1, KERN_ERR "pm_qos_update_request() called for unknown object\n");
285 return; 285 return;
286 } 286 }
287 287
288 o = pm_qos_array[pm_qos_req->pm_qos_class]; 288 o = pm_qos_array[req->pm_qos_class];
289 289
290 if (new_value == PM_QOS_DEFAULT_VALUE) 290 if (new_value == PM_QOS_DEFAULT_VALUE)
291 temp = o->default_value; 291 temp = o->default_value;
292 else 292 else
293 temp = new_value; 293 temp = new_value;
294 294
295 if (temp != pm_qos_req->list.prio) 295 if (temp != req->node.prio)
296 update_target(o, &pm_qos_req->list, 0, temp); 296 update_target(o, &req->node, 0, temp);
297} 297}
298EXPORT_SYMBOL_GPL(pm_qos_update_request); 298EXPORT_SYMBOL_GPL(pm_qos_update_request);
299 299
300/** 300/**
301 * pm_qos_remove_request - modifies an existing qos request 301 * pm_qos_remove_request - modifies an existing qos request
302 * @pm_qos_req: handle to request list element 302 * @req: handle to request list element
303 * 303 *
304 * Will remove pm qos request from the list of requests and 304 * Will remove pm qos request from the list of constraints and
305 * recompute the current target value for the pm_qos_class. Call this 305 * recompute the current target value for the pm_qos_class. Call this
306 * on slow code paths. 306 * on slow code paths.
307 */ 307 */
308void pm_qos_remove_request(struct pm_qos_request_list *pm_qos_req) 308void pm_qos_remove_request(struct pm_qos_request *req)
309{ 309{
310 struct pm_qos_object *o; 310 struct pm_qos_object *o;
311 311
312 if (pm_qos_req == NULL) 312 if (req == NULL)
313 return; 313 return;
314 /* silent return to keep pcm code cleaner */ 314 /* silent return to keep pcm code cleaner */
315 315
316 if (!pm_qos_request_active(pm_qos_req)) { 316 if (!pm_qos_request_active(req)) {
317 WARN(1, KERN_ERR "pm_qos_remove_request() called for unknown object\n"); 317 WARN(1, KERN_ERR "pm_qos_remove_request() called for unknown object\n");
318 return; 318 return;
319 } 319 }
320 320
321 o = pm_qos_array[pm_qos_req->pm_qos_class]; 321 o = pm_qos_array[req->pm_qos_class];
322 update_target(o, &pm_qos_req->list, 1, PM_QOS_DEFAULT_VALUE); 322 update_target(o, &req->node, 1, PM_QOS_DEFAULT_VALUE);
323 memset(pm_qos_req, 0, sizeof(*pm_qos_req)); 323 memset(req, 0, sizeof(*req));
324} 324}
325EXPORT_SYMBOL_GPL(pm_qos_remove_request); 325EXPORT_SYMBOL_GPL(pm_qos_remove_request);
326 326
@@ -368,7 +368,7 @@ static int pm_qos_power_open(struct inode *inode, struct file *filp)
368 368
369 pm_qos_class = find_pm_qos_object_by_minor(iminor(inode)); 369 pm_qos_class = find_pm_qos_object_by_minor(iminor(inode));
370 if (pm_qos_class >= 0) { 370 if (pm_qos_class >= 0) {
371 struct pm_qos_request_list *req = kzalloc(sizeof(*req), GFP_KERNEL); 371 struct pm_qos_request *req = kzalloc(sizeof(*req), GFP_KERNEL);
372 if (!req) 372 if (!req)
373 return -ENOMEM; 373 return -ENOMEM;
374 374
@@ -383,7 +383,7 @@ static int pm_qos_power_open(struct inode *inode, struct file *filp)
383 383
384static int pm_qos_power_release(struct inode *inode, struct file *filp) 384static int pm_qos_power_release(struct inode *inode, struct file *filp)
385{ 385{
386 struct pm_qos_request_list *req; 386 struct pm_qos_request *req;
387 387
388 req = filp->private_data; 388 req = filp->private_data;
389 pm_qos_remove_request(req); 389 pm_qos_remove_request(req);
@@ -399,14 +399,14 @@ static ssize_t pm_qos_power_read(struct file *filp, char __user *buf,
399 s32 value; 399 s32 value;
400 unsigned long flags; 400 unsigned long flags;
401 struct pm_qos_object *o; 401 struct pm_qos_object *o;
402 struct pm_qos_request_list *pm_qos_req = filp->private_data; 402 struct pm_qos_request *req = filp->private_data;
403 403
404 if (!pm_qos_req) 404 if (!req)
405 return -EINVAL; 405 return -EINVAL;
406 if (!pm_qos_request_active(pm_qos_req)) 406 if (!pm_qos_request_active(req))
407 return -EINVAL; 407 return -EINVAL;
408 408
409 o = pm_qos_array[pm_qos_req->pm_qos_class]; 409 o = pm_qos_array[req->pm_qos_class];
410 spin_lock_irqsave(&pm_qos_lock, flags); 410 spin_lock_irqsave(&pm_qos_lock, flags);
411 value = pm_qos_get_value(o); 411 value = pm_qos_get_value(o);
412 spin_unlock_irqrestore(&pm_qos_lock, flags); 412 spin_unlock_irqrestore(&pm_qos_lock, flags);
@@ -418,7 +418,7 @@ static ssize_t pm_qos_power_write(struct file *filp, const char __user *buf,
418 size_t count, loff_t *f_pos) 418 size_t count, loff_t *f_pos)
419{ 419{
420 s32 value; 420 s32 value;
421 struct pm_qos_request_list *pm_qos_req; 421 struct pm_qos_request *req;
422 422
423 if (count == sizeof(s32)) { 423 if (count == sizeof(s32)) {
424 if (copy_from_user(&value, buf, sizeof(s32))) 424 if (copy_from_user(&value, buf, sizeof(s32)))
@@ -449,8 +449,8 @@ static ssize_t pm_qos_power_write(struct file *filp, const char __user *buf,
449 return -EINVAL; 449 return -EINVAL;
450 } 450 }
451 451
452 pm_qos_req = filp->private_data; 452 req = filp->private_data;
453 pm_qos_update_request(pm_qos_req, value); 453 pm_qos_update_request(req, value);
454 454
455 return count; 455 return count;
456} 456}