Skip to content

Commit cc74998

Browse files
Jean Pihetrjwysocki
authored andcommitted
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>
1 parent e8db0be commit cc74998

6 files changed

Lines changed: 59 additions & 59 deletions

File tree

‎drivers/media/video/via-camera.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ struct via_camera {
6969
struct mutex lock;
7070
enum viacam_opstate opstate;
7171
unsigned long flags;
72-
struct pm_qos_request_list qos_request;
72+
struct pm_qos_request qos_request;
7373
/*
7474
* GPIO info for power/reset management
7575
*/

‎drivers/net/wireless/ipw2x00/ipw2100.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ that only one external action is invoked at a time.
174174
#define DRV_DESCRIPTION "Intel(R) PRO/Wireless 2100 Network Driver"
175175
#define DRV_COPYRIGHT "Copyright(c) 2003-2006 Intel Corporation"
176176

177-
static struct pm_qos_request_list ipw2100_pm_qos_req;
177+
static struct pm_qos_request ipw2100_pm_qos_req;
178178

179179
/* Debugging stuff */
180180
#ifdef CONFIG_IPW2100_DEBUG

‎include/linux/netdevice.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -964,7 +964,7 @@ struct net_device {
964964
*/
965965
char name[IFNAMSIZ];
966966

967-
struct pm_qos_request_list pm_qos_req;
967+
struct pm_qos_request pm_qos_req;
968968

969969
/* device name hash chain */
970970
struct hlist_node name_hlist;

‎include/linux/pm_qos.h‎

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,30 +20,30 @@
2020
#define PM_QOS_NETWORK_LAT_DEFAULT_VALUE (2000 * USEC_PER_SEC)
2121
#define PM_QOS_NETWORK_THROUGHPUT_DEFAULT_VALUE 0
2222

23-
struct pm_qos_request_list {
24-
struct plist_node list;
23+
struct pm_qos_request {
24+
struct plist_node node;
2525
int pm_qos_class;
2626
};
2727

2828
#ifdef CONFIG_PM
29-
void pm_qos_add_request(struct pm_qos_request_list *l,
30-
int pm_qos_class, s32 value);
31-
void pm_qos_update_request(struct pm_qos_request_list *pm_qos_req,
29+
void pm_qos_add_request(struct pm_qos_request *req, int pm_qos_class,
30+
s32 value);
31+
void pm_qos_update_request(struct pm_qos_request *req,
3232
s32 new_value);
33-
void pm_qos_remove_request(struct pm_qos_request_list *pm_qos_req);
33+
void pm_qos_remove_request(struct pm_qos_request *req);
3434

3535
int pm_qos_request(int pm_qos_class);
3636
int pm_qos_add_notifier(int pm_qos_class, struct notifier_block *notifier);
3737
int pm_qos_remove_notifier(int pm_qos_class, struct notifier_block *notifier);
38-
int pm_qos_request_active(struct pm_qos_request_list *req);
38+
int pm_qos_request_active(struct pm_qos_request *req);
3939
#else
40-
static inline void pm_qos_add_request(struct pm_qos_request_list *l,
40+
static inline void pm_qos_add_request(struct pm_qos_request *req,
4141
int pm_qos_class, s32 value)
4242
{ return; }
43-
static inline void pm_qos_update_request(struct pm_qos_request_list *pm_qos_req,
43+
static inline void pm_qos_update_request(struct pm_qos_request *req,
4444
s32 new_value)
4545
{ return; }
46-
static inline void pm_qos_remove_request(struct pm_qos_request_list *pm_qos_req)
46+
static inline void pm_qos_remove_request(struct pm_qos_request *req)
4747
{ return; }
4848

4949
static inline int pm_qos_request(int pm_qos_class)
@@ -54,7 +54,7 @@ static inline int pm_qos_add_notifier(int pm_qos_class,
5454
static inline int pm_qos_remove_notifier(int pm_qos_class,
5555
struct notifier_block *notifier)
5656
{ return 0; }
57-
static inline int pm_qos_request_active(struct pm_qos_request_list *req)
57+
static inline int pm_qos_request_active(struct pm_qos_request *req)
5858
{ return 0; }
5959
#endif
6060

‎include/sound/pcm.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -373,7 +373,7 @@ struct snd_pcm_substream {
373373
int number;
374374
char name[32]; /* substream name */
375375
int stream; /* stream (direction) */
376-
struct pm_qos_request_list latency_pm_qos_req; /* pm_qos request */
376+
struct pm_qos_request latency_pm_qos_req; /* pm_qos request */
377377
size_t buffer_bytes_max; /* limit ring buffer size */
378378
struct snd_dma_buffer dma_buffer;
379379
unsigned int dma_buf_id;

‎kernel/power/qos.c‎

Lines changed: 44 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
#include <linux/uaccess.h>
4646

4747
/*
48-
* locking rule: all changes to requests or notifiers lists
48+
* locking rule: all changes to constraints or notifiers lists
4949
* or pm_qos_object list and pm_qos_objects need to happen with pm_qos_lock
5050
* held, taken with _irqsave. One lock to rule them all
5151
*/
@@ -60,7 +60,7 @@ enum pm_qos_type {
6060
* types linux supports for 32 bit quantites
6161
*/
6262
struct pm_qos_object {
63-
struct plist_head requests;
63+
struct plist_head constraints;
6464
struct blocking_notifier_head *notifiers;
6565
struct miscdevice pm_qos_power_miscdev;
6666
char *name;
@@ -74,7 +74,7 @@ static DEFINE_SPINLOCK(pm_qos_lock);
7474
static struct pm_qos_object null_pm_qos;
7575
static BLOCKING_NOTIFIER_HEAD(cpu_dma_lat_notifier);
7676
static 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),
7878
.notifiers = &cpu_dma_lat_notifier,
7979
.name = "cpu_dma_latency",
8080
.target_value = PM_QOS_CPU_DMA_LAT_DEFAULT_VALUE,
@@ -84,7 +84,7 @@ static struct pm_qos_object cpu_dma_pm_qos = {
8484

8585
static BLOCKING_NOTIFIER_HEAD(network_lat_notifier);
8686
static 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),
8888
.notifiers = &network_lat_notifier,
8989
.name = "network_latency",
9090
.target_value = PM_QOS_NETWORK_LAT_DEFAULT_VALUE,
@@ -95,7 +95,7 @@ static struct pm_qos_object network_lat_pm_qos = {
9595

9696
static BLOCKING_NOTIFIER_HEAD(network_throughput_notifier);
9797
static 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),
9999
.notifiers = &network_throughput_notifier,
100100
.name = "network_throughput",
101101
.target_value = PM_QOS_NETWORK_THROUGHPUT_DEFAULT_VALUE,
@@ -129,15 +129,15 @@ static const struct file_operations pm_qos_power_fops = {
129129
/* unlocked internal variant */
130130
static inline int pm_qos_get_value(struct pm_qos_object *o)
131131
{
132-
if (plist_head_empty(&o->requests))
132+
if (plist_head_empty(&o->constraints))
133133
return o->default_value;
134134

135135
switch (o->type) {
136136
case PM_QOS_MIN:
137-
return plist_first(&o->requests)->prio;
137+
return plist_first(&o->constraints)->prio;
138138

139139
case PM_QOS_MAX:
140-
return plist_last(&o->requests)->prio;
140+
return plist_last(&o->constraints)->prio;
141141

142142
default:
143143
/* runtime check for not using enum */
@@ -170,13 +170,13 @@ static void update_target(struct pm_qos_object *o, struct plist_node *node,
170170
* with new value and add, then see if the extremal
171171
* changed
172172
*/
173-
plist_del(node, &o->requests);
173+
plist_del(node, &o->constraints);
174174
plist_node_init(node, value);
175-
plist_add(node, &o->requests);
175+
plist_add(node, &o->constraints);
176176
} else if (del) {
177-
plist_del(node, &o->requests);
177+
plist_del(node, &o->constraints);
178178
} else {
179-
plist_add(node, &o->requests);
179+
plist_add(node, &o->constraints);
180180
}
181181
curr_value = pm_qos_get_value(o);
182182
pm_qos_set_value(o, curr_value);
@@ -222,105 +222,105 @@ int pm_qos_request(int pm_qos_class)
222222
}
223223
EXPORT_SYMBOL_GPL(pm_qos_request);
224224

225-
int pm_qos_request_active(struct pm_qos_request_list *req)
225+
int pm_qos_request_active(struct pm_qos_request *req)
226226
{
227227
return req->pm_qos_class != 0;
228228
}
229229
EXPORT_SYMBOL_GPL(pm_qos_request_active);
230230

231231
/**
232232
* 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
234234
* @pm_qos_class: identifies which list of qos request to use
235235
* @value: defines the qos request
236236
*
237237
* This function inserts a new entry in the pm_qos_class list of requested qos
238238
* 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
240240
* handle. Caller needs to save this handle for later use in updates and
241241
* removal.
242242
*/
243243

244-
void pm_qos_add_request(struct pm_qos_request_list *dep,
244+
void pm_qos_add_request(struct pm_qos_request *req,
245245
int pm_qos_class, s32 value)
246246
{
247247
struct pm_qos_object *o = pm_qos_array[pm_qos_class];
248248
int new_value;
249249

250-
if (pm_qos_request_active(dep)) {
250+
if (pm_qos_request_active(req)) {
251251
WARN(1, KERN_ERR "pm_qos_add_request() called for already added request\n");
252252
return;
253253
}
254254
if (value == PM_QOS_DEFAULT_VALUE)
255255
new_value = o->default_value;
256256
else
257257
new_value = value;
258-
plist_node_init(&dep->list, new_value);
259-
dep->pm_qos_class = pm_qos_class;
260-
update_target(o, &dep->list, 0, PM_QOS_DEFAULT_VALUE);
258+
plist_node_init(&req->node, new_value);
259+
req->pm_qos_class = pm_qos_class;
260+
update_target(o, &req->node, 0, PM_QOS_DEFAULT_VALUE);
261261
}
262262
EXPORT_SYMBOL_GPL(pm_qos_add_request);
263263

264264
/**
265265
* 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
267267
* @value: defines the qos request
268268
*
269269
* Updates an existing qos request for the pm_qos_class of parameters along
270270
* with updating the target pm_qos_class value.
271271
*
272272
* Attempts are made to make this code callable on hot code paths.
273273
*/
274-
void pm_qos_update_request(struct pm_qos_request_list *pm_qos_req,
274+
void pm_qos_update_request(struct pm_qos_request *req,
275275
s32 new_value)
276276
{
277277
s32 temp;
278278
struct pm_qos_object *o;
279279

280-
if (!pm_qos_req) /*guard against callers passing in null */
280+
if (!req) /*guard against callers passing in null */
281281
return;
282282

283-
if (!pm_qos_request_active(pm_qos_req)) {
283+
if (!pm_qos_request_active(req)) {
284284
WARN(1, KERN_ERR "pm_qos_update_request() called for unknown object\n");
285285
return;
286286
}
287287

288-
o = pm_qos_array[pm_qos_req->pm_qos_class];
288+
o = pm_qos_array[req->pm_qos_class];
289289

290290
if (new_value == PM_QOS_DEFAULT_VALUE)
291291
temp = o->default_value;
292292
else
293293
temp = new_value;
294294

295-
if (temp != pm_qos_req->list.prio)
296-
update_target(o, &pm_qos_req->list, 0, temp);
295+
if (temp != req->node.prio)
296+
update_target(o, &req->node, 0, temp);
297297
}
298298
EXPORT_SYMBOL_GPL(pm_qos_update_request);
299299

300300
/**
301301
* 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
303303
*
304-
* Will remove pm qos request from the list of requests and
304+
* Will remove pm qos request from the list of constraints and
305305
* recompute the current target value for the pm_qos_class. Call this
306306
* on slow code paths.
307307
*/
308-
void pm_qos_remove_request(struct pm_qos_request_list *pm_qos_req)
308+
void pm_qos_remove_request(struct pm_qos_request *req)
309309
{
310310
struct pm_qos_object *o;
311311

312-
if (pm_qos_req == NULL)
312+
if (req == NULL)
313313
return;
314314
/* silent return to keep pcm code cleaner */
315315

316-
if (!pm_qos_request_active(pm_qos_req)) {
316+
if (!pm_qos_request_active(req)) {
317317
WARN(1, KERN_ERR "pm_qos_remove_request() called for unknown object\n");
318318
return;
319319
}
320320

321-
o = pm_qos_array[pm_qos_req->pm_qos_class];
322-
update_target(o, &pm_qos_req->list, 1, PM_QOS_DEFAULT_VALUE);
323-
memset(pm_qos_req, 0, sizeof(*pm_qos_req));
321+
o = pm_qos_array[req->pm_qos_class];
322+
update_target(o, &req->node, 1, PM_QOS_DEFAULT_VALUE);
323+
memset(req, 0, sizeof(*req));
324324
}
325325
EXPORT_SYMBOL_GPL(pm_qos_remove_request);
326326

@@ -368,7 +368,7 @@ static int pm_qos_power_open(struct inode *inode, struct file *filp)
368368

369369
pm_qos_class = find_pm_qos_object_by_minor(iminor(inode));
370370
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);
372372
if (!req)
373373
return -ENOMEM;
374374

@@ -383,7 +383,7 @@ static int pm_qos_power_open(struct inode *inode, struct file *filp)
383383

384384
static int pm_qos_power_release(struct inode *inode, struct file *filp)
385385
{
386-
struct pm_qos_request_list *req;
386+
struct pm_qos_request *req;
387387

388388
req = filp->private_data;
389389
pm_qos_remove_request(req);
@@ -399,14 +399,14 @@ static ssize_t pm_qos_power_read(struct file *filp, char __user *buf,
399399
s32 value;
400400
unsigned long flags;
401401
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;
403403

404-
if (!pm_qos_req)
404+
if (!req)
405405
return -EINVAL;
406-
if (!pm_qos_request_active(pm_qos_req))
406+
if (!pm_qos_request_active(req))
407407
return -EINVAL;
408408

409-
o = pm_qos_array[pm_qos_req->pm_qos_class];
409+
o = pm_qos_array[req->pm_qos_class];
410410
spin_lock_irqsave(&pm_qos_lock, flags);
411411
value = pm_qos_get_value(o);
412412
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,
418418
size_t count, loff_t *f_pos)
419419
{
420420
s32 value;
421-
struct pm_qos_request_list *pm_qos_req;
421+
struct pm_qos_request *req;
422422

423423
if (count == sizeof(s32)) {
424424
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,
449449
return -EINVAL;
450450
}
451451

452-
pm_qos_req = filp->private_data;
453-
pm_qos_update_request(pm_qos_req, value);
452+
req = filp->private_data;
453+
pm_qos_update_request(req, value);
454454

455455
return count;
456456
}

0 commit comments

Comments
 (0)