Lines Matching refs:dev

101 static ssize_t control_show(struct device *dev, struct device_attribute *attr,  in control_show()  argument
105 dev->power.runtime_auto ? ctrl_auto : ctrl_on); in control_show()
108 static ssize_t control_store(struct device * dev, struct device_attribute *attr, in control_store() argument
117 device_lock(dev); in control_store()
119 pm_runtime_allow(dev); in control_store()
121 pm_runtime_forbid(dev); in control_store()
124 device_unlock(dev); in control_store()
130 static ssize_t rtpm_active_time_show(struct device *dev, in rtpm_active_time_show() argument
134 spin_lock_irq(&dev->power.lock); in rtpm_active_time_show()
135 update_pm_runtime_accounting(dev); in rtpm_active_time_show()
136 ret = sprintf(buf, "%i\n", jiffies_to_msecs(dev->power.active_jiffies)); in rtpm_active_time_show()
137 spin_unlock_irq(&dev->power.lock); in rtpm_active_time_show()
143 static ssize_t rtpm_suspended_time_show(struct device *dev, in rtpm_suspended_time_show() argument
147 spin_lock_irq(&dev->power.lock); in rtpm_suspended_time_show()
148 update_pm_runtime_accounting(dev); in rtpm_suspended_time_show()
150 jiffies_to_msecs(dev->power.suspended_jiffies)); in rtpm_suspended_time_show()
151 spin_unlock_irq(&dev->power.lock); in rtpm_suspended_time_show()
157 static ssize_t rtpm_status_show(struct device *dev, in rtpm_status_show() argument
162 if (dev->power.runtime_error) { in rtpm_status_show()
164 } else if (dev->power.disable_depth) { in rtpm_status_show()
167 switch (dev->power.runtime_status) { in rtpm_status_show()
189 static ssize_t autosuspend_delay_ms_show(struct device *dev, in autosuspend_delay_ms_show() argument
192 if (!dev->power.use_autosuspend) in autosuspend_delay_ms_show()
194 return sprintf(buf, "%d\n", dev->power.autosuspend_delay); in autosuspend_delay_ms_show()
197 static ssize_t autosuspend_delay_ms_store(struct device *dev, in autosuspend_delay_ms_store() argument
202 if (!dev->power.use_autosuspend) in autosuspend_delay_ms_store()
208 device_lock(dev); in autosuspend_delay_ms_store()
209 pm_runtime_set_autosuspend_delay(dev, delay); in autosuspend_delay_ms_store()
210 device_unlock(dev); in autosuspend_delay_ms_store()
217 static ssize_t pm_qos_resume_latency_show(struct device *dev, in pm_qos_resume_latency_show() argument
221 return sprintf(buf, "%d\n", dev_pm_qos_requested_resume_latency(dev)); in pm_qos_resume_latency_show()
224 static ssize_t pm_qos_resume_latency_store(struct device *dev, in pm_qos_resume_latency_store() argument
237 ret = dev_pm_qos_update_request(dev->power.qos->resume_latency_req, in pm_qos_resume_latency_store()
245 static ssize_t pm_qos_latency_tolerance_show(struct device *dev, in pm_qos_latency_tolerance_show() argument
249 s32 value = dev_pm_qos_get_user_latency_tolerance(dev); in pm_qos_latency_tolerance_show()
259 static ssize_t pm_qos_latency_tolerance_store(struct device *dev, in pm_qos_latency_tolerance_store() argument
272 ret = dev_pm_qos_update_user_latency_tolerance(dev, value); in pm_qos_latency_tolerance_store()
279 static ssize_t pm_qos_no_power_off_show(struct device *dev, in pm_qos_no_power_off_show() argument
283 return sprintf(buf, "%d\n", !!(dev_pm_qos_requested_flags(dev) in pm_qos_no_power_off_show()
287 static ssize_t pm_qos_no_power_off_store(struct device *dev, in pm_qos_no_power_off_store() argument
299 ret = dev_pm_qos_update_flags(dev, PM_QOS_FLAG_NO_POWER_OFF, ret); in pm_qos_no_power_off_store()
306 static ssize_t pm_qos_remote_wakeup_show(struct device *dev, in pm_qos_remote_wakeup_show() argument
310 return sprintf(buf, "%d\n", !!(dev_pm_qos_requested_flags(dev) in pm_qos_remote_wakeup_show()
314 static ssize_t pm_qos_remote_wakeup_store(struct device *dev, in pm_qos_remote_wakeup_store() argument
326 ret = dev_pm_qos_update_flags(dev, PM_QOS_FLAG_REMOTE_WAKEUP, ret); in pm_qos_remote_wakeup_store()
338 wake_show(struct device * dev, struct device_attribute *attr, char * buf) in wake_show() argument
340 return sprintf(buf, "%s\n", device_can_wakeup(dev) in wake_show()
341 ? (device_may_wakeup(dev) ? _enabled : _disabled) in wake_show()
346 wake_store(struct device * dev, struct device_attribute *attr, in wake_store() argument
352 if (!device_can_wakeup(dev)) in wake_store()
360 device_set_wakeup_enable(dev, 1); in wake_store()
363 device_set_wakeup_enable(dev, 0); in wake_store()
371 static ssize_t wakeup_count_show(struct device *dev, in wakeup_count_show() argument
377 spin_lock_irq(&dev->power.lock); in wakeup_count_show()
378 if (dev->power.wakeup) { in wakeup_count_show()
379 count = dev->power.wakeup->event_count; in wakeup_count_show()
382 spin_unlock_irq(&dev->power.lock); in wakeup_count_show()
388 static ssize_t wakeup_active_count_show(struct device *dev, in wakeup_active_count_show() argument
394 spin_lock_irq(&dev->power.lock); in wakeup_active_count_show()
395 if (dev->power.wakeup) { in wakeup_active_count_show()
396 count = dev->power.wakeup->active_count; in wakeup_active_count_show()
399 spin_unlock_irq(&dev->power.lock); in wakeup_active_count_show()
405 static ssize_t wakeup_abort_count_show(struct device *dev, in wakeup_abort_count_show() argument
412 spin_lock_irq(&dev->power.lock); in wakeup_abort_count_show()
413 if (dev->power.wakeup) { in wakeup_abort_count_show()
414 count = dev->power.wakeup->wakeup_count; in wakeup_abort_count_show()
417 spin_unlock_irq(&dev->power.lock); in wakeup_abort_count_show()
423 static ssize_t wakeup_expire_count_show(struct device *dev, in wakeup_expire_count_show() argument
430 spin_lock_irq(&dev->power.lock); in wakeup_expire_count_show()
431 if (dev->power.wakeup) { in wakeup_expire_count_show()
432 count = dev->power.wakeup->expire_count; in wakeup_expire_count_show()
435 spin_unlock_irq(&dev->power.lock); in wakeup_expire_count_show()
441 static ssize_t wakeup_active_show(struct device *dev, in wakeup_active_show() argument
447 spin_lock_irq(&dev->power.lock); in wakeup_active_show()
448 if (dev->power.wakeup) { in wakeup_active_show()
449 active = dev->power.wakeup->active; in wakeup_active_show()
452 spin_unlock_irq(&dev->power.lock); in wakeup_active_show()
458 static ssize_t wakeup_total_time_show(struct device *dev, in wakeup_total_time_show() argument
464 spin_lock_irq(&dev->power.lock); in wakeup_total_time_show()
465 if (dev->power.wakeup) { in wakeup_total_time_show()
466 msec = ktime_to_ms(dev->power.wakeup->total_time); in wakeup_total_time_show()
469 spin_unlock_irq(&dev->power.lock); in wakeup_total_time_show()
475 static ssize_t wakeup_max_time_show(struct device *dev, in wakeup_max_time_show() argument
481 spin_lock_irq(&dev->power.lock); in wakeup_max_time_show()
482 if (dev->power.wakeup) { in wakeup_max_time_show()
483 msec = ktime_to_ms(dev->power.wakeup->max_time); in wakeup_max_time_show()
486 spin_unlock_irq(&dev->power.lock); in wakeup_max_time_show()
492 static ssize_t wakeup_last_time_show(struct device *dev, in wakeup_last_time_show() argument
498 spin_lock_irq(&dev->power.lock); in wakeup_last_time_show()
499 if (dev->power.wakeup) { in wakeup_last_time_show()
500 msec = ktime_to_ms(dev->power.wakeup->last_time); in wakeup_last_time_show()
503 spin_unlock_irq(&dev->power.lock); in wakeup_last_time_show()
510 static ssize_t wakeup_prevent_sleep_time_show(struct device *dev, in wakeup_prevent_sleep_time_show() argument
517 spin_lock_irq(&dev->power.lock); in wakeup_prevent_sleep_time_show()
518 if (dev->power.wakeup) { in wakeup_prevent_sleep_time_show()
519 msec = ktime_to_ms(dev->power.wakeup->prevent_sleep_time); in wakeup_prevent_sleep_time_show()
522 spin_unlock_irq(&dev->power.lock); in wakeup_prevent_sleep_time_show()
532 static ssize_t rtpm_usagecount_show(struct device *dev, in rtpm_usagecount_show() argument
535 return sprintf(buf, "%d\n", atomic_read(&dev->power.usage_count)); in rtpm_usagecount_show()
538 static ssize_t rtpm_children_show(struct device *dev, in rtpm_children_show() argument
541 return sprintf(buf, "%d\n", dev->power.ignore_children ? in rtpm_children_show()
542 0 : atomic_read(&dev->power.child_count)); in rtpm_children_show()
545 static ssize_t rtpm_enabled_show(struct device *dev, in rtpm_enabled_show() argument
548 if ((dev->power.disable_depth) && (dev->power.runtime_auto == false)) in rtpm_enabled_show()
550 else if (dev->power.disable_depth) in rtpm_enabled_show()
552 else if (dev->power.runtime_auto == false) in rtpm_enabled_show()
562 static ssize_t async_show(struct device *dev, struct device_attribute *attr, in async_show() argument
566 device_async_suspend_enabled(dev) ? in async_show()
570 static ssize_t async_store(struct device *dev, struct device_attribute *attr, in async_store() argument
580 device_enable_async_suspend(dev); in async_store()
583 device_disable_async_suspend(dev); in async_store()
676 int dpm_sysfs_add(struct device *dev) in dpm_sysfs_add() argument
680 rc = sysfs_create_group(&dev->kobj, &pm_attr_group); in dpm_sysfs_add()
684 if (pm_runtime_callbacks_present(dev)) { in dpm_sysfs_add()
685 rc = sysfs_merge_group(&dev->kobj, &pm_runtime_attr_group); in dpm_sysfs_add()
689 if (device_can_wakeup(dev)) { in dpm_sysfs_add()
690 rc = sysfs_merge_group(&dev->kobj, &pm_wakeup_attr_group); in dpm_sysfs_add()
694 if (dev->power.set_latency_tolerance) { in dpm_sysfs_add()
695 rc = sysfs_merge_group(&dev->kobj, in dpm_sysfs_add()
703 sysfs_unmerge_group(&dev->kobj, &pm_wakeup_attr_group); in dpm_sysfs_add()
705 sysfs_unmerge_group(&dev->kobj, &pm_runtime_attr_group); in dpm_sysfs_add()
707 sysfs_remove_group(&dev->kobj, &pm_attr_group); in dpm_sysfs_add()
711 int wakeup_sysfs_add(struct device *dev) in wakeup_sysfs_add() argument
713 return sysfs_merge_group(&dev->kobj, &pm_wakeup_attr_group); in wakeup_sysfs_add()
716 void wakeup_sysfs_remove(struct device *dev) in wakeup_sysfs_remove() argument
718 sysfs_unmerge_group(&dev->kobj, &pm_wakeup_attr_group); in wakeup_sysfs_remove()
721 int pm_qos_sysfs_add_resume_latency(struct device *dev) in pm_qos_sysfs_add_resume_latency() argument
723 return sysfs_merge_group(&dev->kobj, &pm_qos_resume_latency_attr_group); in pm_qos_sysfs_add_resume_latency()
726 void pm_qos_sysfs_remove_resume_latency(struct device *dev) in pm_qos_sysfs_remove_resume_latency() argument
728 sysfs_unmerge_group(&dev->kobj, &pm_qos_resume_latency_attr_group); in pm_qos_sysfs_remove_resume_latency()
731 int pm_qos_sysfs_add_flags(struct device *dev) in pm_qos_sysfs_add_flags() argument
733 return sysfs_merge_group(&dev->kobj, &pm_qos_flags_attr_group); in pm_qos_sysfs_add_flags()
736 void pm_qos_sysfs_remove_flags(struct device *dev) in pm_qos_sysfs_remove_flags() argument
738 sysfs_unmerge_group(&dev->kobj, &pm_qos_flags_attr_group); in pm_qos_sysfs_remove_flags()
741 int pm_qos_sysfs_add_latency_tolerance(struct device *dev) in pm_qos_sysfs_add_latency_tolerance() argument
743 return sysfs_merge_group(&dev->kobj, in pm_qos_sysfs_add_latency_tolerance()
747 void pm_qos_sysfs_remove_latency_tolerance(struct device *dev) in pm_qos_sysfs_remove_latency_tolerance() argument
749 sysfs_unmerge_group(&dev->kobj, &pm_qos_latency_tolerance_attr_group); in pm_qos_sysfs_remove_latency_tolerance()
752 void rpm_sysfs_remove(struct device *dev) in rpm_sysfs_remove() argument
754 sysfs_unmerge_group(&dev->kobj, &pm_runtime_attr_group); in rpm_sysfs_remove()
757 void dpm_sysfs_remove(struct device *dev) in dpm_sysfs_remove() argument
759 sysfs_unmerge_group(&dev->kobj, &pm_qos_latency_tolerance_attr_group); in dpm_sysfs_remove()
760 dev_pm_qos_constraints_destroy(dev); in dpm_sysfs_remove()
761 rpm_sysfs_remove(dev); in dpm_sysfs_remove()
762 sysfs_unmerge_group(&dev->kobj, &pm_wakeup_attr_group); in dpm_sysfs_remove()
763 sysfs_remove_group(&dev->kobj, &pm_attr_group); in dpm_sysfs_remove()