aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/base
diff options
context:
space:
mode:
authorAndy Shevchenko <andriy.shevchenko@linux.intel.com>2017-11-10 13:28:09 -0500
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>2017-12-04 19:59:57 -0500
commit47acbd77e6e481abf2f41d3a99cb3762f296b2e6 (patch)
tree41690117be3fa2d3718cb5db0837f6a119301fc9 /drivers/base
parentf0e6d9f164c2269df69b6d2fe05c285392a6a0d4 (diff)
PM / sysfs: Convert to use DEVICE_ATTR_RO / DEVICE_ATTR_RW
Use DEVICE_ATTR_RO() and DEVICE_ATTR_RW() macros instead of open coding them. No functional change intended. Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Acked-by: Pavel Machek <pavel@ucw.cz> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Diffstat (limited to 'drivers/base')
-rw-r--r--drivers/base/power/sysfs.c133
1 files changed, 65 insertions, 68 deletions
diff --git a/drivers/base/power/sysfs.c b/drivers/base/power/sysfs.c
index 1bf5e163ef1f..0f651efc58a1 100644
--- a/drivers/base/power/sysfs.c
+++ b/drivers/base/power/sysfs.c
@@ -119,9 +119,9 @@ static ssize_t control_store(struct device * dev, struct device_attribute *attr,
119 return n; 119 return n;
120} 120}
121 121
122static DEVICE_ATTR(control, 0644, control_show, control_store); 122static DEVICE_ATTR_RW(control);
123 123
124static ssize_t rtpm_active_time_show(struct device *dev, 124static ssize_t runtime_active_time_show(struct device *dev,
125 struct device_attribute *attr, char *buf) 125 struct device_attribute *attr, char *buf)
126{ 126{
127 int ret; 127 int ret;
@@ -132,9 +132,9 @@ static ssize_t rtpm_active_time_show(struct device *dev,
132 return ret; 132 return ret;
133} 133}
134 134
135static DEVICE_ATTR(runtime_active_time, 0444, rtpm_active_time_show, NULL); 135static DEVICE_ATTR_RO(runtime_active_time);
136 136
137static ssize_t rtpm_suspended_time_show(struct device *dev, 137static ssize_t runtime_suspended_time_show(struct device *dev,
138 struct device_attribute *attr, char *buf) 138 struct device_attribute *attr, char *buf)
139{ 139{
140 int ret; 140 int ret;
@@ -146,9 +146,9 @@ static ssize_t rtpm_suspended_time_show(struct device *dev,
146 return ret; 146 return ret;
147} 147}
148 148
149static DEVICE_ATTR(runtime_suspended_time, 0444, rtpm_suspended_time_show, NULL); 149static DEVICE_ATTR_RO(runtime_suspended_time);
150 150
151static ssize_t rtpm_status_show(struct device *dev, 151static ssize_t runtime_status_show(struct device *dev,
152 struct device_attribute *attr, char *buf) 152 struct device_attribute *attr, char *buf)
153{ 153{
154 const char *p; 154 const char *p;
@@ -178,7 +178,7 @@ static ssize_t rtpm_status_show(struct device *dev,
178 return sprintf(buf, p); 178 return sprintf(buf, p);
179} 179}
180 180
181static DEVICE_ATTR(runtime_status, 0444, rtpm_status_show, NULL); 181static DEVICE_ATTR_RO(runtime_status);
182 182
183static ssize_t autosuspend_delay_ms_show(struct device *dev, 183static ssize_t autosuspend_delay_ms_show(struct device *dev,
184 struct device_attribute *attr, char *buf) 184 struct device_attribute *attr, char *buf)
@@ -205,12 +205,11 @@ static ssize_t autosuspend_delay_ms_store(struct device *dev,
205 return n; 205 return n;
206} 206}
207 207
208static DEVICE_ATTR(autosuspend_delay_ms, 0644, autosuspend_delay_ms_show, 208static DEVICE_ATTR_RW(autosuspend_delay_ms);
209 autosuspend_delay_ms_store);
210 209
211static ssize_t pm_qos_resume_latency_show(struct device *dev, 210static ssize_t pm_qos_resume_latency_us_show(struct device *dev,
212 struct device_attribute *attr, 211 struct device_attribute *attr,
213 char *buf) 212 char *buf)
214{ 213{
215 s32 value = dev_pm_qos_requested_resume_latency(dev); 214 s32 value = dev_pm_qos_requested_resume_latency(dev);
216 215
@@ -222,9 +221,9 @@ static ssize_t pm_qos_resume_latency_show(struct device *dev,
222 return sprintf(buf, "%d\n", value); 221 return sprintf(buf, "%d\n", value);
223} 222}
224 223
225static ssize_t pm_qos_resume_latency_store(struct device *dev, 224static ssize_t pm_qos_resume_latency_us_store(struct device *dev,
226 struct device_attribute *attr, 225 struct device_attribute *attr,
227 const char *buf, size_t n) 226 const char *buf, size_t n)
228{ 227{
229 s32 value; 228 s32 value;
230 int ret; 229 int ret;
@@ -250,12 +249,11 @@ static ssize_t pm_qos_resume_latency_store(struct device *dev,
250 return ret < 0 ? ret : n; 249 return ret < 0 ? ret : n;
251} 250}
252 251
253static DEVICE_ATTR(pm_qos_resume_latency_us, 0644, 252static DEVICE_ATTR_RW(pm_qos_resume_latency_us);
254 pm_qos_resume_latency_show, pm_qos_resume_latency_store);
255 253
256static ssize_t pm_qos_latency_tolerance_show(struct device *dev, 254static ssize_t pm_qos_latency_tolerance_us_show(struct device *dev,
257 struct device_attribute *attr, 255 struct device_attribute *attr,
258 char *buf) 256 char *buf)
259{ 257{
260 s32 value = dev_pm_qos_get_user_latency_tolerance(dev); 258 s32 value = dev_pm_qos_get_user_latency_tolerance(dev);
261 259
@@ -267,9 +265,9 @@ static ssize_t pm_qos_latency_tolerance_show(struct device *dev,
267 return sprintf(buf, "%d\n", value); 265 return sprintf(buf, "%d\n", value);
268} 266}
269 267
270static ssize_t pm_qos_latency_tolerance_store(struct device *dev, 268static ssize_t pm_qos_latency_tolerance_us_store(struct device *dev,
271 struct device_attribute *attr, 269 struct device_attribute *attr,
272 const char *buf, size_t n) 270 const char *buf, size_t n)
273{ 271{
274 s32 value; 272 s32 value;
275 int ret; 273 int ret;
@@ -290,8 +288,7 @@ static ssize_t pm_qos_latency_tolerance_store(struct device *dev,
290 return ret < 0 ? ret : n; 288 return ret < 0 ? ret : n;
291} 289}
292 290
293static DEVICE_ATTR(pm_qos_latency_tolerance_us, 0644, 291static DEVICE_ATTR_RW(pm_qos_latency_tolerance_us);
294 pm_qos_latency_tolerance_show, pm_qos_latency_tolerance_store);
295 292
296static ssize_t pm_qos_no_power_off_show(struct device *dev, 293static ssize_t pm_qos_no_power_off_show(struct device *dev,
297 struct device_attribute *attr, 294 struct device_attribute *attr,
@@ -317,24 +314,22 @@ static ssize_t pm_qos_no_power_off_store(struct device *dev,
317 return ret < 0 ? ret : n; 314 return ret < 0 ? ret : n;
318} 315}
319 316
320static DEVICE_ATTR(pm_qos_no_power_off, 0644, 317static DEVICE_ATTR_RW(pm_qos_no_power_off);
321 pm_qos_no_power_off_show, pm_qos_no_power_off_store);
322 318
323#ifdef CONFIG_PM_SLEEP 319#ifdef CONFIG_PM_SLEEP
324static const char _enabled[] = "enabled"; 320static const char _enabled[] = "enabled";
325static const char _disabled[] = "disabled"; 321static const char _disabled[] = "disabled";
326 322
327static ssize_t 323static ssize_t wakeup_show(struct device *dev, struct device_attribute *attr,
328wake_show(struct device * dev, struct device_attribute *attr, char * buf) 324 char *buf)
329{ 325{
330 return sprintf(buf, "%s\n", device_can_wakeup(dev) 326 return sprintf(buf, "%s\n", device_can_wakeup(dev)
331 ? (device_may_wakeup(dev) ? _enabled : _disabled) 327 ? (device_may_wakeup(dev) ? _enabled : _disabled)
332 : ""); 328 : "");
333} 329}
334 330
335static ssize_t 331static ssize_t wakeup_store(struct device *dev, struct device_attribute *attr,
336wake_store(struct device * dev, struct device_attribute *attr, 332 const char *buf, size_t n)
337 const char * buf, size_t n)
338{ 333{
339 if (!device_can_wakeup(dev)) 334 if (!device_can_wakeup(dev))
340 return -EINVAL; 335 return -EINVAL;
@@ -348,10 +343,10 @@ wake_store(struct device * dev, struct device_attribute *attr,
348 return n; 343 return n;
349} 344}
350 345
351static DEVICE_ATTR(wakeup, 0644, wake_show, wake_store); 346static DEVICE_ATTR_RW(wakeup);
352 347
353static ssize_t wakeup_count_show(struct device *dev, 348static ssize_t wakeup_count_show(struct device *dev,
354 struct device_attribute *attr, char *buf) 349 struct device_attribute *attr, char *buf)
355{ 350{
356 unsigned long count = 0; 351 unsigned long count = 0;
357 bool enabled = false; 352 bool enabled = false;
@@ -365,10 +360,11 @@ static ssize_t wakeup_count_show(struct device *dev,
365 return enabled ? sprintf(buf, "%lu\n", count) : sprintf(buf, "\n"); 360 return enabled ? sprintf(buf, "%lu\n", count) : sprintf(buf, "\n");
366} 361}
367 362
368static DEVICE_ATTR(wakeup_count, 0444, wakeup_count_show, NULL); 363static DEVICE_ATTR_RO(wakeup_count);
369 364
370static ssize_t wakeup_active_count_show(struct device *dev, 365static ssize_t wakeup_active_count_show(struct device *dev,
371 struct device_attribute *attr, char *buf) 366 struct device_attribute *attr,
367 char *buf)
372{ 368{
373 unsigned long count = 0; 369 unsigned long count = 0;
374 bool enabled = false; 370 bool enabled = false;
@@ -382,11 +378,11 @@ static ssize_t wakeup_active_count_show(struct device *dev,
382 return enabled ? sprintf(buf, "%lu\n", count) : sprintf(buf, "\n"); 378 return enabled ? sprintf(buf, "%lu\n", count) : sprintf(buf, "\n");
383} 379}
384 380
385static DEVICE_ATTR(wakeup_active_count, 0444, wakeup_active_count_show, NULL); 381static DEVICE_ATTR_RO(wakeup_active_count);
386 382
387static ssize_t wakeup_abort_count_show(struct device *dev, 383static ssize_t wakeup_abort_count_show(struct device *dev,
388 struct device_attribute *attr, 384 struct device_attribute *attr,
389 char *buf) 385 char *buf)
390{ 386{
391 unsigned long count = 0; 387 unsigned long count = 0;
392 bool enabled = false; 388 bool enabled = false;
@@ -400,7 +396,7 @@ static ssize_t wakeup_abort_count_show(struct device *dev,
400 return enabled ? sprintf(buf, "%lu\n", count) : sprintf(buf, "\n"); 396 return enabled ? sprintf(buf, "%lu\n", count) : sprintf(buf, "\n");
401} 397}
402 398
403static DEVICE_ATTR(wakeup_abort_count, 0444, wakeup_abort_count_show, NULL); 399static DEVICE_ATTR_RO(wakeup_abort_count);
404 400
405static ssize_t wakeup_expire_count_show(struct device *dev, 401static ssize_t wakeup_expire_count_show(struct device *dev,
406 struct device_attribute *attr, 402 struct device_attribute *attr,
@@ -418,10 +414,10 @@ static ssize_t wakeup_expire_count_show(struct device *dev,
418 return enabled ? sprintf(buf, "%lu\n", count) : sprintf(buf, "\n"); 414 return enabled ? sprintf(buf, "%lu\n", count) : sprintf(buf, "\n");
419} 415}
420 416
421static DEVICE_ATTR(wakeup_expire_count, 0444, wakeup_expire_count_show, NULL); 417static DEVICE_ATTR_RO(wakeup_expire_count);
422 418
423static ssize_t wakeup_active_show(struct device *dev, 419static ssize_t wakeup_active_show(struct device *dev,
424 struct device_attribute *attr, char *buf) 420 struct device_attribute *attr, char *buf)
425{ 421{
426 unsigned int active = 0; 422 unsigned int active = 0;
427 bool enabled = false; 423 bool enabled = false;
@@ -435,10 +431,11 @@ static ssize_t wakeup_active_show(struct device *dev,
435 return enabled ? sprintf(buf, "%u\n", active) : sprintf(buf, "\n"); 431 return enabled ? sprintf(buf, "%u\n", active) : sprintf(buf, "\n");
436} 432}
437 433
438static DEVICE_ATTR(wakeup_active, 0444, wakeup_active_show, NULL); 434static DEVICE_ATTR_RO(wakeup_active);
439 435
440static ssize_t wakeup_total_time_show(struct device *dev, 436static ssize_t wakeup_total_time_ms_show(struct device *dev,
441 struct device_attribute *attr, char *buf) 437 struct device_attribute *attr,
438 char *buf)
442{ 439{
443 s64 msec = 0; 440 s64 msec = 0;
444 bool enabled = false; 441 bool enabled = false;
@@ -452,10 +449,10 @@ static ssize_t wakeup_total_time_show(struct device *dev,
452 return enabled ? sprintf(buf, "%lld\n", msec) : sprintf(buf, "\n"); 449 return enabled ? sprintf(buf, "%lld\n", msec) : sprintf(buf, "\n");
453} 450}
454 451
455static DEVICE_ATTR(wakeup_total_time_ms, 0444, wakeup_total_time_show, NULL); 452static DEVICE_ATTR_RO(wakeup_total_time_ms);
456 453
457static ssize_t wakeup_max_time_show(struct device *dev, 454static ssize_t wakeup_max_time_ms_show(struct device *dev,
458 struct device_attribute *attr, char *buf) 455 struct device_attribute *attr, char *buf)
459{ 456{
460 s64 msec = 0; 457 s64 msec = 0;
461 bool enabled = false; 458 bool enabled = false;
@@ -469,10 +466,11 @@ static ssize_t wakeup_max_time_show(struct device *dev,
469 return enabled ? sprintf(buf, "%lld\n", msec) : sprintf(buf, "\n"); 466 return enabled ? sprintf(buf, "%lld\n", msec) : sprintf(buf, "\n");
470} 467}
471 468
472static DEVICE_ATTR(wakeup_max_time_ms, 0444, wakeup_max_time_show, NULL); 469static DEVICE_ATTR_RO(wakeup_max_time_ms);
473 470
474static ssize_t wakeup_last_time_show(struct device *dev, 471static ssize_t wakeup_last_time_ms_show(struct device *dev,
475 struct device_attribute *attr, char *buf) 472 struct device_attribute *attr,
473 char *buf)
476{ 474{
477 s64 msec = 0; 475 s64 msec = 0;
478 bool enabled = false; 476 bool enabled = false;
@@ -486,12 +484,12 @@ static ssize_t wakeup_last_time_show(struct device *dev,
486 return enabled ? sprintf(buf, "%lld\n", msec) : sprintf(buf, "\n"); 484 return enabled ? sprintf(buf, "%lld\n", msec) : sprintf(buf, "\n");
487} 485}
488 486
489static DEVICE_ATTR(wakeup_last_time_ms, 0444, wakeup_last_time_show, NULL); 487static DEVICE_ATTR_RO(wakeup_last_time_ms);
490 488
491#ifdef CONFIG_PM_AUTOSLEEP 489#ifdef CONFIG_PM_AUTOSLEEP
492static ssize_t wakeup_prevent_sleep_time_show(struct device *dev, 490static ssize_t wakeup_prevent_sleep_time_ms_show(struct device *dev,
493 struct device_attribute *attr, 491 struct device_attribute *attr,
494 char *buf) 492 char *buf)
495{ 493{
496 s64 msec = 0; 494 s64 msec = 0;
497 bool enabled = false; 495 bool enabled = false;
@@ -505,27 +503,29 @@ static ssize_t wakeup_prevent_sleep_time_show(struct device *dev,
505 return enabled ? sprintf(buf, "%lld\n", msec) : sprintf(buf, "\n"); 503 return enabled ? sprintf(buf, "%lld\n", msec) : sprintf(buf, "\n");
506} 504}
507 505
508static DEVICE_ATTR(wakeup_prevent_sleep_time_ms, 0444, 506static DEVICE_ATTR_RO(wakeup_prevent_sleep_time_ms);
509 wakeup_prevent_sleep_time_show, NULL);
510#endif /* CONFIG_PM_AUTOSLEEP */ 507#endif /* CONFIG_PM_AUTOSLEEP */
511#endif /* CONFIG_PM_SLEEP */ 508#endif /* CONFIG_PM_SLEEP */
512 509
513#ifdef CONFIG_PM_ADVANCED_DEBUG 510#ifdef CONFIG_PM_ADVANCED_DEBUG
514static ssize_t rtpm_usagecount_show(struct device *dev, 511static ssize_t runtime_usage_show(struct device *dev,
515 struct device_attribute *attr, char *buf) 512 struct device_attribute *attr, char *buf)
516{ 513{
517 return sprintf(buf, "%d\n", atomic_read(&dev->power.usage_count)); 514 return sprintf(buf, "%d\n", atomic_read(&dev->power.usage_count));
518} 515}
516static DEVICE_ATTR_RO(runtime_usage);
519 517
520static ssize_t rtpm_children_show(struct device *dev, 518static ssize_t runtime_active_kids_show(struct device *dev,
521 struct device_attribute *attr, char *buf) 519 struct device_attribute *attr,
520 char *buf)
522{ 521{
523 return sprintf(buf, "%d\n", dev->power.ignore_children ? 522 return sprintf(buf, "%d\n", dev->power.ignore_children ?
524 0 : atomic_read(&dev->power.child_count)); 523 0 : atomic_read(&dev->power.child_count));
525} 524}
525static DEVICE_ATTR_RO(runtime_active_kids);
526 526
527static ssize_t rtpm_enabled_show(struct device *dev, 527static ssize_t runtime_enabled_show(struct device *dev,
528 struct device_attribute *attr, char *buf) 528 struct device_attribute *attr, char *buf)
529{ 529{
530 if (dev->power.disable_depth && (dev->power.runtime_auto == false)) 530 if (dev->power.disable_depth && (dev->power.runtime_auto == false))
531 return sprintf(buf, "disabled & forbidden\n"); 531 return sprintf(buf, "disabled & forbidden\n");
@@ -535,10 +535,7 @@ static ssize_t rtpm_enabled_show(struct device *dev,
535 return sprintf(buf, "forbidden\n"); 535 return sprintf(buf, "forbidden\n");
536 return sprintf(buf, "enabled\n"); 536 return sprintf(buf, "enabled\n");
537} 537}
538 538static DEVICE_ATTR_RO(runtime_enabled);
539static DEVICE_ATTR(runtime_usage, 0444, rtpm_usagecount_show, NULL);
540static DEVICE_ATTR(runtime_active_kids, 0444, rtpm_children_show, NULL);
541static DEVICE_ATTR(runtime_enabled, 0444, rtpm_enabled_show, NULL);
542 539
543#ifdef CONFIG_PM_SLEEP 540#ifdef CONFIG_PM_SLEEP
544static ssize_t async_show(struct device *dev, struct device_attribute *attr, 541static ssize_t async_show(struct device *dev, struct device_attribute *attr,
@@ -561,7 +558,7 @@ static ssize_t async_store(struct device *dev, struct device_attribute *attr,
561 return n; 558 return n;
562} 559}
563 560
564static DEVICE_ATTR(async, 0644, async_show, async_store); 561static DEVICE_ATTR_RW(async);
565 562
566#endif /* CONFIG_PM_SLEEP */ 563#endif /* CONFIG_PM_SLEEP */
567#endif /* CONFIG_PM_ADVANCED_DEBUG */ 564#endif /* CONFIG_PM_ADVANCED_DEBUG */