aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/acpi/sleep
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/acpi/sleep')
-rw-r--r--drivers/acpi/sleep/poweroff.c2
-rw-r--r--drivers/acpi/sleep/proc.c269
-rw-r--r--drivers/acpi/sleep/wakeup.c115
3 files changed, 189 insertions, 197 deletions
diff --git a/drivers/acpi/sleep/poweroff.c b/drivers/acpi/sleep/poweroff.c
index f93d2ee54800..a5f947de879b 100644
--- a/drivers/acpi/sleep/poweroff.c
+++ b/drivers/acpi/sleep/poweroff.c
@@ -95,4 +95,4 @@ static int acpi_poweroff_init(void)
95 95
96late_initcall(acpi_poweroff_init); 96late_initcall(acpi_poweroff_init);
97 97
98#endif /* CONFIG_PM */ 98#endif /* CONFIG_PM */
diff --git a/drivers/acpi/sleep/proc.c b/drivers/acpi/sleep/proc.c
index 1be99f0996d6..09a603f3523e 100644
--- a/drivers/acpi/sleep/proc.c
+++ b/drivers/acpi/sleep/proc.c
@@ -13,27 +13,18 @@
13 13
14#include "sleep.h" 14#include "sleep.h"
15 15
16#ifdef CONFIG_ACPI_SLEEP_PROC_SLEEP
17#define ACPI_SYSTEM_FILE_SLEEP "sleep"
18#endif
19
20#define ACPI_SYSTEM_FILE_ALARM "alarm"
21#define ACPI_SYSTEM_FILE_WAKEUP_DEVICE "wakeup"
22
23#define _COMPONENT ACPI_SYSTEM_COMPONENT 16#define _COMPONENT ACPI_SYSTEM_COMPONENT
24ACPI_MODULE_NAME ("sleep") 17ACPI_MODULE_NAME("sleep")
25
26#ifdef CONFIG_ACPI_SLEEP_PROC_SLEEP 18#ifdef CONFIG_ACPI_SLEEP_PROC_SLEEP
27
28static int acpi_system_sleep_seq_show(struct seq_file *seq, void *offset) 19static int acpi_system_sleep_seq_show(struct seq_file *seq, void *offset)
29{ 20{
30 int i; 21 int i;
31 22
32 ACPI_FUNCTION_TRACE("acpi_system_sleep_seq_show"); 23 ACPI_FUNCTION_TRACE("acpi_system_sleep_seq_show");
33 24
34 for (i = 0; i <= ACPI_STATE_S5; i++) { 25 for (i = 0; i <= ACPI_STATE_S5; i++) {
35 if (sleep_states[i]) { 26 if (sleep_states[i]) {
36 seq_printf(seq,"S%d ", i); 27 seq_printf(seq, "S%d ", i);
37 if (i == ACPI_STATE_S4 && acpi_gbl_FACS->S4bios_f) 28 if (i == ACPI_STATE_S4 && acpi_gbl_FACS->S4bios_f)
38 seq_printf(seq, "S4bios "); 29 seq_printf(seq, "S4bios ");
39 } 30 }
@@ -50,24 +41,21 @@ static int acpi_system_sleep_open_fs(struct inode *inode, struct file *file)
50} 41}
51 42
52static ssize_t 43static ssize_t
53acpi_system_write_sleep ( 44acpi_system_write_sleep(struct file *file,
54 struct file *file, 45 const char __user * buffer, size_t count, loff_t * ppos)
55 const char __user *buffer,
56 size_t count,
57 loff_t *ppos)
58{ 46{
59 char str[12]; 47 char str[12];
60 u32 state = 0; 48 u32 state = 0;
61 int error = 0; 49 int error = 0;
62 50
63 if (count > sizeof(str) - 1) 51 if (count > sizeof(str) - 1)
64 goto Done; 52 goto Done;
65 memset(str,0,sizeof(str)); 53 memset(str, 0, sizeof(str));
66 if (copy_from_user(str, buffer, count)) 54 if (copy_from_user(str, buffer, count))
67 return -EFAULT; 55 return -EFAULT;
68 56
69 /* Check for S4 bios request */ 57 /* Check for S4 bios request */
70 if (!strcmp(str,"4b")) { 58 if (!strcmp(str, "4b")) {
71 error = acpi_suspend(4); 59 error = acpi_suspend(4);
72 goto Done; 60 goto Done;
73 } 61 }
@@ -79,17 +67,17 @@ acpi_system_write_sleep (
79 } 67 }
80#endif 68#endif
81 error = acpi_suspend(state); 69 error = acpi_suspend(state);
82 Done: 70 Done:
83 return error ? error : count; 71 return error ? error : count;
84} 72}
85#endif /* CONFIG_ACPI_SLEEP_PROC_SLEEP */ 73#endif /* CONFIG_ACPI_SLEEP_PROC_SLEEP */
86 74
87static int acpi_system_alarm_seq_show(struct seq_file *seq, void *offset) 75static int acpi_system_alarm_seq_show(struct seq_file *seq, void *offset)
88{ 76{
89 u32 sec, min, hr; 77 u32 sec, min, hr;
90 u32 day, mo, yr; 78 u32 day, mo, yr;
91 unsigned char rtc_control = 0; 79 unsigned char rtc_control = 0;
92 unsigned long flags; 80 unsigned long flags;
93 81
94 ACPI_FUNCTION_TRACE("acpi_system_alarm_seq_show"); 82 ACPI_FUNCTION_TRACE("acpi_system_alarm_seq_show");
95 83
@@ -105,13 +93,14 @@ static int acpi_system_alarm_seq_show(struct seq_file *seq, void *offset)
105 /* ACPI spec: only low 6 its should be cared */ 93 /* ACPI spec: only low 6 its should be cared */
106 day = CMOS_READ(acpi_gbl_FADT->day_alrm) & 0x3F; 94 day = CMOS_READ(acpi_gbl_FADT->day_alrm) & 0x3F;
107 else 95 else
108 day = CMOS_READ(RTC_DAY_OF_MONTH); 96 day = CMOS_READ(RTC_DAY_OF_MONTH);
109 if (acpi_gbl_FADT->mon_alrm) 97 if (acpi_gbl_FADT->mon_alrm)
110 mo = CMOS_READ(acpi_gbl_FADT->mon_alrm); 98 mo = CMOS_READ(acpi_gbl_FADT->mon_alrm);
111 else 99 else
112 mo = CMOS_READ(RTC_MONTH); 100 mo = CMOS_READ(RTC_MONTH);
113 if (acpi_gbl_FADT->century) 101 if (acpi_gbl_FADT->century)
114 yr = CMOS_READ(acpi_gbl_FADT->century) * 100 + CMOS_READ(RTC_YEAR); 102 yr = CMOS_READ(acpi_gbl_FADT->century) * 100 +
103 CMOS_READ(RTC_YEAR);
115 else 104 else
116 yr = CMOS_READ(RTC_YEAR); 105 yr = CMOS_READ(RTC_YEAR);
117 106
@@ -126,33 +115,33 @@ static int acpi_system_alarm_seq_show(struct seq_file *seq, void *offset)
126 BCD_TO_BIN(yr); 115 BCD_TO_BIN(yr);
127 } 116 }
128 117
129 /* we're trusting the FADT (see above)*/ 118 /* we're trusting the FADT (see above) */
130 if (!acpi_gbl_FADT->century) 119 if (!acpi_gbl_FADT->century)
131 /* If we're not trusting the FADT, we should at least make it 120 /* If we're not trusting the FADT, we should at least make it
132 * right for _this_ century... ehm, what is _this_ century? 121 * right for _this_ century... ehm, what is _this_ century?
133 * 122 *
134 * TBD: 123 * TBD:
135 * ASAP: find piece of code in the kernel, e.g. star tracker driver, 124 * ASAP: find piece of code in the kernel, e.g. star tracker driver,
136 * which we can trust to determine the century correctly. Atom 125 * which we can trust to determine the century correctly. Atom
137 * watch driver would be nice, too... 126 * watch driver would be nice, too...
138 * 127 *
139 * if that has not happened, change for first release in 2050: 128 * if that has not happened, change for first release in 2050:
140 * if (yr<50) 129 * if (yr<50)
141 * yr += 2100; 130 * yr += 2100;
142 * else 131 * else
143 * yr += 2000; // current line of code 132 * yr += 2000; // current line of code
144 * 133 *
145 * if that has not happened either, please do on 2099/12/31:23:59:59 134 * if that has not happened either, please do on 2099/12/31:23:59:59
146 * s/2000/2100 135 * s/2000/2100
147 * 136 *
148 */ 137 */
149 yr += 2000; 138 yr += 2000;
150 139
151 seq_printf(seq,"%4.4u-", yr); 140 seq_printf(seq, "%4.4u-", yr);
152 (mo > 12) ? seq_puts(seq, "**-") : seq_printf(seq, "%2.2u-", mo); 141 (mo > 12) ? seq_puts(seq, "**-") : seq_printf(seq, "%2.2u-", mo);
153 (day > 31) ? seq_puts(seq, "** ") : seq_printf(seq, "%2.2u ", day); 142 (day > 31) ? seq_puts(seq, "** ") : seq_printf(seq, "%2.2u ", day);
154 (hr > 23) ? seq_puts(seq, "**:") : seq_printf(seq, "%2.2u:", hr); 143 (hr > 23) ? seq_puts(seq, "**:") : seq_printf(seq, "%2.2u:", hr);
155 (min > 59) ? seq_puts(seq, "**:") : seq_printf(seq, "%2.2u:", min); 144 (min > 59) ? seq_puts(seq, "**:") : seq_printf(seq, "%2.2u:", min);
156 (sec > 59) ? seq_puts(seq, "**\n") : seq_printf(seq, "%2.2u\n", sec); 145 (sec > 59) ? seq_puts(seq, "**\n") : seq_printf(seq, "%2.2u\n", sec);
157 146
158 return 0; 147 return 0;
@@ -163,15 +152,11 @@ static int acpi_system_alarm_open_fs(struct inode *inode, struct file *file)
163 return single_open(file, acpi_system_alarm_seq_show, PDE(inode)->data); 152 return single_open(file, acpi_system_alarm_seq_show, PDE(inode)->data);
164} 153}
165 154
166 155static int get_date_field(char **p, u32 * value)
167static int
168get_date_field (
169 char **p,
170 u32 *value)
171{ 156{
172 char *next = NULL; 157 char *next = NULL;
173 char *string_end = NULL; 158 char *string_end = NULL;
174 int result = -EINVAL; 159 int result = -EINVAL;
175 160
176 /* 161 /*
177 * Try to find delimeter, only to insert null. The end of the 162 * Try to find delimeter, only to insert null. The end of the
@@ -193,26 +178,22 @@ get_date_field (
193 return result; 178 return result;
194} 179}
195 180
196
197static ssize_t 181static ssize_t
198acpi_system_write_alarm ( 182acpi_system_write_alarm(struct file *file,
199 struct file *file, 183 const char __user * buffer, size_t count, loff_t * ppos)
200 const char __user *buffer,
201 size_t count,
202 loff_t *ppos)
203{ 184{
204 int result = 0; 185 int result = 0;
205 char alarm_string[30] = {'\0'}; 186 char alarm_string[30] = { '\0' };
206 char *p = alarm_string; 187 char *p = alarm_string;
207 u32 sec, min, hr, day, mo, yr; 188 u32 sec, min, hr, day, mo, yr;
208 int adjust = 0; 189 int adjust = 0;
209 unsigned char rtc_control = 0; 190 unsigned char rtc_control = 0;
210 191
211 ACPI_FUNCTION_TRACE("acpi_system_write_alarm"); 192 ACPI_FUNCTION_TRACE("acpi_system_write_alarm");
212 193
213 if (count > sizeof(alarm_string) - 1) 194 if (count > sizeof(alarm_string) - 1)
214 return_VALUE(-EINVAL); 195 return_VALUE(-EINVAL);
215 196
216 if (copy_from_user(alarm_string, buffer, count)) 197 if (copy_from_user(alarm_string, buffer, count))
217 return_VALUE(-EFAULT); 198 return_VALUE(-EFAULT);
218 199
@@ -271,10 +252,10 @@ acpi_system_write_alarm (
271 } 252 }
272 253
273 if (adjust) { 254 if (adjust) {
274 yr += CMOS_READ(RTC_YEAR); 255 yr += CMOS_READ(RTC_YEAR);
275 mo += CMOS_READ(RTC_MONTH); 256 mo += CMOS_READ(RTC_MONTH);
276 day += CMOS_READ(RTC_DAY_OF_MONTH); 257 day += CMOS_READ(RTC_DAY_OF_MONTH);
277 hr += CMOS_READ(RTC_HOURS); 258 hr += CMOS_READ(RTC_HOURS);
278 min += CMOS_READ(RTC_MINUTES); 259 min += CMOS_READ(RTC_MINUTES);
279 sec += CMOS_READ(RTC_SECONDS); 260 sec += CMOS_READ(RTC_SECONDS);
280 } 261 }
@@ -343,7 +324,7 @@ acpi_system_write_alarm (
343 if (acpi_gbl_FADT->mon_alrm) 324 if (acpi_gbl_FADT->mon_alrm)
344 CMOS_WRITE(mo, acpi_gbl_FADT->mon_alrm); 325 CMOS_WRITE(mo, acpi_gbl_FADT->mon_alrm);
345 if (acpi_gbl_FADT->century) 326 if (acpi_gbl_FADT->century)
346 CMOS_WRITE(yr/100, acpi_gbl_FADT->century); 327 CMOS_WRITE(yr / 100, acpi_gbl_FADT->century);
347 /* enable the rtc alarm interrupt */ 328 /* enable the rtc alarm interrupt */
348 rtc_control |= RTC_AIE; 329 rtc_control |= RTC_AIE;
349 CMOS_WRITE(rtc_control, RTC_CONTROL); 330 CMOS_WRITE(rtc_control, RTC_CONTROL);
@@ -357,35 +338,33 @@ acpi_system_write_alarm (
357 *ppos += count; 338 *ppos += count;
358 339
359 result = 0; 340 result = 0;
360end: 341 end:
361 return_VALUE(result ? result : count); 342 return_VALUE(result ? result : count);
362} 343}
363 344
364extern struct list_head acpi_wakeup_device_list; 345extern struct list_head acpi_wakeup_device_list;
365extern spinlock_t acpi_device_lock; 346extern spinlock_t acpi_device_lock;
366 347
367static int 348static int
368acpi_system_wakeup_device_seq_show(struct seq_file *seq, void *offset) 349acpi_system_wakeup_device_seq_show(struct seq_file *seq, void *offset)
369{ 350{
370 struct list_head * node, * next; 351 struct list_head *node, *next;
371 352
372 seq_printf(seq, "Device Sleep state Status\n"); 353 seq_printf(seq, "Device Sleep state Status\n");
373 354
374 spin_lock(&acpi_device_lock); 355 spin_lock(&acpi_device_lock);
375 list_for_each_safe(node, next, &acpi_wakeup_device_list) { 356 list_for_each_safe(node, next, &acpi_wakeup_device_list) {
376 struct acpi_device * dev = container_of(node, struct acpi_device, wakeup_list); 357 struct acpi_device *dev =
358 container_of(node, struct acpi_device, wakeup_list);
377 359
378 if (!dev->wakeup.flags.valid) 360 if (!dev->wakeup.flags.valid)
379 continue; 361 continue;
380 spin_unlock(&acpi_device_lock); 362 spin_unlock(&acpi_device_lock);
381 if (dev->wakeup.flags.run_wake) 363 seq_printf(seq, "%4s %4d %s%8s\n",
382 seq_printf(seq, "%4s %4d %8s\n", 364 dev->pnp.bus_id,
383 dev->pnp.bus_id, (u32) dev->wakeup.sleep_state, 365 (u32) dev->wakeup.sleep_state,
384 dev->wakeup.state.enabled ? "*enabled" : "*disabled"); 366 dev->wakeup.flags.run_wake ? "*" : "",
385 else 367 dev->wakeup.state.enabled ? "enabled" : "disabled");
386 seq_printf(seq, "%4s %4d %8s\n",
387 dev->pnp.bus_id, (u32) dev->wakeup.sleep_state,
388 dev->wakeup.state.enabled ? "enabled" : "disabled");
389 spin_lock(&acpi_device_lock); 368 spin_lock(&acpi_device_lock);
390 } 369 }
391 spin_unlock(&acpi_device_lock); 370 spin_unlock(&acpi_device_lock);
@@ -393,19 +372,18 @@ acpi_system_wakeup_device_seq_show(struct seq_file *seq, void *offset)
393} 372}
394 373
395static ssize_t 374static ssize_t
396acpi_system_write_wakeup_device ( 375acpi_system_write_wakeup_device(struct file *file,
397 struct file *file, 376 const char __user * buffer,
398 const char __user *buffer, 377 size_t count, loff_t * ppos)
399 size_t count,
400 loff_t *ppos)
401{ 378{
402 struct list_head * node, * next; 379 struct list_head *node, *next;
403 char strbuf[5]; 380 char strbuf[5];
404 char str[5] = ""; 381 char str[5] = "";
405 int len = count; 382 int len = count;
406 struct acpi_device *found_dev = NULL; 383 struct acpi_device *found_dev = NULL;
407 384
408 if (len > 4) len = 4; 385 if (len > 4)
386 len = 4;
409 387
410 if (copy_from_user(strbuf, buffer, len)) 388 if (copy_from_user(strbuf, buffer, len))
411 return -EFAULT; 389 return -EFAULT;
@@ -414,28 +392,36 @@ acpi_system_write_wakeup_device (
414 392
415 spin_lock(&acpi_device_lock); 393 spin_lock(&acpi_device_lock);
416 list_for_each_safe(node, next, &acpi_wakeup_device_list) { 394 list_for_each_safe(node, next, &acpi_wakeup_device_list) {
417 struct acpi_device * dev = container_of(node, struct acpi_device, wakeup_list); 395 struct acpi_device *dev =
396 container_of(node, struct acpi_device, wakeup_list);
418 if (!dev->wakeup.flags.valid) 397 if (!dev->wakeup.flags.valid)
419 continue; 398 continue;
420 399
421 if (!strncmp(dev->pnp.bus_id, str, 4)) { 400 if (!strncmp(dev->pnp.bus_id, str, 4)) {
422 dev->wakeup.state.enabled = dev->wakeup.state.enabled ? 0:1; 401 dev->wakeup.state.enabled =
402 dev->wakeup.state.enabled ? 0 : 1;
423 found_dev = dev; 403 found_dev = dev;
424 break; 404 break;
425 } 405 }
426 } 406 }
427 if (found_dev) { 407 if (found_dev) {
428 list_for_each_safe(node, next, &acpi_wakeup_device_list) { 408 list_for_each_safe(node, next, &acpi_wakeup_device_list) {
429 struct acpi_device * dev = container_of(node, 409 struct acpi_device *dev = container_of(node,
430 struct acpi_device, wakeup_list); 410 struct
411 acpi_device,
412 wakeup_list);
431 413
432 if ((dev != found_dev) && 414 if ((dev != found_dev) &&
433 (dev->wakeup.gpe_number == found_dev->wakeup.gpe_number) && 415 (dev->wakeup.gpe_number ==
434 (dev->wakeup.gpe_device == found_dev->wakeup.gpe_device)) { 416 found_dev->wakeup.gpe_number)
435 printk(KERN_WARNING "ACPI: '%s' and '%s' have the same GPE, " 417 && (dev->wakeup.gpe_device ==
436 "can't disable/enable one seperately\n", 418 found_dev->wakeup.gpe_device)) {
437 dev->pnp.bus_id, found_dev->pnp.bus_id); 419 printk(KERN_WARNING
438 dev->wakeup.state.enabled = found_dev->wakeup.state.enabled; 420 "ACPI: '%s' and '%s' have the same GPE, "
421 "can't disable/enable one seperately\n",
422 dev->pnp.bus_id, found_dev->pnp.bus_id);
423 dev->wakeup.state.enabled =
424 found_dev->wakeup.state.enabled;
439 } 425 }
440 } 426 }
441 } 427 }
@@ -446,37 +432,37 @@ acpi_system_write_wakeup_device (
446static int 432static int
447acpi_system_wakeup_device_open_fs(struct inode *inode, struct file *file) 433acpi_system_wakeup_device_open_fs(struct inode *inode, struct file *file)
448{ 434{
449 return single_open(file, acpi_system_wakeup_device_seq_show, PDE(inode)->data); 435 return single_open(file, acpi_system_wakeup_device_seq_show,
436 PDE(inode)->data);
450} 437}
451 438
452static struct file_operations acpi_system_wakeup_device_fops = { 439static struct file_operations acpi_system_wakeup_device_fops = {
453 .open = acpi_system_wakeup_device_open_fs, 440 .open = acpi_system_wakeup_device_open_fs,
454 .read = seq_read, 441 .read = seq_read,
455 .write = acpi_system_write_wakeup_device, 442 .write = acpi_system_write_wakeup_device,
456 .llseek = seq_lseek, 443 .llseek = seq_lseek,
457 .release = single_release, 444 .release = single_release,
458}; 445};
459 446
460#ifdef CONFIG_ACPI_SLEEP_PROC_SLEEP 447#ifdef CONFIG_ACPI_SLEEP_PROC_SLEEP
461static struct file_operations acpi_system_sleep_fops = { 448static struct file_operations acpi_system_sleep_fops = {
462 .open = acpi_system_sleep_open_fs, 449 .open = acpi_system_sleep_open_fs,
463 .read = seq_read, 450 .read = seq_read,
464 .write = acpi_system_write_sleep, 451 .write = acpi_system_write_sleep,
465 .llseek = seq_lseek, 452 .llseek = seq_lseek,
466 .release = single_release, 453 .release = single_release,
467}; 454};
468#endif /* CONFIG_ACPI_SLEEP_PROC_SLEEP */ 455#endif /* CONFIG_ACPI_SLEEP_PROC_SLEEP */
469 456
470static struct file_operations acpi_system_alarm_fops = { 457static struct file_operations acpi_system_alarm_fops = {
471 .open = acpi_system_alarm_open_fs, 458 .open = acpi_system_alarm_open_fs,
472 .read = seq_read, 459 .read = seq_read,
473 .write = acpi_system_write_alarm, 460 .write = acpi_system_write_alarm,
474 .llseek = seq_lseek, 461 .llseek = seq_lseek,
475 .release = single_release, 462 .release = single_release,
476}; 463};
477 464
478 465static u32 rtc_handler(void *context)
479static u32 rtc_handler(void * context)
480{ 466{
481 acpi_clear_event(ACPI_EVENT_RTC); 467 acpi_clear_event(ACPI_EVENT_RTC);
482 acpi_disable_event(ACPI_EVENT_RTC, 0); 468 acpi_disable_event(ACPI_EVENT_RTC, 0);
@@ -486,28 +472,31 @@ static u32 rtc_handler(void * context)
486 472
487static int acpi_sleep_proc_init(void) 473static int acpi_sleep_proc_init(void)
488{ 474{
489 struct proc_dir_entry *entry = NULL; 475 struct proc_dir_entry *entry = NULL;
490 476
491 if (acpi_disabled) 477 if (acpi_disabled)
492 return 0; 478 return 0;
493 479
494#ifdef CONFIG_ACPI_SLEEP_PROC_SLEEP 480#ifdef CONFIG_ACPI_SLEEP_PROC_SLEEP
495 /* 'sleep' [R/W]*/ 481 /* 'sleep' [R/W] */
496 entry = create_proc_entry(ACPI_SYSTEM_FILE_SLEEP, 482 entry =
497 S_IFREG|S_IRUGO|S_IWUSR, acpi_root_dir); 483 create_proc_entry("sleep", S_IFREG | S_IRUGO | S_IWUSR,
484 acpi_root_dir);
498 if (entry) 485 if (entry)
499 entry->proc_fops = &acpi_system_sleep_fops; 486 entry->proc_fops = &acpi_system_sleep_fops;
500#endif 487#endif
501 488
502 /* 'alarm' [R/W] */ 489 /* 'alarm' [R/W] */
503 entry = create_proc_entry(ACPI_SYSTEM_FILE_ALARM, 490 entry =
504 S_IFREG|S_IRUGO|S_IWUSR, acpi_root_dir); 491 create_proc_entry("alarm", S_IFREG | S_IRUGO | S_IWUSR,
492 acpi_root_dir);
505 if (entry) 493 if (entry)
506 entry->proc_fops = &acpi_system_alarm_fops; 494 entry->proc_fops = &acpi_system_alarm_fops;
507 495
508 /* 'wakeup device' [R/W]*/ 496 /* 'wakeup device' [R/W] */
509 entry = create_proc_entry(ACPI_SYSTEM_FILE_WAKEUP_DEVICE, 497 entry =
510 S_IFREG|S_IRUGO|S_IWUSR, acpi_root_dir); 498 create_proc_entry("wakeup", S_IFREG | S_IRUGO | S_IWUSR,
499 acpi_root_dir);
511 if (entry) 500 if (entry)
512 entry->proc_fops = &acpi_system_wakeup_device_fops; 501 entry->proc_fops = &acpi_system_wakeup_device_fops;
513 502
diff --git a/drivers/acpi/sleep/wakeup.c b/drivers/acpi/sleep/wakeup.c
index d9b199969d5d..4134ed43d026 100644
--- a/drivers/acpi/sleep/wakeup.c
+++ b/drivers/acpi/sleep/wakeup.c
@@ -12,9 +12,9 @@
12#include "sleep.h" 12#include "sleep.h"
13 13
14#define _COMPONENT ACPI_SYSTEM_COMPONENT 14#define _COMPONENT ACPI_SYSTEM_COMPONENT
15ACPI_MODULE_NAME ("wakeup_devices") 15ACPI_MODULE_NAME("wakeup_devices")
16 16
17extern struct list_head acpi_wakeup_device_list; 17extern struct list_head acpi_wakeup_device_list;
18extern spinlock_t acpi_device_lock; 18extern spinlock_t acpi_device_lock;
19 19
20#ifdef CONFIG_ACPI_SLEEP 20#ifdef CONFIG_ACPI_SLEEP
@@ -25,22 +25,21 @@ extern spinlock_t acpi_device_lock;
25 * is higher than requested sleep level 25 * is higher than requested sleep level
26 */ 26 */
27 27
28void 28void acpi_enable_wakeup_device_prep(u8 sleep_state)
29acpi_enable_wakeup_device_prep(
30 u8 sleep_state)
31{ 29{
32 struct list_head * node, * next; 30 struct list_head *node, *next;
33 31
34 ACPI_FUNCTION_TRACE("acpi_enable_wakeup_device_prep"); 32 ACPI_FUNCTION_TRACE("acpi_enable_wakeup_device_prep");
35 33
36 spin_lock(&acpi_device_lock); 34 spin_lock(&acpi_device_lock);
37 list_for_each_safe(node, next, &acpi_wakeup_device_list) { 35 list_for_each_safe(node, next, &acpi_wakeup_device_list) {
38 struct acpi_device * dev = container_of(node, 36 struct acpi_device *dev = container_of(node,
39 struct acpi_device, wakeup_list); 37 struct acpi_device,
40 38 wakeup_list);
41 if (!dev->wakeup.flags.valid || 39
42 !dev->wakeup.state.enabled || 40 if (!dev->wakeup.flags.valid ||
43 (sleep_state > (u32) dev->wakeup.sleep_state)) 41 !dev->wakeup.state.enabled ||
42 (sleep_state > (u32) dev->wakeup.sleep_state))
44 continue; 43 continue;
45 44
46 spin_unlock(&acpi_device_lock); 45 spin_unlock(&acpi_device_lock);
@@ -55,11 +54,9 @@ acpi_enable_wakeup_device_prep(
55 * @sleep_state: ACPI state 54 * @sleep_state: ACPI state
56 * Enable all wakup devices's GPE 55 * Enable all wakup devices's GPE
57 */ 56 */
58void 57void acpi_enable_wakeup_device(u8 sleep_state)
59acpi_enable_wakeup_device(
60 u8 sleep_state)
61{ 58{
62 struct list_head * node, * next; 59 struct list_head *node, *next;
63 60
64 /* 61 /*
65 * Caution: this routine must be invoked when interrupt is disabled 62 * Caution: this routine must be invoked when interrupt is disabled
@@ -68,33 +65,35 @@ acpi_enable_wakeup_device(
68 ACPI_FUNCTION_TRACE("acpi_enable_wakeup_device"); 65 ACPI_FUNCTION_TRACE("acpi_enable_wakeup_device");
69 spin_lock(&acpi_device_lock); 66 spin_lock(&acpi_device_lock);
70 list_for_each_safe(node, next, &acpi_wakeup_device_list) { 67 list_for_each_safe(node, next, &acpi_wakeup_device_list) {
71 struct acpi_device * dev = container_of(node, 68 struct acpi_device *dev = container_of(node,
72 struct acpi_device, wakeup_list); 69 struct acpi_device,
70 wakeup_list);
73 71
74 /* If users want to disable run-wake GPE, 72 /* If users want to disable run-wake GPE,
75 * we only disable it for wake and leave it for runtime 73 * we only disable it for wake and leave it for runtime
76 */ 74 */
77 if (dev->wakeup.flags.run_wake && !dev->wakeup.state.enabled) { 75 if (dev->wakeup.flags.run_wake && !dev->wakeup.state.enabled) {
78 spin_unlock(&acpi_device_lock); 76 spin_unlock(&acpi_device_lock);
79 acpi_set_gpe_type(dev->wakeup.gpe_device, 77 acpi_set_gpe_type(dev->wakeup.gpe_device,
80 dev->wakeup.gpe_number, ACPI_GPE_TYPE_RUNTIME); 78 dev->wakeup.gpe_number,
79 ACPI_GPE_TYPE_RUNTIME);
81 /* Re-enable it, since set_gpe_type will disable it */ 80 /* Re-enable it, since set_gpe_type will disable it */
82 acpi_enable_gpe(dev->wakeup.gpe_device, 81 acpi_enable_gpe(dev->wakeup.gpe_device,
83 dev->wakeup.gpe_number, ACPI_ISR); 82 dev->wakeup.gpe_number, ACPI_ISR);
84 spin_lock(&acpi_device_lock); 83 spin_lock(&acpi_device_lock);
85 continue; 84 continue;
86 } 85 }
87 86
88 if (!dev->wakeup.flags.valid || 87 if (!dev->wakeup.flags.valid ||
89 !dev->wakeup.state.enabled || 88 !dev->wakeup.state.enabled ||
90 (sleep_state > (u32) dev->wakeup.sleep_state)) 89 (sleep_state > (u32) dev->wakeup.sleep_state))
91 continue; 90 continue;
92 91
93 spin_unlock(&acpi_device_lock); 92 spin_unlock(&acpi_device_lock);
94 /* run-wake GPE has been enabled */ 93 /* run-wake GPE has been enabled */
95 if (!dev->wakeup.flags.run_wake) 94 if (!dev->wakeup.flags.run_wake)
96 acpi_enable_gpe(dev->wakeup.gpe_device, 95 acpi_enable_gpe(dev->wakeup.gpe_device,
97 dev->wakeup.gpe_number, ACPI_ISR); 96 dev->wakeup.gpe_number, ACPI_ISR);
98 dev->wakeup.state.active = 1; 97 dev->wakeup.state.active = 1;
99 spin_lock(&acpi_device_lock); 98 spin_lock(&acpi_device_lock);
100 } 99 }
@@ -106,43 +105,43 @@ acpi_enable_wakeup_device(
106 * @sleep_state: ACPI state 105 * @sleep_state: ACPI state
107 * Disable all wakup devices's GPE and wakeup capability 106 * Disable all wakup devices's GPE and wakeup capability
108 */ 107 */
109void 108void acpi_disable_wakeup_device(u8 sleep_state)
110acpi_disable_wakeup_device (
111 u8 sleep_state)
112{ 109{
113 struct list_head * node, * next; 110 struct list_head *node, *next;
114 111
115 ACPI_FUNCTION_TRACE("acpi_disable_wakeup_device"); 112 ACPI_FUNCTION_TRACE("acpi_disable_wakeup_device");
116 113
117 spin_lock(&acpi_device_lock); 114 spin_lock(&acpi_device_lock);
118 list_for_each_safe(node, next, &acpi_wakeup_device_list) { 115 list_for_each_safe(node, next, &acpi_wakeup_device_list) {
119 struct acpi_device * dev = container_of(node, 116 struct acpi_device *dev = container_of(node,
120 struct acpi_device, wakeup_list); 117 struct acpi_device,
118 wakeup_list);
121 119
122 if (dev->wakeup.flags.run_wake && !dev->wakeup.state.enabled) { 120 if (dev->wakeup.flags.run_wake && !dev->wakeup.state.enabled) {
123 spin_unlock(&acpi_device_lock); 121 spin_unlock(&acpi_device_lock);
124 acpi_set_gpe_type(dev->wakeup.gpe_device, 122 acpi_set_gpe_type(dev->wakeup.gpe_device,
125 dev->wakeup.gpe_number, ACPI_GPE_TYPE_WAKE_RUN); 123 dev->wakeup.gpe_number,
124 ACPI_GPE_TYPE_WAKE_RUN);
126 /* Re-enable it, since set_gpe_type will disable it */ 125 /* Re-enable it, since set_gpe_type will disable it */
127 acpi_enable_gpe(dev->wakeup.gpe_device, 126 acpi_enable_gpe(dev->wakeup.gpe_device,
128 dev->wakeup.gpe_number, ACPI_NOT_ISR); 127 dev->wakeup.gpe_number, ACPI_NOT_ISR);
129 spin_lock(&acpi_device_lock); 128 spin_lock(&acpi_device_lock);
130 continue; 129 continue;
131 } 130 }
132 131
133 if (!dev->wakeup.flags.valid || 132 if (!dev->wakeup.flags.valid ||
134 !dev->wakeup.state.active || 133 !dev->wakeup.state.active ||
135 (sleep_state > (u32) dev->wakeup.sleep_state)) 134 (sleep_state > (u32) dev->wakeup.sleep_state))
136 continue; 135 continue;
137 136
138 spin_unlock(&acpi_device_lock); 137 spin_unlock(&acpi_device_lock);
139 acpi_disable_wakeup_device_power(dev); 138 acpi_disable_wakeup_device_power(dev);
140 /* Never disable run-wake GPE */ 139 /* Never disable run-wake GPE */
141 if (!dev->wakeup.flags.run_wake) { 140 if (!dev->wakeup.flags.run_wake) {
142 acpi_disable_gpe(dev->wakeup.gpe_device, 141 acpi_disable_gpe(dev->wakeup.gpe_device,
143 dev->wakeup.gpe_number, ACPI_NOT_ISR); 142 dev->wakeup.gpe_number, ACPI_NOT_ISR);
144 acpi_clear_gpe(dev->wakeup.gpe_device, 143 acpi_clear_gpe(dev->wakeup.gpe_device,
145 dev->wakeup.gpe_number, ACPI_NOT_ISR); 144 dev->wakeup.gpe_number, ACPI_NOT_ISR);
146 } 145 }
147 dev->wakeup.state.active = 0; 146 dev->wakeup.state.active = 0;
148 spin_lock(&acpi_device_lock); 147 spin_lock(&acpi_device_lock);
@@ -152,7 +151,7 @@ acpi_disable_wakeup_device (
152 151
153static int __init acpi_wakeup_device_init(void) 152static int __init acpi_wakeup_device_init(void)
154{ 153{
155 struct list_head * node, * next; 154 struct list_head *node, *next;
156 155
157 if (acpi_disabled) 156 if (acpi_disabled)
158 return 0; 157 return 0;
@@ -160,16 +159,18 @@ static int __init acpi_wakeup_device_init(void)
160 159
161 spin_lock(&acpi_device_lock); 160 spin_lock(&acpi_device_lock);
162 list_for_each_safe(node, next, &acpi_wakeup_device_list) { 161 list_for_each_safe(node, next, &acpi_wakeup_device_list) {
163 struct acpi_device * dev = container_of(node, 162 struct acpi_device *dev = container_of(node,
164 struct acpi_device, wakeup_list); 163 struct acpi_device,
165 164 wakeup_list);
165
166 /* In case user doesn't load button driver */ 166 /* In case user doesn't load button driver */
167 if (dev->wakeup.flags.run_wake && !dev->wakeup.state.enabled) { 167 if (dev->wakeup.flags.run_wake && !dev->wakeup.state.enabled) {
168 spin_unlock(&acpi_device_lock); 168 spin_unlock(&acpi_device_lock);
169 acpi_set_gpe_type(dev->wakeup.gpe_device, 169 acpi_set_gpe_type(dev->wakeup.gpe_device,
170 dev->wakeup.gpe_number, ACPI_GPE_TYPE_WAKE_RUN); 170 dev->wakeup.gpe_number,
171 acpi_enable_gpe(dev->wakeup.gpe_device, 171 ACPI_GPE_TYPE_WAKE_RUN);
172 dev->wakeup.gpe_number, ACPI_NOT_ISR); 172 acpi_enable_gpe(dev->wakeup.gpe_device,
173 dev->wakeup.gpe_number, ACPI_NOT_ISR);
173 dev->wakeup.state.enabled = 1; 174 dev->wakeup.state.enabled = 1;
174 spin_lock(&acpi_device_lock); 175 spin_lock(&acpi_device_lock);
175 } 176 }
@@ -193,17 +194,19 @@ late_initcall(acpi_wakeup_device_init);
193 */ 194 */
194void acpi_wakeup_gpe_poweroff_prepare(void) 195void acpi_wakeup_gpe_poweroff_prepare(void)
195{ 196{
196 struct list_head * node, * next; 197 struct list_head *node, *next;
197 198
198 list_for_each_safe(node, next, &acpi_wakeup_device_list) { 199 list_for_each_safe(node, next, &acpi_wakeup_device_list) {
199 struct acpi_device * dev = container_of(node, 200 struct acpi_device *dev = container_of(node,
200 struct acpi_device, wakeup_list); 201 struct acpi_device,
202 wakeup_list);
201 203
202 /* The GPE can wakeup system from S5, don't touch it */ 204 /* The GPE can wakeup system from S5, don't touch it */
203 if ((u32)dev->wakeup.sleep_state == ACPI_STATE_S5) 205 if ((u32) dev->wakeup.sleep_state == ACPI_STATE_S5)
204 continue; 206 continue;
205 /* acpi_set_gpe_type will automatically disable GPE */ 207 /* acpi_set_gpe_type will automatically disable GPE */
206 acpi_set_gpe_type(dev->wakeup.gpe_device, 208 acpi_set_gpe_type(dev->wakeup.gpe_device,
207 dev->wakeup.gpe_number, ACPI_GPE_TYPE_RUNTIME); 209 dev->wakeup.gpe_number,
210 ACPI_GPE_TYPE_RUNTIME);
208 } 211 }
209} 212}