wmi-acer: Clean (A & B) > 0 tests to (A &= B)
[acer_acpi.git] / acer_acpi.c
blob9acd25d00aafd03a1bde573c035a2078d479c14f
1 /*
2 * Acer Laptop ACPI Extras
4 * Copyright (C) 2005-2007 E.M. Smith
5 * Copyright (C) 2007 Carlos Corbacho <cathectic@gmail.com>
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 * The devolpment page for this driver is located at
23 * http://code.google.com/p/aceracpi
25 * Credits:
27 * John Belmonte - the Toshiba ACPI driver originally adapted for this module.
28 * Julien Lerouge & Karol Kozimor - ASUS Acpi driver authors.
29 * Olaf Tauber - developer of acerhk, the inspiration to solve the 64-bit
30 * driver problem for my Aspire 5024.
31 * Mathieu Segaud - solved the ACPI problem that needed a double-modprobe
32 * in version 0.2 and below.
33 * Jim Ramsay - Figured out and added support for WMID interface
36 #define ACER_ACPI_VERSION "0.10.0"
39 * Comment the following line out to remove /proc support
41 #define CONFIG_PROC
43 #ifdef CONFIG_PROC
44 #define PROC_ACER "acer"
45 #include <linux/proc_fs.h>
46 #endif
48 #include <linux/kernel.h>
49 #include <linux/module.h>
50 #include <linux/init.h>
51 #include <linux/types.h>
52 #include <linux/delay.h>
53 #include <linux/version.h>
55 #if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,17)
56 #include <asm/uaccess.h>
57 #else
58 #include <linux/uaccess.h>
59 #endif
61 #include <linux/io.h>
62 #include <linux/dmi.h>
63 #include <linux/backlight.h>
64 #include <linux/leds.h>
65 #include <linux/platform_device.h>
67 #include <acpi/acpi_drivers.h>
69 #include "wmi-acer.h"
71 /* Workaround needed for older kernels */
72 #ifndef bool
73 #define bool int
74 #endif
76 MODULE_AUTHOR("Mark Smith, Carlos Corbacho");
77 MODULE_DESCRIPTION("Acer Laptop ACPI Extras Driver");
78 MODULE_LICENSE("GPL");
80 #define ACER_LOGPREFIX "acer_acpi: "
81 #define ACER_ERR KERN_ERR ACER_LOGPREFIX
82 #define ACER_NOTICE KERN_NOTICE ACER_LOGPREFIX
83 #define ACER_INFO KERN_INFO ACER_LOGPREFIX
85 #define DEBUG(level, message...) { \
86 if (debug >= level) \
87 printk(KERN_DEBUG ACER_LOGPREFIX message);\
91 * The maximum temperature one can set for fan control override.
92 * Doesn't propably make much sense if over 80 degrees celsius though...
94 #define ACER_MAX_TEMPERATURE_OVERRIDE 150
97 * The following defines quirks to get some specific functions to work
98 * which are known to not be supported over ACPI (such as the mail LED
99 * on WMID based Acer's)
101 struct acer_quirks {
102 const char *vendor;
103 const char *model;
104 u16 quirks;
108 * Keyboard controller ports
110 #define ACER_KBD_STATUS_REG 0x64 /* Status register (R) */
111 #define ACER_KBD_CNTL_REG 0x64 /* Controller command register (W) */
112 #define ACER_KBD_DATA_REG 0x60 /* Keyboard data register (R/W) */
115 * Magic Number
116 * Meaning is unknown - this number is required for writing to ACPI for AMW0
117 * (it's also used in acerhk when directly accessing the EC)
119 #define ACER_AMW0_WRITE 0x9610
122 * Bit masks for the old AMW0 interface
124 #define ACER_AMW0_WIRELESS_MASK 0x35
125 #define ACER_AMW0_BLUETOOTH_MASK 0x34
126 #define ACER_AMW0_MAILLED_MASK 0x31
129 * Method IDs for new WMID interface
131 #define ACER_WMID_GET_WIRELESS_METHODID 1
132 #define ACER_WMID_GET_BLUETOOTH_METHODID 2
133 #define ACER_WMID_GET_BRIGHTNESS_METHODID 3
134 #define ACER_WMID_SET_WIRELESS_METHODID 4
135 #define ACER_WMID_SET_BLUETOOTH_METHODID 5
136 #define ACER_WMID_SET_BRIGHTNESS_METHODID 6
137 #define ACER_WMID_GET_THREEG_METHODID 10
138 #define ACER_WMID_SET_THREEG_METHODID 11
141 * Acer ACPI method GUIDs
143 #define AMW0_GUID1 "67C3371D-95A3-4C37-BB61-DD47B491DAAB"
144 #define WMID_GUID1 "6AF4F258-B401-42fd-BE91-3D4AC2D7C0D3"
147 * Interface capability flags
149 #define ACER_CAP_MAILLED (1<<0)
150 #define ACER_CAP_WIRELESS (1<<1)
151 #define ACER_CAP_BLUETOOTH (1<<2)
152 #define ACER_CAP_BRIGHTNESS (1<<3)
153 #define ACER_CAP_THREEG (1<<4)
154 #define ACER_CAP_TOUCHPAD_READ (1<<5)
155 #define ACER_CAP_TEMPERATURE_OVERRIDE (1<<6)
156 #define ACER_CAP_ANY (0xFFFFFFFF)
159 * Interface type flags
161 enum interface_flags {
162 ACER_AMW0,
163 ACER_WMID,
167 * Presumed start states -
168 * On some AMW0 laptops, we do not yet know how to get the device status from
169 * the EC, so we must store this ourselves.
171 * Plus, we can't tell which features are enabled or disabled on a specific
172 * model - e.g. The 5020 series can _support_ bluetooth; but the 5021 has no
173 * bluetooth, whilst the 5024 does. However, the BIOS identifies both laptops
174 * as 5020, and you can add bluetooth later.
176 * Basically the code works like this:
177 * - On init, any values specified on the commandline are set.
178 * - For interfaces where the current values cannot be detected and which
179 * have not been set on the commandline, we set them to some sane default
180 * (disabled)
182 * See AMW0_init and acer_commandline_init
185 #define ACER_DEFAULT_WIRELESS 0
186 #define ACER_DEFAULT_BLUETOOTH 0
187 #define ACER_DEFAULT_MAILLED 0
188 #define ACER_DEFAULT_THREEG 0
190 static int max_brightness = 0xF;
192 static int wireless = -1;
193 static int bluetooth = -1;
194 static int mailled = -1;
195 static int brightness = -1;
196 static int threeg = -1;
197 static int fan_temperature_override = -1;
198 static int debug = 0;
199 static int force_series;
201 module_param(mailled, int, 0444);
202 module_param(wireless, int, 0444);
203 module_param(bluetooth, int, 0444);
204 module_param(brightness, int, 0444);
205 module_param(threeg, int, 0444);
206 module_param(force_series, int, 0444);
207 module_param(fan_temperature_override, int, 0444);
208 module_param(debug, int, 0664);
209 MODULE_PARM_DESC(wireless, "Set initial state of Wireless hardware");
210 MODULE_PARM_DESC(bluetooth, "Set initial state of Bluetooth hardware");
211 MODULE_PARM_DESC(mailled, "Set initial state of Mail LED");
212 MODULE_PARM_DESC(brightness, "Set initial LCD backlight brightness");
213 MODULE_PARM_DESC(threeg, "Set initial state of 3G hardware");
214 MODULE_PARM_DESC(fan_temperature_override, "Set initial state of the 'FAN temperature-override'");
215 MODULE_PARM_DESC(debug, "Debugging verbosity level (0=least 2=most)");
216 MODULE_PARM_DESC(force_series, "Force a different laptop series for extra features (5020, 5720 or 2490)");
218 #ifdef CONFIG_PROC
219 struct ProcItem {
220 const char *name;
221 char *(*read_func) (char *, u32);
222 unsigned long (*write_func) (const char *, unsigned long, u32);
223 unsigned int capability;
226 static struct proc_dir_entry *acer_proc_dir;
227 #endif
230 * Wait for the keyboard controller to become ready
232 static int wait_kbd_write(void)
234 int i = 0;
235 while ((inb(ACER_KBD_STATUS_REG) & 0x02) && (i < 10000)) {
236 udelay(50);
237 i++;
239 return -(i == 10000);
242 static void send_kbd_cmd(u8 cmd, u8 val)
244 preempt_disable();
245 if (!wait_kbd_write())
246 outb(cmd, ACER_KBD_CNTL_REG);
247 if (!wait_kbd_write())
248 outb(val, ACER_KBD_DATA_REG);
249 preempt_enable_no_resched();
252 static void set_keyboard_quirk(void)
254 send_kbd_cmd(0x59, 0x90);
257 struct acer_data {
258 int mailled;
259 int wireless;
260 int bluetooth;
261 int threeg;
262 int brightness;
265 /* Each low-level interface must define at least some of the following */
266 struct Interface {
268 * The ACPI device type
270 u32 type;
273 * The capabilities this interface provides
274 * In the future, these can be removed/added at runtime when we have a
275 * way of detecting what capabilities are /actually/ present on an
276 * interface
278 u32 capability;
281 * Initializes an interface, should allocate the interface-specific
282 * data
284 void (*init) (struct Interface *);
287 * Private data for the current interface
289 struct acer_data data;
292 /* The static interface pointer, points to the currently detected interface */
293 static struct Interface *interface;
296 * Embedded Controller quirks
297 * Some laptops require us to directly access the EC to either enable or query
298 * features that are not available through ACPI.
301 struct quirk_entry {
302 u8 wireless;
303 u8 mailled;
304 u8 brightness;
305 u8 touchpad;
306 u8 temperature_override;
307 u8 mmkeys;
308 u8 bluetooth;
309 u8 max_brightness;
312 static struct quirk_entry *quirks;
314 static void set_quirks(void)
316 if (quirks->mailled != 0) {
317 interface->capability |= ACER_CAP_MAILLED;
318 DEBUG(1, "Using EC direct-access quirk for mail LED\n");
321 if (quirks->touchpad != 0) {
322 interface->capability |= ACER_CAP_TOUCHPAD_READ;
323 DEBUG(1, "Using EC direct-access quirk for reading touchpad status\n");
326 if (quirks->temperature_override != 0) {
327 interface->capability |= ACER_CAP_TEMPERATURE_OVERRIDE;
328 DEBUG(1, "Using EC direct-access quirk for temperature override setting (fan)\n");
331 if (quirks->brightness != 0) {
332 interface->capability |= ACER_CAP_BRIGHTNESS;
333 DEBUG(1, "Using EC direct-access quirk for backlight brightness\n");
336 if (quirks->mmkeys != 0) {
337 set_keyboard_quirk();
338 printk(ACER_INFO "Setting keyboard quirk to enable multimedia keys\n");
341 if (quirks->bluetooth != 0) {
342 interface->capability |= ACER_CAP_BLUETOOTH;
343 DEBUG(1, "Using EC direct-access quirk for bluetooth\n");
346 if (quirks->wireless != 0) {
347 interface->capability |= ACER_CAP_WIRELESS;
348 DEBUG(1, "Using EC direct-access quirk for wireless\n");
351 if (quirks->max_brightness != 0) {
352 max_brightness = quirks->max_brightness;
353 DEBUG(1, "Changing maximum brightness level\n");
357 static int dmi_matched(struct dmi_system_id *dmi)
359 quirks = dmi->driver_data;
360 return 0;
363 static struct quirk_entry quirk_unknown = {
366 static struct quirk_entry quirk_acer_aspire_5020 = {
367 .wireless = 1,
368 .mailled = 2,
369 .brightness = 1,
370 .bluetooth = 1,
373 static struct quirk_entry quirk_acer_aspire_5680 = {
374 .mmkeys = 1,
377 static struct quirk_entry quirk_acer_aspire_9300 = {
378 .brightness = 2,
381 static struct quirk_entry quirk_acer_travelmate_2490 = {
382 .mmkeys = 1,
383 .mailled = 1,
384 .temperature_override = 1,
385 .touchpad = 1,
389 * This is similar to the Aspire 5020, but with a different wireless quirk
391 static struct quirk_entry quirk_acer_travelmate_5620 = {
392 .wireless = 2,
393 .mailled = 2,
394 .brightness = 1,
395 .bluetooth = 1,
398 static struct quirk_entry quirk_acer_travelmate_5720 = {
399 .max_brightness = 0x9,
400 .touchpad = 2,
401 .wireless = 2,
402 .bluetooth = 2,
403 .brightness = 1,
406 static struct dmi_system_id acer_quirks[] = {
408 .callback = dmi_matched,
409 .ident = "Acer Aspire 3020",
410 .matches = {
411 DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
412 DMI_MATCH(DMI_PRODUCT_NAME, "Aspire 3020"),
414 .driver_data = &quirk_acer_aspire_5020,
417 .callback = dmi_matched,
418 .ident = "Acer Aspire 3040",
419 .matches = {
420 DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
421 DMI_MATCH(DMI_PRODUCT_NAME, "Aspire 3040"),
423 .driver_data = &quirk_acer_aspire_5020,
426 .callback = dmi_matched,
427 .ident = "Acer Aspire 5020",
428 .matches = {
429 DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
430 DMI_MATCH(DMI_PRODUCT_NAME, "Aspire 5020"),
432 .driver_data = &quirk_acer_aspire_5020,
435 .callback = dmi_matched,
436 .ident = "Acer Aspire 5040",
437 .matches = {
438 DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
439 DMI_MATCH(DMI_PRODUCT_NAME, "Aspire 5040"),
441 .driver_data = &quirk_acer_aspire_5020,
444 .callback = dmi_matched,
445 .ident = "Acer Aspire 5560",
446 .matches = {
447 DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
448 DMI_MATCH(DMI_PRODUCT_NAME, "Aspire 5560"),
450 .driver_data = &quirk_acer_travelmate_5620,
453 .callback = dmi_matched,
454 .ident = "Acer Aspire 5650",
455 .matches = {
456 DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
457 DMI_MATCH(DMI_PRODUCT_NAME, "Aspire 5650"),
459 .driver_data = &quirk_acer_travelmate_2490,
462 .callback = dmi_matched,
463 .ident = "Acer Aspire 5680",
464 .matches = {
465 DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
466 DMI_MATCH(DMI_PRODUCT_NAME, "Aspire 5680"),
468 .driver_data = &quirk_acer_aspire_5680,
471 .callback = dmi_matched,
472 .ident = "Acer Aspire 9300",
473 .matches = {
474 DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
475 DMI_MATCH(DMI_PRODUCT_NAME, "Aspire 9300"),
477 .driver_data = &quirk_acer_aspire_9300,
480 .callback = dmi_matched,
481 .ident = "Acer TravelMate 2420",
482 .matches = {
483 DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
484 DMI_MATCH(DMI_PRODUCT_NAME, "TravelMate 2420"),
486 .driver_data = &quirk_acer_aspire_5020,
489 .callback = dmi_matched,
490 .ident = "Acer TravelMate 2490",
491 .matches = {
492 DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
493 DMI_MATCH(DMI_PRODUCT_NAME, "TravelMate 2490"),
495 .driver_data = &quirk_acer_travelmate_2490,
498 .callback = dmi_matched,
499 .ident = "Acer TravelMate 5620",
500 .matches = {
501 DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
502 DMI_MATCH(DMI_PRODUCT_NAME, "TravelMate 5620"),
504 .driver_data = &quirk_acer_travelmate_5620,
507 .callback = dmi_matched,
508 .ident = "Acer TravelMate 5720",
509 .matches = {
510 DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
511 DMI_MATCH(DMI_PRODUCT_NAME, "TravelMate 5720"),
513 .driver_data = &quirk_acer_travelmate_5720,
518 /* Find which quirks are needed for a particular vendor/ model pair */
519 static void find_quirks(void)
521 DEBUG (1, "Looking for quirks\n");
522 if (!force_series) {
523 dmi_check_system(acer_quirks);
524 } else if (force_series == 5020) {
525 DEBUG(0, "Forcing Acer Aspire 5020\n");
526 quirks = &quirk_acer_aspire_5020;
527 } else if (force_series == 2490) {
528 DEBUG(0, "Forcing Acer TravelMate 2490\n");
529 quirks = &quirk_acer_travelmate_2490;
530 } else if (force_series == 5620) {
531 DEBUG(0, "Forcing Acer TravelMate 5620\n");
532 quirks = &quirk_acer_travelmate_5620;
533 } else if (force_series == 5720) {
534 DEBUG(0, "Forcing Acer TravelMate 5720\n");
535 quirks = &quirk_acer_travelmate_5720;
538 if (quirks == NULL) {
539 DEBUG(1, "No quirks known for this laptop\n");
540 quirks = &quirk_unknown;
542 set_quirks();
546 * General interface convenience methods
549 static bool has_cap(u32 cap)
551 if ((interface->capability & cap) != 0) {
552 return 1;
554 return 0;
558 * Old interface (now known as the AMW0 interface)
560 struct WMAB_args {
561 u32 eax;
562 u32 ebx;
563 u32 ecx;
564 u32 edx;
567 static acpi_status WMAB_execute(struct WMAB_args *regbuf, struct acpi_buffer *result)
569 struct acpi_buffer input;
570 acpi_status status;
571 input.length = sizeof(struct WMAB_args);
572 input.pointer = (u8*)regbuf;
574 status = wmi_acer_evaluate_method(AMW0_GUID1, 1, 1, &input, result);
575 DEBUG(2, " Args: 0x%08x 0x%08x 0x%08x 0x%08x\n", regbuf->eax, regbuf->ebx, regbuf->ecx, regbuf->edx );
577 return status;
580 static void AMW0_init(struct Interface *iface) {
581 bool help = 0;
584 * If the commandline doesn't specify these, we need to force them to
585 * the default values
587 if (mailled == -1 && !quirks->mailled)
588 mailled = ACER_DEFAULT_MAILLED;
589 if (wireless == -1 && !quirks->wireless)
590 wireless = ACER_DEFAULT_WIRELESS;
591 if (bluetooth == -1 && !quirks->bluetooth)
592 bluetooth = ACER_DEFAULT_BLUETOOTH;
595 * Set the cached "current" values to impossible ones so that
596 * acer_commandline_init will definitely set them.
598 if (quirks->bluetooth == 0) {
599 help = 1;
600 iface->data.bluetooth = -1;
601 printk(ACER_INFO "No EC data for reading bluetooth - bluetooth value when read will be a 'best guess'\n");
604 if (quirks->wireless == 0) {
605 help = 1;
606 printk(ACER_INFO "No EC data for reading wireless - wireless value when read will be a 'best guess'\n");
607 iface->data.wireless = -1;
609 if (quirks->mailled == 0) {
610 help = 1;
611 printk(ACER_INFO "No EC data for reading mail LED - mail LED value when read will be a 'best guess'\n");
612 iface->data.mailled = -1;
615 if (help) {
616 printk(ACER_INFO "We need more data from your laptop's Embedded Controller (EC) to better support it\n");
617 printk(ACER_INFO "Please see http://code.google.com/p/aceracpi/wiki/EmbeddedController on how to help\n");
621 static acpi_status AMW0_get_bool(bool *value, u32 cap, struct Interface *iface)
623 struct acer_data *data = &iface->data;
624 u8 result;
626 DEBUG(2, " AMW0_get_bool: cap=%d\n", cap);
628 * On some models, we can read these values from the EC. On others,
629 * we use a stored value
631 switch (cap) {
632 case ACER_CAP_MAILLED:
633 switch (quirks->mailled) {
634 case 2:
635 ec_read(0x0A, &result);
636 *value = (result >> 7) & 0x01;
637 return 0;
638 default:
639 *value = data->mailled;
641 break;
642 case ACER_CAP_WIRELESS:
643 switch (quirks->wireless) {
644 case 1:
645 ec_read(0x0A, &result);
646 *value = (result >> 2) & 0x01;
647 return 0;
648 case 2:
649 ec_read(0x71, &result);
650 *value = result & 0x01;
651 return 0;
652 default:
653 *value = data->wireless;
655 break;
656 case ACER_CAP_BLUETOOTH:
657 switch (quirks->bluetooth) {
658 case 1:
659 ec_read(0x0A, &result);
660 *value = (result >> 4) & 0x01;
661 return 0;
662 case 2:
663 ec_read(0x71, &result);
664 *value = (result >> 1) & 0x01;
665 return 0;
666 default:
667 *value = data->bluetooth;
669 break;
670 case ACER_CAP_TOUCHPAD_READ:
671 switch (quirks->touchpad) {
672 case 2:
673 ec_read(0x74, &result);
674 *value = (result >> 3) & 0x01;
675 return 0;
676 default:
677 break;
679 default:
680 return AE_BAD_ADDRESS;
682 return AE_OK;
685 static acpi_status AMW0_set_bool(bool value, u32 cap, struct Interface *iface)
687 struct WMAB_args args;
688 struct acer_data *data = &iface->data;
689 acpi_status status;
691 args.eax = ACER_AMW0_WRITE;
692 args.ebx = value ? (1<<8) : 0;
694 switch (cap) {
695 case ACER_CAP_MAILLED:
696 args.ebx |= ACER_AMW0_MAILLED_MASK;
697 break;
698 case ACER_CAP_WIRELESS:
699 args.ebx |= ACER_AMW0_WIRELESS_MASK;
700 break;
701 case ACER_CAP_BLUETOOTH:
702 args.ebx |= ACER_AMW0_BLUETOOTH_MASK;
703 break;
704 default:
705 return AE_BAD_ADDRESS;
708 /* Actually do the set */
709 status = WMAB_execute(&args, NULL);
712 * Currently no way to query the state, so cache the new value on
713 * success
715 if (ACPI_SUCCESS(status)) {
716 switch (cap) {
717 case ACER_CAP_MAILLED:
718 data->mailled = value;
719 break;
720 case ACER_CAP_WIRELESS:
721 data->wireless = value;
722 break;
723 case ACER_CAP_BLUETOOTH:
724 data->bluetooth = value;
725 break;
729 return status;
732 static acpi_status AMW0_get_u8(u8 *value, u32 cap, struct Interface *iface) {
733 switch (cap) {
734 case ACER_CAP_BRIGHTNESS:
735 switch (quirks->brightness) {
736 case 1:
737 return ec_read(0x83, value);
738 case 2:
739 return ec_read(0x85, value);
740 default:
741 return AE_BAD_ADDRESS;
743 break;
744 default:
745 return AE_BAD_ADDRESS;
747 return AE_OK;
750 static acpi_status AMW0_set_u8(u8 value, u32 cap, struct Interface *iface) {
751 switch (cap) {
752 case ACER_CAP_BRIGHTNESS:
753 switch (quirks->brightness) {
754 case 1:
755 return ec_write(0x83, value);
756 case 2:
757 return ec_write(0x85, value);
758 default:
759 return AE_BAD_ADDRESS;
760 break;
762 default:
763 return AE_BAD_ADDRESS;
765 return AE_OK;
768 static struct Interface AMW0_interface = {
769 .type = ACER_AMW0,
770 .capability = (
771 ACER_CAP_MAILLED |
772 ACER_CAP_WIRELESS |
773 ACER_CAP_BLUETOOTH
775 .init = AMW0_init,
779 * New interface (The WMID interface)
781 static acpi_status
782 WMI_execute_u32(u32 method_id, u32 in, u32 *out)
784 struct acpi_buffer input = { (acpi_size) sizeof(u32), (void *)(&in) };
785 struct acpi_buffer result = { ACPI_ALLOCATE_BUFFER, NULL };
786 union acpi_object *obj;
787 u32 tmp;
788 acpi_status status;
790 DEBUG(2, " WMI_execute_u32:\n");
791 status = wmi_acer_evaluate_method(WMID_GUID1, 1, method_id, &input, &result);
792 DEBUG(2, " In: 0x%08x\n", in);
794 if (ACPI_FAILURE(status))
795 return status;
797 obj = (union acpi_object *) result.pointer;
798 if (obj && obj->type == ACPI_TYPE_BUFFER && obj->buffer.length == sizeof(u32)) {
799 tmp = *((u32 *) obj->buffer.pointer);
800 DEBUG(2, " Out: 0x%08x\n", tmp);
801 } else {
802 tmp = 0;
803 if (obj) {
804 DEBUG(2, " Got unexpected result of type %d\n", obj->type);
805 } else {
806 DEBUG(2, " Got unexpected null result\n");
810 if (out)
811 *out = tmp;
813 if (result.length > 0 && result.pointer)
814 kfree(result.pointer);
816 DEBUG(2, " Returning from WMI_execute_u32:\n");
817 return status;
820 static acpi_status WMID_get_u8(u8 *value, u32 cap, struct Interface *iface) {
821 acpi_status status;
822 u32 result;
823 u32 method_id = 0;
825 DEBUG(2, " WMID_get_u8: cap=%d\n", cap);
826 switch (cap) {
827 case ACER_CAP_WIRELESS:
828 method_id = ACER_WMID_GET_WIRELESS_METHODID;
829 break;
830 case ACER_CAP_BLUETOOTH:
831 method_id = ACER_WMID_GET_BLUETOOTH_METHODID;
832 break;
833 case ACER_CAP_BRIGHTNESS:
834 method_id = ACER_WMID_GET_BRIGHTNESS_METHODID;
835 break;
836 case ACER_CAP_THREEG:
837 method_id = ACER_WMID_GET_THREEG_METHODID;
838 break;
839 case ACER_CAP_MAILLED:
840 if (quirks->mailled == 1) {
841 ec_read(0x9f, value);
842 *value &= 0x01;
843 return 0;
845 case ACER_CAP_TOUCHPAD_READ:
846 switch (quirks->touchpad) {
847 case 1:
848 ec_read(0x9e, value);
849 *value = 1 - ((*value >> 3) & 0x01);
850 return 0;
851 default:
852 break;
854 case ACER_CAP_TEMPERATURE_OVERRIDE:
855 if (quirks->temperature_override == 1) {
856 ec_read(0xa9, value);
857 return 0;
859 default:
860 return AE_BAD_ADDRESS;
862 status = WMI_execute_u32(method_id, 0, &result);
863 DEBUG(2, " WMI_execute_u32 status=%d:\n", status);
865 if (ACPI_SUCCESS(status))
866 *value = (u8)result;
868 DEBUG(2, " Returning from WMID_get_u8:\n");
869 return status;
872 static acpi_status WMID_set_u8(u8 value, u32 cap, struct Interface *iface) {
873 u32 method_id = 0;
875 switch (cap) {
876 case ACER_CAP_BRIGHTNESS:
877 method_id = ACER_WMID_SET_BRIGHTNESS_METHODID;
878 break;
879 case ACER_CAP_WIRELESS:
880 method_id = ACER_WMID_SET_WIRELESS_METHODID;
881 break;
882 case ACER_CAP_BLUETOOTH:
883 method_id = ACER_WMID_SET_BLUETOOTH_METHODID;
884 break;
885 case ACER_CAP_THREEG:
886 method_id = ACER_WMID_SET_THREEG_METHODID;
887 break;
888 case ACER_CAP_MAILLED:
889 if (quirks->mailled == 1) {
890 send_kbd_cmd(0x59, value ? 0x92 : 0x93);
891 return 0;
893 case ACER_CAP_TEMPERATURE_OVERRIDE:
894 if (quirks->temperature_override == 1) {
895 ec_write(0xa9, value);
896 return 0;
898 default:
899 return AE_BAD_ADDRESS;
901 return WMI_execute_u32(method_id, (u32)value, NULL);
905 static struct Interface WMID_interface = {
906 .type = ACER_WMID,
907 .capability = (
908 ACER_CAP_WIRELESS
909 | ACER_CAP_BRIGHTNESS
910 | ACER_CAP_BLUETOOTH
911 | ACER_CAP_THREEG
915 #ifdef CONFIG_PROC
917 * High-level Procfs file handlers
920 static int
921 dispatch_read(char *page, char **start, off_t off, int count, int *eof,
922 struct ProcItem *item)
924 char *p = page;
925 int len;
927 DEBUG(2, " dispatch_read: \n");
928 if (off == 0)
929 p = item->read_func(p, item->capability);
930 len = (p - page);
931 if (len <= off + count)
932 *eof = 1;
933 *start = page + off;
934 len -= off;
935 if (len > count)
936 len = count;
937 if (len < 0)
938 len = 0;
939 return len;
942 static int
943 dispatch_write(struct file *file, const char __user *buffer,
944 unsigned long count, struct ProcItem *item)
946 int result;
947 char *tmp_buffer;
950 * Arg buffer points to userspace memory, which can't be accessed
951 * directly. Since we're making a copy, zero-terminate the
952 * destination so that sscanf can be used on it safely.
954 tmp_buffer = kmalloc(count + 1, GFP_KERNEL);
955 if (copy_from_user(tmp_buffer, buffer, count)) {
956 result = -EFAULT;
957 } else {
958 tmp_buffer[count] = 0;
959 result = item->write_func(tmp_buffer, count, item->capability);
961 kfree(tmp_buffer);
962 return result;
964 #endif
967 * Generic Device (interface-independent)
970 static acpi_status get_bool(bool *value, u32 cap) {
971 acpi_status status = AE_BAD_ADDRESS;
972 u8 tmp = 0;
974 DEBUG(2, " get_bool: cap=%d, interface type=%d\n",
975 cap, interface->type);
976 switch (interface->type) {
977 case ACER_AMW0:
978 status = AMW0_get_bool(value, cap, interface);
979 break;
980 case ACER_WMID:
981 status = WMID_get_u8(&tmp, cap, interface);
982 *value = (tmp == 1) ? 1 : 0;
983 break;
985 DEBUG(2, " Returning from get_bool:\n");
986 return status;
989 static acpi_status set_bool(int value, u32 cap) {
990 acpi_status status = AE_BAD_PARAMETER;
992 DEBUG(2, " set_bool: cap=%d, interface type=%d, value=%d\n",
993 cap, interface->type, value);
994 if ((value == 0 || value == 1) && (interface->capability & cap)) {
995 switch (interface->type) {
996 case ACER_AMW0:
997 status = AMW0_set_bool(value == 1, cap, interface);
998 break;
999 case ACER_WMID:
1000 status = WMID_set_u8(value == 1, cap, interface);
1001 break;
1004 return status;
1007 static acpi_status get_u8(u8 *value, u32 cap) {
1008 DEBUG(2, " get_u8: cap=%d\n", cap);
1009 switch (interface->type) {
1010 case ACER_AMW0:
1011 return AMW0_get_u8(value, cap, interface);
1012 break;
1013 case ACER_WMID:
1014 return WMID_get_u8(value, cap, interface);
1015 break;
1016 default:
1017 return AE_BAD_ADDRESS;
1021 static acpi_status set_u8(u8 value, u8 min, u8 max, u32 cap) {
1023 DEBUG(2, " set_u8: cap=%d, interface type=%d, value=%d\n",
1024 cap, interface->type, value);
1026 if ((value >= min && value <= max) && (interface->capability & cap) ) {
1027 switch (interface->type) {
1028 case ACER_AMW0:
1029 return AMW0_set_u8(value, cap, interface);
1030 case ACER_WMID:
1031 return WMID_set_u8(value, cap, interface);
1032 default:
1033 return AE_BAD_PARAMETER;
1036 return AE_BAD_PARAMETER;
1039 /* Each _u8 needs a small wrapper that sets the boundary values */
1040 static acpi_status set_brightness(u8 value)
1042 return set_u8(value, 0, max_brightness, ACER_CAP_BRIGHTNESS);
1045 static acpi_status set_temperature_override(u8 value)
1047 return set_u8(value, 0, ACER_MAX_TEMPERATURE_OVERRIDE, ACER_CAP_TEMPERATURE_OVERRIDE);
1050 static void __init acer_commandline_init(void)
1052 DEBUG(1, "Commandline args: mailled(%d) wireless(%d) bluetooth(%d) brightness(%d)\n",
1053 mailled, wireless, bluetooth, brightness);
1056 * These will all fail silently if the value given is invalid, or the
1057 * capability isn't available on the given interface
1059 set_bool(mailled, ACER_CAP_MAILLED);
1060 set_bool(wireless, ACER_CAP_WIRELESS);
1061 set_bool(bluetooth, ACER_CAP_BLUETOOTH);
1062 set_bool(threeg, ACER_CAP_THREEG);
1063 set_temperature_override(fan_temperature_override);
1064 set_brightness((u8)brightness);
1067 #ifdef CONFIG_PROC
1069 * Procfs interface (deprecated)
1071 static char *read_bool(char *p, u32 cap)
1073 bool result;
1074 acpi_status status;
1076 DEBUG(2, " read_bool: cap=%d\n", cap);
1077 status = get_bool(&result, cap);
1078 if (ACPI_SUCCESS(status))
1079 p += sprintf(p, "%d\n", result);
1080 else
1081 p += sprintf(p, "Read error" );
1082 return p;
1085 static unsigned long write_bool(const char *buffer, unsigned long count, u32 cap)
1087 int value;
1089 DEBUG(2, " write_bool: cap=%d, interface type=%d\n buffer=%s\n",
1090 cap, interface->type, buffer);
1092 if (sscanf(buffer, "%i", &value) == 1) {
1093 acpi_status status = set_bool(value, cap);
1094 if (ACPI_FAILURE(status))
1095 return -EINVAL;
1096 } else {
1097 return -EINVAL;
1099 return count;
1102 static char *read_u8(char *p, u32 cap)
1104 u8 result;
1105 acpi_status status;
1107 DEBUG(2, " read_u8: cap=%d\n", cap);
1108 status = get_u8(&result, cap);
1109 if (ACPI_SUCCESS(status))
1110 p += sprintf(p, "%u\n", result);
1111 else
1112 p += sprintf(p, "Read error" );
1113 return p;
1116 static unsigned long write_u8(const char *buffer, unsigned long count, u32 cap)
1118 int value;
1119 acpi_status (*set_method)(u8);
1121 /* Choose the appropriate set_u8 wrapper here, based on the capability */
1122 switch (cap) {
1123 case ACER_CAP_BRIGHTNESS:
1124 set_method = set_brightness;
1125 break;
1126 case ACER_CAP_TEMPERATURE_OVERRIDE:
1127 set_method = set_temperature_override;
1128 break;
1129 default:
1130 return -EINVAL;
1133 if (sscanf(buffer, "%i", &value) == 1) {
1134 acpi_status status = (*set_method)(value);
1135 if (ACPI_FAILURE(status))
1136 return -EINVAL;
1137 } else {
1138 return -EINVAL;
1140 return count;
1143 static char *read_version(char *p, u32 cap)
1145 p += sprintf(p, "%s\n", ACER_ACPI_VERSION);
1146 return p;
1149 static char *read_interface(char *p, u32 cap)
1151 p += sprintf(p, "%s\n", (interface->type == ACER_AMW0 ) ? "AMW0": "WMID");
1152 return p;
1155 static struct ProcItem proc_items[] = {
1156 {"mailled", read_bool, write_bool, ACER_CAP_MAILLED},
1157 {"bluetooth", read_bool, write_bool, ACER_CAP_BLUETOOTH},
1158 {"wireless", read_bool, write_bool, ACER_CAP_WIRELESS},
1159 {"brightness", read_u8, write_u8, ACER_CAP_BRIGHTNESS},
1160 {"threeg", read_bool, write_bool, ACER_CAP_THREEG},
1161 {"touchpad", read_bool, NULL, ACER_CAP_TOUCHPAD_READ},
1162 {"fan_temperature_override", read_u8, write_u8, ACER_CAP_TEMPERATURE_OVERRIDE},
1163 {"version", read_version, NULL, ACER_CAP_ANY},
1164 {"interface", read_interface, NULL, ACER_CAP_ANY},
1165 {NULL}
1168 static int __init add_proc_entries(void)
1170 struct proc_dir_entry *proc;
1171 struct ProcItem *item;
1173 for (item = proc_items; item->name; ++item) {
1175 * Only add the proc file if the current interface actually
1176 * supports it
1178 if (interface->capability & item->capability) {
1179 proc = create_proc_read_entry(item->name,
1180 S_IFREG | S_IRUGO | S_IWUSR,
1181 acer_proc_dir,
1182 (read_proc_t *) dispatch_read,
1183 item);
1184 if (proc)
1185 proc->owner = THIS_MODULE;
1186 if (proc && item->write_func)
1187 proc->write_proc = (write_proc_t *) dispatch_write;
1191 return 0;
1194 static int __exit remove_proc_entries(void)
1196 struct ProcItem *item;
1198 for (item = proc_items; item->name; ++item)
1199 remove_proc_entry(item->name, acer_proc_dir);
1200 return 0;
1202 #endif
1205 * LED device (Mail LED only, no other LEDs known yet)
1207 static void mail_led_set(struct led_classdev *led_cdev, enum led_brightness value)
1209 bool tmp = value;
1210 set_bool(tmp, ACER_CAP_MAILLED);
1213 static struct led_classdev mail_led = {
1214 .name = "acer_acpi:mail",
1215 .brightness_set = mail_led_set,
1218 static void acer_led_init(struct device *dev)
1220 led_classdev_register(dev, &mail_led);
1223 static void acer_led_exit(void)
1225 led_classdev_unregister(&mail_led);
1228 #if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,18)
1230 * Backlight device
1232 static struct backlight_device *acer_backlight_device;
1234 static int read_brightness(struct backlight_device *bd)
1236 u8 value;
1237 get_u8(&value, ACER_CAP_BRIGHTNESS);
1238 return value;
1241 #if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,20)
1242 static int update_bl_status(struct backlight_device *bd)
1244 set_brightness(bd->props->brightness);
1245 return 0;
1248 static struct backlight_properties acer_backlight_properties = {
1249 .get_brightness = read_brightness,
1250 .update_status = update_bl_status,
1253 static int __init acer_backlight_init(struct device *dev)
1255 struct backlight_device *bd;
1257 DEBUG(1, "Loading backlight driver\n");
1258 bd = backlight_device_register("acer_acpi", dev, NULL, &acer_backlight_properties);
1259 if (IS_ERR(bd)) {
1260 printk(ACER_ERR "Could not register Acer backlight device\n");
1261 acer_backlight_device = NULL;
1262 return PTR_ERR(bd);
1265 acer_backlight_device = bd;
1267 bd->props->max_brightness = max_brightness;
1268 return 0;
1270 #else
1271 static int update_bl_status(struct backlight_device *bd)
1273 set_brightness(bd->props.brightness);
1274 return 0;
1277 static struct backlight_ops acer_backlight_ops = {
1278 .get_brightness = read_brightness,
1279 .update_status = update_bl_status,
1282 static int __init acer_backlight_init(struct device *dev)
1284 struct backlight_device *bd;
1286 DEBUG(1, "Loading backlight driver\n");
1287 bd = backlight_device_register("acer_acpi", dev, NULL, &acer_backlight_ops);
1288 if (IS_ERR(bd)) {
1289 printk(ACER_ERR "Could not register Acer backlight device\n");
1290 acer_backlight_device = NULL;
1291 return PTR_ERR(bd);
1294 acer_backlight_device = bd;
1296 bd->props.max_brightness = max_brightness;
1297 bd->props.brightness = read_brightness(NULL);
1298 backlight_update_status(bd);
1299 return 0;
1301 #endif
1303 static void __exit acer_backlight_exit(void)
1305 backlight_device_unregister(acer_backlight_device);
1307 #endif
1310 * Read/ write bool sysfs macro
1312 #define show_set_bool(value, cap) \
1313 static ssize_t \
1314 show_bool_##value(struct device *dev, struct device_attribute *attr, \
1315 char *buf) \
1317 bool result; \
1318 acpi_status status = get_bool(&result, cap); \
1319 if (ACPI_SUCCESS(status)) \
1320 return sprintf(buf, "%d\n", result); \
1321 return sprintf(buf, "Read error" ); \
1324 static ssize_t \
1325 set_bool_##value(struct device *dev, struct device_attribute *attr, \
1326 const char *buf, size_t count) \
1328 bool tmp = simple_strtoul(buf, NULL, 10); \
1329 acpi_status status = set_bool(tmp, cap); \
1330 if (ACPI_FAILURE(status)) \
1331 return -EINVAL; \
1332 return count; \
1334 static DEVICE_ATTR(value, S_IWUGO | S_IRUGO | S_IWUSR, \
1335 show_bool_##value, set_bool_##value);
1337 show_set_bool(wireless, ACER_CAP_WIRELESS);
1338 show_set_bool(bluetooth, ACER_CAP_BLUETOOTH);
1339 show_set_bool(threeg, ACER_CAP_THREEG);
1340 show_set_bool(fan_temperature_override, ACER_CAP_TEMPERATURE_OVERRIDE);
1343 * Read-only bool sysfs macro
1345 #define show_bool(value, cap) \
1346 static ssize_t \
1347 show_bool_##value(struct device *dev, struct device_attribute *attr, \
1348 char *buf) \
1350 bool result; \
1351 acpi_status status = get_bool(&result, cap); \
1352 if (ACPI_SUCCESS(status)) \
1353 return sprintf(buf, "%d\n", result); \
1354 return sprintf(buf, "Read error" ); \
1356 static DEVICE_ATTR(value, S_IWUGO | S_IRUGO | S_IWUSR, \
1357 show_bool_##value, NULL);
1359 show_bool(touchpad, ACER_CAP_TOUCHPAD_READ);
1362 * Read interface sysfs macro
1364 static ssize_t show_interface(struct device *dev, struct device_attribute *attr,
1365 char *buf)
1367 return sprintf(buf, "%s\n", (interface->type == ACER_AMW0 ) ? "AMW0" : "WMID");
1370 static DEVICE_ATTR(interface, S_IWUGO | S_IRUGO | S_IWUSR, show_interface, NULL);
1373 * Platform device
1375 static int __devinit acer_platform_probe(struct platform_device *device)
1377 if (has_cap(ACER_CAP_MAILLED))
1378 acer_led_init(&device->dev);
1379 #if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,18)
1380 if (has_cap(ACER_CAP_BRIGHTNESS))
1381 acer_backlight_init(&device->dev);
1382 #endif
1383 return 0;
1386 static int acer_platform_remove(struct platform_device *device)
1388 if (has_cap(ACER_CAP_MAILLED))
1389 acer_led_exit();
1390 #if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,18)
1391 if (has_cap(ACER_CAP_BRIGHTNESS))
1392 acer_backlight_exit();
1393 #endif
1394 return 0;
1397 static int acer_platform_suspend(struct platform_device *device, pm_message_t state)
1400 * WMID fix for suspend-to-disk - save all current states now so we can
1401 * restore them on resume
1403 bool value;
1404 u8 u8value;
1405 struct acer_data *data = &interface->data;
1407 #define save_bool_device(device, cap) \
1408 if (has_cap(cap)) {\
1409 get_bool(&value, cap);\
1410 data->device = value;\
1413 #define save_u8_device(device, cap) \
1414 if (has_cap(cap)) {\
1415 get_u8(&u8value, cap);\
1416 data->device = u8value;\
1419 if (interface->type == ACER_WMID) {
1420 save_bool_device(wireless, ACER_CAP_WIRELESS);
1421 save_bool_device(bluetooth, ACER_CAP_BLUETOOTH);
1422 save_bool_device(threeg, ACER_CAP_THREEG);
1423 save_u8_device(brightness, ACER_CAP_BRIGHTNESS);
1426 return 0;
1429 static int acer_platform_resume(struct platform_device *device)
1431 struct acer_data *data = &interface->data;
1433 #define restore_bool_device(device, cap) \
1434 if (has_cap(cap))\
1435 set_bool(data->device, cap);\
1437 restore_bool_device(wireless, ACER_CAP_WIRELESS);
1438 restore_bool_device(bluetooth, ACER_CAP_BLUETOOTH);
1439 restore_bool_device(threeg, ACER_CAP_THREEG);
1440 restore_bool_device(mailled, ACER_CAP_MAILLED);
1442 if (has_cap(ACER_CAP_BRIGHTNESS))
1443 set_brightness((u8)data->brightness);
1445 /* Check if this laptop requires the keyboard quirk */
1446 if (quirks->mmkeys != 0) {
1447 set_keyboard_quirk();
1448 printk(ACER_INFO "Setting keyboard quirk to enable multimedia keys\n");
1451 return 0;
1454 static struct platform_driver acer_platform_driver = {
1455 .driver = {
1456 .name = "acer_acpi",
1457 .owner = THIS_MODULE,
1459 .probe = acer_platform_probe,
1460 .remove = acer_platform_remove,
1461 .suspend = acer_platform_suspend,
1462 .resume = acer_platform_resume,
1465 static struct platform_device *acer_platform_device;
1467 static int remove_sysfs(struct platform_device *device)
1469 #define remove_device_file(value, cap) \
1470 if (has_cap(cap)) \
1471 device_remove_file(&device->dev, &dev_attr_##value);
1473 remove_device_file(wireless, ACER_CAP_WIRELESS);
1474 remove_device_file(bluetooth, ACER_CAP_BLUETOOTH);
1475 remove_device_file(threeg, ACER_CAP_THREEG);
1476 remove_device_file(interface, ACER_CAP_ANY);
1477 remove_device_file(fan_temperature_override, ACER_CAP_TEMPERATURE_OVERRIDE);
1478 remove_device_file(touchpad, ACER_CAP_TOUCHPAD_READ);
1479 return 0;
1482 static int create_sysfs(void)
1484 int retval = -ENOMEM;
1486 #define add_device_file(value, cap) \
1487 if (has_cap(cap)) {\
1488 retval = device_create_file(&acer_platform_device->dev, &dev_attr_##value);\
1489 if (retval)\
1490 goto error;\
1493 add_device_file(wireless, ACER_CAP_WIRELESS);
1494 add_device_file(bluetooth, ACER_CAP_BLUETOOTH);
1495 add_device_file(threeg, ACER_CAP_THREEG);
1496 add_device_file(interface, ACER_CAP_ANY);
1497 add_device_file(fan_temperature_override, ACER_CAP_TEMPERATURE_OVERRIDE);
1498 add_device_file(touchpad, ACER_CAP_TOUCHPAD_READ);
1500 return 0;
1502 error:
1503 remove_sysfs(acer_platform_device);
1504 return retval;
1507 static int __init acer_acpi_init(void)
1509 printk(ACER_INFO "Acer Laptop ACPI Extras version %s\n",
1510 ACER_ACPI_VERSION);
1513 * Detect which WMI interface we're using.
1515 if (wmi_acer_has_guid(WMID_GUID1)) {
1516 DEBUG(0, "Detected Acer WMID interface\n");
1517 interface = &WMID_interface;
1518 } else if (wmi_acer_has_guid(AMW0_GUID1)) {
1519 DEBUG(0, "Detected Acer AMW0 interface\n");
1520 interface = &AMW0_interface;
1521 } else {
1522 printk(ACER_ERR "No or unsupported WMI interface, unable to load.\n");
1523 return -ENODEV;
1526 /* Find if this laptop requires any quirks */
1527 DEBUG(1, "Finding quirks\n");
1528 find_quirks();
1530 /* Now that we have a known interface, initialize it */
1531 DEBUG(1, "Initialising interface\n");
1532 if (interface->init)
1533 interface->init(interface);
1535 #ifdef CONFIG_PROC
1536 /* Create the proc entries */
1537 acer_proc_dir = proc_mkdir(PROC_ACER, acpi_root_dir);
1538 if (!acer_proc_dir) {
1539 printk(ACER_ERR "Unable to create /proc entries, aborting.\n");
1540 goto error_proc_mkdir;
1543 acer_proc_dir->owner = THIS_MODULE;
1544 if (add_proc_entries()) {
1545 printk(ACER_ERR "Unable to create /proc entries, aborting.\n");
1546 goto error_proc_add;
1548 #endif
1551 * Register the driver
1553 if (platform_driver_register(&acer_platform_driver)) {
1554 printk(ACER_ERR "Unable to register platform driver, aborting.\n");
1555 goto error_platform_register;
1557 acer_platform_device = platform_device_alloc("acer_acpi", -1);
1558 platform_device_add(acer_platform_device);
1560 create_sysfs();
1562 DEBUG(1, "Driver registered\n");
1564 /* Override any initial settings with values from the commandline */
1565 acer_commandline_init();
1567 return 0;
1569 error_platform_register:
1570 #ifdef CONFIG_PROC
1571 remove_proc_entries();
1572 error_proc_add:
1573 if (acer_proc_dir)
1574 remove_proc_entry(PROC_ACER, acpi_root_dir);
1575 error_proc_mkdir:
1576 #endif
1577 return -ENODEV;
1580 static void __exit acer_acpi_exit(void)
1582 remove_sysfs(acer_platform_device);
1583 platform_device_del(acer_platform_device);
1584 platform_driver_unregister(&acer_platform_driver);
1586 #ifdef CONFIG_PROC
1587 remove_proc_entries();
1589 if (acer_proc_dir)
1590 remove_proc_entry(PROC_ACER, acpi_root_dir);
1591 #endif
1592 printk(ACER_INFO "Acer Laptop ACPI Extras unloaded\n");
1593 return;
1596 module_init(acer_acpi_init);
1597 module_exit(acer_acpi_exit);