main.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754
  1. /*
  2. * kernel/power/main.c - PM subsystem core functionality.
  3. *
  4. * Copyright (c) 2003 Patrick Mochel
  5. * Copyright (c) 2003 Open Source Development Lab
  6. *
  7. * This file is released under the GPLv2
  8. *
  9. */
  10. #include <linux/module.h>
  11. #include <linux/suspend.h>
  12. #include <linux/kobject.h>
  13. #include <linux/string.h>
  14. #include <linux/delay.h>
  15. #include <linux/errno.h>
  16. #include <linux/kmod.h>
  17. #include <linux/init.h>
  18. #include <linux/console.h>
  19. #include <linux/cpu.h>
  20. #include <linux/resume-trace.h>
  21. #include <linux/freezer.h>
  22. #include <linux/vmstat.h>
  23. #include <linux/syscalls.h>
  24. #include "power.h"
  25. DEFINE_MUTEX(pm_mutex);
  26. unsigned int pm_flags;
  27. EXPORT_SYMBOL(pm_flags);
  28. #ifdef CONFIG_PM_SLEEP
  29. /* Routines for PM-transition notifications */
  30. static BLOCKING_NOTIFIER_HEAD(pm_chain_head);
  31. int register_pm_notifier(struct notifier_block *nb)
  32. {
  33. return blocking_notifier_chain_register(&pm_chain_head, nb);
  34. }
  35. EXPORT_SYMBOL_GPL(register_pm_notifier);
  36. int unregister_pm_notifier(struct notifier_block *nb)
  37. {
  38. return blocking_notifier_chain_unregister(&pm_chain_head, nb);
  39. }
  40. EXPORT_SYMBOL_GPL(unregister_pm_notifier);
  41. int pm_notifier_call_chain(unsigned long val)
  42. {
  43. return (blocking_notifier_call_chain(&pm_chain_head, val, NULL)
  44. == NOTIFY_BAD) ? -EINVAL : 0;
  45. }
  46. #ifdef CONFIG_PM_DEBUG
  47. int pm_test_level = TEST_NONE;
  48. static const char * const pm_tests[__TEST_AFTER_LAST] = {
  49. [TEST_NONE] = "none",
  50. [TEST_CORE] = "core",
  51. [TEST_CPUS] = "processors",
  52. [TEST_PLATFORM] = "platform",
  53. [TEST_DEVICES] = "devices",
  54. [TEST_FREEZER] = "freezer",
  55. };
  56. static ssize_t pm_test_show(struct kobject *kobj, struct kobj_attribute *attr,
  57. char *buf)
  58. {
  59. char *s = buf;
  60. int level;
  61. for (level = TEST_FIRST; level <= TEST_MAX; level++)
  62. if (pm_tests[level]) {
  63. if (level == pm_test_level)
  64. s += sprintf(s, "[%s] ", pm_tests[level]);
  65. else
  66. s += sprintf(s, "%s ", pm_tests[level]);
  67. }
  68. if (s != buf)
  69. /* convert the last space to a newline */
  70. *(s-1) = '\n';
  71. return (s - buf);
  72. }
  73. static ssize_t pm_test_store(struct kobject *kobj, struct kobj_attribute *attr,
  74. const char *buf, size_t n)
  75. {
  76. const char * const *s;
  77. int level;
  78. char *p;
  79. int len;
  80. int error = -EINVAL;
  81. p = memchr(buf, '\n', n);
  82. len = p ? p - buf : n;
  83. mutex_lock(&pm_mutex);
  84. level = TEST_FIRST;
  85. for (s = &pm_tests[level]; level <= TEST_MAX; s++, level++)
  86. if (*s && len == strlen(*s) && !strncmp(buf, *s, len)) {
  87. pm_test_level = level;
  88. error = 0;
  89. break;
  90. }
  91. mutex_unlock(&pm_mutex);
  92. return error ? error : n;
  93. }
  94. power_attr(pm_test);
  95. #endif /* CONFIG_PM_DEBUG */
  96. #endif /* CONFIG_PM_SLEEP */
  97. #ifdef CONFIG_SUSPEND
  98. static int suspend_test(int level)
  99. {
  100. #ifdef CONFIG_PM_DEBUG
  101. if (pm_test_level == level) {
  102. printk(KERN_INFO "suspend debug: Waiting for 5 seconds.\n");
  103. mdelay(5000);
  104. return 1;
  105. }
  106. #endif /* !CONFIG_PM_DEBUG */
  107. return 0;
  108. }
  109. #ifdef CONFIG_PM_TEST_SUSPEND
  110. /*
  111. * We test the system suspend code by setting an RTC wakealarm a short
  112. * time in the future, then suspending. Suspending the devices won't
  113. * normally take long ... some systems only need a few milliseconds.
  114. *
  115. * The time it takes is system-specific though, so when we test this
  116. * during system bootup we allow a LOT of time.
  117. */
  118. #define TEST_SUSPEND_SECONDS 5
  119. static unsigned long suspend_test_start_time;
  120. static void suspend_test_start(void)
  121. {
  122. /* FIXME Use better timebase than "jiffies", ideally a clocksource.
  123. * What we want is a hardware counter that will work correctly even
  124. * during the irqs-are-off stages of the suspend/resume cycle...
  125. */
  126. suspend_test_start_time = jiffies;
  127. }
  128. static void suspend_test_finish(const char *label)
  129. {
  130. long nj = jiffies - suspend_test_start_time;
  131. unsigned msec;
  132. msec = jiffies_to_msecs(abs(nj));
  133. pr_info("PM: %s took %d.%03d seconds\n", label,
  134. msec / 1000, msec % 1000);
  135. /* Warning on suspend means the RTC alarm period needs to be
  136. * larger -- the system was sooo slooowwww to suspend that the
  137. * alarm (should have) fired before the system went to sleep!
  138. *
  139. * Warning on either suspend or resume also means the system
  140. * has some performance issues. The stack dump of a WARN_ON
  141. * is more likely to get the right attention than a printk...
  142. */
  143. WARN(msec > (TEST_SUSPEND_SECONDS * 1000), "Component: %s\n", label);
  144. }
  145. #else
  146. static void suspend_test_start(void)
  147. {
  148. }
  149. static void suspend_test_finish(const char *label)
  150. {
  151. }
  152. #endif
  153. /* This is just an arbitrary number */
  154. #define FREE_PAGE_NUMBER (100)
  155. static struct platform_suspend_ops *suspend_ops;
  156. /**
  157. * suspend_set_ops - Set the global suspend method table.
  158. * @ops: Pointer to ops structure.
  159. */
  160. void suspend_set_ops(struct platform_suspend_ops *ops)
  161. {
  162. mutex_lock(&pm_mutex);
  163. suspend_ops = ops;
  164. mutex_unlock(&pm_mutex);
  165. }
  166. /**
  167. * suspend_valid_only_mem - generic memory-only valid callback
  168. *
  169. * Platform drivers that implement mem suspend only and only need
  170. * to check for that in their .valid callback can use this instead
  171. * of rolling their own .valid callback.
  172. */
  173. int suspend_valid_only_mem(suspend_state_t state)
  174. {
  175. return state == PM_SUSPEND_MEM;
  176. }
  177. /**
  178. * suspend_prepare - Do prep work before entering low-power state.
  179. *
  180. * This is common code that is called for each state that we're entering.
  181. * Run suspend notifiers, allocate a console and stop all processes.
  182. */
  183. static int suspend_prepare(void)
  184. {
  185. int error;
  186. unsigned int free_pages;
  187. if (!suspend_ops || !suspend_ops->enter)
  188. return -EPERM;
  189. pm_prepare_console();
  190. error = pm_notifier_call_chain(PM_SUSPEND_PREPARE);
  191. if (error)
  192. goto Finish;
  193. error = usermodehelper_disable();
  194. if (error)
  195. goto Finish;
  196. if (suspend_freeze_processes()) {
  197. error = -EAGAIN;
  198. goto Thaw;
  199. }
  200. free_pages = global_page_state(NR_FREE_PAGES);
  201. if (free_pages < FREE_PAGE_NUMBER) {
  202. pr_debug("PM: free some memory\n");
  203. shrink_all_memory(FREE_PAGE_NUMBER - free_pages);
  204. if (nr_free_pages() < FREE_PAGE_NUMBER) {
  205. error = -ENOMEM;
  206. printk(KERN_ERR "PM: No enough memory\n");
  207. }
  208. }
  209. if (!error)
  210. return 0;
  211. Thaw:
  212. suspend_thaw_processes();
  213. usermodehelper_enable();
  214. Finish:
  215. pm_notifier_call_chain(PM_POST_SUSPEND);
  216. pm_restore_console();
  217. return error;
  218. }
  219. /* default implementation */
  220. void __attribute__ ((weak)) arch_suspend_disable_irqs(void)
  221. {
  222. local_irq_disable();
  223. }
  224. /* default implementation */
  225. void __attribute__ ((weak)) arch_suspend_enable_irqs(void)
  226. {
  227. local_irq_enable();
  228. }
  229. /**
  230. * suspend_enter - enter the desired system sleep state.
  231. * @state: state to enter
  232. *
  233. * This function should be called after devices have been suspended.
  234. */
  235. static int suspend_enter(suspend_state_t state)
  236. {
  237. int error;
  238. device_pm_lock();
  239. if (suspend_ops->prepare) {
  240. error = suspend_ops->prepare();
  241. if (error)
  242. goto Done;
  243. }
  244. error = device_power_down(PMSG_SUSPEND);
  245. if (error) {
  246. printk(KERN_ERR "PM: Some devices failed to power down\n");
  247. goto Platfrom_finish;
  248. }
  249. if (suspend_ops->prepare_late) {
  250. error = suspend_ops->prepare_late();
  251. if (error)
  252. goto Power_up_devices;
  253. }
  254. if (suspend_test(TEST_PLATFORM))
  255. goto Platform_wake;
  256. error = disable_nonboot_cpus();
  257. if (error || suspend_test(TEST_CPUS))
  258. goto Enable_cpus;
  259. arch_suspend_disable_irqs();
  260. BUG_ON(!irqs_disabled());
  261. error = sysdev_suspend(PMSG_SUSPEND);
  262. if (!error) {
  263. if (!suspend_test(TEST_CORE))
  264. error = suspend_ops->enter(state);
  265. sysdev_resume();
  266. }
  267. arch_suspend_enable_irqs();
  268. BUG_ON(irqs_disabled());
  269. Enable_cpus:
  270. enable_nonboot_cpus();
  271. Platform_wake:
  272. if (suspend_ops->wake)
  273. suspend_ops->wake();
  274. Power_up_devices:
  275. device_power_up(PMSG_RESUME);
  276. Platfrom_finish:
  277. if (suspend_ops->finish)
  278. suspend_ops->finish();
  279. Done:
  280. device_pm_unlock();
  281. return error;
  282. }
  283. /**
  284. * suspend_devices_and_enter - suspend devices and enter the desired system
  285. * sleep state.
  286. * @state: state to enter
  287. */
  288. int suspend_devices_and_enter(suspend_state_t state)
  289. {
  290. int error;
  291. if (!suspend_ops)
  292. return -ENOSYS;
  293. if (suspend_ops->begin) {
  294. error = suspend_ops->begin(state);
  295. if (error)
  296. goto Close;
  297. }
  298. suspend_console();
  299. suspend_test_start();
  300. error = device_suspend(PMSG_SUSPEND);
  301. if (error) {
  302. printk(KERN_ERR "PM: Some devices failed to suspend\n");
  303. goto Recover_platform;
  304. }
  305. suspend_test_finish("suspend devices");
  306. if (suspend_test(TEST_DEVICES))
  307. goto Recover_platform;
  308. suspend_enter(state);
  309. Resume_devices:
  310. suspend_test_start();
  311. device_resume(PMSG_RESUME);
  312. suspend_test_finish("resume devices");
  313. resume_console();
  314. Close:
  315. if (suspend_ops->end)
  316. suspend_ops->end();
  317. return error;
  318. Recover_platform:
  319. if (suspend_ops->recover)
  320. suspend_ops->recover();
  321. goto Resume_devices;
  322. }
  323. /**
  324. * suspend_finish - Do final work before exiting suspend sequence.
  325. *
  326. * Call platform code to clean up, restart processes, and free the
  327. * console that we've allocated. This is not called for suspend-to-disk.
  328. */
  329. static void suspend_finish(void)
  330. {
  331. suspend_thaw_processes();
  332. usermodehelper_enable();
  333. pm_notifier_call_chain(PM_POST_SUSPEND);
  334. pm_restore_console();
  335. }
  336. static const char * const pm_states[PM_SUSPEND_MAX] = {
  337. [PM_SUSPEND_STANDBY] = "standby",
  338. [PM_SUSPEND_MEM] = "mem",
  339. };
  340. static inline int valid_state(suspend_state_t state)
  341. {
  342. /* All states need lowlevel support and need to be valid
  343. * to the lowlevel implementation, no valid callback
  344. * implies that none are valid. */
  345. if (!suspend_ops || !suspend_ops->valid || !suspend_ops->valid(state))
  346. return 0;
  347. return 1;
  348. }
  349. /**
  350. * enter_state - Do common work of entering low-power state.
  351. * @state: pm_state structure for state we're entering.
  352. *
  353. * Make sure we're the only ones trying to enter a sleep state. Fail
  354. * if someone has beat us to it, since we don't want anything weird to
  355. * happen when we wake up.
  356. * Then, do the setup for suspend, enter the state, and cleaup (after
  357. * we've woken up).
  358. */
  359. static int enter_state(suspend_state_t state)
  360. {
  361. int error;
  362. if (!valid_state(state))
  363. return -ENODEV;
  364. if (!mutex_trylock(&pm_mutex))
  365. return -EBUSY;
  366. printk(KERN_INFO "PM: Syncing filesystems ... ");
  367. sys_sync();
  368. printk("done.\n");
  369. pr_debug("PM: Preparing system for %s sleep\n", pm_states[state]);
  370. error = suspend_prepare();
  371. if (error)
  372. goto Unlock;
  373. if (suspend_test(TEST_FREEZER))
  374. goto Finish;
  375. pr_debug("PM: Entering %s sleep\n", pm_states[state]);
  376. error = suspend_devices_and_enter(state);
  377. Finish:
  378. pr_debug("PM: Finishing wakeup.\n");
  379. suspend_finish();
  380. Unlock:
  381. mutex_unlock(&pm_mutex);
  382. return error;
  383. }
  384. /**
  385. * pm_suspend - Externally visible function for suspending system.
  386. * @state: Enumerated value of state to enter.
  387. *
  388. * Determine whether or not value is within range, get state
  389. * structure, and enter (above).
  390. */
  391. int pm_suspend(suspend_state_t state)
  392. {
  393. if (state > PM_SUSPEND_ON && state <= PM_SUSPEND_MAX)
  394. return enter_state(state);
  395. return -EINVAL;
  396. }
  397. EXPORT_SYMBOL(pm_suspend);
  398. #endif /* CONFIG_SUSPEND */
  399. struct kobject *power_kobj;
  400. /**
  401. * state - control system power state.
  402. *
  403. * show() returns what states are supported, which is hard-coded to
  404. * 'standby' (Power-On Suspend), 'mem' (Suspend-to-RAM), and
  405. * 'disk' (Suspend-to-Disk).
  406. *
  407. * store() accepts one of those strings, translates it into the
  408. * proper enumerated value, and initiates a suspend transition.
  409. */
  410. static ssize_t state_show(struct kobject *kobj, struct kobj_attribute *attr,
  411. char *buf)
  412. {
  413. char *s = buf;
  414. #ifdef CONFIG_SUSPEND
  415. int i;
  416. for (i = 0; i < PM_SUSPEND_MAX; i++) {
  417. if (pm_states[i] && valid_state(i))
  418. s += sprintf(s,"%s ", pm_states[i]);
  419. }
  420. #endif
  421. #ifdef CONFIG_HIBERNATION
  422. s += sprintf(s, "%s\n", "disk");
  423. #else
  424. if (s != buf)
  425. /* convert the last space to a newline */
  426. *(s-1) = '\n';
  427. #endif
  428. return (s - buf);
  429. }
  430. static ssize_t state_store(struct kobject *kobj, struct kobj_attribute *attr,
  431. const char *buf, size_t n)
  432. {
  433. #ifdef CONFIG_SUSPEND
  434. suspend_state_t state = PM_SUSPEND_STANDBY;
  435. const char * const *s;
  436. #endif
  437. char *p;
  438. int len;
  439. int error = -EINVAL;
  440. p = memchr(buf, '\n', n);
  441. len = p ? p - buf : n;
  442. /* First, check if we are requested to hibernate */
  443. if (len == 4 && !strncmp(buf, "disk", len)) {
  444. error = hibernate();
  445. goto Exit;
  446. }
  447. #ifdef CONFIG_SUSPEND
  448. for (s = &pm_states[state]; state < PM_SUSPEND_MAX; s++, state++) {
  449. if (*s && len == strlen(*s) && !strncmp(buf, *s, len))
  450. break;
  451. }
  452. if (state < PM_SUSPEND_MAX && *s)
  453. error = enter_state(state);
  454. #endif
  455. Exit:
  456. return error ? error : n;
  457. }
  458. power_attr(state);
  459. #ifdef CONFIG_PM_TRACE
  460. int pm_trace_enabled;
  461. static ssize_t pm_trace_show(struct kobject *kobj, struct kobj_attribute *attr,
  462. char *buf)
  463. {
  464. return sprintf(buf, "%d\n", pm_trace_enabled);
  465. }
  466. static ssize_t
  467. pm_trace_store(struct kobject *kobj, struct kobj_attribute *attr,
  468. const char *buf, size_t n)
  469. {
  470. int val;
  471. if (sscanf(buf, "%d", &val) == 1) {
  472. pm_trace_enabled = !!val;
  473. return n;
  474. }
  475. return -EINVAL;
  476. }
  477. power_attr(pm_trace);
  478. #endif /* CONFIG_PM_TRACE */
  479. static struct attribute * g[] = {
  480. &state_attr.attr,
  481. #ifdef CONFIG_PM_TRACE
  482. &pm_trace_attr.attr,
  483. #endif
  484. #if defined(CONFIG_PM_SLEEP) && defined(CONFIG_PM_DEBUG)
  485. &pm_test_attr.attr,
  486. #endif
  487. NULL,
  488. };
  489. static struct attribute_group attr_group = {
  490. .attrs = g,
  491. };
  492. static int __init pm_init(void)
  493. {
  494. power_kobj = kobject_create_and_add("power", NULL);
  495. if (!power_kobj)
  496. return -ENOMEM;
  497. return sysfs_create_group(power_kobj, &attr_group);
  498. }
  499. core_initcall(pm_init);
  500. #ifdef CONFIG_PM_TEST_SUSPEND
  501. #include <linux/rtc.h>
  502. /*
  503. * To test system suspend, we need a hands-off mechanism to resume the
  504. * system. RTCs wake alarms are a common self-contained mechanism.
  505. */
  506. static void __init test_wakealarm(struct rtc_device *rtc, suspend_state_t state)
  507. {
  508. static char err_readtime[] __initdata =
  509. KERN_ERR "PM: can't read %s time, err %d\n";
  510. static char err_wakealarm [] __initdata =
  511. KERN_ERR "PM: can't set %s wakealarm, err %d\n";
  512. static char err_suspend[] __initdata =
  513. KERN_ERR "PM: suspend test failed, error %d\n";
  514. static char info_test[] __initdata =
  515. KERN_INFO "PM: test RTC wakeup from '%s' suspend\n";
  516. unsigned long now;
  517. struct rtc_wkalrm alm;
  518. int status;
  519. /* this may fail if the RTC hasn't been initialized */
  520. status = rtc_read_time(rtc, &alm.time);
  521. if (status < 0) {
  522. printk(err_readtime, dev_name(&rtc->dev), status);
  523. return;
  524. }
  525. rtc_tm_to_time(&alm.time, &now);
  526. memset(&alm, 0, sizeof alm);
  527. rtc_time_to_tm(now + TEST_SUSPEND_SECONDS, &alm.time);
  528. alm.enabled = true;
  529. status = rtc_set_alarm(rtc, &alm);
  530. if (status < 0) {
  531. printk(err_wakealarm, dev_name(&rtc->dev), status);
  532. return;
  533. }
  534. if (state == PM_SUSPEND_MEM) {
  535. printk(info_test, pm_states[state]);
  536. status = pm_suspend(state);
  537. if (status == -ENODEV)
  538. state = PM_SUSPEND_STANDBY;
  539. }
  540. if (state == PM_SUSPEND_STANDBY) {
  541. printk(info_test, pm_states[state]);
  542. status = pm_suspend(state);
  543. }
  544. if (status < 0)
  545. printk(err_suspend, status);
  546. /* Some platforms can't detect that the alarm triggered the
  547. * wakeup, or (accordingly) disable it after it afterwards.
  548. * It's supposed to give oneshot behavior; cope.
  549. */
  550. alm.enabled = false;
  551. rtc_set_alarm(rtc, &alm);
  552. }
  553. static int __init has_wakealarm(struct device *dev, void *name_ptr)
  554. {
  555. struct rtc_device *candidate = to_rtc_device(dev);
  556. if (!candidate->ops->set_alarm)
  557. return 0;
  558. if (!device_may_wakeup(candidate->dev.parent))
  559. return 0;
  560. *(const char **)name_ptr = dev_name(dev);
  561. return 1;
  562. }
  563. /*
  564. * Kernel options like "test_suspend=mem" force suspend/resume sanity tests
  565. * at startup time. They're normally disabled, for faster boot and because
  566. * we can't know which states really work on this particular system.
  567. */
  568. static suspend_state_t test_state __initdata = PM_SUSPEND_ON;
  569. static char warn_bad_state[] __initdata =
  570. KERN_WARNING "PM: can't test '%s' suspend state\n";
  571. static int __init setup_test_suspend(char *value)
  572. {
  573. unsigned i;
  574. /* "=mem" ==> "mem" */
  575. value++;
  576. for (i = 0; i < PM_SUSPEND_MAX; i++) {
  577. if (!pm_states[i])
  578. continue;
  579. if (strcmp(pm_states[i], value) != 0)
  580. continue;
  581. test_state = (__force suspend_state_t) i;
  582. return 0;
  583. }
  584. printk(warn_bad_state, value);
  585. return 0;
  586. }
  587. __setup("test_suspend", setup_test_suspend);
  588. static int __init test_suspend(void)
  589. {
  590. static char warn_no_rtc[] __initdata =
  591. KERN_WARNING "PM: no wakealarm-capable RTC driver is ready\n";
  592. char *pony = NULL;
  593. struct rtc_device *rtc = NULL;
  594. /* PM is initialized by now; is that state testable? */
  595. if (test_state == PM_SUSPEND_ON)
  596. goto done;
  597. if (!valid_state(test_state)) {
  598. printk(warn_bad_state, pm_states[test_state]);
  599. goto done;
  600. }
  601. /* RTCs have initialized by now too ... can we use one? */
  602. class_find_device(rtc_class, NULL, &pony, has_wakealarm);
  603. if (pony)
  604. rtc = rtc_class_open(pony);
  605. if (!rtc) {
  606. printk(warn_no_rtc);
  607. goto done;
  608. }
  609. /* go for it */
  610. test_wakealarm(rtc, test_state);
  611. rtc_class_close(rtc);
  612. done:
  613. return 0;
  614. }
  615. late_initcall(test_suspend);
  616. #endif /* CONFIG_PM_TEST_SUSPEND */