aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/acpi/sleep/proc.c
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/proc.c
parentc65ade4dc8b486e8c8b9b0a6399789a5428e2039 (diff)
[ACPI] Lindent all ACPI files
Signed-off-by: Len Brown <len.brown@intel.com>
Diffstat (limited to 'drivers/acpi/sleep/proc.c')
-rw-r--r--drivers/acpi/sleep/proc.c243
1 files changed, 123 insertions, 120 deletions
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