blob: 48ddeefd69328b510c0fd785a311faa81177ca85 [file] [log] [blame]
xjb04a4022021-11-25 15:01:52 +08001/*
2 * drivers/base/power/sysfs.c - sysfs entries for device PM
3 */
4
5#include <linux/device.h>
6#include <linux/string.h>
7#include <linux/export.h>
8#include <linux/pm_qos.h>
9#include <linux/pm_runtime.h>
10#include <linux/pm_wakeup.h>
11#include <linux/atomic.h>
12#include <linux/jiffies.h>
13#include "power.h"
14
15/*
16 * control - Report/change current runtime PM setting of the device
17 *
18 * Runtime power management of a device can be blocked with the help of
19 * this attribute. All devices have one of the following two values for
20 * the power/control file:
21 *
22 * + "auto\n" to allow the device to be power managed at run time;
23 * + "on\n" to prevent the device from being power managed at run time;
24 *
25 * The default for all devices is "auto", which means that devices may be
26 * subject to automatic power management, depending on their drivers.
27 * Changing this attribute to "on" prevents the driver from power managing
28 * the device at run time. Doing that while the device is suspended causes
29 * it to be woken up.
30 *
31 * wakeup - Report/change current wakeup option for device
32 *
33 * Some devices support "wakeup" events, which are hardware signals
34 * used to activate devices from suspended or low power states. Such
35 * devices have one of three values for the sysfs power/wakeup file:
36 *
37 * + "enabled\n" to issue the events;
38 * + "disabled\n" not to do so; or
39 * + "\n" for temporary or permanent inability to issue wakeup.
40 *
41 * (For example, unconfigured USB devices can't issue wakeups.)
42 *
43 * Familiar examples of devices that can issue wakeup events include
44 * keyboards and mice (both PS2 and USB styles), power buttons, modems,
45 * "Wake-On-LAN" Ethernet links, GPIO lines, and more. Some events
46 * will wake the entire system from a suspend state; others may just
47 * wake up the device (if the system as a whole is already active).
48 * Some wakeup events use normal IRQ lines; other use special out
49 * of band signaling.
50 *
51 * It is the responsibility of device drivers to enable (or disable)
52 * wakeup signaling as part of changing device power states, respecting
53 * the policy choices provided through the driver model.
54 *
55 * Devices may not be able to generate wakeup events from all power
56 * states. Also, the events may be ignored in some configurations;
57 * for example, they might need help from other devices that aren't
58 * active, or which may have wakeup disabled. Some drivers rely on
59 * wakeup events internally (unless they are disabled), keeping
60 * their hardware in low power modes whenever they're unused. This
61 * saves runtime power, without requiring system-wide sleep states.
62 *
63 * async - Report/change current async suspend setting for the device
64 *
65 * Asynchronous suspend and resume of the device during system-wide power
66 * state transitions can be enabled by writing "enabled" to this file.
67 * Analogously, if "disabled" is written to this file, the device will be
68 * suspended and resumed synchronously.
69 *
70 * All devices have one of the following two values for power/async:
71 *
72 * + "enabled\n" to permit the asynchronous suspend/resume of the device;
73 * + "disabled\n" to forbid it;
74 *
75 * NOTE: It generally is unsafe to permit the asynchronous suspend/resume
76 * of a device unless it is certain that all of the PM dependencies of the
77 * device are known to the PM core. However, for some devices this
78 * attribute is set to "enabled" by bus type code or device drivers and in
79 * that cases it should be safe to leave the default value.
80 *
81 * autosuspend_delay_ms - Report/change a device's autosuspend_delay value
82 *
83 * Some drivers don't want to carry out a runtime suspend as soon as a
84 * device becomes idle; they want it always to remain idle for some period
85 * of time before suspending it. This period is the autosuspend_delay
86 * value (expressed in milliseconds) and it can be controlled by the user.
87 * If the value is negative then the device will never be runtime
88 * suspended.
89 *
90 * NOTE: The autosuspend_delay_ms attribute and the autosuspend_delay
91 * value are used only if the driver calls pm_runtime_use_autosuspend().
92 *
93 * wakeup_count - Report the number of wakeup events related to the device
94 */
95
96const char power_group_name[] = "power";
97EXPORT_SYMBOL_GPL(power_group_name);
98
99static const char ctrl_auto[] = "auto";
100static const char ctrl_on[] = "on";
101
102static ssize_t control_show(struct device *dev, struct device_attribute *attr,
103 char *buf)
104{
105 return sprintf(buf, "%s\n",
106 dev->power.runtime_auto ? ctrl_auto : ctrl_on);
107}
108
109static ssize_t control_store(struct device * dev, struct device_attribute *attr,
110 const char * buf, size_t n)
111{
112 device_lock(dev);
113 if (sysfs_streq(buf, ctrl_auto))
114 pm_runtime_allow(dev);
115 else if (sysfs_streq(buf, ctrl_on))
116 pm_runtime_forbid(dev);
117 else
118 n = -EINVAL;
119 device_unlock(dev);
120 return n;
121}
122
123static DEVICE_ATTR_RW(control);
124
125static ssize_t runtime_active_time_show(struct device *dev,
126 struct device_attribute *attr, char *buf)
127{
128 int ret;
129 spin_lock_irq(&dev->power.lock);
130 update_pm_runtime_accounting(dev);
131 ret = sprintf(buf, "%i\n", jiffies_to_msecs(dev->power.active_jiffies));
132 spin_unlock_irq(&dev->power.lock);
133 return ret;
134}
135
136static DEVICE_ATTR_RO(runtime_active_time);
137
138static ssize_t runtime_suspended_time_show(struct device *dev,
139 struct device_attribute *attr, char *buf)
140{
141 int ret;
142 spin_lock_irq(&dev->power.lock);
143 update_pm_runtime_accounting(dev);
144 ret = sprintf(buf, "%i\n",
145 jiffies_to_msecs(dev->power.suspended_jiffies));
146 spin_unlock_irq(&dev->power.lock);
147 return ret;
148}
149
150static DEVICE_ATTR_RO(runtime_suspended_time);
151
152static ssize_t runtime_status_show(struct device *dev,
153 struct device_attribute *attr, char *buf)
154{
155 const char *p;
156
157 if (dev->power.runtime_error) {
158 p = "error\n";
159 } else if (dev->power.disable_depth) {
160 p = "unsupported\n";
161 } else {
162 switch (dev->power.runtime_status) {
163 case RPM_SUSPENDED:
164 p = "suspended\n";
165 break;
166 case RPM_SUSPENDING:
167 p = "suspending\n";
168 break;
169 case RPM_RESUMING:
170 p = "resuming\n";
171 break;
172 case RPM_ACTIVE:
173 p = "active\n";
174 break;
175 default:
176 return -EIO;
177 }
178 }
179 return sprintf(buf, p);
180}
181
182static DEVICE_ATTR_RO(runtime_status);
183
184static ssize_t autosuspend_delay_ms_show(struct device *dev,
185 struct device_attribute *attr, char *buf)
186{
187 if (!dev->power.use_autosuspend)
188 return -EIO;
189 return sprintf(buf, "%d\n", dev->power.autosuspend_delay);
190}
191
192static ssize_t autosuspend_delay_ms_store(struct device *dev,
193 struct device_attribute *attr, const char *buf, size_t n)
194{
195 long delay;
196
197 if (!dev->power.use_autosuspend)
198 return -EIO;
199
200 if (kstrtol(buf, 10, &delay) != 0 || delay != (int) delay)
201 return -EINVAL;
202
203 device_lock(dev);
204 pm_runtime_set_autosuspend_delay(dev, delay);
205 device_unlock(dev);
206 return n;
207}
208
209static DEVICE_ATTR_RW(autosuspend_delay_ms);
210
211static ssize_t pm_qos_resume_latency_us_show(struct device *dev,
212 struct device_attribute *attr,
213 char *buf)
214{
215 s32 value = dev_pm_qos_requested_resume_latency(dev);
216
217 if (value == 0)
218 return sprintf(buf, "n/a\n");
219 if (value == PM_QOS_RESUME_LATENCY_NO_CONSTRAINT)
220 value = 0;
221
222 return sprintf(buf, "%d\n", value);
223}
224
225static ssize_t pm_qos_resume_latency_us_store(struct device *dev,
226 struct device_attribute *attr,
227 const char *buf, size_t n)
228{
229 s32 value;
230 int ret;
231
232 if (!kstrtos32(buf, 0, &value)) {
233 /*
234 * Prevent users from writing negative or "no constraint" values
235 * directly.
236 */
237 if (value < 0 || value == PM_QOS_RESUME_LATENCY_NO_CONSTRAINT)
238 return -EINVAL;
239
240 if (value == 0)
241 value = PM_QOS_RESUME_LATENCY_NO_CONSTRAINT;
242 } else if (sysfs_streq(buf, "n/a")) {
243 value = 0;
244 } else {
245 return -EINVAL;
246 }
247
248 ret = dev_pm_qos_update_request(dev->power.qos->resume_latency_req,
249 value);
250 return ret < 0 ? ret : n;
251}
252
253static DEVICE_ATTR_RW(pm_qos_resume_latency_us);
254
255static ssize_t pm_qos_latency_tolerance_us_show(struct device *dev,
256 struct device_attribute *attr,
257 char *buf)
258{
259 s32 value = dev_pm_qos_get_user_latency_tolerance(dev);
260
261 if (value < 0)
262 return sprintf(buf, "auto\n");
263 if (value == PM_QOS_LATENCY_ANY)
264 return sprintf(buf, "any\n");
265
266 return sprintf(buf, "%d\n", value);
267}
268
269static ssize_t pm_qos_latency_tolerance_us_store(struct device *dev,
270 struct device_attribute *attr,
271 const char *buf, size_t n)
272{
273 s32 value;
274 int ret;
275
276 if (kstrtos32(buf, 0, &value) == 0) {
277 /* Users can't write negative values directly */
278 if (value < 0)
279 return -EINVAL;
280 } else {
281 if (sysfs_streq(buf, "auto"))
282 value = PM_QOS_LATENCY_TOLERANCE_NO_CONSTRAINT;
283 else if (sysfs_streq(buf, "any"))
284 value = PM_QOS_LATENCY_ANY;
285 else
286 return -EINVAL;
287 }
288 ret = dev_pm_qos_update_user_latency_tolerance(dev, value);
289 return ret < 0 ? ret : n;
290}
291
292static DEVICE_ATTR_RW(pm_qos_latency_tolerance_us);
293
294static ssize_t pm_qos_no_power_off_show(struct device *dev,
295 struct device_attribute *attr,
296 char *buf)
297{
298 return sprintf(buf, "%d\n", !!(dev_pm_qos_requested_flags(dev)
299 & PM_QOS_FLAG_NO_POWER_OFF));
300}
301
302static ssize_t pm_qos_no_power_off_store(struct device *dev,
303 struct device_attribute *attr,
304 const char *buf, size_t n)
305{
306 int ret;
307
308 if (kstrtoint(buf, 0, &ret))
309 return -EINVAL;
310
311 if (ret != 0 && ret != 1)
312 return -EINVAL;
313
314 ret = dev_pm_qos_update_flags(dev, PM_QOS_FLAG_NO_POWER_OFF, ret);
315 return ret < 0 ? ret : n;
316}
317
318static DEVICE_ATTR_RW(pm_qos_no_power_off);
319
320#ifdef CONFIG_PM_SLEEP
321static const char _enabled[] = "enabled";
322static const char _disabled[] = "disabled";
323
324static ssize_t wakeup_show(struct device *dev, struct device_attribute *attr,
325 char *buf)
326{
327 return sprintf(buf, "%s\n", device_can_wakeup(dev)
328 ? (device_may_wakeup(dev) ? _enabled : _disabled)
329 : "");
330}
331
332static ssize_t wakeup_store(struct device *dev, struct device_attribute *attr,
333 const char *buf, size_t n)
334{
335 if (!device_can_wakeup(dev))
336 return -EINVAL;
337
338 if (sysfs_streq(buf, _enabled))
339 device_set_wakeup_enable(dev, 1);
340 else if (sysfs_streq(buf, _disabled))
341 device_set_wakeup_enable(dev, 0);
342 else
343 return -EINVAL;
344 return n;
345}
346
347static DEVICE_ATTR_RW(wakeup);
348
349static ssize_t wakeup_count_show(struct device *dev,
350 struct device_attribute *attr, char *buf)
351{
352 unsigned long count = 0;
353 bool enabled = false;
354
355 spin_lock_irq(&dev->power.lock);
356 if (dev->power.wakeup) {
357 count = dev->power.wakeup->wakeup_count;
358 enabled = true;
359 }
360 spin_unlock_irq(&dev->power.lock);
361 return enabled ? sprintf(buf, "%lu\n", count) : sprintf(buf, "\n");
362}
363
364static DEVICE_ATTR_RO(wakeup_count);
365
366static ssize_t wakeup_active_count_show(struct device *dev,
367 struct device_attribute *attr,
368 char *buf)
369{
370 unsigned long count = 0;
371 bool enabled = false;
372
373 spin_lock_irq(&dev->power.lock);
374 if (dev->power.wakeup) {
375 count = dev->power.wakeup->active_count;
376 enabled = true;
377 }
378 spin_unlock_irq(&dev->power.lock);
379 return enabled ? sprintf(buf, "%lu\n", count) : sprintf(buf, "\n");
380}
381
382static DEVICE_ATTR_RO(wakeup_active_count);
383
384static ssize_t wakeup_abort_count_show(struct device *dev,
385 struct device_attribute *attr,
386 char *buf)
387{
388 unsigned long count = 0;
389 bool enabled = false;
390
391 spin_lock_irq(&dev->power.lock);
392 if (dev->power.wakeup) {
393 count = dev->power.wakeup->wakeup_count;
394 enabled = true;
395 }
396 spin_unlock_irq(&dev->power.lock);
397 return enabled ? sprintf(buf, "%lu\n", count) : sprintf(buf, "\n");
398}
399
400static DEVICE_ATTR_RO(wakeup_abort_count);
401
402static ssize_t wakeup_expire_count_show(struct device *dev,
403 struct device_attribute *attr,
404 char *buf)
405{
406 unsigned long count = 0;
407 bool enabled = false;
408
409 spin_lock_irq(&dev->power.lock);
410 if (dev->power.wakeup) {
411 count = dev->power.wakeup->expire_count;
412 enabled = true;
413 }
414 spin_unlock_irq(&dev->power.lock);
415 return enabled ? sprintf(buf, "%lu\n", count) : sprintf(buf, "\n");
416}
417
418static DEVICE_ATTR_RO(wakeup_expire_count);
419
420static ssize_t wakeup_active_show(struct device *dev,
421 struct device_attribute *attr, char *buf)
422{
423 unsigned int active = 0;
424 bool enabled = false;
425
426 spin_lock_irq(&dev->power.lock);
427 if (dev->power.wakeup) {
428 active = dev->power.wakeup->active;
429 enabled = true;
430 }
431 spin_unlock_irq(&dev->power.lock);
432 return enabled ? sprintf(buf, "%u\n", active) : sprintf(buf, "\n");
433}
434
435static DEVICE_ATTR_RO(wakeup_active);
436
437static ssize_t wakeup_total_time_ms_show(struct device *dev,
438 struct device_attribute *attr,
439 char *buf)
440{
441 s64 msec = 0;
442 bool enabled = false;
443
444 spin_lock_irq(&dev->power.lock);
445 if (dev->power.wakeup) {
446 msec = ktime_to_ms(dev->power.wakeup->total_time);
447 enabled = true;
448 }
449 spin_unlock_irq(&dev->power.lock);
450 return enabled ? sprintf(buf, "%lld\n", msec) : sprintf(buf, "\n");
451}
452
453static DEVICE_ATTR_RO(wakeup_total_time_ms);
454
455static ssize_t wakeup_max_time_ms_show(struct device *dev,
456 struct device_attribute *attr, char *buf)
457{
458 s64 msec = 0;
459 bool enabled = false;
460
461 spin_lock_irq(&dev->power.lock);
462 if (dev->power.wakeup) {
463 msec = ktime_to_ms(dev->power.wakeup->max_time);
464 enabled = true;
465 }
466 spin_unlock_irq(&dev->power.lock);
467 return enabled ? sprintf(buf, "%lld\n", msec) : sprintf(buf, "\n");
468}
469
470static DEVICE_ATTR_RO(wakeup_max_time_ms);
471
472static ssize_t wakeup_last_time_ms_show(struct device *dev,
473 struct device_attribute *attr,
474 char *buf)
475{
476 s64 msec = 0;
477 bool enabled = false;
478
479 spin_lock_irq(&dev->power.lock);
480 if (dev->power.wakeup) {
481 msec = ktime_to_ms(dev->power.wakeup->last_time);
482 enabled = true;
483 }
484 spin_unlock_irq(&dev->power.lock);
485 return enabled ? sprintf(buf, "%lld\n", msec) : sprintf(buf, "\n");
486}
487
488static DEVICE_ATTR_RO(wakeup_last_time_ms);
489
490#ifdef CONFIG_PM_AUTOSLEEP
491static ssize_t wakeup_prevent_sleep_time_ms_show(struct device *dev,
492 struct device_attribute *attr,
493 char *buf)
494{
495 s64 msec = 0;
496 bool enabled = false;
497
498 spin_lock_irq(&dev->power.lock);
499 if (dev->power.wakeup) {
500 msec = ktime_to_ms(dev->power.wakeup->prevent_sleep_time);
501 enabled = true;
502 }
503 spin_unlock_irq(&dev->power.lock);
504 return enabled ? sprintf(buf, "%lld\n", msec) : sprintf(buf, "\n");
505}
506
507static DEVICE_ATTR_RO(wakeup_prevent_sleep_time_ms);
508#endif /* CONFIG_PM_AUTOSLEEP */
509#endif /* CONFIG_PM_SLEEP */
510
511#ifdef CONFIG_PM_ADVANCED_DEBUG
512static ssize_t runtime_usage_show(struct device *dev,
513 struct device_attribute *attr, char *buf)
514{
515 return sprintf(buf, "%d\n", atomic_read(&dev->power.usage_count));
516}
517static DEVICE_ATTR_RO(runtime_usage);
518
519static ssize_t runtime_active_kids_show(struct device *dev,
520 struct device_attribute *attr,
521 char *buf)
522{
523 return sprintf(buf, "%d\n", dev->power.ignore_children ?
524 0 : atomic_read(&dev->power.child_count));
525}
526static DEVICE_ATTR_RO(runtime_active_kids);
527
528static ssize_t runtime_enabled_show(struct device *dev,
529 struct device_attribute *attr, char *buf)
530{
531 if (dev->power.disable_depth && (dev->power.runtime_auto == false))
532 return sprintf(buf, "disabled & forbidden\n");
533 if (dev->power.disable_depth)
534 return sprintf(buf, "disabled\n");
535 if (dev->power.runtime_auto == false)
536 return sprintf(buf, "forbidden\n");
537 return sprintf(buf, "enabled\n");
538}
539static DEVICE_ATTR_RO(runtime_enabled);
540
541#ifdef CONFIG_PM_SLEEP
542static ssize_t async_show(struct device *dev, struct device_attribute *attr,
543 char *buf)
544{
545 return sprintf(buf, "%s\n",
546 device_async_suspend_enabled(dev) ?
547 _enabled : _disabled);
548}
549
550static ssize_t async_store(struct device *dev, struct device_attribute *attr,
551 const char *buf, size_t n)
552{
553 if (sysfs_streq(buf, _enabled))
554 device_enable_async_suspend(dev);
555 else if (sysfs_streq(buf, _disabled))
556 device_disable_async_suspend(dev);
557 else
558 return -EINVAL;
559 return n;
560}
561
562static DEVICE_ATTR_RW(async);
563
564#endif /* CONFIG_PM_SLEEP */
565#endif /* CONFIG_PM_ADVANCED_DEBUG */
566
567static struct attribute *power_attrs[] = {
568#ifdef CONFIG_PM_ADVANCED_DEBUG
569#ifdef CONFIG_PM_SLEEP
570 &dev_attr_async.attr,
571#endif
572 &dev_attr_runtime_status.attr,
573 &dev_attr_runtime_usage.attr,
574 &dev_attr_runtime_active_kids.attr,
575 &dev_attr_runtime_enabled.attr,
576#endif /* CONFIG_PM_ADVANCED_DEBUG */
577 NULL,
578};
579static const struct attribute_group pm_attr_group = {
580 .name = power_group_name,
581 .attrs = power_attrs,
582};
583
584static struct attribute *wakeup_attrs[] = {
585#ifdef CONFIG_PM_SLEEP
586 &dev_attr_wakeup.attr,
587 &dev_attr_wakeup_count.attr,
588 &dev_attr_wakeup_active_count.attr,
589 &dev_attr_wakeup_abort_count.attr,
590 &dev_attr_wakeup_expire_count.attr,
591 &dev_attr_wakeup_active.attr,
592 &dev_attr_wakeup_total_time_ms.attr,
593 &dev_attr_wakeup_max_time_ms.attr,
594 &dev_attr_wakeup_last_time_ms.attr,
595#ifdef CONFIG_PM_AUTOSLEEP
596 &dev_attr_wakeup_prevent_sleep_time_ms.attr,
597#endif
598#endif
599 NULL,
600};
601static const struct attribute_group pm_wakeup_attr_group = {
602 .name = power_group_name,
603 .attrs = wakeup_attrs,
604};
605
606static struct attribute *runtime_attrs[] = {
607#ifndef CONFIG_PM_ADVANCED_DEBUG
608 &dev_attr_runtime_status.attr,
609#endif
610 &dev_attr_control.attr,
611 &dev_attr_runtime_suspended_time.attr,
612 &dev_attr_runtime_active_time.attr,
613 &dev_attr_autosuspend_delay_ms.attr,
614 NULL,
615};
616static const struct attribute_group pm_runtime_attr_group = {
617 .name = power_group_name,
618 .attrs = runtime_attrs,
619};
620
621static struct attribute *pm_qos_resume_latency_attrs[] = {
622 &dev_attr_pm_qos_resume_latency_us.attr,
623 NULL,
624};
625static const struct attribute_group pm_qos_resume_latency_attr_group = {
626 .name = power_group_name,
627 .attrs = pm_qos_resume_latency_attrs,
628};
629
630static struct attribute *pm_qos_latency_tolerance_attrs[] = {
631 &dev_attr_pm_qos_latency_tolerance_us.attr,
632 NULL,
633};
634static const struct attribute_group pm_qos_latency_tolerance_attr_group = {
635 .name = power_group_name,
636 .attrs = pm_qos_latency_tolerance_attrs,
637};
638
639static struct attribute *pm_qos_flags_attrs[] = {
640 &dev_attr_pm_qos_no_power_off.attr,
641 NULL,
642};
643static const struct attribute_group pm_qos_flags_attr_group = {
644 .name = power_group_name,
645 .attrs = pm_qos_flags_attrs,
646};
647
648int dpm_sysfs_add(struct device *dev)
649{
650 int rc;
651
652 /* No need to create PM sysfs if explicitly disabled. */
653 if (device_pm_not_required(dev))
654 return 0;
655
656 rc = sysfs_create_group(&dev->kobj, &pm_attr_group);
657 if (rc)
658 return rc;
659
660 if (pm_runtime_callbacks_present(dev)) {
661 rc = sysfs_merge_group(&dev->kobj, &pm_runtime_attr_group);
662 if (rc)
663 goto err_out;
664 }
665 if (device_can_wakeup(dev)) {
666 rc = sysfs_merge_group(&dev->kobj, &pm_wakeup_attr_group);
667 if (rc)
668 goto err_runtime;
669 }
670 if (dev->power.set_latency_tolerance) {
671 rc = sysfs_merge_group(&dev->kobj,
672 &pm_qos_latency_tolerance_attr_group);
673 if (rc)
674 goto err_wakeup;
675 }
676 rc = pm_wakeup_source_sysfs_add(dev);
677 if (rc)
678 goto err_latency;
679 return 0;
680
681 err_latency:
682 sysfs_unmerge_group(&dev->kobj, &pm_qos_latency_tolerance_attr_group);
683 err_wakeup:
684 sysfs_unmerge_group(&dev->kobj, &pm_wakeup_attr_group);
685 err_runtime:
686 sysfs_unmerge_group(&dev->kobj, &pm_runtime_attr_group);
687 err_out:
688 sysfs_remove_group(&dev->kobj, &pm_attr_group);
689 return rc;
690}
691
692int wakeup_sysfs_add(struct device *dev)
693{
694 return sysfs_merge_group(&dev->kobj, &pm_wakeup_attr_group);
695}
696
697void wakeup_sysfs_remove(struct device *dev)
698{
699 sysfs_unmerge_group(&dev->kobj, &pm_wakeup_attr_group);
700}
701
702int pm_qos_sysfs_add_resume_latency(struct device *dev)
703{
704 return sysfs_merge_group(&dev->kobj, &pm_qos_resume_latency_attr_group);
705}
706
707void pm_qos_sysfs_remove_resume_latency(struct device *dev)
708{
709 sysfs_unmerge_group(&dev->kobj, &pm_qos_resume_latency_attr_group);
710}
711
712int pm_qos_sysfs_add_flags(struct device *dev)
713{
714 return sysfs_merge_group(&dev->kobj, &pm_qos_flags_attr_group);
715}
716
717void pm_qos_sysfs_remove_flags(struct device *dev)
718{
719 sysfs_unmerge_group(&dev->kobj, &pm_qos_flags_attr_group);
720}
721
722int pm_qos_sysfs_add_latency_tolerance(struct device *dev)
723{
724 return sysfs_merge_group(&dev->kobj,
725 &pm_qos_latency_tolerance_attr_group);
726}
727
728void pm_qos_sysfs_remove_latency_tolerance(struct device *dev)
729{
730 sysfs_unmerge_group(&dev->kobj, &pm_qos_latency_tolerance_attr_group);
731}
732
733void rpm_sysfs_remove(struct device *dev)
734{
735 sysfs_unmerge_group(&dev->kobj, &pm_runtime_attr_group);
736}
737
738void dpm_sysfs_remove(struct device *dev)
739{
740 if (device_pm_not_required(dev))
741 return;
742 sysfs_unmerge_group(&dev->kobj, &pm_qos_latency_tolerance_attr_group);
743 dev_pm_qos_constraints_destroy(dev);
744 rpm_sysfs_remove(dev);
745 sysfs_unmerge_group(&dev->kobj, &pm_wakeup_attr_group);
746 sysfs_remove_group(&dev->kobj, &pm_attr_group);
747}