diff options
Diffstat (limited to 'drivers/acpi/ibm_acpi.c')
-rw-r--r-- | drivers/acpi/ibm_acpi.c | 322 |
1 files changed, 156 insertions, 166 deletions
diff --git a/drivers/acpi/ibm_acpi.c b/drivers/acpi/ibm_acpi.c index ad85e10001f4..62233bd7147c 100644 --- a/drivers/acpi/ibm_acpi.c +++ b/drivers/acpi/ibm_acpi.c | |||
@@ -86,52 +86,46 @@ static acpi_handle root_handle = NULL; | |||
86 | static acpi_handle *object##_parent = &parent##_handle; \ | 86 | static acpi_handle *object##_parent = &parent##_handle; \ |
87 | static char *object##_paths[] = { paths } | 87 | static char *object##_paths[] = { paths } |
88 | 88 | ||
89 | IBM_HANDLE(ec, root, | 89 | IBM_HANDLE(ec, root, "\\_SB.PCI0.ISA.EC", /* A21e, A22p, T20, T21, X20 */ |
90 | "\\_SB.PCI0.ISA.EC", /* A21e, A22p, T20, T21, X20 */ | 90 | "\\_SB.PCI0.LPC.EC", /* all others */ |
91 | "\\_SB.PCI0.LPC.EC", /* all others */ | 91 | ); |
92 | ); | 92 | |
93 | 93 | IBM_HANDLE(vid, root, "\\_SB.PCI0.VID", /* A21e, G40, X30, X40 */ | |
94 | IBM_HANDLE(vid, root, | 94 | "\\_SB.PCI0.AGP.VID", /* all others */ |
95 | "\\_SB.PCI0.VID", /* A21e, G40, X30, X40 */ | 95 | ); |
96 | "\\_SB.PCI0.AGP.VID", /* all others */ | 96 | |
97 | ); | 97 | IBM_HANDLE(cmos, root, "\\UCMS", /* R50, R50p, R51, T4x, X31, X40 */ |
98 | 98 | "\\CMOS", /* A3x, G40, R32, T23, T30, X22, X24, X30 */ | |
99 | IBM_HANDLE(cmos, root, | 99 | "\\CMS", /* R40, R40e */ |
100 | "\\UCMS", /* R50, R50p, R51, T4x, X31, X40 */ | 100 | ); /* A21e, A22p, T20, T21, X20 */ |
101 | "\\CMOS", /* A3x, G40, R32, T23, T30, X22, X24, X30 */ | 101 | |
102 | "\\CMS", /* R40, R40e */ | 102 | IBM_HANDLE(dock, root, "\\_SB.GDCK", /* X30, X31, X40 */ |
103 | ); /* A21e, A22p, T20, T21, X20 */ | 103 | "\\_SB.PCI0.DOCK", /* A22p, T20, T21, X20 */ |
104 | 104 | "\\_SB.PCI0.PCI1.DOCK", /* all others */ | |
105 | IBM_HANDLE(dock, root, | 105 | ); /* A21e, G40, R32, R40, R40e */ |
106 | "\\_SB.GDCK", /* X30, X31, X40 */ | 106 | |
107 | "\\_SB.PCI0.DOCK", /* A22p, T20, T21, X20 */ | 107 | IBM_HANDLE(bay, root, "\\_SB.PCI0.IDE0.SCND.MSTR"); /* all except A21e */ |
108 | "\\_SB.PCI0.PCI1.DOCK", /* all others */ | 108 | IBM_HANDLE(bayej, root, "\\_SB.PCI0.IDE0.SCND.MSTR._EJ0"); /* all except A2x, A3x */ |
109 | ); /* A21e, G40, R32, R40, R40e */ | 109 | |
110 | 110 | IBM_HANDLE(lght, root, "\\LGHT"); /* A21e, A22p, T20, T21, X20 */ | |
111 | IBM_HANDLE(bay, root, | 111 | IBM_HANDLE(hkey, ec, "HKEY"); /* all */ |
112 | "\\_SB.PCI0.IDE0.SCND.MSTR"); /* all except A21e */ | 112 | IBM_HANDLE(led, ec, "LED"); /* all except A21e, A22p, T20, T21, X20 */ |
113 | IBM_HANDLE(bayej, root, | 113 | IBM_HANDLE(sysl, ec, "SYSL"); /* A21e, A22p, T20, T21, X20 */ |
114 | "\\_SB.PCI0.IDE0.SCND.MSTR._EJ0"); /* all except A2x, A3x */ | 114 | IBM_HANDLE(bled, ec, "BLED"); /* A22p, T20, T21, X20 */ |
115 | 115 | IBM_HANDLE(beep, ec, "BEEP"); /* all models */ | |
116 | IBM_HANDLE(lght, root, "\\LGHT"); /* A21e, A22p, T20, T21, X20 */ | ||
117 | IBM_HANDLE(hkey, ec, "HKEY"); /* all */ | ||
118 | IBM_HANDLE(led, ec, "LED"); /* all except A21e, A22p, T20, T21, X20 */ | ||
119 | IBM_HANDLE(sysl, ec, "SYSL"); /* A21e, A22p, T20, T21, X20 */ | ||
120 | IBM_HANDLE(bled, ec, "BLED"); /* A22p, T20, T21, X20 */ | ||
121 | IBM_HANDLE(beep, ec, "BEEP"); /* all models */ | ||
122 | 116 | ||
123 | struct ibm_struct { | 117 | struct ibm_struct { |
124 | char *name; | 118 | char *name; |
125 | 119 | ||
126 | char *hid; | 120 | char *hid; |
127 | struct acpi_driver *driver; | 121 | struct acpi_driver *driver; |
128 | |||
129 | int (*init) (struct ibm_struct *); | ||
130 | int (*read) (struct ibm_struct *, char *); | ||
131 | int (*write) (struct ibm_struct *, char *); | ||
132 | void (*exit) (struct ibm_struct *); | ||
133 | 122 | ||
134 | void (*notify) (struct ibm_struct *, u32); | 123 | int (*init) (struct ibm_struct *); |
124 | int (*read) (struct ibm_struct *, char *); | ||
125 | int (*write) (struct ibm_struct *, char *); | ||
126 | void (*exit) (struct ibm_struct *); | ||
127 | |||
128 | void (*notify) (struct ibm_struct *, u32); | ||
135 | acpi_handle *handle; | 129 | acpi_handle *handle; |
136 | int type; | 130 | int type; |
137 | struct acpi_device *device; | 131 | struct acpi_device *device; |
@@ -165,15 +159,15 @@ static int acpi_evalf(acpi_handle handle, | |||
165 | void *res, char *method, char *fmt, ...) | 159 | void *res, char *method, char *fmt, ...) |
166 | { | 160 | { |
167 | char *fmt0 = fmt; | 161 | char *fmt0 = fmt; |
168 | struct acpi_object_list params; | 162 | struct acpi_object_list params; |
169 | union acpi_object in_objs[IBM_MAX_ACPI_ARGS]; | 163 | union acpi_object in_objs[IBM_MAX_ACPI_ARGS]; |
170 | struct acpi_buffer result; | 164 | struct acpi_buffer result; |
171 | union acpi_object out_obj; | 165 | union acpi_object out_obj; |
172 | acpi_status status; | 166 | acpi_status status; |
173 | va_list ap; | 167 | va_list ap; |
174 | char res_type; | 168 | char res_type; |
175 | int success; | 169 | int success; |
176 | int quiet; | 170 | int quiet; |
177 | 171 | ||
178 | if (!*fmt) { | 172 | if (!*fmt) { |
179 | printk(IBM_ERR "acpi_evalf() called with empty format\n"); | 173 | printk(IBM_ERR "acpi_evalf() called with empty format\n"); |
@@ -199,7 +193,7 @@ static int acpi_evalf(acpi_handle handle, | |||
199 | in_objs[params.count].integer.value = va_arg(ap, int); | 193 | in_objs[params.count].integer.value = va_arg(ap, int); |
200 | in_objs[params.count++].type = ACPI_TYPE_INTEGER; | 194 | in_objs[params.count++].type = ACPI_TYPE_INTEGER; |
201 | break; | 195 | break; |
202 | /* add more types as needed */ | 196 | /* add more types as needed */ |
203 | default: | 197 | default: |
204 | printk(IBM_ERR "acpi_evalf() called " | 198 | printk(IBM_ERR "acpi_evalf() called " |
205 | "with invalid format character '%c'\n", c); | 199 | "with invalid format character '%c'\n", c); |
@@ -214,15 +208,15 @@ static int acpi_evalf(acpi_handle handle, | |||
214 | status = acpi_evaluate_object(handle, method, ¶ms, &result); | 208 | status = acpi_evaluate_object(handle, method, ¶ms, &result); |
215 | 209 | ||
216 | switch (res_type) { | 210 | switch (res_type) { |
217 | case 'd': /* int */ | 211 | case 'd': /* int */ |
218 | if (res) | 212 | if (res) |
219 | *(int *)res = out_obj.integer.value; | 213 | *(int *)res = out_obj.integer.value; |
220 | success = status == AE_OK && out_obj.type == ACPI_TYPE_INTEGER; | 214 | success = status == AE_OK && out_obj.type == ACPI_TYPE_INTEGER; |
221 | break; | 215 | break; |
222 | case 'v': /* void */ | 216 | case 'v': /* void */ |
223 | success = status == AE_OK; | 217 | success = status == AE_OK; |
224 | break; | 218 | break; |
225 | /* add more types as needed */ | 219 | /* add more types as needed */ |
226 | default: | 220 | default: |
227 | printk(IBM_ERR "acpi_evalf() called " | 221 | printk(IBM_ERR "acpi_evalf() called " |
228 | "with invalid format character '%c'\n", res_type); | 222 | "with invalid format character '%c'\n", res_type); |
@@ -303,9 +297,9 @@ static int hotkey_set(struct ibm_struct *ibm, int status, int mask) | |||
303 | if (!ibm->supported) | 297 | if (!ibm->supported) |
304 | return 0; | 298 | return 0; |
305 | 299 | ||
306 | for (i=0; i<32; i++) { | 300 | for (i = 0; i < 32; i++) { |
307 | int bit = ((1 << i) & mask) != 0; | 301 | int bit = ((1 << i) & mask) != 0; |
308 | if (!acpi_evalf(hkey_handle, NULL, "MHKM", "vdd", i+1, bit)) | 302 | if (!acpi_evalf(hkey_handle, NULL, "MHKM", "vdd", i + 1, bit)) |
309 | return -EIO; | 303 | return -EIO; |
310 | } | 304 | } |
311 | 305 | ||
@@ -318,8 +312,7 @@ static int hotkey_init(struct ibm_struct *ibm) | |||
318 | 312 | ||
319 | ibm->supported = 1; | 313 | ibm->supported = 1; |
320 | ret = hotkey_get(ibm, | 314 | ret = hotkey_get(ibm, |
321 | &ibm->state.hotkey.status, | 315 | &ibm->state.hotkey.status, &ibm->state.hotkey.mask); |
322 | &ibm->state.hotkey.mask); | ||
323 | if (ret < 0) { | 316 | if (ret < 0) { |
324 | /* mask not supported on A21e, A22p, T20, T21, X20, X22, X24 */ | 317 | /* mask not supported on A21e, A22p, T20, T21, X20, X22, X24 */ |
325 | ibm->supported = 0; | 318 | ibm->supported = 0; |
@@ -329,7 +322,7 @@ static int hotkey_init(struct ibm_struct *ibm) | |||
329 | } | 322 | } |
330 | 323 | ||
331 | return ret; | 324 | return ret; |
332 | } | 325 | } |
333 | 326 | ||
334 | static int hotkey_read(struct ibm_struct *ibm, char *p) | 327 | static int hotkey_read(struct ibm_struct *ibm, char *p) |
335 | { | 328 | { |
@@ -368,7 +361,7 @@ static int hotkey_write(struct ibm_struct *ibm, char *buf) | |||
368 | status = 0; | 361 | status = 0; |
369 | } else if (strlencmp(cmd, "reset") == 0) { | 362 | } else if (strlencmp(cmd, "reset") == 0) { |
370 | status = ibm->state.hotkey.status; | 363 | status = ibm->state.hotkey.status; |
371 | mask = ibm->state.hotkey.mask; | 364 | mask = ibm->state.hotkey.mask; |
372 | } else if (sscanf(cmd, "0x%x", &mask) == 1) { | 365 | } else if (sscanf(cmd, "0x%x", &mask) == 1) { |
373 | /* mask set */ | 366 | /* mask set */ |
374 | } else if (sscanf(cmd, "%x", &mask) == 1) { | 367 | } else if (sscanf(cmd, "%x", &mask) == 1) { |
@@ -382,7 +375,7 @@ static int hotkey_write(struct ibm_struct *ibm, char *buf) | |||
382 | return -EIO; | 375 | return -EIO; |
383 | 376 | ||
384 | return 0; | 377 | return 0; |
385 | } | 378 | } |
386 | 379 | ||
387 | static void hotkey_exit(struct ibm_struct *ibm) | 380 | static void hotkey_exit(struct ibm_struct *ibm) |
388 | { | 381 | { |
@@ -398,7 +391,7 @@ static void hotkey_notify(struct ibm_struct *ibm, u32 event) | |||
398 | else { | 391 | else { |
399 | printk(IBM_ERR "unknown hotkey event %d\n", event); | 392 | printk(IBM_ERR "unknown hotkey event %d\n", event); |
400 | acpi_bus_generate_event(ibm->device, event, 0); | 393 | acpi_bus_generate_event(ibm->device, event, 0); |
401 | } | 394 | } |
402 | } | 395 | } |
403 | 396 | ||
404 | static int bluetooth_init(struct ibm_struct *ibm) | 397 | static int bluetooth_init(struct ibm_struct *ibm) |
@@ -456,15 +449,14 @@ static int bluetooth_write(struct ibm_struct *ibm, char *buf) | |||
456 | } | 449 | } |
457 | 450 | ||
458 | if (do_cmd && !acpi_evalf(hkey_handle, NULL, "SBDC", "vd", status)) | 451 | if (do_cmd && !acpi_evalf(hkey_handle, NULL, "SBDC", "vd", status)) |
459 | return -EIO; | 452 | return -EIO; |
460 | 453 | ||
461 | return 0; | 454 | return 0; |
462 | } | 455 | } |
463 | 456 | ||
464 | static int video_init(struct ibm_struct *ibm) | 457 | static int video_init(struct ibm_struct *ibm) |
465 | { | 458 | { |
466 | if (!acpi_evalf(vid_handle, | 459 | if (!acpi_evalf(vid_handle, &ibm->state.video.autoswitch, "^VDEE", "d")) |
467 | &ibm->state.video.autoswitch, "^VDEE", "d")) | ||
468 | return -ENODEV; | 460 | return -ENODEV; |
469 | 461 | ||
470 | return 0; | 462 | return 0; |
@@ -566,8 +558,7 @@ static int video_write(struct ibm_struct *ibm, char *buf) | |||
566 | 558 | ||
567 | static void video_exit(struct ibm_struct *ibm) | 559 | static void video_exit(struct ibm_struct *ibm) |
568 | { | 560 | { |
569 | acpi_evalf(vid_handle, NULL, "_DOS", "vd", | 561 | acpi_evalf(vid_handle, NULL, "_DOS", "vd", ibm->state.video.autoswitch); |
570 | ibm->state.video.autoswitch); | ||
571 | } | 562 | } |
572 | 563 | ||
573 | static int light_init(struct ibm_struct *ibm) | 564 | static int light_init(struct ibm_struct *ibm) |
@@ -600,7 +591,7 @@ static int light_write(struct ibm_struct *ibm, char *buf) | |||
600 | int cmos_cmd, lght_cmd; | 591 | int cmos_cmd, lght_cmd; |
601 | char *cmd; | 592 | char *cmd; |
602 | int success; | 593 | int success; |
603 | 594 | ||
604 | while ((cmd = next_cmd(&buf))) { | 595 | while ((cmd = next_cmd(&buf))) { |
605 | if (strlencmp(cmd, "on") == 0) { | 596 | if (strlencmp(cmd, "on") == 0) { |
606 | cmos_cmd = 0x0c; | 597 | cmos_cmd = 0x0c; |
@@ -610,10 +601,10 @@ static int light_write(struct ibm_struct *ibm, char *buf) | |||
610 | lght_cmd = 0; | 601 | lght_cmd = 0; |
611 | } else | 602 | } else |
612 | return -EINVAL; | 603 | return -EINVAL; |
613 | 604 | ||
614 | success = cmos_handle ? | 605 | success = cmos_handle ? |
615 | acpi_evalf(cmos_handle, NULL, NULL, "vd", cmos_cmd) : | 606 | acpi_evalf(cmos_handle, NULL, NULL, "vd", cmos_cmd) : |
616 | acpi_evalf(lght_handle, NULL, NULL, "vd", lght_cmd); | 607 | acpi_evalf(lght_handle, NULL, NULL, "vd", lght_cmd); |
617 | if (!success) | 608 | if (!success) |
618 | return -EIO; | 609 | return -EIO; |
619 | } | 610 | } |
@@ -671,22 +662,22 @@ static int dock_write(struct ibm_struct *ibm, char *buf) | |||
671 | } | 662 | } |
672 | 663 | ||
673 | return 0; | 664 | return 0; |
674 | } | 665 | } |
675 | 666 | ||
676 | static void dock_notify(struct ibm_struct *ibm, u32 event) | 667 | static void dock_notify(struct ibm_struct *ibm, u32 event) |
677 | { | 668 | { |
678 | int docked = dock_docked(); | 669 | int docked = dock_docked(); |
679 | 670 | ||
680 | if (event == 3 && docked) | 671 | if (event == 3 && docked) |
681 | acpi_bus_generate_event(ibm->device, event, 1); /* button */ | 672 | acpi_bus_generate_event(ibm->device, event, 1); /* button */ |
682 | else if (event == 3 && !docked) | 673 | else if (event == 3 && !docked) |
683 | acpi_bus_generate_event(ibm->device, event, 2); /* undock */ | 674 | acpi_bus_generate_event(ibm->device, event, 2); /* undock */ |
684 | else if (event == 0 && docked) | 675 | else if (event == 0 && docked) |
685 | acpi_bus_generate_event(ibm->device, event, 3); /* dock */ | 676 | acpi_bus_generate_event(ibm->device, event, 3); /* dock */ |
686 | else { | 677 | else { |
687 | printk(IBM_ERR "unknown dock event %d, status %d\n", | 678 | printk(IBM_ERR "unknown dock event %d, status %d\n", |
688 | event, _sta(dock_handle)); | 679 | event, _sta(dock_handle)); |
689 | acpi_bus_generate_event(ibm->device, event, 0); /* unknown */ | 680 | acpi_bus_generate_event(ibm->device, event, 0); /* unknown */ |
690 | } | 681 | } |
691 | } | 682 | } |
692 | 683 | ||
@@ -696,7 +687,7 @@ static int bay_init(struct ibm_struct *ibm) | |||
696 | { | 687 | { |
697 | /* bay not supported on A21e, A22p, A31, A31p, G40, R32, R40e */ | 688 | /* bay not supported on A21e, A22p, A31, A31p, G40, R32, R40e */ |
698 | ibm->supported = bay_handle && bayej_handle && | 689 | ibm->supported = bay_handle && bayej_handle && |
699 | acpi_evalf(bay_handle, NULL, "_STA", "qv"); | 690 | acpi_evalf(bay_handle, NULL, "_STA", "qv"); |
700 | 691 | ||
701 | return 0; | 692 | return 0; |
702 | } | 693 | } |
@@ -705,7 +696,7 @@ static int bay_read(struct ibm_struct *ibm, char *p) | |||
705 | { | 696 | { |
706 | int len = 0; | 697 | int len = 0; |
707 | int occupied = bay_occupied(); | 698 | int occupied = bay_occupied(); |
708 | 699 | ||
709 | if (!ibm->supported) | 700 | if (!ibm->supported) |
710 | len += sprintf(p + len, "status:\t\tnot supported\n"); | 701 | len += sprintf(p + len, "status:\t\tnot supported\n"); |
711 | else if (!occupied) | 702 | else if (!occupied) |
@@ -732,7 +723,7 @@ static int bay_write(struct ibm_struct *ibm, char *buf) | |||
732 | } | 723 | } |
733 | 724 | ||
734 | return 0; | 725 | return 0; |
735 | } | 726 | } |
736 | 727 | ||
737 | static void bay_notify(struct ibm_struct *ibm, u32 event) | 728 | static void bay_notify(struct ibm_struct *ibm, u32 event) |
738 | { | 729 | { |
@@ -773,8 +764,8 @@ static int cmos_write(struct ibm_struct *ibm, char *buf) | |||
773 | } | 764 | } |
774 | 765 | ||
775 | return 0; | 766 | return 0; |
776 | } | 767 | } |
777 | 768 | ||
778 | static int led_read(struct ibm_struct *ibm, char *p) | 769 | static int led_read(struct ibm_struct *ibm, char *p) |
779 | { | 770 | { |
780 | int len = 0; | 771 | int len = 0; |
@@ -809,7 +800,7 @@ static int led_write(struct ibm_struct *ibm, char *buf) | |||
809 | led_cmd = sysl_cmd = bled_a = bled_b = 0; | 800 | led_cmd = sysl_cmd = bled_a = bled_b = 0; |
810 | } else | 801 | } else |
811 | return -EINVAL; | 802 | return -EINVAL; |
812 | 803 | ||
813 | if (led_handle) { | 804 | if (led_handle) { |
814 | if (!acpi_evalf(led_handle, NULL, NULL, "vdd", | 805 | if (!acpi_evalf(led_handle, NULL, NULL, "vdd", |
815 | led, led_cmd)) | 806 | led, led_cmd)) |
@@ -827,8 +818,8 @@ static int led_write(struct ibm_struct *ibm, char *buf) | |||
827 | } | 818 | } |
828 | 819 | ||
829 | return 0; | 820 | return 0; |
830 | } | 821 | } |
831 | 822 | ||
832 | static int beep_read(struct ibm_struct *ibm, char *p) | 823 | static int beep_read(struct ibm_struct *ibm, char *p) |
833 | { | 824 | { |
834 | int len = 0; | 825 | int len = 0; |
@@ -854,80 +845,81 @@ static int beep_write(struct ibm_struct *ibm, char *buf) | |||
854 | } | 845 | } |
855 | 846 | ||
856 | return 0; | 847 | return 0; |
857 | } | 848 | } |
858 | 849 | ||
859 | static struct ibm_struct ibms[] = { | 850 | static struct ibm_struct ibms[] = { |
860 | { | 851 | { |
861 | .name = "driver", | 852 | .name = "driver", |
862 | .init = driver_init, | 853 | .init = driver_init, |
863 | .read = driver_read, | 854 | .read = driver_read, |
864 | }, | 855 | }, |
865 | { | 856 | { |
866 | .name = "hotkey", | 857 | .name = "hotkey", |
867 | .hid = "IBM0068", | 858 | .hid = "IBM0068", |
868 | .init = hotkey_init, | 859 | .init = hotkey_init, |
869 | .read = hotkey_read, | 860 | .read = hotkey_read, |
870 | .write = hotkey_write, | 861 | .write = hotkey_write, |
871 | .exit = hotkey_exit, | 862 | .exit = hotkey_exit, |
872 | .notify = hotkey_notify, | 863 | .notify = hotkey_notify, |
873 | .handle = &hkey_handle, | 864 | .handle = &hkey_handle, |
874 | .type = ACPI_DEVICE_NOTIFY, | 865 | .type = ACPI_DEVICE_NOTIFY, |
875 | }, | 866 | }, |
876 | { | 867 | { |
877 | .name = "bluetooth", | 868 | .name = "bluetooth", |
878 | .init = bluetooth_init, | 869 | .init = bluetooth_init, |
879 | .read = bluetooth_read, | 870 | .read = bluetooth_read, |
880 | .write = bluetooth_write, | 871 | .write = bluetooth_write, |
881 | }, | 872 | }, |
882 | { | 873 | { |
883 | .name = "video", | 874 | .name = "video", |
884 | .init = video_init, | 875 | .init = video_init, |
885 | .read = video_read, | 876 | .read = video_read, |
886 | .write = video_write, | 877 | .write = video_write, |
887 | .exit = video_exit, | 878 | .exit = video_exit, |
888 | }, | 879 | }, |
889 | { | 880 | { |
890 | .name = "light", | 881 | .name = "light", |
891 | .init = light_init, | 882 | .init = light_init, |
892 | .read = light_read, | 883 | .read = light_read, |
893 | .write = light_write, | 884 | .write = light_write, |
894 | }, | 885 | }, |
895 | { | 886 | { |
896 | .name = "dock", | 887 | .name = "dock", |
897 | .read = dock_read, | 888 | .read = dock_read, |
898 | .write = dock_write, | 889 | .write = dock_write, |
899 | .notify = dock_notify, | 890 | .notify = dock_notify, |
900 | .handle = &dock_handle, | 891 | .handle = &dock_handle, |
901 | .type = ACPI_SYSTEM_NOTIFY, | 892 | .type = ACPI_SYSTEM_NOTIFY, |
902 | }, | 893 | }, |
903 | { | 894 | { |
904 | .name = "bay", | 895 | .name = "bay", |
905 | .init = bay_init, | 896 | .init = bay_init, |
906 | .read = bay_read, | 897 | .read = bay_read, |
907 | .write = bay_write, | 898 | .write = bay_write, |
908 | .notify = bay_notify, | 899 | .notify = bay_notify, |
909 | .handle = &bay_handle, | 900 | .handle = &bay_handle, |
910 | .type = ACPI_SYSTEM_NOTIFY, | 901 | .type = ACPI_SYSTEM_NOTIFY, |
911 | }, | 902 | }, |
912 | { | 903 | { |
913 | .name = "cmos", | 904 | .name = "cmos", |
914 | .read = cmos_read, | 905 | .read = cmos_read, |
915 | .write = cmos_write, | 906 | .write = cmos_write, |
916 | .experimental = 1, | 907 | .experimental = 1, |
917 | }, | 908 | }, |
918 | { | 909 | { |
919 | .name = "led", | 910 | .name = "led", |
920 | .read = led_read, | 911 | .read = led_read, |
921 | .write = led_write, | 912 | .write = led_write, |
922 | .experimental = 1, | 913 | .experimental = 1, |
923 | }, | 914 | }, |
924 | { | 915 | { |
925 | .name = "beep", | 916 | .name = "beep", |
926 | .read = beep_read, | 917 | .read = beep_read, |
927 | .write = beep_write, | 918 | .write = beep_write, |
928 | .experimental = 1, | 919 | .experimental = 1, |
929 | }, | 920 | }, |
930 | }; | 921 | }; |
922 | |||
931 | #define NUM_IBMS (sizeof(ibms)/sizeof(ibms[0])) | 923 | #define NUM_IBMS (sizeof(ibms)/sizeof(ibms[0])) |
932 | 924 | ||
933 | static int dispatch_read(char *page, char **start, off_t off, int count, | 925 | static int dispatch_read(char *page, char **start, off_t off, int count, |
@@ -935,7 +927,7 @@ static int dispatch_read(char *page, char **start, off_t off, int count, | |||
935 | { | 927 | { |
936 | struct ibm_struct *ibm = (struct ibm_struct *)data; | 928 | struct ibm_struct *ibm = (struct ibm_struct *)data; |
937 | int len; | 929 | int len; |
938 | 930 | ||
939 | if (!ibm || !ibm->read) | 931 | if (!ibm || !ibm->read) |
940 | return -EINVAL; | 932 | return -EINVAL; |
941 | 933 | ||
@@ -955,7 +947,7 @@ static int dispatch_read(char *page, char **start, off_t off, int count, | |||
955 | return len; | 947 | return len; |
956 | } | 948 | } |
957 | 949 | ||
958 | static int dispatch_write(struct file *file, const char __user *userbuf, | 950 | static int dispatch_write(struct file *file, const char __user * userbuf, |
959 | unsigned long count, void *data) | 951 | unsigned long count, void *data) |
960 | { | 952 | { |
961 | struct ibm_struct *ibm = (struct ibm_struct *)data; | 953 | struct ibm_struct *ibm = (struct ibm_struct *)data; |
@@ -969,9 +961,9 @@ static int dispatch_write(struct file *file, const char __user *userbuf, | |||
969 | if (!kernbuf) | 961 | if (!kernbuf) |
970 | return -ENOMEM; | 962 | return -ENOMEM; |
971 | 963 | ||
972 | if (copy_from_user(kernbuf, userbuf, count)) { | 964 | if (copy_from_user(kernbuf, userbuf, count)) { |
973 | kfree(kernbuf); | 965 | kfree(kernbuf); |
974 | return -EFAULT; | 966 | return -EFAULT; |
975 | } | 967 | } |
976 | 968 | ||
977 | kernbuf[count] = 0; | 969 | kernbuf[count] = 0; |
@@ -982,7 +974,7 @@ static int dispatch_write(struct file *file, const char __user *userbuf, | |||
982 | 974 | ||
983 | kfree(kernbuf); | 975 | kfree(kernbuf); |
984 | 976 | ||
985 | return ret; | 977 | return ret; |
986 | } | 978 | } |
987 | 979 | ||
988 | static void dispatch_notify(acpi_handle handle, u32 event, void *data) | 980 | static void dispatch_notify(acpi_handle handle, u32 event, void *data) |
@@ -1085,7 +1077,7 @@ static int ibm_init(struct ibm_struct *ibm) | |||
1085 | } | 1077 | } |
1086 | entry->owner = THIS_MODULE; | 1078 | entry->owner = THIS_MODULE; |
1087 | ibm->proc_created = 1; | 1079 | ibm->proc_created = 1; |
1088 | 1080 | ||
1089 | entry->data = ibm; | 1081 | entry->data = ibm; |
1090 | if (ibm->read) | 1082 | if (ibm->read) |
1091 | entry->read_proc = &dispatch_read; | 1083 | entry->read_proc = &dispatch_read; |
@@ -1120,18 +1112,18 @@ static void ibm_exit(struct ibm_struct *ibm) | |||
1120 | } | 1112 | } |
1121 | 1113 | ||
1122 | static int ibm_handle_init(char *name, | 1114 | static int ibm_handle_init(char *name, |
1123 | acpi_handle *handle, acpi_handle parent, | 1115 | acpi_handle * handle, acpi_handle parent, |
1124 | char **paths, int num_paths, int required) | 1116 | char **paths, int num_paths, int required) |
1125 | { | 1117 | { |
1126 | int i; | 1118 | int i; |
1127 | acpi_status status; | 1119 | acpi_status status; |
1128 | 1120 | ||
1129 | for (i=0; i<num_paths; i++) { | 1121 | for (i = 0; i < num_paths; i++) { |
1130 | status = acpi_get_handle(parent, paths[i], handle); | 1122 | status = acpi_get_handle(parent, paths[i], handle); |
1131 | if (ACPI_SUCCESS(status)) | 1123 | if (ACPI_SUCCESS(status)) |
1132 | return 0; | 1124 | return 0; |
1133 | } | 1125 | } |
1134 | 1126 | ||
1135 | *handle = NULL; | 1127 | *handle = NULL; |
1136 | 1128 | ||
1137 | if (required) { | 1129 | if (required) { |
@@ -1146,7 +1138,6 @@ static int ibm_handle_init(char *name, | |||
1146 | ibm_handle_init(#object, &object##_handle, *object##_parent, \ | 1138 | ibm_handle_init(#object, &object##_handle, *object##_parent, \ |
1147 | object##_paths, sizeof(object##_paths)/sizeof(char*), required) | 1139 | object##_paths, sizeof(object##_paths)/sizeof(char*), required) |
1148 | 1140 | ||
1149 | |||
1150 | static int set_ibm_param(const char *val, struct kernel_param *kp) | 1141 | static int set_ibm_param(const char *val, struct kernel_param *kp) |
1151 | { | 1142 | { |
1152 | unsigned int i; | 1143 | unsigned int i; |
@@ -1158,7 +1149,7 @@ static int set_ibm_param(const char *val, struct kernel_param *kp) | |||
1158 | strcpy(arg_with_comma, val); | 1149 | strcpy(arg_with_comma, val); |
1159 | strcat(arg_with_comma, ","); | 1150 | strcat(arg_with_comma, ","); |
1160 | 1151 | ||
1161 | for (i=0; i<NUM_IBMS; i++) | 1152 | for (i = 0; i < NUM_IBMS; i++) |
1162 | if (strcmp(ibms[i].name, kp->name) == 0) | 1153 | if (strcmp(ibms[i].name, kp->name) == 0) |
1163 | return ibms[i].write(&ibms[i], arg_with_comma); | 1154 | return ibms[i].write(&ibms[i], arg_with_comma); |
1164 | BUG(); | 1155 | BUG(); |
@@ -1172,7 +1163,7 @@ static void acpi_ibm_exit(void) | |||
1172 | { | 1163 | { |
1173 | int i; | 1164 | int i; |
1174 | 1165 | ||
1175 | for (i=NUM_IBMS-1; i>=0; i--) | 1166 | for (i = NUM_IBMS - 1; i >= 0; i--) |
1176 | ibm_exit(&ibms[i]); | 1167 | ibm_exit(&ibms[i]); |
1177 | 1168 | ||
1178 | remove_proc_entry(IBM_DIR, acpi_root_dir); | 1169 | remove_proc_entry(IBM_DIR, acpi_root_dir); |
@@ -1185,15 +1176,14 @@ static int __init acpi_ibm_init(void) | |||
1185 | if (acpi_disabled) | 1176 | if (acpi_disabled) |
1186 | return -ENODEV; | 1177 | return -ENODEV; |
1187 | 1178 | ||
1188 | if (!acpi_specific_hotkey_enabled){ | 1179 | if (!acpi_specific_hotkey_enabled) { |
1189 | printk(IBM_ERR "Using generic hotkey driver\n"); | 1180 | printk(IBM_ERR "Using generic hotkey driver\n"); |
1190 | return -ENODEV; | 1181 | return -ENODEV; |
1191 | } | 1182 | } |
1192 | /* these handles are required */ | 1183 | /* these handles are required */ |
1193 | if (IBM_HANDLE_INIT(ec, 1) < 0 || | 1184 | if (IBM_HANDLE_INIT(ec, 1) < 0 || |
1194 | IBM_HANDLE_INIT(hkey, 1) < 0 || | 1185 | IBM_HANDLE_INIT(hkey, 1) < 0 || |
1195 | IBM_HANDLE_INIT(vid, 1) < 0 || | 1186 | IBM_HANDLE_INIT(vid, 1) < 0 || IBM_HANDLE_INIT(beep, 1) < 0) |
1196 | IBM_HANDLE_INIT(beep, 1) < 0) | ||
1197 | return -ENODEV; | 1187 | return -ENODEV; |
1198 | 1188 | ||
1199 | /* these handles have alternatives */ | 1189 | /* these handles have alternatives */ |
@@ -1205,10 +1195,10 @@ static int __init acpi_ibm_init(void) | |||
1205 | return -ENODEV; | 1195 | return -ENODEV; |
1206 | 1196 | ||
1207 | /* these handles are not required */ | 1197 | /* these handles are not required */ |
1208 | IBM_HANDLE_INIT(dock, 0); | 1198 | IBM_HANDLE_INIT(dock, 0); |
1209 | IBM_HANDLE_INIT(bay, 0); | 1199 | IBM_HANDLE_INIT(bay, 0); |
1210 | IBM_HANDLE_INIT(bayej, 0); | 1200 | IBM_HANDLE_INIT(bayej, 0); |
1211 | IBM_HANDLE_INIT(bled, 0); | 1201 | IBM_HANDLE_INIT(bled, 0); |
1212 | 1202 | ||
1213 | proc_dir = proc_mkdir(IBM_DIR, acpi_root_dir); | 1203 | proc_dir = proc_mkdir(IBM_DIR, acpi_root_dir); |
1214 | if (!proc_dir) { | 1204 | if (!proc_dir) { |
@@ -1216,8 +1206,8 @@ static int __init acpi_ibm_init(void) | |||
1216 | return -ENODEV; | 1206 | return -ENODEV; |
1217 | } | 1207 | } |
1218 | proc_dir->owner = THIS_MODULE; | 1208 | proc_dir->owner = THIS_MODULE; |
1219 | 1209 | ||
1220 | for (i=0; i<NUM_IBMS; i++) { | 1210 | for (i = 0; i < NUM_IBMS; i++) { |
1221 | ret = ibm_init(&ibms[i]); | 1211 | ret = ibm_init(&ibms[i]); |
1222 | if (ret < 0) { | 1212 | if (ret < 0) { |
1223 | acpi_ibm_exit(); | 1213 | acpi_ibm_exit(); |