diff options
Diffstat (limited to 'drivers/base/power/sysfs.c')
| -rw-r--r-- | drivers/base/power/sysfs.c | 182 |
1 files changed, 5 insertions, 177 deletions
diff --git a/drivers/base/power/sysfs.c b/drivers/base/power/sysfs.c index 50d16e3cb0a..17b7934f31c 100644 --- a/drivers/base/power/sysfs.c +++ b/drivers/base/power/sysfs.c | |||
| @@ -4,8 +4,6 @@ | |||
| 4 | 4 | ||
| 5 | #include <linux/device.h> | 5 | #include <linux/device.h> |
| 6 | #include <linux/string.h> | 6 | #include <linux/string.h> |
| 7 | #include <linux/export.h> | ||
| 8 | #include <linux/pm_qos.h> | ||
| 9 | #include <linux/pm_runtime.h> | 7 | #include <linux/pm_runtime.h> |
| 10 | #include <linux/atomic.h> | 8 | #include <linux/atomic.h> |
| 11 | #include <linux/jiffies.h> | 9 | #include <linux/jiffies.h> |
| @@ -218,85 +216,6 @@ static ssize_t autosuspend_delay_ms_store(struct device *dev, | |||
| 218 | static DEVICE_ATTR(autosuspend_delay_ms, 0644, autosuspend_delay_ms_show, | 216 | static DEVICE_ATTR(autosuspend_delay_ms, 0644, autosuspend_delay_ms_show, |
| 219 | autosuspend_delay_ms_store); | 217 | autosuspend_delay_ms_store); |
| 220 | 218 | ||
| 221 | static ssize_t pm_qos_latency_show(struct device *dev, | ||
| 222 | struct device_attribute *attr, char *buf) | ||
| 223 | { | ||
| 224 | return sprintf(buf, "%d\n", dev_pm_qos_requested_latency(dev)); | ||
| 225 | } | ||
| 226 | |||
| 227 | static ssize_t pm_qos_latency_store(struct device *dev, | ||
| 228 | struct device_attribute *attr, | ||
| 229 | const char *buf, size_t n) | ||
| 230 | { | ||
| 231 | s32 value; | ||
| 232 | int ret; | ||
| 233 | |||
| 234 | if (kstrtos32(buf, 0, &value)) | ||
| 235 | return -EINVAL; | ||
| 236 | |||
| 237 | if (value < 0) | ||
| 238 | return -EINVAL; | ||
| 239 | |||
| 240 | ret = dev_pm_qos_update_request(dev->power.qos->latency_req, value); | ||
| 241 | return ret < 0 ? ret : n; | ||
| 242 | } | ||
| 243 | |||
| 244 | static DEVICE_ATTR(pm_qos_resume_latency_us, 0644, | ||
| 245 | pm_qos_latency_show, pm_qos_latency_store); | ||
| 246 | |||
| 247 | static ssize_t pm_qos_no_power_off_show(struct device *dev, | ||
| 248 | struct device_attribute *attr, | ||
| 249 | char *buf) | ||
| 250 | { | ||
| 251 | return sprintf(buf, "%d\n", !!(dev_pm_qos_requested_flags(dev) | ||
| 252 | & PM_QOS_FLAG_NO_POWER_OFF)); | ||
| 253 | } | ||
| 254 | |||
| 255 | static ssize_t pm_qos_no_power_off_store(struct device *dev, | ||
| 256 | struct device_attribute *attr, | ||
| 257 | const char *buf, size_t n) | ||
| 258 | { | ||
| 259 | int ret; | ||
| 260 | |||
| 261 | if (kstrtoint(buf, 0, &ret)) | ||
| 262 | return -EINVAL; | ||
| 263 | |||
| 264 | if (ret != 0 && ret != 1) | ||
| 265 | return -EINVAL; | ||
| 266 | |||
| 267 | ret = dev_pm_qos_update_flags(dev, PM_QOS_FLAG_NO_POWER_OFF, ret); | ||
| 268 | return ret < 0 ? ret : n; | ||
| 269 | } | ||
| 270 | |||
| 271 | static DEVICE_ATTR(pm_qos_no_power_off, 0644, | ||
| 272 | pm_qos_no_power_off_show, pm_qos_no_power_off_store); | ||
| 273 | |||
| 274 | static ssize_t pm_qos_remote_wakeup_show(struct device *dev, | ||
| 275 | struct device_attribute *attr, | ||
| 276 | char *buf) | ||
| 277 | { | ||
| 278 | return sprintf(buf, "%d\n", !!(dev_pm_qos_requested_flags(dev) | ||
| 279 | & PM_QOS_FLAG_REMOTE_WAKEUP)); | ||
| 280 | } | ||
| 281 | |||
| 282 | static ssize_t pm_qos_remote_wakeup_store(struct device *dev, | ||
| 283 | struct device_attribute *attr, | ||
| 284 | const char *buf, size_t n) | ||
| 285 | { | ||
| 286 | int ret; | ||
| 287 | |||
| 288 | if (kstrtoint(buf, 0, &ret)) | ||
| 289 | return -EINVAL; | ||
| 290 | |||
| 291 | if (ret != 0 && ret != 1) | ||
| 292 | return -EINVAL; | ||
| 293 | |||
| 294 | ret = dev_pm_qos_update_flags(dev, PM_QOS_FLAG_REMOTE_WAKEUP, ret); | ||
| 295 | return ret < 0 ? ret : n; | ||
| 296 | } | ||
| 297 | |||
| 298 | static DEVICE_ATTR(pm_qos_remote_wakeup, 0644, | ||
| 299 | pm_qos_remote_wakeup_show, pm_qos_remote_wakeup_store); | ||
| 300 | #endif /* CONFIG_PM_RUNTIME */ | 219 | #endif /* CONFIG_PM_RUNTIME */ |
| 301 | 220 | ||
| 302 | #ifdef CONFIG_PM_SLEEP | 221 | #ifdef CONFIG_PM_SLEEP |
| @@ -368,41 +287,22 @@ static ssize_t wakeup_active_count_show(struct device *dev, | |||
| 368 | 287 | ||
| 369 | static DEVICE_ATTR(wakeup_active_count, 0444, wakeup_active_count_show, NULL); | 288 | static DEVICE_ATTR(wakeup_active_count, 0444, wakeup_active_count_show, NULL); |
| 370 | 289 | ||
| 371 | static ssize_t wakeup_abort_count_show(struct device *dev, | 290 | static ssize_t wakeup_hit_count_show(struct device *dev, |
| 372 | struct device_attribute *attr, | 291 | struct device_attribute *attr, char *buf) |
| 373 | char *buf) | ||
| 374 | { | ||
| 375 | unsigned long count = 0; | ||
| 376 | bool enabled = false; | ||
| 377 | |||
| 378 | spin_lock_irq(&dev->power.lock); | ||
| 379 | if (dev->power.wakeup) { | ||
| 380 | count = dev->power.wakeup->wakeup_count; | ||
| 381 | enabled = true; | ||
| 382 | } | ||
| 383 | spin_unlock_irq(&dev->power.lock); | ||
| 384 | return enabled ? sprintf(buf, "%lu\n", count) : sprintf(buf, "\n"); | ||
| 385 | } | ||
| 386 | |||
| 387 | static DEVICE_ATTR(wakeup_abort_count, 0444, wakeup_abort_count_show, NULL); | ||
| 388 | |||
| 389 | static ssize_t wakeup_expire_count_show(struct device *dev, | ||
| 390 | struct device_attribute *attr, | ||
| 391 | char *buf) | ||
| 392 | { | 292 | { |
| 393 | unsigned long count = 0; | 293 | unsigned long count = 0; |
| 394 | bool enabled = false; | 294 | bool enabled = false; |
| 395 | 295 | ||
| 396 | spin_lock_irq(&dev->power.lock); | 296 | spin_lock_irq(&dev->power.lock); |
| 397 | if (dev->power.wakeup) { | 297 | if (dev->power.wakeup) { |
| 398 | count = dev->power.wakeup->expire_count; | 298 | count = dev->power.wakeup->hit_count; |
| 399 | enabled = true; | 299 | enabled = true; |
| 400 | } | 300 | } |
| 401 | spin_unlock_irq(&dev->power.lock); | 301 | spin_unlock_irq(&dev->power.lock); |
| 402 | return enabled ? sprintf(buf, "%lu\n", count) : sprintf(buf, "\n"); | 302 | return enabled ? sprintf(buf, "%lu\n", count) : sprintf(buf, "\n"); |
| 403 | } | 303 | } |
| 404 | 304 | ||
| 405 | static DEVICE_ATTR(wakeup_expire_count, 0444, wakeup_expire_count_show, NULL); | 305 | static DEVICE_ATTR(wakeup_hit_count, 0444, wakeup_hit_count_show, NULL); |
| 406 | 306 | ||
| 407 | static ssize_t wakeup_active_show(struct device *dev, | 307 | static ssize_t wakeup_active_show(struct device *dev, |
| 408 | struct device_attribute *attr, char *buf) | 308 | struct device_attribute *attr, char *buf) |
| @@ -471,27 +371,6 @@ static ssize_t wakeup_last_time_show(struct device *dev, | |||
| 471 | } | 371 | } |
| 472 | 372 | ||
| 473 | static DEVICE_ATTR(wakeup_last_time_ms, 0444, wakeup_last_time_show, NULL); | 373 | static DEVICE_ATTR(wakeup_last_time_ms, 0444, wakeup_last_time_show, NULL); |
| 474 | |||
| 475 | #ifdef CONFIG_PM_AUTOSLEEP | ||
| 476 | static ssize_t wakeup_prevent_sleep_time_show(struct device *dev, | ||
| 477 | struct device_attribute *attr, | ||
| 478 | char *buf) | ||
| 479 | { | ||
| 480 | s64 msec = 0; | ||
| 481 | bool enabled = false; | ||
| 482 | |||
| 483 | spin_lock_irq(&dev->power.lock); | ||
| 484 | if (dev->power.wakeup) { | ||
| 485 | msec = ktime_to_ms(dev->power.wakeup->prevent_sleep_time); | ||
| 486 | enabled = true; | ||
| 487 | } | ||
| 488 | spin_unlock_irq(&dev->power.lock); | ||
| 489 | return enabled ? sprintf(buf, "%lld\n", msec) : sprintf(buf, "\n"); | ||
| 490 | } | ||
| 491 | |||
| 492 | static DEVICE_ATTR(wakeup_prevent_sleep_time_ms, 0444, | ||
| 493 | wakeup_prevent_sleep_time_show, NULL); | ||
| 494 | #endif /* CONFIG_PM_AUTOSLEEP */ | ||
| 495 | #endif /* CONFIG_PM_SLEEP */ | 374 | #endif /* CONFIG_PM_SLEEP */ |
| 496 | 375 | ||
| 497 | #ifdef CONFIG_PM_ADVANCED_DEBUG | 376 | #ifdef CONFIG_PM_ADVANCED_DEBUG |
| @@ -528,8 +407,6 @@ static DEVICE_ATTR(runtime_enabled, 0444, rtpm_enabled_show, NULL); | |||
| 528 | 407 | ||
| 529 | #endif | 408 | #endif |
| 530 | 409 | ||
| 531 | #ifdef CONFIG_PM_SLEEP | ||
| 532 | |||
| 533 | static ssize_t async_show(struct device *dev, struct device_attribute *attr, | 410 | static ssize_t async_show(struct device *dev, struct device_attribute *attr, |
| 534 | char *buf) | 411 | char *buf) |
| 535 | { | 412 | { |
| @@ -556,8 +433,6 @@ static ssize_t async_store(struct device *dev, struct device_attribute *attr, | |||
| 556 | } | 433 | } |
| 557 | 434 | ||
| 558 | static DEVICE_ATTR(async, 0644, async_show, async_store); | 435 | static DEVICE_ATTR(async, 0644, async_show, async_store); |
| 559 | |||
| 560 | #endif | ||
| 561 | #endif /* CONFIG_PM_ADVANCED_DEBUG */ | 436 | #endif /* CONFIG_PM_ADVANCED_DEBUG */ |
| 562 | 437 | ||
| 563 | static struct attribute *power_attrs[] = { | 438 | static struct attribute *power_attrs[] = { |
| @@ -584,15 +459,11 @@ static struct attribute *wakeup_attrs[] = { | |||
| 584 | &dev_attr_wakeup.attr, | 459 | &dev_attr_wakeup.attr, |
| 585 | &dev_attr_wakeup_count.attr, | 460 | &dev_attr_wakeup_count.attr, |
| 586 | &dev_attr_wakeup_active_count.attr, | 461 | &dev_attr_wakeup_active_count.attr, |
| 587 | &dev_attr_wakeup_abort_count.attr, | 462 | &dev_attr_wakeup_hit_count.attr, |
| 588 | &dev_attr_wakeup_expire_count.attr, | ||
| 589 | &dev_attr_wakeup_active.attr, | 463 | &dev_attr_wakeup_active.attr, |
| 590 | &dev_attr_wakeup_total_time_ms.attr, | 464 | &dev_attr_wakeup_total_time_ms.attr, |
| 591 | &dev_attr_wakeup_max_time_ms.attr, | 465 | &dev_attr_wakeup_max_time_ms.attr, |
| 592 | &dev_attr_wakeup_last_time_ms.attr, | 466 | &dev_attr_wakeup_last_time_ms.attr, |
| 593 | #ifdef CONFIG_PM_AUTOSLEEP | ||
| 594 | &dev_attr_wakeup_prevent_sleep_time_ms.attr, | ||
| 595 | #endif | ||
| 596 | #endif | 467 | #endif |
| 597 | NULL, | 468 | NULL, |
| 598 | }; | 469 | }; |
| @@ -618,29 +489,6 @@ static struct attribute_group pm_runtime_attr_group = { | |||
| 618 | .attrs = runtime_attrs, | 489 | .attrs = runtime_attrs, |
| 619 | }; | 490 | }; |
| 620 | 491 | ||
| 621 | static struct attribute *pm_qos_latency_attrs[] = { | ||
| 622 | #ifdef CONFIG_PM_RUNTIME | ||
| 623 | &dev_attr_pm_qos_resume_latency_us.attr, | ||
| 624 | #endif /* CONFIG_PM_RUNTIME */ | ||
| 625 | NULL, | ||
| 626 | }; | ||
| 627 | static struct attribute_group pm_qos_latency_attr_group = { | ||
| 628 | .name = power_group_name, | ||
| 629 | .attrs = pm_qos_latency_attrs, | ||
| 630 | }; | ||
| 631 | |||
| 632 | static struct attribute *pm_qos_flags_attrs[] = { | ||
| 633 | #ifdef CONFIG_PM_RUNTIME | ||
| 634 | &dev_attr_pm_qos_no_power_off.attr, | ||
| 635 | &dev_attr_pm_qos_remote_wakeup.attr, | ||
| 636 | #endif /* CONFIG_PM_RUNTIME */ | ||
| 637 | NULL, | ||
| 638 | }; | ||
| 639 | static struct attribute_group pm_qos_flags_attr_group = { | ||
| 640 | .name = power_group_name, | ||
| 641 | .attrs = pm_qos_flags_attrs, | ||
| 642 | }; | ||
| 643 | |||
| 644 | int dpm_sysfs_add(struct device *dev) | 492 | int dpm_sysfs_add(struct device *dev) |
| 645 | { | 493 | { |
| 646 | int rc; | 494 | int rc; |
| @@ -681,26 +529,6 @@ void wakeup_sysfs_remove(struct device *dev) | |||
| 681 | sysfs_unmerge_group(&dev->kobj, &pm_wakeup_attr_group); | 529 | sysfs_unmerge_group(&dev->kobj, &pm_wakeup_attr_group); |
| 682 | } | 530 | } |
| 683 | 531 | ||
| 684 | int pm_qos_sysfs_add_latency(struct device *dev) | ||
| 685 | { | ||
| 686 | return sysfs_merge_group(&dev->kobj, &pm_qos_latency_attr_group); | ||
| 687 | } | ||
| 688 | |||
| 689 | void pm_qos_sysfs_remove_latency(struct device *dev) | ||
| 690 | { | ||
| 691 | sysfs_unmerge_group(&dev->kobj, &pm_qos_latency_attr_group); | ||
| 692 | } | ||
| 693 | |||
| 694 | int pm_qos_sysfs_add_flags(struct device *dev) | ||
| 695 | { | ||
| 696 | return sysfs_merge_group(&dev->kobj, &pm_qos_flags_attr_group); | ||
| 697 | } | ||
| 698 | |||
| 699 | void pm_qos_sysfs_remove_flags(struct device *dev) | ||
| 700 | { | ||
| 701 | sysfs_unmerge_group(&dev->kobj, &pm_qos_flags_attr_group); | ||
| 702 | } | ||
| 703 | |||
| 704 | void rpm_sysfs_remove(struct device *dev) | 532 | void rpm_sysfs_remove(struct device *dev) |
| 705 | { | 533 | { |
| 706 | sysfs_unmerge_group(&dev->kobj, &pm_runtime_attr_group); | 534 | sysfs_unmerge_group(&dev->kobj, &pm_runtime_attr_group); |
