aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/acpi/sleep
diff options
context:
space:
mode:
authorLen Brown <len.brown@intel.com>2005-08-05 00:44:28 -0400
committerLen Brown <len.brown@intel.com>2005-08-05 00:45:14 -0400
commit4be44fcd3bf648b782f4460fd06dfae6c42ded4b (patch)
tree5b5b7d296ea58786f53b95e5eac9565ff66890b0 /drivers/acpi/sleep
parentc65ade4dc8b486e8c8b9b0a6399789a5428e2039 (diff)
[ACPI] Lindent all ACPI files
Signed-off-by: Len Brown <len.brown@intel.com>
Diffstat (limited to 'drivers/acpi/sleep')
-rw-r--r--drivers/acpi/sleep/poweroff.c2
-rw-r--r--drivers/acpi/sleep/proc.c243
-rw-r--r--drivers/acpi/sleep/wakeup.c115
3 files changed, 183 insertions, 177 deletions
diff --git a/drivers/acpi/sleep/poweroff.c b/drivers/acpi/sleep/poweroff.c
index 186b182c5825..f8538b5b893e 100644
--- a/drivers/acpi/sleep/poweroff.c
+++ b/drivers/acpi/sleep/poweroff.c
@@ -91,4 +91,4 @@ static int acpi_poweroff_init(void)
91 91
92late_initcall(acpi_poweroff_init); 92late_initcall(acpi_poweroff_init);
93 93
94#endif /* CONFIG_PM */ 94#endif /* CONFIG_PM */
diff --git a/drivers/acpi/sleep/proc.c b/drivers/acpi/sleep/proc.c
index a962fc24f704..09a603f3523e 100644
--- a/drivers/acpi/sleep/proc.c
+++ b/drivers/acpi/sleep/proc.c
@@ -14,19 +14,17 @@
14#include "sleep.h" 14#include "sleep.h"
15 15
16#define _COMPONENT ACPI_SYSTEM_COMPONENT 16#define _COMPONENT ACPI_SYSTEM_COMPONENT
17ACPI_MODULE_NAME ("sleep") 17ACPI_MODULE_NAME("sleep")
18
19#ifdef CONFIG_ACPI_SLEEP_PROC_SLEEP 18#ifdef CONFIG_ACPI_SLEEP_PROC_SLEEP
20
21static 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)
22{ 20{
23 int i; 21 int i;
24 22
25 ACPI_FUNCTION_TRACE("acpi_system_sleep_seq_show"); 23 ACPI_FUNCTION_TRACE("acpi_system_sleep_seq_show");
26 24
27 for (i = 0; i <= ACPI_STATE_S5; i++) { 25 for (i = 0; i <= ACPI_STATE_S5; i++) {
28 if (sleep_states[i]) { 26 if (sleep_states[i]) {
29 seq_printf(seq,"S%d ", i); 27 seq_printf(seq, "S%d ", i);
30 if (i == ACPI_STATE_S4 && acpi_gbl_FACS->S4bios_f) 28 if (i == ACPI_STATE_S4 && acpi_gbl_FACS->S4bios_f)
31 seq_printf(seq, "S4bios "); 29 seq_printf(seq, "S4bios ");
32 } 30 }
@@ -43,24 +41,21 @@ static int acpi_system_sleep_open_fs(struct inode *inode, struct file *file)
43} 41}
44 42
45static ssize_t 43static ssize_t
46acpi_system_write_sleep ( 44acpi_system_write_sleep(struct file *file,
47 struct file *file, 45 const char __user * buffer, size_t count, loff_t * ppos)
48 const char __user *buffer,
49 size_t count,
50 loff_t *ppos)
51{ 46{
52 char str[12]; 47 char str[12];
53 u32 state = 0; 48 u32 state = 0;
54 int error = 0; 49 int error = 0;
55 50
56 if (count > sizeof(str) - 1) 51 if (count > sizeof(str) - 1)
57 goto Done; 52 goto Done;
58 memset(str,0,sizeof(str)); 53 memset(str, 0, sizeof(str));
59 if (copy_from_user(str, buffer, count)) 54 if (copy_from_user(str, buffer, count))
60 return -EFAULT; 55 return -EFAULT;
61 56
62 /* Check for S4 bios request */ 57 /* Check for S4 bios request */
63 if (!strcmp(str,"4b")) { 58 if (!strcmp(str, "4b")) {
64 error = acpi_suspend(4); 59 error = acpi_suspend(4);
65 goto Done; 60 goto Done;
66 } 61 }
@@ -72,17 +67,17 @@ acpi_system_write_sleep (
72 } 67 }
73#endif 68#endif
74 error = acpi_suspend(state); 69 error = acpi_suspend(state);
75 Done: 70 Done:
76 return error ? error : count; 71 return error ? error : count;
77} 72}
78#endif /* CONFIG_ACPI_SLEEP_PROC_SLEEP */ 73#endif /* CONFIG_ACPI_SLEEP_PROC_SLEEP */
79 74
80static 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)
81{ 76{
82 u32 sec, min, hr; 77 u32 sec, min, hr;
83 u32 day, mo, yr; 78 u32 day, mo, yr;
84 unsigned char rtc_control = 0; 79 unsigned char rtc_control = 0;
85 unsigned long flags; 80 unsigned long flags;
86 81
87 ACPI_FUNCTION_TRACE("acpi_system_alarm_seq_show"); 82 ACPI_FUNCTION_TRACE("acpi_system_alarm_seq_show");
88 83
@@ -98,13 +93,14 @@ static int acpi_system_alarm_seq_show(struct seq_file *seq, void *offset)
98 /* ACPI spec: only low 6 its should be cared */ 93 /* ACPI spec: only low 6 its should be cared */
99 day = CMOS_READ(acpi_gbl_FADT->day_alrm) & 0x3F; 94 day = CMOS_READ(acpi_gbl_FADT->day_alrm) & 0x3F;
100 else 95 else
101 day = CMOS_READ(RTC_DAY_OF_MONTH); 96 day = CMOS_READ(RTC_DAY_OF_MONTH);
102 if (acpi_gbl_FADT->mon_alrm) 97 if (acpi_gbl_FADT->mon_alrm)
103 mo = CMOS_READ(acpi_gbl_FADT->mon_alrm); 98 mo = CMOS_READ(acpi_gbl_FADT->mon_alrm);
104 else 99 else
105 mo = CMOS_READ(RTC_MONTH); 100 mo = CMOS_READ(RTC_MONTH);
106 if (acpi_gbl_FADT->century) 101 if (acpi_gbl_FADT->century)
107 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);
108 else 104 else
109 yr = CMOS_READ(RTC_YEAR); 105 yr = CMOS_READ(RTC_YEAR);
110 106
@@ -119,33 +115,33 @@ static int acpi_system_alarm_seq_show(struct seq_file *seq, void *offset)
119 BCD_TO_BIN(yr); 115 BCD_TO_BIN(yr);
120 } 116 }
121 117
122 /* we're trusting the FADT (see above)*/ 118 /* we're trusting the FADT (see above) */
123 if (!acpi_gbl_FADT->century) 119 if (!acpi_gbl_FADT->century)
124 /* 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
125 * right for _this_ century... ehm, what is _this_ century? 121 * right for _this_ century... ehm, what is _this_ century?
126 * 122 *
127 * TBD: 123 * TBD:
128 * 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,
129 * which we can trust to determine the century correctly. Atom 125 * which we can trust to determine the century correctly. Atom
130 * watch driver would be nice, too... 126 * watch driver would be nice, too...
131 * 127 *
132 * if that has not happened, change for first release in 2050: 128 * if that has not happened, change for first release in 2050:
133 * if (yr<50) 129 * if (yr<50)
134 * yr += 2100; 130 * yr += 2100;
135 * else 131 * else
136 * yr += 2000; // current line of code 132 * yr += 2000; // current line of code
137 * 133 *
138 * 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
139 * s/2000/2100 135 * s/2000/2100
140 * 136 *
141 */ 137 */
142 yr += 2000; 138 yr += 2000;
143 139
144 seq_printf(seq,"%4.4u-", yr); 140 seq_printf(seq, "%4.4u-", yr);
145 (mo > 12) ? seq_puts(seq, "**-") : seq_printf(seq, "%2.2u-", mo); 141 (mo > 12) ? seq_puts(seq, "**-") : seq_printf(seq, "%2.2u-", mo);
146 (day > 31) ? seq_puts(seq, "** ") : seq_printf(seq, "%2.2u ", day); 142 (day > 31) ? seq_puts(seq, "** ") : seq_printf(seq, "%2.2u ", day);
147 (hr > 23) ? seq_puts(seq, "**:") : seq_printf(seq, "%2.2u:", hr); 143 (hr > 23) ? seq_puts(seq, "**:") : seq_printf(seq, "%2.2u:", hr);
148 (min > 59) ? seq_puts(seq, "**:") : seq_printf(seq, "%2.2u:", min); 144 (min > 59) ? seq_puts(seq, "**:") : seq_printf(seq, "%2.2u:", min);
149 (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);
150 146
151 return 0; 147 return 0;
@@ -156,15 +152,11 @@ static int acpi_system_alarm_open_fs(struct inode *inode, struct file *file)
156 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);
157} 153}
158 154
159 155static int get_date_field(char **p, u32 * value)
160static int
161get_date_field (
162 char **p,
163 u32 *value)
164{ 156{
165 char *next = NULL; 157 char *next = NULL;
166 char *string_end = NULL; 158 char *string_end = NULL;
167 int result = -EINVAL; 159 int result = -EINVAL;
168 160
169 /* 161 /*
170 * 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
@@ -186,26 +178,22 @@ get_date_field (
186 return result; 178 return result;
187} 179}
188 180
189
190static ssize_t 181static ssize_t
191acpi_system_write_alarm ( 182acpi_system_write_alarm(struct file *file,
192 struct file *file, 183 const char __user * buffer, size_t count, loff_t * ppos)
193 const char __user *buffer,
194 size_t count,
195 loff_t *ppos)
196{ 184{
197 int result = 0; 185 int result = 0;
198 char alarm_string[30] = {'\0'}; 186 char alarm_string[30] = { '\0' };
199 char *p = alarm_string; 187 char *p = alarm_string;
200 u32 sec, min, hr, day, mo, yr; 188 u32 sec, min, hr, day, mo, yr;
201 int adjust = 0; 189 int adjust = 0;
202 unsigned char rtc_control = 0; 190 unsigned char rtc_control = 0;
203 191
204 ACPI_FUNCTION_TRACE("acpi_system_write_alarm"); 192 ACPI_FUNCTION_TRACE("acpi_system_write_alarm");
205 193
206 if (count > sizeof(alarm_string) - 1) 194 if (count > sizeof(alarm_string) - 1)
207 return_VALUE(-EINVAL); 195 return_VALUE(-EINVAL);
208 196
209 if (copy_from_user(alarm_string, buffer, count)) 197 if (copy_from_user(alarm_string, buffer, count))
210 return_VALUE(-EFAULT); 198 return_VALUE(-EFAULT);
211 199
@@ -264,10 +252,10 @@ acpi_system_write_alarm (
264 } 252 }
265 253
266 if (adjust) { 254 if (adjust) {
267 yr += CMOS_READ(RTC_YEAR); 255 yr += CMOS_READ(RTC_YEAR);
268 mo += CMOS_READ(RTC_MONTH); 256 mo += CMOS_READ(RTC_MONTH);
269 day += CMOS_READ(RTC_DAY_OF_MONTH); 257 day += CMOS_READ(RTC_DAY_OF_MONTH);
270 hr += CMOS_READ(RTC_HOURS); 258 hr += CMOS_READ(RTC_HOURS);
271 min += CMOS_READ(RTC_MINUTES); 259 min += CMOS_READ(RTC_MINUTES);
272 sec += CMOS_READ(RTC_SECONDS); 260 sec += CMOS_READ(RTC_SECONDS);
273 } 261 }
@@ -336,7 +324,7 @@ acpi_system_write_alarm (
336 if (acpi_gbl_FADT->mon_alrm) 324 if (acpi_gbl_FADT->mon_alrm)
337 CMOS_WRITE(mo, acpi_gbl_FADT->mon_alrm); 325 CMOS_WRITE(mo, acpi_gbl_FADT->mon_alrm);
338 if (acpi_gbl_FADT->century) 326 if (acpi_gbl_FADT->century)
339 CMOS_WRITE(yr/100, acpi_gbl_FADT->century); 327 CMOS_WRITE(yr / 100, acpi_gbl_FADT->century);
340 /* enable the rtc alarm interrupt */ 328 /* enable the rtc alarm interrupt */
341 rtc_control |= RTC_AIE; 329 rtc_control |= RTC_AIE;
342 CMOS_WRITE(rtc_control, RTC_CONTROL); 330 CMOS_WRITE(rtc_control, RTC_CONTROL);
@@ -350,29 +338,31 @@ acpi_system_write_alarm (
350 *ppos += count; 338 *ppos += count;
351 339
352 result = 0; 340 result = 0;
353end: 341 end:
354 return_VALUE(result ? result : count); 342 return_VALUE(result ? result : count);
355} 343}
356 344
357extern struct list_head acpi_wakeup_device_list; 345extern struct list_head acpi_wakeup_device_list;
358extern spinlock_t acpi_device_lock; 346extern spinlock_t acpi_device_lock;
359 347
360static int 348static int
361acpi_system_wakeup_device_seq_show(struct seq_file *seq, void *offset) 349acpi_system_wakeup_device_seq_show(struct seq_file *seq, void *offset)
362{ 350{
363 struct list_head * node, * next; 351 struct list_head *node, *next;
364 352
365 seq_printf(seq, "Device Sleep state Status\n"); 353 seq_printf(seq, "Device Sleep state Status\n");
366 354
367 spin_lock(&acpi_device_lock); 355 spin_lock(&acpi_device_lock);
368 list_for_each_safe(node, next, &acpi_wakeup_device_list) { 356 list_for_each_safe(node, next, &acpi_wakeup_device_list) {
369 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);
370 359
371 if (!dev->wakeup.flags.valid) 360 if (!dev->wakeup.flags.valid)
372 continue; 361 continue;
373 spin_unlock(&acpi_device_lock); 362 spin_unlock(&acpi_device_lock);
374 seq_printf(seq, "%4s %4d %s%8s\n", 363 seq_printf(seq, "%4s %4d %s%8s\n",
375 dev->pnp.bus_id, (u32) dev->wakeup.sleep_state, 364 dev->pnp.bus_id,
365 (u32) dev->wakeup.sleep_state,
376 dev->wakeup.flags.run_wake ? "*" : "", 366 dev->wakeup.flags.run_wake ? "*" : "",
377 dev->wakeup.state.enabled ? "enabled" : "disabled"); 367 dev->wakeup.state.enabled ? "enabled" : "disabled");
378 spin_lock(&acpi_device_lock); 368 spin_lock(&acpi_device_lock);
@@ -382,19 +372,18 @@ acpi_system_wakeup_device_seq_show(struct seq_file *seq, void *offset)
382} 372}
383 373
384static ssize_t 374static ssize_t
385acpi_system_write_wakeup_device ( 375acpi_system_write_wakeup_device(struct file *file,
386 struct file *file, 376 const char __user * buffer,
387 const char __user *buffer, 377 size_t count, loff_t * ppos)
388 size_t count,
389 loff_t *ppos)
390{ 378{
391 struct list_head * node, * next; 379 struct list_head *node, *next;
392 char strbuf[5]; 380 char strbuf[5];
393 char str[5] = ""; 381 char str[5] = "";
394 int len = count; 382 int len = count;
395 struct acpi_device *found_dev = NULL; 383 struct acpi_device *found_dev = NULL;
396 384
397 if (len > 4) len = 4; 385 if (len > 4)
386 len = 4;
398 387
399 if (copy_from_user(strbuf, buffer, len)) 388 if (copy_from_user(strbuf, buffer, len))
400 return -EFAULT; 389 return -EFAULT;
@@ -403,28 +392,36 @@ acpi_system_write_wakeup_device (
403 392
404 spin_lock(&acpi_device_lock); 393 spin_lock(&acpi_device_lock);
405 list_for_each_safe(node, next, &acpi_wakeup_device_list) { 394 list_for_each_safe(node, next, &acpi_wakeup_device_list) {
406 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);
407 if (!dev->wakeup.flags.valid) 397 if (!dev->wakeup.flags.valid)
408 continue; 398 continue;
409 399
410 if (!strncmp(dev->pnp.bus_id, str, 4)) { 400 if (!strncmp(dev->pnp.bus_id, str, 4)) {
411 dev->wakeup.state.enabled = dev->wakeup.state.enabled ? 0:1; 401 dev->wakeup.state.enabled =
402 dev->wakeup.state.enabled ? 0 : 1;
412 found_dev = dev; 403 found_dev = dev;
413 break; 404 break;
414 } 405 }
415 } 406 }
416 if (found_dev) { 407 if (found_dev) {
417 list_for_each_safe(node, next, &acpi_wakeup_device_list) { 408 list_for_each_safe(node, next, &acpi_wakeup_device_list) {
418 struct acpi_device * dev = container_of(node, 409 struct acpi_device *dev = container_of(node,
419 struct acpi_device, wakeup_list); 410 struct
411 acpi_device,
412 wakeup_list);
420 413
421 if ((dev != found_dev) && 414 if ((dev != found_dev) &&
422 (dev->wakeup.gpe_number == found_dev->wakeup.gpe_number) && 415 (dev->wakeup.gpe_number ==
423 (dev->wakeup.gpe_device == found_dev->wakeup.gpe_device)) { 416 found_dev->wakeup.gpe_number)
424 printk(KERN_WARNING "ACPI: '%s' and '%s' have the same GPE, " 417 && (dev->wakeup.gpe_device ==
425 "can't disable/enable one seperately\n", 418 found_dev->wakeup.gpe_device)) {
426 dev->pnp.bus_id, found_dev->pnp.bus_id); 419 printk(KERN_WARNING
427 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;
428 } 425 }
429 } 426 }
430 } 427 }
@@ -435,37 +432,37 @@ acpi_system_write_wakeup_device (
435static int 432static int
436acpi_system_wakeup_device_open_fs(struct inode *inode, struct file *file) 433acpi_system_wakeup_device_open_fs(struct inode *inode, struct file *file)
437{ 434{
438 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);
439} 437}
440 438
441static struct file_operations acpi_system_wakeup_device_fops = { 439static struct file_operations acpi_system_wakeup_device_fops = {
442 .open = acpi_system_wakeup_device_open_fs, 440 .open = acpi_system_wakeup_device_open_fs,
443 .read = seq_read, 441 .read = seq_read,
444 .write = acpi_system_write_wakeup_device, 442 .write = acpi_system_write_wakeup_device,
445 .llseek = seq_lseek, 443 .llseek = seq_lseek,
446 .release = single_release, 444 .release = single_release,
447}; 445};
448 446
449#ifdef CONFIG_ACPI_SLEEP_PROC_SLEEP 447#ifdef CONFIG_ACPI_SLEEP_PROC_SLEEP
450static struct file_operations acpi_system_sleep_fops = { 448static struct file_operations acpi_system_sleep_fops = {
451 .open = acpi_system_sleep_open_fs, 449 .open = acpi_system_sleep_open_fs,
452 .read = seq_read, 450 .read = seq_read,
453 .write = acpi_system_write_sleep, 451 .write = acpi_system_write_sleep,
454 .llseek = seq_lseek, 452 .llseek = seq_lseek,
455 .release = single_release, 453 .release = single_release,
456}; 454};
457#endif /* CONFIG_ACPI_SLEEP_PROC_SLEEP */ 455#endif /* CONFIG_ACPI_SLEEP_PROC_SLEEP */
458 456
459static struct file_operations acpi_system_alarm_fops = { 457static struct file_operations acpi_system_alarm_fops = {
460 .open = acpi_system_alarm_open_fs, 458 .open = acpi_system_alarm_open_fs,
461 .read = seq_read, 459 .read = seq_read,
462 .write = acpi_system_write_alarm, 460 .write = acpi_system_write_alarm,
463 .llseek = seq_lseek, 461 .llseek = seq_lseek,
464 .release = single_release, 462 .release = single_release,
465}; 463};
466 464
467 465static u32 rtc_handler(void *context)
468static u32 rtc_handler(void * context)
469{ 466{
470 acpi_clear_event(ACPI_EVENT_RTC); 467 acpi_clear_event(ACPI_EVENT_RTC);
471 acpi_disable_event(ACPI_EVENT_RTC, 0); 468 acpi_disable_event(ACPI_EVENT_RTC, 0);
@@ -479,21 +476,27 @@ static int acpi_sleep_proc_init(void)
479 476
480 if (acpi_disabled) 477 if (acpi_disabled)
481 return 0; 478 return 0;
482 479
483#ifdef CONFIG_ACPI_SLEEP_PROC_SLEEP 480#ifdef CONFIG_ACPI_SLEEP_PROC_SLEEP
484 /* 'sleep' [R/W] */ 481 /* 'sleep' [R/W] */
485 entry = create_proc_entry("sleep", S_IFREG|S_IRUGO|S_IWUSR, acpi_root_dir); 482 entry =
483 create_proc_entry("sleep", S_IFREG | S_IRUGO | S_IWUSR,
484 acpi_root_dir);
486 if (entry) 485 if (entry)
487 entry->proc_fops = &acpi_system_sleep_fops; 486 entry->proc_fops = &acpi_system_sleep_fops;
488#endif 487#endif
489 488
490 /* 'alarm' [R/W] */ 489 /* 'alarm' [R/W] */
491 entry = create_proc_entry("alarm", S_IFREG|S_IRUGO|S_IWUSR, acpi_root_dir); 490 entry =
491 create_proc_entry("alarm", S_IFREG | S_IRUGO | S_IWUSR,
492 acpi_root_dir);
492 if (entry) 493 if (entry)
493 entry->proc_fops = &acpi_system_alarm_fops; 494 entry->proc_fops = &acpi_system_alarm_fops;
494 495
495 /* 'wakeup device' [R/W] */ 496 /* 'wakeup device' [R/W] */
496 entry = create_proc_entry("wakeup", S_IFREG|S_IRUGO|S_IWUSR, acpi_root_dir); 497 entry =
498 create_proc_entry("wakeup", S_IFREG | S_IRUGO | S_IWUSR,
499 acpi_root_dir);
497 if (entry) 500 if (entry)
498 entry->proc_fops = &acpi_system_wakeup_device_fops; 501 entry->proc_fops = &acpi_system_wakeup_device_fops;
499 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}