sysfs.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635
  1. /*
  2. * drivers/base/power/sysfs.c - sysfs entries for device PM
  3. */
  4. #include <linux/device.h>
  5. #include <linux/string.h>
  6. #include <linux/export.h>
  7. #include <linux/pm_qos.h>
  8. #include <linux/pm_runtime.h>
  9. #include <linux/atomic.h>
  10. #include <linux/jiffies.h>
  11. #include "power.h"
  12. /*
  13. * control - Report/change current runtime PM setting of the device
  14. *
  15. * Runtime power management of a device can be blocked with the help of
  16. * this attribute. All devices have one of the following two values for
  17. * the power/control file:
  18. *
  19. * + "auto\n" to allow the device to be power managed at run time;
  20. * + "on\n" to prevent the device from being power managed at run time;
  21. *
  22. * The default for all devices is "auto", which means that devices may be
  23. * subject to automatic power management, depending on their drivers.
  24. * Changing this attribute to "on" prevents the driver from power managing
  25. * the device at run time. Doing that while the device is suspended causes
  26. * it to be woken up.
  27. *
  28. * wakeup - Report/change current wakeup option for device
  29. *
  30. * Some devices support "wakeup" events, which are hardware signals
  31. * used to activate devices from suspended or low power states. Such
  32. * devices have one of three values for the sysfs power/wakeup file:
  33. *
  34. * + "enabled\n" to issue the events;
  35. * + "disabled\n" not to do so; or
  36. * + "\n" for temporary or permanent inability to issue wakeup.
  37. *
  38. * (For example, unconfigured USB devices can't issue wakeups.)
  39. *
  40. * Familiar examples of devices that can issue wakeup events include
  41. * keyboards and mice (both PS2 and USB styles), power buttons, modems,
  42. * "Wake-On-LAN" Ethernet links, GPIO lines, and more. Some events
  43. * will wake the entire system from a suspend state; others may just
  44. * wake up the device (if the system as a whole is already active).
  45. * Some wakeup events use normal IRQ lines; other use special out
  46. * of band signaling.
  47. *
  48. * It is the responsibility of device drivers to enable (or disable)
  49. * wakeup signaling as part of changing device power states, respecting
  50. * the policy choices provided through the driver model.
  51. *
  52. * Devices may not be able to generate wakeup events from all power
  53. * states. Also, the events may be ignored in some configurations;
  54. * for example, they might need help from other devices that aren't
  55. * active, or which may have wakeup disabled. Some drivers rely on
  56. * wakeup events internally (unless they are disabled), keeping
  57. * their hardware in low power modes whenever they're unused. This
  58. * saves runtime power, without requiring system-wide sleep states.
  59. *
  60. * async - Report/change current async suspend setting for the device
  61. *
  62. * Asynchronous suspend and resume of the device during system-wide power
  63. * state transitions can be enabled by writing "enabled" to this file.
  64. * Analogously, if "disabled" is written to this file, the device will be
  65. * suspended and resumed synchronously.
  66. *
  67. * All devices have one of the following two values for power/async:
  68. *
  69. * + "enabled\n" to permit the asynchronous suspend/resume of the device;
  70. * + "disabled\n" to forbid it;
  71. *
  72. * NOTE: It generally is unsafe to permit the asynchronous suspend/resume
  73. * of a device unless it is certain that all of the PM dependencies of the
  74. * device are known to the PM core. However, for some devices this
  75. * attribute is set to "enabled" by bus type code or device drivers and in
  76. * that cases it should be safe to leave the default value.
  77. *
  78. * autosuspend_delay_ms - Report/change a device's autosuspend_delay value
  79. *
  80. * Some drivers don't want to carry out a runtime suspend as soon as a
  81. * device becomes idle; they want it always to remain idle for some period
  82. * of time before suspending it. This period is the autosuspend_delay
  83. * value (expressed in milliseconds) and it can be controlled by the user.
  84. * If the value is negative then the device will never be runtime
  85. * suspended.
  86. *
  87. * NOTE: The autosuspend_delay_ms attribute and the autosuspend_delay
  88. * value are used only if the driver calls pm_runtime_use_autosuspend().
  89. *
  90. * wakeup_count - Report the number of wakeup events related to the device
  91. */
  92. static const char enabled[] = "enabled";
  93. static const char disabled[] = "disabled";
  94. const char power_group_name[] = "power";
  95. EXPORT_SYMBOL_GPL(power_group_name);
  96. #ifdef CONFIG_PM_RUNTIME
  97. static const char ctrl_auto[] = "auto";
  98. static const char ctrl_on[] = "on";
  99. static ssize_t control_show(struct device *dev, struct device_attribute *attr,
  100. char *buf)
  101. {
  102. return sprintf(buf, "%s\n",
  103. dev->power.runtime_auto ? ctrl_auto : ctrl_on);
  104. }
  105. static ssize_t control_store(struct device * dev, struct device_attribute *attr,
  106. const char * buf, size_t n)
  107. {
  108. char *cp;
  109. int len = n;
  110. cp = memchr(buf, '\n', n);
  111. if (cp)
  112. len = cp - buf;
  113. device_lock(dev);
  114. if (len == sizeof ctrl_auto - 1 && strncmp(buf, ctrl_auto, len) == 0)
  115. pm_runtime_allow(dev);
  116. else if (len == sizeof ctrl_on - 1 && strncmp(buf, ctrl_on, len) == 0)
  117. pm_runtime_forbid(dev);
  118. else
  119. n = -EINVAL;
  120. device_unlock(dev);
  121. return n;
  122. }
  123. static DEVICE_ATTR(control, 0644, control_show, control_store);
  124. static ssize_t rtpm_active_time_show(struct device *dev,
  125. struct device_attribute *attr, char *buf)
  126. {
  127. int ret;
  128. spin_lock_irq(&dev->power.lock);
  129. update_pm_runtime_accounting(dev);
  130. ret = sprintf(buf, "%i\n", jiffies_to_msecs(dev->power.active_jiffies));
  131. spin_unlock_irq(&dev->power.lock);
  132. return ret;
  133. }
  134. static DEVICE_ATTR(runtime_active_time, 0444, rtpm_active_time_show, NULL);
  135. static ssize_t rtpm_suspended_time_show(struct device *dev,
  136. struct device_attribute *attr, char *buf)
  137. {
  138. int ret;
  139. spin_lock_irq(&dev->power.lock);
  140. update_pm_runtime_accounting(dev);
  141. ret = sprintf(buf, "%i\n",
  142. jiffies_to_msecs(dev->power.suspended_jiffies));
  143. spin_unlock_irq(&dev->power.lock);
  144. return ret;
  145. }
  146. static DEVICE_ATTR(runtime_suspended_time, 0444, rtpm_suspended_time_show, NULL);
  147. static ssize_t rtpm_status_show(struct device *dev,
  148. struct device_attribute *attr, char *buf)
  149. {
  150. const char *p;
  151. if (dev->power.runtime_error) {
  152. p = "error\n";
  153. } else if (dev->power.disable_depth) {
  154. p = "unsupported\n";
  155. } else {
  156. switch (dev->power.runtime_status) {
  157. case RPM_SUSPENDED:
  158. p = "suspended\n";
  159. break;
  160. case RPM_SUSPENDING:
  161. p = "suspending\n";
  162. break;
  163. case RPM_RESUMING:
  164. p = "resuming\n";
  165. break;
  166. case RPM_ACTIVE:
  167. p = "active\n";
  168. break;
  169. default:
  170. return -EIO;
  171. }
  172. }
  173. return sprintf(buf, p);
  174. }
  175. static DEVICE_ATTR(runtime_status, 0444, rtpm_status_show, NULL);
  176. static ssize_t autosuspend_delay_ms_show(struct device *dev,
  177. struct device_attribute *attr, char *buf)
  178. {
  179. if (!dev->power.use_autosuspend)
  180. return -EIO;
  181. return sprintf(buf, "%d\n", dev->power.autosuspend_delay);
  182. }
  183. static ssize_t autosuspend_delay_ms_store(struct device *dev,
  184. struct device_attribute *attr, const char *buf, size_t n)
  185. {
  186. long delay;
  187. if (!dev->power.use_autosuspend)
  188. return -EIO;
  189. if (strict_strtol(buf, 10, &delay) != 0 || delay != (int) delay)
  190. return -EINVAL;
  191. device_lock(dev);
  192. pm_runtime_set_autosuspend_delay(dev, delay);
  193. device_unlock(dev);
  194. return n;
  195. }
  196. static DEVICE_ATTR(autosuspend_delay_ms, 0644, autosuspend_delay_ms_show,
  197. autosuspend_delay_ms_store);
  198. static ssize_t pm_qos_latency_show(struct device *dev,
  199. struct device_attribute *attr, char *buf)
  200. {
  201. return sprintf(buf, "%d\n", dev->power.pq_req->node.prio);
  202. }
  203. static ssize_t pm_qos_latency_store(struct device *dev,
  204. struct device_attribute *attr,
  205. const char *buf, size_t n)
  206. {
  207. s32 value;
  208. int ret;
  209. if (kstrtos32(buf, 0, &value))
  210. return -EINVAL;
  211. if (value < 0)
  212. return -EINVAL;
  213. ret = dev_pm_qos_update_request(dev->power.pq_req, value);
  214. return ret < 0 ? ret : n;
  215. }
  216. static DEVICE_ATTR(pm_qos_resume_latency_us, 0644,
  217. pm_qos_latency_show, pm_qos_latency_store);
  218. #endif /* CONFIG_PM_RUNTIME */
  219. #ifdef CONFIG_PM_SLEEP
  220. static ssize_t
  221. wake_show(struct device * dev, struct device_attribute *attr, char * buf)
  222. {
  223. return sprintf(buf, "%s\n", device_can_wakeup(dev)
  224. ? (device_may_wakeup(dev) ? enabled : disabled)
  225. : "");
  226. }
  227. static ssize_t
  228. wake_store(struct device * dev, struct device_attribute *attr,
  229. const char * buf, size_t n)
  230. {
  231. char *cp;
  232. int len = n;
  233. if (!device_can_wakeup(dev))
  234. return -EINVAL;
  235. cp = memchr(buf, '\n', n);
  236. if (cp)
  237. len = cp - buf;
  238. if (len == sizeof enabled - 1
  239. && strncmp(buf, enabled, sizeof enabled - 1) == 0)
  240. device_set_wakeup_enable(dev, 1);
  241. else if (len == sizeof disabled - 1
  242. && strncmp(buf, disabled, sizeof disabled - 1) == 0)
  243. device_set_wakeup_enable(dev, 0);
  244. else
  245. return -EINVAL;
  246. return n;
  247. }
  248. static DEVICE_ATTR(wakeup, 0644, wake_show, wake_store);
  249. static ssize_t wakeup_count_show(struct device *dev,
  250. struct device_attribute *attr, char *buf)
  251. {
  252. unsigned long count = 0;
  253. bool enabled = false;
  254. spin_lock_irq(&dev->power.lock);
  255. if (dev->power.wakeup) {
  256. count = dev->power.wakeup->event_count;
  257. enabled = true;
  258. }
  259. spin_unlock_irq(&dev->power.lock);
  260. return enabled ? sprintf(buf, "%lu\n", count) : sprintf(buf, "\n");
  261. }
  262. static DEVICE_ATTR(wakeup_count, 0444, wakeup_count_show, NULL);
  263. static ssize_t wakeup_active_count_show(struct device *dev,
  264. struct device_attribute *attr, char *buf)
  265. {
  266. unsigned long count = 0;
  267. bool enabled = false;
  268. spin_lock_irq(&dev->power.lock);
  269. if (dev->power.wakeup) {
  270. count = dev->power.wakeup->active_count;
  271. enabled = true;
  272. }
  273. spin_unlock_irq(&dev->power.lock);
  274. return enabled ? sprintf(buf, "%lu\n", count) : sprintf(buf, "\n");
  275. }
  276. static DEVICE_ATTR(wakeup_active_count, 0444, wakeup_active_count_show, NULL);
  277. static ssize_t wakeup_abort_count_show(struct device *dev,
  278. struct device_attribute *attr,
  279. char *buf)
  280. {
  281. unsigned long count = 0;
  282. bool enabled = false;
  283. spin_lock_irq(&dev->power.lock);
  284. if (dev->power.wakeup) {
  285. count = dev->power.wakeup->wakeup_count;
  286. enabled = true;
  287. }
  288. spin_unlock_irq(&dev->power.lock);
  289. return enabled ? sprintf(buf, "%lu\n", count) : sprintf(buf, "\n");
  290. }
  291. static DEVICE_ATTR(wakeup_abort_count, 0444, wakeup_abort_count_show, NULL);
  292. static ssize_t wakeup_expire_count_show(struct device *dev,
  293. struct device_attribute *attr,
  294. char *buf)
  295. {
  296. unsigned long count = 0;
  297. bool enabled = false;
  298. spin_lock_irq(&dev->power.lock);
  299. if (dev->power.wakeup) {
  300. count = dev->power.wakeup->expire_count;
  301. enabled = true;
  302. }
  303. spin_unlock_irq(&dev->power.lock);
  304. return enabled ? sprintf(buf, "%lu\n", count) : sprintf(buf, "\n");
  305. }
  306. static DEVICE_ATTR(wakeup_expire_count, 0444, wakeup_expire_count_show, NULL);
  307. static ssize_t wakeup_active_show(struct device *dev,
  308. struct device_attribute *attr, char *buf)
  309. {
  310. unsigned int active = 0;
  311. bool enabled = false;
  312. spin_lock_irq(&dev->power.lock);
  313. if (dev->power.wakeup) {
  314. active = dev->power.wakeup->active;
  315. enabled = true;
  316. }
  317. spin_unlock_irq(&dev->power.lock);
  318. return enabled ? sprintf(buf, "%u\n", active) : sprintf(buf, "\n");
  319. }
  320. static DEVICE_ATTR(wakeup_active, 0444, wakeup_active_show, NULL);
  321. static ssize_t wakeup_total_time_show(struct device *dev,
  322. struct device_attribute *attr, char *buf)
  323. {
  324. s64 msec = 0;
  325. bool enabled = false;
  326. spin_lock_irq(&dev->power.lock);
  327. if (dev->power.wakeup) {
  328. msec = ktime_to_ms(dev->power.wakeup->total_time);
  329. enabled = true;
  330. }
  331. spin_unlock_irq(&dev->power.lock);
  332. return enabled ? sprintf(buf, "%lld\n", msec) : sprintf(buf, "\n");
  333. }
  334. static DEVICE_ATTR(wakeup_total_time_ms, 0444, wakeup_total_time_show, NULL);
  335. static ssize_t wakeup_max_time_show(struct device *dev,
  336. struct device_attribute *attr, char *buf)
  337. {
  338. s64 msec = 0;
  339. bool enabled = false;
  340. spin_lock_irq(&dev->power.lock);
  341. if (dev->power.wakeup) {
  342. msec = ktime_to_ms(dev->power.wakeup->max_time);
  343. enabled = true;
  344. }
  345. spin_unlock_irq(&dev->power.lock);
  346. return enabled ? sprintf(buf, "%lld\n", msec) : sprintf(buf, "\n");
  347. }
  348. static DEVICE_ATTR(wakeup_max_time_ms, 0444, wakeup_max_time_show, NULL);
  349. static ssize_t wakeup_last_time_show(struct device *dev,
  350. struct device_attribute *attr, char *buf)
  351. {
  352. s64 msec = 0;
  353. bool enabled = false;
  354. spin_lock_irq(&dev->power.lock);
  355. if (dev->power.wakeup) {
  356. msec = ktime_to_ms(dev->power.wakeup->last_time);
  357. enabled = true;
  358. }
  359. spin_unlock_irq(&dev->power.lock);
  360. return enabled ? sprintf(buf, "%lld\n", msec) : sprintf(buf, "\n");
  361. }
  362. static DEVICE_ATTR(wakeup_last_time_ms, 0444, wakeup_last_time_show, NULL);
  363. #ifdef CONFIG_PM_AUTOSLEEP
  364. static ssize_t wakeup_prevent_sleep_time_show(struct device *dev,
  365. struct device_attribute *attr,
  366. char *buf)
  367. {
  368. s64 msec = 0;
  369. bool enabled = false;
  370. spin_lock_irq(&dev->power.lock);
  371. if (dev->power.wakeup) {
  372. msec = ktime_to_ms(dev->power.wakeup->prevent_sleep_time);
  373. enabled = true;
  374. }
  375. spin_unlock_irq(&dev->power.lock);
  376. return enabled ? sprintf(buf, "%lld\n", msec) : sprintf(buf, "\n");
  377. }
  378. static DEVICE_ATTR(wakeup_prevent_sleep_time_ms, 0444,
  379. wakeup_prevent_sleep_time_show, NULL);
  380. #endif /* CONFIG_PM_AUTOSLEEP */
  381. #endif /* CONFIG_PM_SLEEP */
  382. #ifdef CONFIG_PM_ADVANCED_DEBUG
  383. #ifdef CONFIG_PM_RUNTIME
  384. static ssize_t rtpm_usagecount_show(struct device *dev,
  385. struct device_attribute *attr, char *buf)
  386. {
  387. return sprintf(buf, "%d\n", atomic_read(&dev->power.usage_count));
  388. }
  389. static ssize_t rtpm_children_show(struct device *dev,
  390. struct device_attribute *attr, char *buf)
  391. {
  392. return sprintf(buf, "%d\n", dev->power.ignore_children ?
  393. 0 : atomic_read(&dev->power.child_count));
  394. }
  395. static ssize_t rtpm_enabled_show(struct device *dev,
  396. struct device_attribute *attr, char *buf)
  397. {
  398. if ((dev->power.disable_depth) && (dev->power.runtime_auto == false))
  399. return sprintf(buf, "disabled & forbidden\n");
  400. else if (dev->power.disable_depth)
  401. return sprintf(buf, "disabled\n");
  402. else if (dev->power.runtime_auto == false)
  403. return sprintf(buf, "forbidden\n");
  404. return sprintf(buf, "enabled\n");
  405. }
  406. static DEVICE_ATTR(runtime_usage, 0444, rtpm_usagecount_show, NULL);
  407. static DEVICE_ATTR(runtime_active_kids, 0444, rtpm_children_show, NULL);
  408. static DEVICE_ATTR(runtime_enabled, 0444, rtpm_enabled_show, NULL);
  409. #endif
  410. static ssize_t async_show(struct device *dev, struct device_attribute *attr,
  411. char *buf)
  412. {
  413. return sprintf(buf, "%s\n",
  414. device_async_suspend_enabled(dev) ? enabled : disabled);
  415. }
  416. static ssize_t async_store(struct device *dev, struct device_attribute *attr,
  417. const char *buf, size_t n)
  418. {
  419. char *cp;
  420. int len = n;
  421. cp = memchr(buf, '\n', n);
  422. if (cp)
  423. len = cp - buf;
  424. if (len == sizeof enabled - 1 && strncmp(buf, enabled, len) == 0)
  425. device_enable_async_suspend(dev);
  426. else if (len == sizeof disabled - 1 && strncmp(buf, disabled, len) == 0)
  427. device_disable_async_suspend(dev);
  428. else
  429. return -EINVAL;
  430. return n;
  431. }
  432. static DEVICE_ATTR(async, 0644, async_show, async_store);
  433. #endif /* CONFIG_PM_ADVANCED_DEBUG */
  434. static struct attribute *power_attrs[] = {
  435. #ifdef CONFIG_PM_ADVANCED_DEBUG
  436. #ifdef CONFIG_PM_SLEEP
  437. &dev_attr_async.attr,
  438. #endif
  439. #ifdef CONFIG_PM_RUNTIME
  440. &dev_attr_runtime_status.attr,
  441. &dev_attr_runtime_usage.attr,
  442. &dev_attr_runtime_active_kids.attr,
  443. &dev_attr_runtime_enabled.attr,
  444. #endif
  445. #endif /* CONFIG_PM_ADVANCED_DEBUG */
  446. NULL,
  447. };
  448. static struct attribute_group pm_attr_group = {
  449. .name = power_group_name,
  450. .attrs = power_attrs,
  451. };
  452. static struct attribute *wakeup_attrs[] = {
  453. #ifdef CONFIG_PM_SLEEP
  454. &dev_attr_wakeup.attr,
  455. &dev_attr_wakeup_count.attr,
  456. &dev_attr_wakeup_active_count.attr,
  457. &dev_attr_wakeup_abort_count.attr,
  458. &dev_attr_wakeup_expire_count.attr,
  459. &dev_attr_wakeup_active.attr,
  460. &dev_attr_wakeup_total_time_ms.attr,
  461. &dev_attr_wakeup_max_time_ms.attr,
  462. &dev_attr_wakeup_last_time_ms.attr,
  463. #ifdef CONFIG_PM_AUTOSLEEP
  464. &dev_attr_wakeup_prevent_sleep_time_ms.attr,
  465. #endif
  466. #endif
  467. NULL,
  468. };
  469. static struct attribute_group pm_wakeup_attr_group = {
  470. .name = power_group_name,
  471. .attrs = wakeup_attrs,
  472. };
  473. static struct attribute *runtime_attrs[] = {
  474. #ifdef CONFIG_PM_RUNTIME
  475. #ifndef CONFIG_PM_ADVANCED_DEBUG
  476. &dev_attr_runtime_status.attr,
  477. #endif
  478. &dev_attr_control.attr,
  479. &dev_attr_runtime_suspended_time.attr,
  480. &dev_attr_runtime_active_time.attr,
  481. &dev_attr_autosuspend_delay_ms.attr,
  482. #endif /* CONFIG_PM_RUNTIME */
  483. NULL,
  484. };
  485. static struct attribute_group pm_runtime_attr_group = {
  486. .name = power_group_name,
  487. .attrs = runtime_attrs,
  488. };
  489. static struct attribute *pm_qos_attrs[] = {
  490. #ifdef CONFIG_PM_RUNTIME
  491. &dev_attr_pm_qos_resume_latency_us.attr,
  492. #endif /* CONFIG_PM_RUNTIME */
  493. NULL,
  494. };
  495. static struct attribute_group pm_qos_attr_group = {
  496. .name = power_group_name,
  497. .attrs = pm_qos_attrs,
  498. };
  499. int dpm_sysfs_add(struct device *dev)
  500. {
  501. int rc;
  502. rc = sysfs_create_group(&dev->kobj, &pm_attr_group);
  503. if (rc)
  504. return rc;
  505. if (pm_runtime_callbacks_present(dev)) {
  506. rc = sysfs_merge_group(&dev->kobj, &pm_runtime_attr_group);
  507. if (rc)
  508. goto err_out;
  509. }
  510. if (device_can_wakeup(dev)) {
  511. rc = sysfs_merge_group(&dev->kobj, &pm_wakeup_attr_group);
  512. if (rc) {
  513. if (pm_runtime_callbacks_present(dev))
  514. sysfs_unmerge_group(&dev->kobj,
  515. &pm_runtime_attr_group);
  516. goto err_out;
  517. }
  518. }
  519. return 0;
  520. err_out:
  521. sysfs_remove_group(&dev->kobj, &pm_attr_group);
  522. return rc;
  523. }
  524. int wakeup_sysfs_add(struct device *dev)
  525. {
  526. return sysfs_merge_group(&dev->kobj, &pm_wakeup_attr_group);
  527. }
  528. void wakeup_sysfs_remove(struct device *dev)
  529. {
  530. sysfs_unmerge_group(&dev->kobj, &pm_wakeup_attr_group);
  531. }
  532. int pm_qos_sysfs_add(struct device *dev)
  533. {
  534. return sysfs_merge_group(&dev->kobj, &pm_qos_attr_group);
  535. }
  536. void pm_qos_sysfs_remove(struct device *dev)
  537. {
  538. sysfs_unmerge_group(&dev->kobj, &pm_qos_attr_group);
  539. }
  540. void rpm_sysfs_remove(struct device *dev)
  541. {
  542. sysfs_unmerge_group(&dev->kobj, &pm_runtime_attr_group);
  543. }
  544. void dpm_sysfs_remove(struct device *dev)
  545. {
  546. rpm_sysfs_remove(dev);
  547. sysfs_unmerge_group(&dev->kobj, &pm_wakeup_attr_group);
  548. sysfs_remove_group(&dev->kobj, &pm_attr_group);
  549. }