Commit b368fae6abaa1736b8f26128c32947d47237b8e5
Committed by
Linus Torvalds
1 parent
44f0610333
Exists in
master
and in
7 other branches
[PATCH] sonypi: Enable ACPI events for Sony laptop hotkeys
Signed-off-by: Ben Collins <bcollins@ubuntu.com> Cc: "Brown, Len" <len.brown@intel.com> Cc: linux-acpi@vger.kernel.org Cc: Stelian Pop <stelian@popies.net> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Showing 1 changed file with 45 additions and 0 deletions Side-by-side Diff
drivers/char/sonypi.c
... | ... | @@ -510,6 +510,11 @@ |
510 | 510 | #define SONYPI_ACPI_ACTIVE 0 |
511 | 511 | #endif /* CONFIG_ACPI */ |
512 | 512 | |
513 | +#ifdef CONFIG_ACPI | |
514 | +static struct acpi_device *sonypi_acpi_device; | |
515 | +static int acpi_enabled; | |
516 | +#endif | |
517 | + | |
513 | 518 | static int sonypi_ec_write(u8 addr, u8 value) |
514 | 519 | { |
515 | 520 | #ifdef CONFIG_ACPI_EC |
... | ... | @@ -863,6 +868,11 @@ |
863 | 868 | if (useinput) |
864 | 869 | sonypi_report_input_event(event); |
865 | 870 | |
871 | +#ifdef CONFIG_ACPI | |
872 | + if (acpi_enabled) | |
873 | + acpi_bus_generate_event(sonypi_acpi_device, 1, event); | |
874 | +#endif | |
875 | + | |
866 | 876 | kfifo_put(sonypi_device.fifo, (unsigned char *)&event, sizeof(event)); |
867 | 877 | kill_fasync(&sonypi_device.fifo_async, SIGIO, POLL_IN); |
868 | 878 | wake_up_interruptible(&sonypi_device.fifo_proc_list); |
... | ... | @@ -1164,6 +1174,32 @@ |
1164 | 1174 | return 0; |
1165 | 1175 | } |
1166 | 1176 | |
1177 | +#ifdef CONFIG_ACPI | |
1178 | +static int sonypi_acpi_add(struct acpi_device *device) | |
1179 | +{ | |
1180 | + sonypi_acpi_device = device; | |
1181 | + strcpy(acpi_device_name(device), "Sony laptop hotkeys"); | |
1182 | + strcpy(acpi_device_class(device), "sony/hotkey"); | |
1183 | + return 0; | |
1184 | +} | |
1185 | + | |
1186 | +static int sonypi_acpi_remove(struct acpi_device *device, int type) | |
1187 | +{ | |
1188 | + sonypi_acpi_device = NULL; | |
1189 | + return 0; | |
1190 | +} | |
1191 | + | |
1192 | +static struct acpi_driver sonypi_acpi_driver = { | |
1193 | + .name = "sonypi", | |
1194 | + .class = "hkey", | |
1195 | + .ids = "SNY6001", | |
1196 | + .ops = { | |
1197 | + .add = sonypi_acpi_add, | |
1198 | + .remove = sonypi_acpi_remove, | |
1199 | + }, | |
1200 | +}; | |
1201 | +#endif | |
1202 | + | |
1167 | 1203 | static int __devinit sonypi_create_input_devices(void) |
1168 | 1204 | { |
1169 | 1205 | struct input_dev *jog_dev; |
... | ... | @@ -1511,6 +1547,11 @@ |
1511 | 1547 | if (error) |
1512 | 1548 | goto err_free_device; |
1513 | 1549 | |
1550 | +#ifdef CONFIG_ACPI | |
1551 | + if (acpi_bus_register_driver(&sonypi_acpi_driver) > 0) | |
1552 | + acpi_enabled = 1; | |
1553 | +#endif | |
1554 | + | |
1514 | 1555 | return 0; |
1515 | 1556 | |
1516 | 1557 | err_free_device: |
... | ... | @@ -1522,6 +1563,10 @@ |
1522 | 1563 | |
1523 | 1564 | static void __exit sonypi_exit(void) |
1524 | 1565 | { |
1566 | +#ifdef CONFIG_ACPI | |
1567 | + if (acpi_enabled) | |
1568 | + acpi_bus_unregister_driver(&sonypi_acpi_driver); | |
1569 | +#endif | |
1525 | 1570 | platform_device_unregister(sonypi_platform_device); |
1526 | 1571 | platform_driver_unregister(&sonypi_driver); |
1527 | 1572 | printk(KERN_INFO "sonypi: removed.\n"); |