Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 2 | * kernel/power/disk.c - Suspend-to-disk support. |
| 3 | * |
| 4 | * Copyright (c) 2003 Patrick Mochel |
| 5 | * Copyright (c) 2003 Open Source Development Lab |
| 6 | * Copyright (c) 2004 Pavel Machek <pavel@suse.cz> |
| 7 | * |
| 8 | * This file is released under the GPLv2. |
| 9 | * |
| 10 | */ |
| 11 | |
| 12 | #include <linux/suspend.h> |
| 13 | #include <linux/syscalls.h> |
| 14 | #include <linux/reboot.h> |
| 15 | #include <linux/string.h> |
| 16 | #include <linux/device.h> |
| 17 | #include <linux/delay.h> |
| 18 | #include <linux/fs.h> |
Andrew Morton | d53d9f1 | 2005-07-12 13:58:07 -0700 | [diff] [blame] | 19 | #include <linux/mount.h> |
Eric W. Biederman | 88d10bb | 2005-09-22 21:43:46 -0700 | [diff] [blame] | 20 | #include <linux/pm.h> |
Andrew Morton | d53d9f1 | 2005-07-12 13:58:07 -0700 | [diff] [blame] | 21 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 22 | #include "power.h" |
| 23 | |
| 24 | |
| 25 | extern suspend_disk_method_t pm_disk_mode; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 26 | |
Rafael J. Wysocki | 72a97e0 | 2006-01-06 00:13:46 -0800 | [diff] [blame] | 27 | extern int swsusp_shrink_memory(void); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 28 | extern int swsusp_suspend(void); |
Rafael J. Wysocki | f577eb3 | 2006-03-23 02:59:59 -0800 | [diff] [blame^] | 29 | extern int swsusp_write(void); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 30 | extern int swsusp_check(void); |
Rafael J. Wysocki | f577eb3 | 2006-03-23 02:59:59 -0800 | [diff] [blame^] | 31 | extern int swsusp_read(void); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 32 | extern void swsusp_close(void); |
| 33 | extern int swsusp_resume(void); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 34 | |
| 35 | |
| 36 | static int noresume = 0; |
| 37 | char resume_file[256] = CONFIG_PM_STD_PARTITION; |
| 38 | dev_t swsusp_resume_device; |
| 39 | |
| 40 | /** |
| 41 | * power_down - Shut machine down for hibernate. |
| 42 | * @mode: Suspend-to-disk mode |
| 43 | * |
| 44 | * Use the platform driver, if configured so, and return gracefully if it |
| 45 | * fails. |
| 46 | * Otherwise, try to power off and reboot. If they fail, halt the machine, |
| 47 | * there ain't no turning back. |
| 48 | */ |
| 49 | |
| 50 | static void power_down(suspend_disk_method_t mode) |
| 51 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 52 | int error = 0; |
| 53 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 54 | switch(mode) { |
| 55 | case PM_DISK_PLATFORM: |
Alexey Starikovskiy | 729b4d4 | 2005-12-01 04:29:00 -0500 | [diff] [blame] | 56 | kernel_shutdown_prepare(SYSTEM_SUSPEND_DISK); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 57 | error = pm_ops->enter(PM_SUSPEND_DISK); |
| 58 | break; |
| 59 | case PM_DISK_SHUTDOWN: |
Eric W. Biederman | fdde86a | 2005-07-26 12:01:17 -0600 | [diff] [blame] | 60 | kernel_power_off(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 61 | break; |
| 62 | case PM_DISK_REBOOT: |
Eric W. Biederman | fdde86a | 2005-07-26 12:01:17 -0600 | [diff] [blame] | 63 | kernel_restart(NULL); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 64 | break; |
| 65 | } |
Eric W. Biederman | fdde86a | 2005-07-26 12:01:17 -0600 | [diff] [blame] | 66 | kernel_halt(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 67 | /* Valid image is on the disk, if we continue we risk serious data corruption |
| 68 | after resume. */ |
| 69 | printk(KERN_CRIT "Please power me down manually\n"); |
| 70 | while(1); |
| 71 | } |
| 72 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 73 | static inline void platform_finish(void) |
| 74 | { |
| 75 | if (pm_disk_mode == PM_DISK_PLATFORM) { |
| 76 | if (pm_ops && pm_ops->finish) |
| 77 | pm_ops->finish(PM_SUSPEND_DISK); |
| 78 | } |
| 79 | } |
| 80 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 81 | static int prepare_processes(void) |
| 82 | { |
| 83 | int error; |
| 84 | |
| 85 | pm_prepare_console(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 86 | sys_sync(); |
Li Shaohua | 5a72e04 | 2005-06-25 14:55:06 -0700 | [diff] [blame] | 87 | disable_nonboot_cpus(); |
| 88 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 89 | if (freeze_processes()) { |
| 90 | error = -EBUSY; |
Li Shaohua | 5a72e04 | 2005-06-25 14:55:06 -0700 | [diff] [blame] | 91 | goto thaw; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 92 | } |
| 93 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 94 | /* Free memory before shutting down devices. */ |
Rafael J. Wysocki | 72a97e0 | 2006-01-06 00:13:46 -0800 | [diff] [blame] | 95 | if (!(error = swsusp_shrink_memory())) |
| 96 | return 0; |
Li Shaohua | 5a72e04 | 2005-06-25 14:55:06 -0700 | [diff] [blame] | 97 | thaw: |
| 98 | thaw_processes(); |
| 99 | enable_nonboot_cpus(); |
| 100 | pm_restore_console(); |
| 101 | return error; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 102 | } |
| 103 | |
| 104 | static void unprepare_processes(void) |
| 105 | { |
Li Shaohua | 5a72e04 | 2005-06-25 14:55:06 -0700 | [diff] [blame] | 106 | platform_finish(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 107 | thaw_processes(); |
Li Shaohua | 5a72e04 | 2005-06-25 14:55:06 -0700 | [diff] [blame] | 108 | enable_nonboot_cpus(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 109 | pm_restore_console(); |
| 110 | } |
| 111 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 112 | /** |
| 113 | * pm_suspend_disk - The granpappy of power management. |
| 114 | * |
| 115 | * If we're going through the firmware, then get it over with quickly. |
| 116 | * |
| 117 | * If not, then call swsusp to do its thing, then figure out how |
| 118 | * to power down the system. |
| 119 | */ |
| 120 | |
| 121 | int pm_suspend_disk(void) |
| 122 | { |
| 123 | int error; |
| 124 | |
| 125 | error = prepare_processes(); |
Li Shaohua | 5a72e04 | 2005-06-25 14:55:06 -0700 | [diff] [blame] | 126 | if (error) |
| 127 | return error; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 128 | |
Pavel Machek | 99dc7d6 | 2005-09-03 15:57:05 -0700 | [diff] [blame] | 129 | error = device_suspend(PMSG_FREEZE); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 130 | if (error) { |
Pavel Machek | 99dc7d6 | 2005-09-03 15:57:05 -0700 | [diff] [blame] | 131 | printk("Some devices failed to suspend\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 132 | unprepare_processes(); |
| 133 | return error; |
| 134 | } |
| 135 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 136 | pr_debug("PM: snapshotting memory.\n"); |
| 137 | in_suspend = 1; |
| 138 | if ((error = swsusp_suspend())) |
| 139 | goto Done; |
| 140 | |
| 141 | if (in_suspend) { |
Rafael J. Wysocki | 0245b3e | 2005-10-30 15:00:01 -0800 | [diff] [blame] | 142 | device_resume(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 143 | pr_debug("PM: writing image.\n"); |
Rafael J. Wysocki | f577eb3 | 2006-03-23 02:59:59 -0800 | [diff] [blame^] | 144 | error = swsusp_write(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 145 | if (!error) |
| 146 | power_down(pm_disk_mode); |
Pavel Machek | 99dc7d6 | 2005-09-03 15:57:05 -0700 | [diff] [blame] | 147 | else { |
Pavel Machek | 99dc7d6 | 2005-09-03 15:57:05 -0700 | [diff] [blame] | 148 | swsusp_free(); |
| 149 | unprepare_processes(); |
| 150 | return error; |
| 151 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 152 | } else |
| 153 | pr_debug("PM: Image restored successfully.\n"); |
Pavel Machek | 99dc7d6 | 2005-09-03 15:57:05 -0700 | [diff] [blame] | 154 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 155 | swsusp_free(); |
| 156 | Done: |
Pavel Machek | 99dc7d6 | 2005-09-03 15:57:05 -0700 | [diff] [blame] | 157 | device_resume(); |
| 158 | unprepare_processes(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 159 | return error; |
| 160 | } |
| 161 | |
| 162 | |
| 163 | /** |
| 164 | * software_resume - Resume from a saved image. |
| 165 | * |
| 166 | * Called as a late_initcall (so all devices are discovered and |
| 167 | * initialized), we call swsusp to see if we have a saved image or not. |
| 168 | * If so, we quiesce devices, the restore the saved image. We will |
| 169 | * return above (in pm_suspend_disk() ) if everything goes well. |
| 170 | * Otherwise, we fail gracefully and return to the normally |
| 171 | * scheduled program. |
| 172 | * |
| 173 | */ |
| 174 | |
| 175 | static int software_resume(void) |
| 176 | { |
| 177 | int error; |
| 178 | |
Shaohua Li | dd5d666 | 2005-09-03 15:57:04 -0700 | [diff] [blame] | 179 | down(&pm_sem); |
Pavel Machek | 3efa147 | 2005-07-07 17:56:43 -0700 | [diff] [blame] | 180 | if (!swsusp_resume_device) { |
Shaohua Li | dd5d666 | 2005-09-03 15:57:04 -0700 | [diff] [blame] | 181 | if (!strlen(resume_file)) { |
| 182 | up(&pm_sem); |
Pavel Machek | 3efa147 | 2005-07-07 17:56:43 -0700 | [diff] [blame] | 183 | return -ENOENT; |
Shaohua Li | dd5d666 | 2005-09-03 15:57:04 -0700 | [diff] [blame] | 184 | } |
Pavel Machek | 3efa147 | 2005-07-07 17:56:43 -0700 | [diff] [blame] | 185 | swsusp_resume_device = name_to_dev_t(resume_file); |
| 186 | pr_debug("swsusp: Resume From Partition %s\n", resume_file); |
| 187 | } else { |
| 188 | pr_debug("swsusp: Resume From Partition %d:%d\n", |
| 189 | MAJOR(swsusp_resume_device), MINOR(swsusp_resume_device)); |
| 190 | } |
| 191 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 192 | if (noresume) { |
| 193 | /** |
| 194 | * FIXME: If noresume is specified, we need to find the partition |
| 195 | * and reset it back to normal swap space. |
| 196 | */ |
Shaohua Li | dd5d666 | 2005-09-03 15:57:04 -0700 | [diff] [blame] | 197 | up(&pm_sem); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 198 | return 0; |
| 199 | } |
| 200 | |
| 201 | pr_debug("PM: Checking swsusp image.\n"); |
| 202 | |
| 203 | if ((error = swsusp_check())) |
| 204 | goto Done; |
| 205 | |
| 206 | pr_debug("PM: Preparing processes for restore.\n"); |
| 207 | |
| 208 | if ((error = prepare_processes())) { |
| 209 | swsusp_close(); |
Li Shaohua | 5a72e04 | 2005-06-25 14:55:06 -0700 | [diff] [blame] | 210 | goto Done; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 211 | } |
| 212 | |
| 213 | pr_debug("PM: Reading swsusp image.\n"); |
| 214 | |
Rafael J. Wysocki | f577eb3 | 2006-03-23 02:59:59 -0800 | [diff] [blame^] | 215 | if ((error = swsusp_read())) { |
Rafael J. Wysocki | 2c1b4a5 | 2005-10-30 14:59:58 -0800 | [diff] [blame] | 216 | swsusp_free(); |
| 217 | goto Thaw; |
| 218 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 219 | |
| 220 | pr_debug("PM: Preparing devices for restore.\n"); |
| 221 | |
Pavel Machek | 99dc7d6 | 2005-09-03 15:57:05 -0700 | [diff] [blame] | 222 | if ((error = device_suspend(PMSG_FREEZE))) { |
| 223 | printk("Some devices failed to suspend\n"); |
Rafael J. Wysocki | 2c1b4a5 | 2005-10-30 14:59:58 -0800 | [diff] [blame] | 224 | swsusp_free(); |
| 225 | goto Thaw; |
Pavel Machek | 99dc7d6 | 2005-09-03 15:57:05 -0700 | [diff] [blame] | 226 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 227 | |
| 228 | mb(); |
| 229 | |
| 230 | pr_debug("PM: Restoring saved image.\n"); |
| 231 | swsusp_resume(); |
| 232 | pr_debug("PM: Restore failed, recovering.n"); |
Pavel Machek | 99dc7d6 | 2005-09-03 15:57:05 -0700 | [diff] [blame] | 233 | device_resume(); |
Rafael J. Wysocki | 2c1b4a5 | 2005-10-30 14:59:58 -0800 | [diff] [blame] | 234 | Thaw: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 235 | unprepare_processes(); |
| 236 | Done: |
Shaohua Li | dd5d666 | 2005-09-03 15:57:04 -0700 | [diff] [blame] | 237 | /* For success case, the suspend path will release the lock */ |
| 238 | up(&pm_sem); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 239 | pr_debug("PM: Resume from disk failed.\n"); |
| 240 | return 0; |
| 241 | } |
| 242 | |
| 243 | late_initcall(software_resume); |
| 244 | |
| 245 | |
| 246 | static char * pm_disk_modes[] = { |
| 247 | [PM_DISK_FIRMWARE] = "firmware", |
| 248 | [PM_DISK_PLATFORM] = "platform", |
| 249 | [PM_DISK_SHUTDOWN] = "shutdown", |
| 250 | [PM_DISK_REBOOT] = "reboot", |
| 251 | }; |
| 252 | |
| 253 | /** |
| 254 | * disk - Control suspend-to-disk mode |
| 255 | * |
| 256 | * Suspend-to-disk can be handled in several ways. The greatest |
| 257 | * distinction is who writes memory to disk - the firmware or the OS. |
| 258 | * If the firmware does it, we assume that it also handles suspending |
| 259 | * the system. |
| 260 | * If the OS does it, then we have three options for putting the system |
| 261 | * to sleep - using the platform driver (e.g. ACPI or other PM registers), |
| 262 | * powering off the system or rebooting the system (for testing). |
| 263 | * |
| 264 | * The system will support either 'firmware' or 'platform', and that is |
| 265 | * known a priori (and encoded in pm_ops). But, the user may choose |
| 266 | * 'shutdown' or 'reboot' as alternatives. |
| 267 | * |
| 268 | * show() will display what the mode is currently set to. |
| 269 | * store() will accept one of |
| 270 | * |
| 271 | * 'firmware' |
| 272 | * 'platform' |
| 273 | * 'shutdown' |
| 274 | * 'reboot' |
| 275 | * |
| 276 | * It will only change to 'firmware' or 'platform' if the system |
| 277 | * supports it (as determined from pm_ops->pm_disk_mode). |
| 278 | */ |
| 279 | |
| 280 | static ssize_t disk_show(struct subsystem * subsys, char * buf) |
| 281 | { |
| 282 | return sprintf(buf, "%s\n", pm_disk_modes[pm_disk_mode]); |
| 283 | } |
| 284 | |
| 285 | |
| 286 | static ssize_t disk_store(struct subsystem * s, const char * buf, size_t n) |
| 287 | { |
| 288 | int error = 0; |
| 289 | int i; |
| 290 | int len; |
| 291 | char *p; |
| 292 | suspend_disk_method_t mode = 0; |
| 293 | |
| 294 | p = memchr(buf, '\n', n); |
| 295 | len = p ? p - buf : n; |
| 296 | |
| 297 | down(&pm_sem); |
| 298 | for (i = PM_DISK_FIRMWARE; i < PM_DISK_MAX; i++) { |
| 299 | if (!strncmp(buf, pm_disk_modes[i], len)) { |
| 300 | mode = i; |
| 301 | break; |
| 302 | } |
| 303 | } |
| 304 | if (mode) { |
| 305 | if (mode == PM_DISK_SHUTDOWN || mode == PM_DISK_REBOOT) |
| 306 | pm_disk_mode = mode; |
| 307 | else { |
| 308 | if (pm_ops && pm_ops->enter && |
| 309 | (mode == pm_ops->pm_disk_mode)) |
| 310 | pm_disk_mode = mode; |
| 311 | else |
| 312 | error = -EINVAL; |
| 313 | } |
| 314 | } else |
| 315 | error = -EINVAL; |
| 316 | |
| 317 | pr_debug("PM: suspend-to-disk mode set to '%s'\n", |
| 318 | pm_disk_modes[mode]); |
| 319 | up(&pm_sem); |
| 320 | return error ? error : n; |
| 321 | } |
| 322 | |
| 323 | power_attr(disk); |
| 324 | |
| 325 | static ssize_t resume_show(struct subsystem * subsys, char *buf) |
| 326 | { |
| 327 | return sprintf(buf,"%d:%d\n", MAJOR(swsusp_resume_device), |
| 328 | MINOR(swsusp_resume_device)); |
| 329 | } |
| 330 | |
Andrew Morton | a576219 | 2006-01-06 00:09:50 -0800 | [diff] [blame] | 331 | static ssize_t resume_store(struct subsystem *subsys, const char *buf, size_t n) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 332 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 333 | unsigned int maj, min; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 334 | dev_t res; |
Andrew Morton | a576219 | 2006-01-06 00:09:50 -0800 | [diff] [blame] | 335 | int ret = -EINVAL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 336 | |
Andrew Morton | a576219 | 2006-01-06 00:09:50 -0800 | [diff] [blame] | 337 | if (sscanf(buf, "%u:%u", &maj, &min) != 2) |
| 338 | goto out; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 339 | |
Andrew Morton | a576219 | 2006-01-06 00:09:50 -0800 | [diff] [blame] | 340 | res = MKDEV(maj,min); |
| 341 | if (maj != MAJOR(res) || min != MINOR(res)) |
| 342 | goto out; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 343 | |
Andrew Morton | a576219 | 2006-01-06 00:09:50 -0800 | [diff] [blame] | 344 | down(&pm_sem); |
| 345 | swsusp_resume_device = res; |
| 346 | up(&pm_sem); |
| 347 | printk("Attempting manual resume\n"); |
| 348 | noresume = 0; |
| 349 | software_resume(); |
| 350 | ret = n; |
| 351 | out: |
| 352 | return ret; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 353 | } |
| 354 | |
| 355 | power_attr(resume); |
| 356 | |
Rafael J. Wysocki | ca0aec0 | 2006-01-06 00:15:56 -0800 | [diff] [blame] | 357 | static ssize_t image_size_show(struct subsystem * subsys, char *buf) |
| 358 | { |
Rafael J. Wysocki | 853609b | 2006-02-01 03:05:07 -0800 | [diff] [blame] | 359 | return sprintf(buf, "%lu\n", image_size); |
Rafael J. Wysocki | ca0aec0 | 2006-01-06 00:15:56 -0800 | [diff] [blame] | 360 | } |
| 361 | |
| 362 | static ssize_t image_size_store(struct subsystem * subsys, const char * buf, size_t n) |
| 363 | { |
Rafael J. Wysocki | 853609b | 2006-02-01 03:05:07 -0800 | [diff] [blame] | 364 | unsigned long size; |
Rafael J. Wysocki | ca0aec0 | 2006-01-06 00:15:56 -0800 | [diff] [blame] | 365 | |
Rafael J. Wysocki | 853609b | 2006-02-01 03:05:07 -0800 | [diff] [blame] | 366 | if (sscanf(buf, "%lu", &size) == 1) { |
Rafael J. Wysocki | ca0aec0 | 2006-01-06 00:15:56 -0800 | [diff] [blame] | 367 | image_size = size; |
| 368 | return n; |
| 369 | } |
| 370 | |
| 371 | return -EINVAL; |
| 372 | } |
| 373 | |
| 374 | power_attr(image_size); |
| 375 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 376 | static struct attribute * g[] = { |
| 377 | &disk_attr.attr, |
| 378 | &resume_attr.attr, |
Rafael J. Wysocki | ca0aec0 | 2006-01-06 00:15:56 -0800 | [diff] [blame] | 379 | &image_size_attr.attr, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 380 | NULL, |
| 381 | }; |
| 382 | |
| 383 | |
| 384 | static struct attribute_group attr_group = { |
| 385 | .attrs = g, |
| 386 | }; |
| 387 | |
| 388 | |
| 389 | static int __init pm_disk_init(void) |
| 390 | { |
| 391 | return sysfs_create_group(&power_subsys.kset.kobj,&attr_group); |
| 392 | } |
| 393 | |
| 394 | core_initcall(pm_disk_init); |
| 395 | |
| 396 | |
| 397 | static int __init resume_setup(char *str) |
| 398 | { |
| 399 | if (noresume) |
| 400 | return 1; |
| 401 | |
| 402 | strncpy( resume_file, str, 255 ); |
| 403 | return 1; |
| 404 | } |
| 405 | |
| 406 | static int __init noresume_setup(char *str) |
| 407 | { |
| 408 | noresume = 1; |
| 409 | return 1; |
| 410 | } |
| 411 | |
| 412 | __setup("noresume", noresume_setup); |
| 413 | __setup("resume=", resume_setup); |