diff options
| author | Linus Torvalds <torvalds@woody.osdl.org> | 2006-12-22 21:46:56 -0500 |
|---|---|---|
| committer | Linus Torvalds <torvalds@woody.osdl.org> | 2006-12-22 21:46:56 -0500 |
| commit | 18ed1c051317ac3a685120cead2adb192b802347 (patch) | |
| tree | c08a9147119a6cb69114166c7107f6b0bba6e2ab /drivers | |
| parent | dab6df63086762629936e8b89a5984bae39724f6 (diff) | |
| parent | 36bcbec7ce21e2e8b3143b11a05747330abeca70 (diff) | |
Merge branch 'release' of git://git.kernel.org/pub/scm/linux/kernel/git/lenb/linux-acpi-2.6
* 'release' of git://git.kernel.org/pub/scm/linux/kernel/git/lenb/linux-acpi-2.6: (68 commits)
ACPI: replace kmalloc+memset with kzalloc
ACPI: Add support for acpi_load_table/acpi_unload_table_id
fbdev: update after backlight argument change
ACPI: video: Add dev argument for backlight_device_register
ACPI: Implement acpi_video_get_next_level()
ACPI: Kconfig - depend on PM rather than selecting it
ACPI: fix NULL check in drivers/acpi/osl.c
ACPI: make drivers/acpi/ec.c:ec_ecdt static
ACPI: prevent processor module from loading on failures
ACPI: fix single linked list manipulation
ACPI: ibm_acpi: allow clean removal
ACPI: fix git automerge failure
ACPI: ibm_acpi: respond to workqueue update
ACPI: dock: add uevent to indicate change in device status
ACPI: ec: Lindent once again
ACPI: ec: Change #define to enums there possible.
ACPI: ec: Style changes.
ACPI: ec: Acquire Global Lock under EC mutex.
ACPI: ec: Drop udelay() from poll mode. Loop by reading status field instead.
ACPI: ec: Rename gpe_bit to gpe
...
Diffstat (limited to 'drivers')
49 files changed, 1762 insertions, 747 deletions
diff --git a/drivers/acpi/Kconfig b/drivers/acpi/Kconfig index 0f9d4be7ed75..1639998e4d27 100644 --- a/drivers/acpi/Kconfig +++ b/drivers/acpi/Kconfig | |||
| @@ -11,7 +11,7 @@ config ACPI | |||
| 11 | bool "ACPI Support" | 11 | bool "ACPI Support" |
| 12 | depends on IA64 || X86 | 12 | depends on IA64 || X86 |
| 13 | depends on PCI | 13 | depends on PCI |
| 14 | select PM | 14 | depends on PM |
| 15 | default y | 15 | default y |
| 16 | ---help--- | 16 | ---help--- |
| 17 | Advanced Configuration and Power Interface (ACPI) support for | 17 | Advanced Configuration and Power Interface (ACPI) support for |
| @@ -97,6 +97,7 @@ config ACPI_BATTERY | |||
| 97 | 97 | ||
| 98 | config ACPI_BUTTON | 98 | config ACPI_BUTTON |
| 99 | tristate "Button" | 99 | tristate "Button" |
| 100 | depends on INPUT | ||
| 100 | default y | 101 | default y |
| 101 | help | 102 | help |
| 102 | This driver handles events on the power, sleep and lid buttons. | 103 | This driver handles events on the power, sleep and lid buttons. |
| @@ -172,6 +173,7 @@ config ACPI_NUMA | |||
| 172 | config ACPI_ASUS | 173 | config ACPI_ASUS |
| 173 | tristate "ASUS/Medion Laptop Extras" | 174 | tristate "ASUS/Medion Laptop Extras" |
| 174 | depends on X86 | 175 | depends on X86 |
| 176 | select BACKLIGHT_CLASS_DEVICE | ||
| 175 | ---help--- | 177 | ---help--- |
| 176 | This driver provides support for extra features of ACPI-compatible | 178 | This driver provides support for extra features of ACPI-compatible |
| 177 | ASUS laptops. As some of Medion laptops are made by ASUS, it may also | 179 | ASUS laptops. As some of Medion laptops are made by ASUS, it may also |
| @@ -200,6 +202,7 @@ config ACPI_ASUS | |||
| 200 | config ACPI_IBM | 202 | config ACPI_IBM |
| 201 | tristate "IBM ThinkPad Laptop Extras" | 203 | tristate "IBM ThinkPad Laptop Extras" |
| 202 | depends on X86 | 204 | depends on X86 |
| 205 | select BACKLIGHT_CLASS_DEVICE | ||
| 203 | ---help--- | 206 | ---help--- |
| 204 | This is a Linux ACPI driver for the IBM ThinkPad laptops. It adds | 207 | This is a Linux ACPI driver for the IBM ThinkPad laptops. It adds |
| 205 | support for Fn-Fx key combinations, Bluetooth control, video | 208 | support for Fn-Fx key combinations, Bluetooth control, video |
| @@ -222,9 +225,21 @@ config ACPI_IBM_DOCK | |||
| 222 | 225 | ||
| 223 | If you are not sure, say N here. | 226 | If you are not sure, say N here. |
| 224 | 227 | ||
| 228 | config ACPI_IBM_BAY | ||
| 229 | bool "Legacy Removable Bay Support" | ||
| 230 | depends on ACPI_IBM | ||
| 231 | depends on ACPI_BAY=n | ||
| 232 | default n | ||
| 233 | ---help--- | ||
| 234 | Allows the ibm_acpi driver to handle removable bays. | ||
| 235 | This support is obsoleted by CONFIG_ACPI_BAY. | ||
| 236 | |||
| 237 | If you are not sure, say N here. | ||
| 238 | |||
| 225 | config ACPI_TOSHIBA | 239 | config ACPI_TOSHIBA |
| 226 | tristate "Toshiba Laptop Extras" | 240 | tristate "Toshiba Laptop Extras" |
| 227 | depends on X86 | 241 | depends on X86 |
| 242 | select BACKLIGHT_CLASS_DEVICE | ||
| 228 | ---help--- | 243 | ---help--- |
| 229 | This driver adds support for access to certain system settings | 244 | This driver adds support for access to certain system settings |
| 230 | on "legacy free" Toshiba laptops. These laptops can be recognized by | 245 | on "legacy free" Toshiba laptops. These laptops can be recognized by |
diff --git a/drivers/acpi/ac.c b/drivers/acpi/ac.c index 11abc7bf777e..6daeace796a8 100644 --- a/drivers/acpi/ac.c +++ b/drivers/acpi/ac.c | |||
| @@ -109,7 +109,7 @@ static struct proc_dir_entry *acpi_ac_dir; | |||
| 109 | 109 | ||
| 110 | static int acpi_ac_seq_show(struct seq_file *seq, void *offset) | 110 | static int acpi_ac_seq_show(struct seq_file *seq, void *offset) |
| 111 | { | 111 | { |
| 112 | struct acpi_ac *ac = (struct acpi_ac *)seq->private; | 112 | struct acpi_ac *ac = seq->private; |
| 113 | 113 | ||
| 114 | 114 | ||
| 115 | if (!ac) | 115 | if (!ac) |
| @@ -187,7 +187,7 @@ static int acpi_ac_remove_fs(struct acpi_device *device) | |||
| 187 | 187 | ||
| 188 | static void acpi_ac_notify(acpi_handle handle, u32 event, void *data) | 188 | static void acpi_ac_notify(acpi_handle handle, u32 event, void *data) |
| 189 | { | 189 | { |
| 190 | struct acpi_ac *ac = (struct acpi_ac *)data; | 190 | struct acpi_ac *ac = data; |
| 191 | struct acpi_device *device = NULL; | 191 | struct acpi_device *device = NULL; |
| 192 | 192 | ||
| 193 | 193 | ||
| @@ -221,10 +221,9 @@ static int acpi_ac_add(struct acpi_device *device) | |||
| 221 | if (!device) | 221 | if (!device) |
| 222 | return -EINVAL; | 222 | return -EINVAL; |
| 223 | 223 | ||
| 224 | ac = kmalloc(sizeof(struct acpi_ac), GFP_KERNEL); | 224 | ac = kzalloc(sizeof(struct acpi_ac), GFP_KERNEL); |
| 225 | if (!ac) | 225 | if (!ac) |
| 226 | return -ENOMEM; | 226 | return -ENOMEM; |
| 227 | memset(ac, 0, sizeof(struct acpi_ac)); | ||
| 228 | 227 | ||
| 229 | ac->device = device; | 228 | ac->device = device; |
| 230 | strcpy(acpi_device_name(device), ACPI_AC_DEVICE_NAME); | 229 | strcpy(acpi_device_name(device), ACPI_AC_DEVICE_NAME); |
| @@ -269,7 +268,7 @@ static int acpi_ac_remove(struct acpi_device *device, int type) | |||
| 269 | if (!device || !acpi_driver_data(device)) | 268 | if (!device || !acpi_driver_data(device)) |
| 270 | return -EINVAL; | 269 | return -EINVAL; |
| 271 | 270 | ||
| 272 | ac = (struct acpi_ac *)acpi_driver_data(device); | 271 | ac = acpi_driver_data(device); |
| 273 | 272 | ||
| 274 | status = acpi_remove_notify_handler(device->handle, | 273 | status = acpi_remove_notify_handler(device->handle, |
| 275 | ACPI_ALL_NOTIFY, acpi_ac_notify); | 274 | ACPI_ALL_NOTIFY, acpi_ac_notify); |
diff --git a/drivers/acpi/acpi_memhotplug.c b/drivers/acpi/acpi_memhotplug.c index 6bcd9e8e7bcb..cd946ed192d3 100644 --- a/drivers/acpi/acpi_memhotplug.c +++ b/drivers/acpi/acpi_memhotplug.c | |||
| @@ -395,10 +395,9 @@ static int acpi_memory_device_add(struct acpi_device *device) | |||
| 395 | if (!device) | 395 | if (!device) |
| 396 | return -EINVAL; | 396 | return -EINVAL; |
| 397 | 397 | ||
| 398 | mem_device = kmalloc(sizeof(struct acpi_memory_device), GFP_KERNEL); | 398 | mem_device = kzalloc(sizeof(struct acpi_memory_device), GFP_KERNEL); |
| 399 | if (!mem_device) | 399 | if (!mem_device) |
| 400 | return -ENOMEM; | 400 | return -ENOMEM; |
| 401 | memset(mem_device, 0, sizeof(struct acpi_memory_device)); | ||
| 402 | 401 | ||
| 403 | INIT_LIST_HEAD(&mem_device->res_list); | 402 | INIT_LIST_HEAD(&mem_device->res_list); |
| 404 | mem_device->device = device; | 403 | mem_device->device = device; |
| @@ -429,7 +428,7 @@ static int acpi_memory_device_remove(struct acpi_device *device, int type) | |||
| 429 | if (!device || !acpi_driver_data(device)) | 428 | if (!device || !acpi_driver_data(device)) |
| 430 | return -EINVAL; | 429 | return -EINVAL; |
| 431 | 430 | ||
| 432 | mem_device = (struct acpi_memory_device *)acpi_driver_data(device); | 431 | mem_device = acpi_driver_data(device); |
| 433 | kfree(mem_device); | 432 | kfree(mem_device); |
| 434 | 433 | ||
| 435 | return 0; | 434 | return 0; |
diff --git a/drivers/acpi/asus_acpi.c b/drivers/acpi/asus_acpi.c index c7ac9297a204..396140bbbe57 100644 --- a/drivers/acpi/asus_acpi.c +++ b/drivers/acpi/asus_acpi.c | |||
| @@ -35,6 +35,7 @@ | |||
| 35 | #include <linux/init.h> | 35 | #include <linux/init.h> |
| 36 | #include <linux/types.h> | 36 | #include <linux/types.h> |
| 37 | #include <linux/proc_fs.h> | 37 | #include <linux/proc_fs.h> |
| 38 | #include <linux/backlight.h> | ||
| 38 | #include <acpi/acpi_drivers.h> | 39 | #include <acpi/acpi_drivers.h> |
| 39 | #include <acpi/acpi_bus.h> | 40 | #include <acpi/acpi_bus.h> |
| 40 | #include <asm/uaccess.h> | 41 | #include <asm/uaccess.h> |
| @@ -402,6 +403,8 @@ static struct model_data model_conf[END_MODEL] = { | |||
| 402 | /* procdir we use */ | 403 | /* procdir we use */ |
| 403 | static struct proc_dir_entry *asus_proc_dir; | 404 | static struct proc_dir_entry *asus_proc_dir; |
| 404 | 405 | ||
| 406 | static struct backlight_device *asus_backlight_device; | ||
| 407 | |||
| 405 | /* | 408 | /* |
| 406 | * This header is made available to allow proper configuration given model, | 409 | * This header is made available to allow proper configuration given model, |
| 407 | * revision number , ... this info cannot go in struct asus_hotk because it is | 410 | * revision number , ... this info cannot go in struct asus_hotk because it is |
| @@ -779,7 +782,7 @@ proc_write_lcd(struct file *file, const char __user * buffer, | |||
| 779 | return rv; | 782 | return rv; |
| 780 | } | 783 | } |
| 781 | 784 | ||
| 782 | static int read_brightness(void) | 785 | static int read_brightness(struct backlight_device *bd) |
| 783 | { | 786 | { |
| 784 | int value; | 787 | int value; |
| 785 | 788 | ||
| @@ -801,9 +804,10 @@ static int read_brightness(void) | |||
| 801 | /* | 804 | /* |
| 802 | * Change the brightness level | 805 | * Change the brightness level |
| 803 | */ | 806 | */ |
| 804 | static void set_brightness(int value) | 807 | static int set_brightness(int value) |
| 805 | { | 808 | { |
| 806 | acpi_status status = 0; | 809 | acpi_status status = 0; |
| 810 | int ret = 0; | ||
| 807 | 811 | ||
| 808 | /* SPLV laptop */ | 812 | /* SPLV laptop */ |
| 809 | if (hotk->methods->brightness_set) { | 813 | if (hotk->methods->brightness_set) { |
| @@ -811,11 +815,12 @@ static void set_brightness(int value) | |||
| 811 | value, NULL)) | 815 | value, NULL)) |
| 812 | printk(KERN_WARNING | 816 | printk(KERN_WARNING |
| 813 | "Asus ACPI: Error changing brightness\n"); | 817 | "Asus ACPI: Error changing brightness\n"); |
| 814 | return; | 818 | ret = -EIO; |
| 819 | goto out; | ||
| 815 | } | 820 | } |
| 816 | 821 | ||
| 817 | /* No SPLV method if we are here, act as appropriate */ | 822 | /* No SPLV method if we are here, act as appropriate */ |
| 818 | value -= read_brightness(); | 823 | value -= read_brightness(NULL); |
| 819 | while (value != 0) { | 824 | while (value != 0) { |
| 820 | status = acpi_evaluate_object(NULL, (value > 0) ? | 825 | status = acpi_evaluate_object(NULL, (value > 0) ? |
| 821 | hotk->methods->brightness_up : | 826 | hotk->methods->brightness_up : |
| @@ -825,15 +830,22 @@ static void set_brightness(int value) | |||
| 825 | if (ACPI_FAILURE(status)) | 830 | if (ACPI_FAILURE(status)) |
| 826 | printk(KERN_WARNING | 831 | printk(KERN_WARNING |
| 827 | "Asus ACPI: Error changing brightness\n"); | 832 | "Asus ACPI: Error changing brightness\n"); |
| 833 | ret = -EIO; | ||
| 828 | } | 834 | } |
| 829 | return; | 835 | out: |
| 836 | return ret; | ||
| 837 | } | ||
| 838 | |||
| 839 | static int set_brightness_status(struct backlight_device *bd) | ||
| 840 | { | ||
| 841 | return set_brightness(bd->props->brightness); | ||
| 830 | } | 842 | } |
| 831 | 843 | ||
| 832 | static int | 844 | static int |
| 833 | proc_read_brn(char *page, char **start, off_t off, int count, int *eof, | 845 | proc_read_brn(char *page, char **start, off_t off, int count, int *eof, |
| 834 | void *data) | 846 | void *data) |
| 835 | { | 847 | { |
| 836 | return sprintf(page, "%d\n", read_brightness()); | 848 | return sprintf(page, "%d\n", read_brightness(NULL)); |
| 837 | } | 849 | } |
| 838 | 850 | ||
| 839 | static int | 851 | static int |
| @@ -1134,7 +1146,7 @@ static int asus_hotk_get_info(void) | |||
| 1134 | if (ACPI_FAILURE(status)) | 1146 | if (ACPI_FAILURE(status)) |
| 1135 | printk(KERN_WARNING " Couldn't get the DSDT table header\n"); | 1147 | printk(KERN_WARNING " Couldn't get the DSDT table header\n"); |
| 1136 | else | 1148 | else |
| 1137 | asus_info = (struct acpi_table_header *)dsdt.pointer; | 1149 | asus_info = dsdt.pointer; |
| 1138 | 1150 | ||
| 1139 | /* We have to write 0 on init this far for all ASUS models */ | 1151 | /* We have to write 0 on init this far for all ASUS models */ |
| 1140 | if (!write_acpi_int(hotk->handle, "INIT", 0, &buffer)) { | 1152 | if (!write_acpi_int(hotk->handle, "INIT", 0, &buffer)) { |
| @@ -1156,7 +1168,7 @@ static int asus_hotk_get_info(void) | |||
| 1156 | * asus_model_match() and try something completely different. | 1168 | * asus_model_match() and try something completely different. |
| 1157 | */ | 1169 | */ |
| 1158 | if (buffer.pointer) { | 1170 | if (buffer.pointer) { |
| 1159 | model = (union acpi_object *)buffer.pointer; | 1171 | model = buffer.pointer; |
| 1160 | switch (model->type) { | 1172 | switch (model->type) { |
| 1161 | case ACPI_TYPE_STRING: | 1173 | case ACPI_TYPE_STRING: |
| 1162 | string = model->string.pointer; | 1174 | string = model->string.pointer; |
| @@ -1252,11 +1264,9 @@ static int asus_hotk_add(struct acpi_device *device) | |||
| 1252 | printk(KERN_NOTICE "Asus Laptop ACPI Extras version %s\n", | 1264 | printk(KERN_NOTICE "Asus Laptop ACPI Extras version %s\n", |
| 1253 | ASUS_ACPI_VERSION); | 1265 | ASUS_ACPI_VERSION); |
| 1254 | 1266 | ||
| 1255 | hotk = | 1267 | hotk = kzalloc(sizeof(struct asus_hotk), GFP_KERNEL); |
| 1256 | (struct asus_hotk *)kmalloc(sizeof(struct asus_hotk), GFP_KERNEL); | ||
| 1257 | if (!hotk) | 1268 | if (!hotk) |
| 1258 | return -ENOMEM; | 1269 | return -ENOMEM; |
| 1259 | memset(hotk, 0, sizeof(struct asus_hotk)); | ||
| 1260 | 1270 | ||
| 1261 | hotk->handle = device->handle; | 1271 | hotk->handle = device->handle; |
| 1262 | strcpy(acpi_device_name(device), ACPI_HOTK_DEVICE_NAME); | 1272 | strcpy(acpi_device_name(device), ACPI_HOTK_DEVICE_NAME); |
| @@ -1333,6 +1343,26 @@ static int asus_hotk_remove(struct acpi_device *device, int type) | |||
| 1333 | return 0; | 1343 | return 0; |
| 1334 | } | 1344 | } |
| 1335 | 1345 | ||
| 1346 | static struct backlight_properties asus_backlight_data = { | ||
| 1347 | .owner = THIS_MODULE, | ||
| 1348 | .get_brightness = read_brightness, | ||
| 1349 | .update_status = set_brightness_status, | ||
| 1350 | .max_brightness = 15, | ||
| 1351 | }; | ||
| 1352 | |||
| 1353 | static void __exit asus_acpi_exit(void) | ||
| 1354 | { | ||
| 1355 | if (asus_backlight_device) | ||
| 1356 | backlight_device_unregister(asus_backlight_device); | ||
| 1357 | |||
| 1358 | acpi_bus_unregister_driver(&asus_hotk_driver); | ||
| 1359 | remove_proc_entry(PROC_ASUS, acpi_root_dir); | ||
| 1360 | |||
| 1361 | kfree(asus_info); | ||
| 1362 | |||
| 1363 | return; | ||
| 1364 | } | ||
| 1365 | |||
| 1336 | static int __init asus_acpi_init(void) | 1366 | static int __init asus_acpi_init(void) |
| 1337 | { | 1367 | { |
| 1338 | int result; | 1368 | int result; |
| @@ -1370,17 +1400,15 @@ static int __init asus_acpi_init(void) | |||
| 1370 | return result; | 1400 | return result; |
| 1371 | } | 1401 | } |
| 1372 | 1402 | ||
| 1373 | return 0; | 1403 | asus_backlight_device = backlight_device_register("asus",NULL,NULL, |
| 1374 | } | 1404 | &asus_backlight_data); |
| 1375 | 1405 | if (IS_ERR(asus_backlight_device)) { | |
| 1376 | static void __exit asus_acpi_exit(void) | 1406 | printk(KERN_ERR "Could not register asus backlight device\n"); |
| 1377 | { | 1407 | asus_backlight_device = NULL; |
| 1378 | acpi_bus_unregister_driver(&asus_hotk_driver); | 1408 | asus_acpi_exit(); |
| 1379 | remove_proc_entry(PROC_ASUS, acpi_root_dir); | 1409 | } |
| 1380 | |||
| 1381 | kfree(asus_info); | ||
| 1382 | 1410 | ||
| 1383 | return; | 1411 | return 0; |
| 1384 | } | 1412 | } |
| 1385 | 1413 | ||
| 1386 | module_init(asus_acpi_init); | 1414 | module_init(asus_acpi_init); |
diff --git a/drivers/acpi/battery.c b/drivers/acpi/battery.c index 026e40755cdd..5f43e0d14899 100644 --- a/drivers/acpi/battery.c +++ b/drivers/acpi/battery.c | |||
| @@ -149,7 +149,7 @@ acpi_battery_get_info(struct acpi_battery *battery, | |||
| 149 | return -ENODEV; | 149 | return -ENODEV; |
| 150 | } | 150 | } |
| 151 | 151 | ||
| 152 | package = (union acpi_object *)buffer.pointer; | 152 | package = buffer.pointer; |
| 153 | 153 | ||
| 154 | /* Extract Package Data */ | 154 | /* Extract Package Data */ |
| 155 | 155 | ||
| @@ -160,12 +160,11 @@ acpi_battery_get_info(struct acpi_battery *battery, | |||
| 160 | goto end; | 160 | goto end; |
| 161 | } | 161 | } |
| 162 | 162 | ||
| 163 | data.pointer = kmalloc(data.length, GFP_KERNEL); | 163 | data.pointer = kzalloc(data.length, GFP_KERNEL); |
| 164 | if (!data.pointer) { | 164 | if (!data.pointer) { |
| 165 | result = -ENOMEM; | 165 | result = -ENOMEM; |
| 166 | goto end; | 166 | goto end; |
| 167 | } | 167 | } |
| 168 | memset(data.pointer, 0, data.length); | ||
| 169 | 168 | ||
| 170 | status = acpi_extract_package(package, &format, &data); | 169 | status = acpi_extract_package(package, &format, &data); |
| 171 | if (ACPI_FAILURE(status)) { | 170 | if (ACPI_FAILURE(status)) { |
| @@ -179,7 +178,7 @@ acpi_battery_get_info(struct acpi_battery *battery, | |||
| 179 | kfree(buffer.pointer); | 178 | kfree(buffer.pointer); |
| 180 | 179 | ||
| 181 | if (!result) | 180 | if (!result) |
| 182 | (*bif) = (struct acpi_battery_info *)data.pointer; | 181 | (*bif) = data.pointer; |
| 183 | 182 | ||
| 184 | return result; | 183 | return result; |
| 185 | } | 184 | } |
| @@ -209,7 +208,7 @@ acpi_battery_get_status(struct acpi_battery *battery, | |||
| 209 | return -ENODEV; | 208 | return -ENODEV; |
| 210 | } | 209 | } |
| 211 | 210 | ||
| 212 | package = (union acpi_object *)buffer.pointer; | 211 | package = buffer.pointer; |
| 213 | 212 | ||
| 214 | /* Extract Package Data */ | 213 | /* Extract Package Data */ |
| 215 | 214 | ||
| @@ -220,12 +219,11 @@ acpi_battery_get_status(struct acpi_battery *battery, | |||
| 220 | goto end; | 219 | goto end; |
| 221 | } | 220 | } |
| 222 | 221 | ||
| 223 | data.pointer = kmalloc(data.length, GFP_KERNEL); | 222 | data.pointer = kzalloc(data.length, GFP_KERNEL); |
| 224 | if (!data.pointer) { | 223 | if (!data.pointer) { |
| 225 | result = -ENOMEM; | 224 | result = -ENOMEM; |
| 226 | goto end; | 225 | goto end; |
| 227 | } | 226 | } |
| 228 | memset(data.pointer, 0, data.length); | ||
| 229 | 227 | ||
| 230 | status = acpi_extract_package(package, &format, &data); | 228 | status = acpi_extract_package(package, &format, &data); |
| 231 | if (ACPI_FAILURE(status)) { | 229 | if (ACPI_FAILURE(status)) { |
| @@ -239,7 +237,7 @@ acpi_battery_get_status(struct acpi_battery *battery, | |||
| 239 | kfree(buffer.pointer); | 237 | kfree(buffer.pointer); |
| 240 | 238 | ||
| 241 | if (!result) | 239 | if (!result) |
| 242 | (*bst) = (struct acpi_battery_status *)data.pointer; | 240 | (*bst) = data.pointer; |
| 243 | 241 | ||
| 244 | return result; | 242 | return result; |
| 245 | } | 243 | } |
| @@ -334,7 +332,7 @@ static struct proc_dir_entry *acpi_battery_dir; | |||
| 334 | static int acpi_battery_read_info(struct seq_file *seq, void *offset) | 332 | static int acpi_battery_read_info(struct seq_file *seq, void *offset) |
| 335 | { | 333 | { |
| 336 | int result = 0; | 334 | int result = 0; |
| 337 | struct acpi_battery *battery = (struct acpi_battery *)seq->private; | 335 | struct acpi_battery *battery = seq->private; |
| 338 | struct acpi_battery_info *bif = NULL; | 336 | struct acpi_battery_info *bif = NULL; |
| 339 | char *units = "?"; | 337 | char *units = "?"; |
| 340 | 338 | ||
| @@ -418,7 +416,7 @@ static int acpi_battery_info_open_fs(struct inode *inode, struct file *file) | |||
| 418 | static int acpi_battery_read_state(struct seq_file *seq, void *offset) | 416 | static int acpi_battery_read_state(struct seq_file *seq, void *offset) |
| 419 | { | 417 | { |
| 420 | int result = 0; | 418 | int result = 0; |
| 421 | struct acpi_battery *battery = (struct acpi_battery *)seq->private; | 419 | struct acpi_battery *battery = seq->private; |
| 422 | struct acpi_battery_status *bst = NULL; | 420 | struct acpi_battery_status *bst = NULL; |
| 423 | char *units = "?"; | 421 | char *units = "?"; |
| 424 | 422 | ||
| @@ -494,7 +492,7 @@ static int acpi_battery_state_open_fs(struct inode *inode, struct file *file) | |||
| 494 | 492 | ||
| 495 | static int acpi_battery_read_alarm(struct seq_file *seq, void *offset) | 493 | static int acpi_battery_read_alarm(struct seq_file *seq, void *offset) |
| 496 | { | 494 | { |
| 497 | struct acpi_battery *battery = (struct acpi_battery *)seq->private; | 495 | struct acpi_battery *battery = seq->private; |
| 498 | char *units = "?"; | 496 | char *units = "?"; |
| 499 | 497 | ||
| 500 | 498 | ||
| @@ -531,8 +529,8 @@ acpi_battery_write_alarm(struct file *file, | |||
| 531 | { | 529 | { |
| 532 | int result = 0; | 530 | int result = 0; |
| 533 | char alarm_string[12] = { '\0' }; | 531 | char alarm_string[12] = { '\0' }; |
| 534 | struct seq_file *m = (struct seq_file *)file->private_data; | 532 | struct seq_file *m = file->private_data; |
| 535 | struct acpi_battery *battery = (struct acpi_battery *)m->private; | 533 | struct acpi_battery *battery = m->private; |
| 536 | 534 | ||
| 537 | 535 | ||
| 538 | if (!battery || (count > sizeof(alarm_string) - 1)) | 536 | if (!battery || (count > sizeof(alarm_string) - 1)) |
| @@ -658,7 +656,7 @@ static int acpi_battery_remove_fs(struct acpi_device *device) | |||
| 658 | 656 | ||
| 659 | static void acpi_battery_notify(acpi_handle handle, u32 event, void *data) | 657 | static void acpi_battery_notify(acpi_handle handle, u32 event, void *data) |
| 660 | { | 658 | { |
| 661 | struct acpi_battery *battery = (struct acpi_battery *)data; | 659 | struct acpi_battery *battery = data; |
| 662 | struct acpi_device *device = NULL; | 660 | struct acpi_device *device = NULL; |
| 663 | 661 | ||
| 664 | 662 | ||
| @@ -694,10 +692,9 @@ static int acpi_battery_add(struct acpi_device *device) | |||
| 694 | if (!device) | 692 | if (!device) |
| 695 | return -EINVAL; | 693 | return -EINVAL; |
| 696 | 694 | ||
| 697 | battery = kmalloc(sizeof(struct acpi_battery), GFP_KERNEL); | 695 | battery = kzalloc(sizeof(struct acpi_battery), GFP_KERNEL); |
| 698 | if (!battery) | 696 | if (!battery) |
| 699 | return -ENOMEM; | 697 | return -ENOMEM; |
| 700 | memset(battery, 0, sizeof(struct acpi_battery)); | ||
| 701 | 698 | ||
| 702 | battery->device = device; | 699 | battery->device = device; |
| 703 | strcpy(acpi_device_name(device), ACPI_BATTERY_DEVICE_NAME); | 700 | strcpy(acpi_device_name(device), ACPI_BATTERY_DEVICE_NAME); |
| @@ -742,7 +739,7 @@ static int acpi_battery_remove(struct acpi_device *device, int type) | |||
| 742 | if (!device || !acpi_driver_data(device)) | 739 | if (!device || !acpi_driver_data(device)) |
| 743 | return -EINVAL; | 740 | return -EINVAL; |
| 744 | 741 | ||
| 745 | battery = (struct acpi_battery *)acpi_driver_data(device); | 742 | battery = acpi_driver_data(device); |
| 746 | 743 | ||
| 747 | status = acpi_remove_notify_handler(device->handle, | 744 | status = acpi_remove_notify_handler(device->handle, |
| 748 | ACPI_ALL_NOTIFY, | 745 | ACPI_ALL_NOTIFY, |
diff --git a/drivers/acpi/button.c b/drivers/acpi/button.c index 5ef885e82c78..ac860583c203 100644 --- a/drivers/acpi/button.c +++ b/drivers/acpi/button.c | |||
| @@ -29,6 +29,7 @@ | |||
| 29 | #include <linux/types.h> | 29 | #include <linux/types.h> |
| 30 | #include <linux/proc_fs.h> | 30 | #include <linux/proc_fs.h> |
| 31 | #include <linux/seq_file.h> | 31 | #include <linux/seq_file.h> |
| 32 | #include <linux/input.h> | ||
| 32 | #include <acpi/acpi_bus.h> | 33 | #include <acpi/acpi_bus.h> |
| 33 | #include <acpi/acpi_drivers.h> | 34 | #include <acpi/acpi_drivers.h> |
| 34 | 35 | ||
| @@ -62,7 +63,7 @@ | |||
| 62 | #define _COMPONENT ACPI_BUTTON_COMPONENT | 63 | #define _COMPONENT ACPI_BUTTON_COMPONENT |
| 63 | ACPI_MODULE_NAME("acpi_button") | 64 | ACPI_MODULE_NAME("acpi_button") |
| 64 | 65 | ||
| 65 | MODULE_AUTHOR("Paul Diefenbaugh"); | 66 | MODULE_AUTHOR("Paul Diefenbaugh"); |
| 66 | MODULE_DESCRIPTION(ACPI_BUTTON_DRIVER_NAME); | 67 | MODULE_DESCRIPTION(ACPI_BUTTON_DRIVER_NAME); |
| 67 | MODULE_LICENSE("GPL"); | 68 | MODULE_LICENSE("GPL"); |
| 68 | 69 | ||
| @@ -78,12 +79,14 @@ static struct acpi_driver acpi_button_driver = { | |||
| 78 | .ops = { | 79 | .ops = { |
| 79 | .add = acpi_button_add, | 80 | .add = acpi_button_add, |
| 80 | .remove = acpi_button_remove, | 81 | .remove = acpi_button_remove, |
| 81 | }, | 82 | }, |
| 82 | }; | 83 | }; |
| 83 | 84 | ||
| 84 | struct acpi_button { | 85 | struct acpi_button { |
| 85 | struct acpi_device *device; /* Fixed button kludge */ | 86 | struct acpi_device *device; /* Fixed button kludge */ |
| 86 | u8 type; | 87 | unsigned int type; |
| 88 | struct input_dev *input; | ||
| 89 | char phys[32]; /* for input device */ | ||
| 87 | unsigned long pushed; | 90 | unsigned long pushed; |
| 88 | }; | 91 | }; |
| 89 | 92 | ||
| @@ -109,8 +112,7 @@ static struct proc_dir_entry *acpi_button_dir; | |||
| 109 | 112 | ||
| 110 | static int acpi_button_info_seq_show(struct seq_file *seq, void *offset) | 113 | static int acpi_button_info_seq_show(struct seq_file *seq, void *offset) |
| 111 | { | 114 | { |
| 112 | struct acpi_button *button = (struct acpi_button *)seq->private; | 115 | struct acpi_button *button = seq->private; |
| 113 | |||
| 114 | 116 | ||
| 115 | if (!button || !button->device) | 117 | if (!button || !button->device) |
| 116 | return 0; | 118 | return 0; |
| @@ -128,22 +130,17 @@ static int acpi_button_info_open_fs(struct inode *inode, struct file *file) | |||
| 128 | 130 | ||
| 129 | static int acpi_button_state_seq_show(struct seq_file *seq, void *offset) | 131 | static int acpi_button_state_seq_show(struct seq_file *seq, void *offset) |
| 130 | { | 132 | { |
| 131 | struct acpi_button *button = (struct acpi_button *)seq->private; | 133 | struct acpi_button *button = seq->private; |
| 132 | acpi_status status; | 134 | acpi_status status; |
| 133 | unsigned long state; | 135 | unsigned long state; |
| 134 | 136 | ||
| 135 | |||
| 136 | if (!button || !button->device) | 137 | if (!button || !button->device) |
| 137 | return 0; | 138 | return 0; |
| 138 | 139 | ||
| 139 | status = acpi_evaluate_integer(button->device->handle, "_LID", NULL, &state); | 140 | status = acpi_evaluate_integer(button->device->handle, "_LID", NULL, &state); |
| 140 | if (ACPI_FAILURE(status)) { | 141 | seq_printf(seq, "state: %s\n", |
| 141 | seq_printf(seq, "state: unsupported\n"); | 142 | ACPI_FAILURE(status) ? "unsupported" : |
| 142 | } else { | 143 | (state ? "open" : "closed")); |
| 143 | seq_printf(seq, "state: %s\n", | ||
| 144 | (state ? "open" : "closed")); | ||
| 145 | } | ||
| 146 | |||
| 147 | return 0; | 144 | return 0; |
| 148 | } | 145 | } |
| 149 | 146 | ||
| @@ -159,8 +156,7 @@ static struct proc_dir_entry *acpi_lid_dir; | |||
| 159 | static int acpi_button_add_fs(struct acpi_device *device) | 156 | static int acpi_button_add_fs(struct acpi_device *device) |
| 160 | { | 157 | { |
| 161 | struct proc_dir_entry *entry = NULL; | 158 | struct proc_dir_entry *entry = NULL; |
| 162 | struct acpi_button *button = NULL; | 159 | struct acpi_button *button; |
| 163 | |||
| 164 | 160 | ||
| 165 | if (!device || !acpi_driver_data(device)) | 161 | if (!device || !acpi_driver_data(device)) |
| 166 | return -EINVAL; | 162 | return -EINVAL; |
| @@ -228,10 +224,8 @@ static int acpi_button_add_fs(struct acpi_device *device) | |||
| 228 | 224 | ||
| 229 | static int acpi_button_remove_fs(struct acpi_device *device) | 225 | static int acpi_button_remove_fs(struct acpi_device *device) |
| 230 | { | 226 | { |
| 231 | struct acpi_button *button = NULL; | 227 | struct acpi_button *button = acpi_driver_data(device); |
| 232 | |||
| 233 | 228 | ||
| 234 | button = acpi_driver_data(device); | ||
| 235 | if (acpi_device_dir(device)) { | 229 | if (acpi_device_dir(device)) { |
| 236 | if (button->type == ACPI_BUTTON_TYPE_LID) | 230 | if (button->type == ACPI_BUTTON_TYPE_LID) |
| 237 | remove_proc_entry(ACPI_BUTTON_FILE_STATE, | 231 | remove_proc_entry(ACPI_BUTTON_FILE_STATE, |
| @@ -253,14 +247,34 @@ static int acpi_button_remove_fs(struct acpi_device *device) | |||
| 253 | 247 | ||
| 254 | static void acpi_button_notify(acpi_handle handle, u32 event, void *data) | 248 | static void acpi_button_notify(acpi_handle handle, u32 event, void *data) |
| 255 | { | 249 | { |
| 256 | struct acpi_button *button = (struct acpi_button *)data; | 250 | struct acpi_button *button = data; |
| 257 | 251 | struct input_dev *input; | |
| 258 | 252 | ||
| 259 | if (!button || !button->device) | 253 | if (!button || !button->device) |
| 260 | return; | 254 | return; |
| 261 | 255 | ||
| 262 | switch (event) { | 256 | switch (event) { |
| 263 | case ACPI_BUTTON_NOTIFY_STATUS: | 257 | case ACPI_BUTTON_NOTIFY_STATUS: |
| 258 | input = button->input; | ||
| 259 | |||
| 260 | if (button->type == ACPI_BUTTON_TYPE_LID) { | ||
| 261 | struct acpi_handle *handle = button->device->handle; | ||
| 262 | unsigned long state; | ||
| 263 | |||
| 264 | if (!ACPI_FAILURE(acpi_evaluate_integer(handle, "_LID", | ||
| 265 | NULL, &state))) | ||
| 266 | input_report_switch(input, SW_LID, !state); | ||
| 267 | |||
| 268 | } else { | ||
| 269 | int keycode = test_bit(KEY_SLEEP, input->keybit) ? | ||
| 270 | KEY_SLEEP : KEY_POWER; | ||
| 271 | |||
| 272 | input_report_key(input, keycode, 1); | ||
| 273 | input_sync(input); | ||
| 274 | input_report_key(input, keycode, 0); | ||
| 275 | } | ||
| 276 | input_sync(input); | ||
| 277 | |||
| 264 | acpi_bus_generate_event(button->device, event, | 278 | acpi_bus_generate_event(button->device, event, |
| 265 | ++button->pushed); | 279 | ++button->pushed); |
| 266 | break; | 280 | break; |
| @@ -275,8 +289,7 @@ static void acpi_button_notify(acpi_handle handle, u32 event, void *data) | |||
| 275 | 289 | ||
| 276 | static acpi_status acpi_button_notify_fixed(void *data) | 290 | static acpi_status acpi_button_notify_fixed(void *data) |
| 277 | { | 291 | { |
| 278 | struct acpi_button *button = (struct acpi_button *)data; | 292 | struct acpi_button *button = data; |
| 279 | |||
| 280 | 293 | ||
| 281 | if (!button) | 294 | if (!button) |
| 282 | return AE_BAD_PARAMETER; | 295 | return AE_BAD_PARAMETER; |
| @@ -286,24 +299,75 @@ static acpi_status acpi_button_notify_fixed(void *data) | |||
| 286 | return AE_OK; | 299 | return AE_OK; |
| 287 | } | 300 | } |
| 288 | 301 | ||
| 289 | static int acpi_button_add(struct acpi_device *device) | 302 | static int acpi_button_install_notify_handlers(struct acpi_button *button) |
| 290 | { | 303 | { |
| 291 | int result = 0; | 304 | acpi_status status; |
| 292 | acpi_status status = AE_OK; | ||
| 293 | struct acpi_button *button = NULL; | ||
| 294 | 305 | ||
| 306 | switch (button->type) { | ||
| 307 | case ACPI_BUTTON_TYPE_POWERF: | ||
| 308 | status = | ||
| 309 | acpi_install_fixed_event_handler(ACPI_EVENT_POWER_BUTTON, | ||
| 310 | acpi_button_notify_fixed, | ||
| 311 | button); | ||
| 312 | break; | ||
| 313 | case ACPI_BUTTON_TYPE_SLEEPF: | ||
| 314 | status = | ||
| 315 | acpi_install_fixed_event_handler(ACPI_EVENT_SLEEP_BUTTON, | ||
| 316 | acpi_button_notify_fixed, | ||
| 317 | button); | ||
| 318 | break; | ||
| 319 | default: | ||
| 320 | status = acpi_install_notify_handler(button->device->handle, | ||
| 321 | ACPI_DEVICE_NOTIFY, | ||
| 322 | acpi_button_notify, | ||
| 323 | button); | ||
| 324 | break; | ||
| 325 | } | ||
| 326 | |||
| 327 | return ACPI_FAILURE(status) ? -ENODEV : 0; | ||
| 328 | } | ||
| 329 | |||
| 330 | static void acpi_button_remove_notify_handlers(struct acpi_button *button) | ||
| 331 | { | ||
| 332 | switch (button->type) { | ||
| 333 | case ACPI_BUTTON_TYPE_POWERF: | ||
| 334 | acpi_remove_fixed_event_handler(ACPI_EVENT_POWER_BUTTON, | ||
| 335 | acpi_button_notify_fixed); | ||
| 336 | break; | ||
| 337 | case ACPI_BUTTON_TYPE_SLEEPF: | ||
| 338 | acpi_remove_fixed_event_handler(ACPI_EVENT_SLEEP_BUTTON, | ||
| 339 | acpi_button_notify_fixed); | ||
| 340 | break; | ||
| 341 | default: | ||
| 342 | acpi_remove_notify_handler(button->device->handle, | ||
| 343 | ACPI_DEVICE_NOTIFY, | ||
| 344 | acpi_button_notify); | ||
| 345 | break; | ||
| 346 | } | ||
| 347 | } | ||
| 348 | |||
| 349 | static int acpi_button_add(struct acpi_device *device) | ||
| 350 | { | ||
| 351 | int error; | ||
| 352 | struct acpi_button *button; | ||
| 353 | struct input_dev *input; | ||
| 295 | 354 | ||
| 296 | if (!device) | 355 | if (!device) |
| 297 | return -EINVAL; | 356 | return -EINVAL; |
| 298 | 357 | ||
| 299 | button = kmalloc(sizeof(struct acpi_button), GFP_KERNEL); | 358 | button = kzalloc(sizeof(struct acpi_button), GFP_KERNEL); |
| 300 | if (!button) | 359 | if (!button) |
| 301 | return -ENOMEM; | 360 | return -ENOMEM; |
| 302 | memset(button, 0, sizeof(struct acpi_button)); | ||
| 303 | 361 | ||
| 304 | button->device = device; | 362 | button->device = device; |
| 305 | acpi_driver_data(device) = button; | 363 | acpi_driver_data(device) = button; |
| 306 | 364 | ||
| 365 | button->input = input = input_allocate_device(); | ||
| 366 | if (!input) { | ||
| 367 | error = -ENOMEM; | ||
| 368 | goto err_free_button; | ||
| 369 | } | ||
| 370 | |||
| 307 | /* | 371 | /* |
| 308 | * Determine the button type (via hid), as fixed-feature buttons | 372 | * Determine the button type (via hid), as fixed-feature buttons |
| 309 | * need to be handled a bit differently than generic-space. | 373 | * need to be handled a bit differently than generic-space. |
| @@ -338,39 +402,48 @@ static int acpi_button_add(struct acpi_device *device) | |||
| 338 | } else { | 402 | } else { |
| 339 | printk(KERN_ERR PREFIX "Unsupported hid [%s]\n", | 403 | printk(KERN_ERR PREFIX "Unsupported hid [%s]\n", |
| 340 | acpi_device_hid(device)); | 404 | acpi_device_hid(device)); |
| 341 | result = -ENODEV; | 405 | error = -ENODEV; |
| 342 | goto end; | 406 | goto err_free_input; |
| 343 | } | 407 | } |
| 344 | 408 | ||
| 345 | result = acpi_button_add_fs(device); | 409 | error = acpi_button_add_fs(device); |
| 346 | if (result) | 410 | if (error) |
| 347 | goto end; | 411 | goto err_free_input; |
| 412 | |||
| 413 | error = acpi_button_install_notify_handlers(button); | ||
| 414 | if (error) | ||
| 415 | goto err_remove_fs; | ||
| 416 | |||
| 417 | snprintf(button->phys, sizeof(button->phys), | ||
| 418 | "%s/button/input0", acpi_device_hid(device)); | ||
| 419 | |||
| 420 | input->name = acpi_device_name(device); | ||
| 421 | input->phys = button->phys; | ||
| 422 | input->id.bustype = BUS_HOST; | ||
| 423 | input->id.product = button->type; | ||
| 348 | 424 | ||
| 349 | switch (button->type) { | 425 | switch (button->type) { |
| 426 | case ACPI_BUTTON_TYPE_POWER: | ||
| 350 | case ACPI_BUTTON_TYPE_POWERF: | 427 | case ACPI_BUTTON_TYPE_POWERF: |
| 351 | status = | 428 | input->evbit[0] = BIT(EV_KEY); |
| 352 | acpi_install_fixed_event_handler(ACPI_EVENT_POWER_BUTTON, | 429 | set_bit(KEY_POWER, input->keybit); |
| 353 | acpi_button_notify_fixed, | ||
| 354 | button); | ||
| 355 | break; | 430 | break; |
| 431 | |||
| 432 | case ACPI_BUTTON_TYPE_SLEEP: | ||
| 356 | case ACPI_BUTTON_TYPE_SLEEPF: | 433 | case ACPI_BUTTON_TYPE_SLEEPF: |
| 357 | status = | 434 | input->evbit[0] = BIT(EV_KEY); |
| 358 | acpi_install_fixed_event_handler(ACPI_EVENT_SLEEP_BUTTON, | 435 | set_bit(KEY_SLEEP, input->keybit); |
| 359 | acpi_button_notify_fixed, | ||
| 360 | button); | ||
| 361 | break; | 436 | break; |
| 362 | default: | 437 | |
| 363 | status = acpi_install_notify_handler(device->handle, | 438 | case ACPI_BUTTON_TYPE_LID: |
| 364 | ACPI_DEVICE_NOTIFY, | 439 | input->evbit[0] = BIT(EV_SW); |
| 365 | acpi_button_notify, | 440 | set_bit(SW_LID, input->swbit); |
| 366 | button); | ||
| 367 | break; | 441 | break; |
| 368 | } | 442 | } |
| 369 | 443 | ||
| 370 | if (ACPI_FAILURE(status)) { | 444 | error = input_register_device(input); |
| 371 | result = -ENODEV; | 445 | if (error) |
| 372 | goto end; | 446 | goto err_remove_handlers; |
| 373 | } | ||
| 374 | 447 | ||
| 375 | if (device->wakeup.flags.valid) { | 448 | if (device->wakeup.flags.valid) { |
| 376 | /* Button's GPE is run-wake GPE */ | 449 | /* Button's GPE is run-wake GPE */ |
| @@ -385,47 +458,31 @@ static int acpi_button_add(struct acpi_device *device) | |||
| 385 | printk(KERN_INFO PREFIX "%s [%s]\n", | 458 | printk(KERN_INFO PREFIX "%s [%s]\n", |
| 386 | acpi_device_name(device), acpi_device_bid(device)); | 459 | acpi_device_name(device), acpi_device_bid(device)); |
| 387 | 460 | ||
| 388 | end: | 461 | return 0; |
| 389 | if (result) { | ||
| 390 | acpi_button_remove_fs(device); | ||
| 391 | kfree(button); | ||
| 392 | } | ||
| 393 | 462 | ||
| 394 | return result; | 463 | err_remove_handlers: |
| 464 | acpi_button_remove_notify_handlers(button); | ||
| 465 | err_remove_fs: | ||
| 466 | acpi_button_remove_fs(device); | ||
| 467 | err_free_input: | ||
| 468 | input_free_device(input); | ||
| 469 | err_free_button: | ||
| 470 | kfree(button); | ||
| 471 | return error; | ||
| 395 | } | 472 | } |
| 396 | 473 | ||
| 397 | static int acpi_button_remove(struct acpi_device *device, int type) | 474 | static int acpi_button_remove(struct acpi_device *device, int type) |
| 398 | { | 475 | { |
| 399 | acpi_status status = 0; | 476 | struct acpi_button *button; |
| 400 | struct acpi_button *button = NULL; | ||
| 401 | |||
| 402 | 477 | ||
| 403 | if (!device || !acpi_driver_data(device)) | 478 | if (!device || !acpi_driver_data(device)) |
| 404 | return -EINVAL; | 479 | return -EINVAL; |
| 405 | 480 | ||
| 406 | button = acpi_driver_data(device); | 481 | button = acpi_driver_data(device); |
| 407 | 482 | ||
| 408 | /* Unregister for device notifications. */ | 483 | acpi_button_remove_notify_handlers(button); |
| 409 | switch (button->type) { | ||
| 410 | case ACPI_BUTTON_TYPE_POWERF: | ||
| 411 | status = | ||
| 412 | acpi_remove_fixed_event_handler(ACPI_EVENT_POWER_BUTTON, | ||
| 413 | acpi_button_notify_fixed); | ||
| 414 | break; | ||
| 415 | case ACPI_BUTTON_TYPE_SLEEPF: | ||
| 416 | status = | ||
| 417 | acpi_remove_fixed_event_handler(ACPI_EVENT_SLEEP_BUTTON, | ||
| 418 | acpi_button_notify_fixed); | ||
| 419 | break; | ||
| 420 | default: | ||
| 421 | status = acpi_remove_notify_handler(device->handle, | ||
| 422 | ACPI_DEVICE_NOTIFY, | ||
| 423 | acpi_button_notify); | ||
| 424 | break; | ||
| 425 | } | ||
| 426 | |||
| 427 | acpi_button_remove_fs(device); | 484 | acpi_button_remove_fs(device); |
| 428 | 485 | input_unregister_device(button->input); | |
| 429 | kfree(button); | 486 | kfree(button); |
| 430 | 487 | ||
| 431 | return 0; | 488 | return 0; |
| @@ -433,8 +490,7 @@ static int acpi_button_remove(struct acpi_device *device, int type) | |||
| 433 | 490 | ||
| 434 | static int __init acpi_button_init(void) | 491 | static int __init acpi_button_init(void) |
| 435 | { | 492 | { |
| 436 | int result = 0; | 493 | int result; |
| 437 | |||
| 438 | 494 | ||
| 439 | acpi_button_dir = proc_mkdir(ACPI_BUTTON_CLASS, acpi_root_dir); | 495 | acpi_button_dir = proc_mkdir(ACPI_BUTTON_CLASS, acpi_root_dir); |
| 440 | if (!acpi_button_dir) | 496 | if (!acpi_button_dir) |
| @@ -451,7 +507,6 @@ static int __init acpi_button_init(void) | |||
| 451 | 507 | ||
| 452 | static void __exit acpi_button_exit(void) | 508 | static void __exit acpi_button_exit(void) |
| 453 | { | 509 | { |
| 454 | |||
| 455 | acpi_bus_unregister_driver(&acpi_button_driver); | 510 | acpi_bus_unregister_driver(&acpi_button_driver); |
| 456 | 511 | ||
| 457 | if (acpi_power_dir) | 512 | if (acpi_power_dir) |
| @@ -461,8 +516,6 @@ static void __exit acpi_button_exit(void) | |||
| 461 | if (acpi_lid_dir) | 516 | if (acpi_lid_dir) |
| 462 | remove_proc_entry(ACPI_BUTTON_SUBCLASS_LID, acpi_button_dir); | 517 | remove_proc_entry(ACPI_BUTTON_SUBCLASS_LID, acpi_button_dir); |
| 463 | remove_proc_entry(ACPI_BUTTON_CLASS, acpi_root_dir); | 518 | remove_proc_entry(ACPI_BUTTON_CLASS, acpi_root_dir); |
| 464 | |||
| 465 | return; | ||
| 466 | } | 519 | } |
| 467 | 520 | ||
| 468 | module_init(acpi_button_init); | 521 | module_init(acpi_button_init); |
diff --git a/drivers/acpi/container.c b/drivers/acpi/container.c index 871aa520ece7..0a1863ec91f3 100644 --- a/drivers/acpi/container.c +++ b/drivers/acpi/container.c | |||
| @@ -96,11 +96,10 @@ static int acpi_container_add(struct acpi_device *device) | |||
| 96 | return -EINVAL; | 96 | return -EINVAL; |
| 97 | } | 97 | } |
| 98 | 98 | ||
| 99 | container = kmalloc(sizeof(struct acpi_container), GFP_KERNEL); | 99 | container = kzalloc(sizeof(struct acpi_container), GFP_KERNEL); |
| 100 | if (!container) | 100 | if (!container) |
| 101 | return -ENOMEM; | 101 | return -ENOMEM; |
| 102 | 102 | ||
| 103 | memset(container, 0, sizeof(struct acpi_container)); | ||
| 104 | container->handle = device->handle; | 103 | container->handle = device->handle; |
| 105 | strcpy(acpi_device_name(device), ACPI_CONTAINER_DEVICE_NAME); | 104 | strcpy(acpi_device_name(device), ACPI_CONTAINER_DEVICE_NAME); |
| 106 | strcpy(acpi_device_class(device), ACPI_CONTAINER_CLASS); | 105 | strcpy(acpi_device_class(device), ACPI_CONTAINER_CLASS); |
| @@ -117,7 +116,7 @@ static int acpi_container_remove(struct acpi_device *device, int type) | |||
| 117 | acpi_status status = AE_OK; | 116 | acpi_status status = AE_OK; |
| 118 | struct acpi_container *pc = NULL; | 117 | struct acpi_container *pc = NULL; |
| 119 | 118 | ||
| 120 | pc = (struct acpi_container *)acpi_driver_data(device); | 119 | pc = acpi_driver_data(device); |
| 121 | kfree(pc); | 120 | kfree(pc); |
| 122 | return status; | 121 | return status; |
| 123 | } | 122 | } |
diff --git a/drivers/acpi/dock.c b/drivers/acpi/dock.c index bf5b79ed3613..90990a4b6526 100644 --- a/drivers/acpi/dock.c +++ b/drivers/acpi/dock.c | |||
| @@ -27,6 +27,7 @@ | |||
| 27 | #include <linux/init.h> | 27 | #include <linux/init.h> |
| 28 | #include <linux/types.h> | 28 | #include <linux/types.h> |
| 29 | #include <linux/notifier.h> | 29 | #include <linux/notifier.h> |
| 30 | #include <linux/platform_device.h> | ||
| 30 | #include <linux/jiffies.h> | 31 | #include <linux/jiffies.h> |
| 31 | #include <acpi/acpi_bus.h> | 32 | #include <acpi/acpi_bus.h> |
| 32 | #include <acpi/acpi_drivers.h> | 33 | #include <acpi/acpi_drivers.h> |
| @@ -39,13 +40,15 @@ MODULE_DESCRIPTION(ACPI_DOCK_DRIVER_NAME); | |||
| 39 | MODULE_LICENSE("GPL"); | 40 | MODULE_LICENSE("GPL"); |
| 40 | 41 | ||
| 41 | static struct atomic_notifier_head dock_notifier_list; | 42 | static struct atomic_notifier_head dock_notifier_list; |
| 43 | static struct platform_device dock_device; | ||
| 44 | static char dock_device_name[] = "dock"; | ||
| 42 | 45 | ||
| 43 | struct dock_station { | 46 | struct dock_station { |
| 44 | acpi_handle handle; | 47 | acpi_handle handle; |
| 45 | unsigned long last_dock_time; | 48 | unsigned long last_dock_time; |
| 46 | u32 flags; | 49 | u32 flags; |
| 47 | spinlock_t dd_lock; | 50 | spinlock_t dd_lock; |
| 48 | spinlock_t hp_lock; | 51 | struct mutex hp_lock; |
| 49 | struct list_head dependent_devices; | 52 | struct list_head dependent_devices; |
| 50 | struct list_head hotplug_devices; | 53 | struct list_head hotplug_devices; |
| 51 | }; | 54 | }; |
| @@ -115,9 +118,9 @@ static void | |||
| 115 | dock_add_hotplug_device(struct dock_station *ds, | 118 | dock_add_hotplug_device(struct dock_station *ds, |
| 116 | struct dock_dependent_device *dd) | 119 | struct dock_dependent_device *dd) |
| 117 | { | 120 | { |
| 118 | spin_lock(&ds->hp_lock); | 121 | mutex_lock(&ds->hp_lock); |
| 119 | list_add_tail(&dd->hotplug_list, &ds->hotplug_devices); | 122 | list_add_tail(&dd->hotplug_list, &ds->hotplug_devices); |
| 120 | spin_unlock(&ds->hp_lock); | 123 | mutex_unlock(&ds->hp_lock); |
| 121 | } | 124 | } |
| 122 | 125 | ||
| 123 | /** | 126 | /** |
| @@ -131,9 +134,9 @@ static void | |||
| 131 | dock_del_hotplug_device(struct dock_station *ds, | 134 | dock_del_hotplug_device(struct dock_station *ds, |
| 132 | struct dock_dependent_device *dd) | 135 | struct dock_dependent_device *dd) |
| 133 | { | 136 | { |
| 134 | spin_lock(&ds->hp_lock); | 137 | mutex_lock(&ds->hp_lock); |
| 135 | list_del(&dd->hotplug_list); | 138 | list_del(&dd->hotplug_list); |
| 136 | spin_unlock(&ds->hp_lock); | 139 | mutex_unlock(&ds->hp_lock); |
| 137 | } | 140 | } |
| 138 | 141 | ||
| 139 | /** | 142 | /** |
| @@ -296,7 +299,7 @@ static void hotplug_dock_devices(struct dock_station *ds, u32 event) | |||
| 296 | { | 299 | { |
| 297 | struct dock_dependent_device *dd; | 300 | struct dock_dependent_device *dd; |
| 298 | 301 | ||
| 299 | spin_lock(&ds->hp_lock); | 302 | mutex_lock(&ds->hp_lock); |
| 300 | 303 | ||
| 301 | /* | 304 | /* |
| 302 | * First call driver specific hotplug functions | 305 | * First call driver specific hotplug functions |
| @@ -318,15 +321,17 @@ static void hotplug_dock_devices(struct dock_station *ds, u32 event) | |||
| 318 | else | 321 | else |
| 319 | dock_create_acpi_device(dd->handle); | 322 | dock_create_acpi_device(dd->handle); |
| 320 | } | 323 | } |
| 321 | spin_unlock(&ds->hp_lock); | 324 | mutex_unlock(&ds->hp_lock); |
| 322 | } | 325 | } |
| 323 | 326 | ||
| 324 | static void dock_event(struct dock_station *ds, u32 event, int num) | 327 | static void dock_event(struct dock_station *ds, u32 event, int num) |
| 325 | { | 328 | { |
| 329 | struct device *dev = &dock_device.dev; | ||
| 326 | /* | 330 | /* |
| 327 | * we don't do events until someone tells me that | 331 | * Indicate that the status of the dock station has |
| 328 | * they would like to have them. | 332 | * changed. |
| 329 | */ | 333 | */ |
| 334 | kobject_uevent(&dev->kobj, KOBJ_CHANGE); | ||
| 330 | } | 335 | } |
| 331 | 336 | ||
| 332 | /** | 337 | /** |
| @@ -441,6 +446,9 @@ static int dock_in_progress(struct dock_station *ds) | |||
| 441 | */ | 446 | */ |
| 442 | int register_dock_notifier(struct notifier_block *nb) | 447 | int register_dock_notifier(struct notifier_block *nb) |
| 443 | { | 448 | { |
| 449 | if (!dock_station) | ||
| 450 | return -ENODEV; | ||
| 451 | |||
| 444 | return atomic_notifier_chain_register(&dock_notifier_list, nb); | 452 | return atomic_notifier_chain_register(&dock_notifier_list, nb); |
| 445 | } | 453 | } |
| 446 | 454 | ||
| @@ -452,6 +460,9 @@ EXPORT_SYMBOL_GPL(register_dock_notifier); | |||
| 452 | */ | 460 | */ |
| 453 | void unregister_dock_notifier(struct notifier_block *nb) | 461 | void unregister_dock_notifier(struct notifier_block *nb) |
| 454 | { | 462 | { |
| 463 | if (!dock_station) | ||
| 464 | return; | ||
| 465 | |||
| 455 | atomic_notifier_chain_unregister(&dock_notifier_list, nb); | 466 | atomic_notifier_chain_unregister(&dock_notifier_list, nb); |
| 456 | } | 467 | } |
| 457 | 468 | ||
| @@ -512,6 +523,37 @@ void unregister_hotplug_dock_device(acpi_handle handle) | |||
| 512 | EXPORT_SYMBOL_GPL(unregister_hotplug_dock_device); | 523 | EXPORT_SYMBOL_GPL(unregister_hotplug_dock_device); |
| 513 | 524 | ||
| 514 | /** | 525 | /** |
| 526 | * handle_eject_request - handle an undock request checking for error conditions | ||
| 527 | * | ||
| 528 | * Check to make sure the dock device is still present, then undock and | ||
| 529 | * hotremove all the devices that may need removing. | ||
| 530 | */ | ||
| 531 | static int handle_eject_request(struct dock_station *ds, u32 event) | ||
| 532 | { | ||
| 533 | if (!dock_present(ds)) | ||
| 534 | return -ENODEV; | ||
| 535 | |||
| 536 | if (dock_in_progress(ds)) | ||
| 537 | return -EBUSY; | ||
| 538 | |||
| 539 | /* | ||
| 540 | * here we need to generate the undock | ||
| 541 | * event prior to actually doing the undock | ||
| 542 | * so that the device struct still exists. | ||
| 543 | */ | ||
| 544 | dock_event(ds, event, UNDOCK_EVENT); | ||
| 545 | hotplug_dock_devices(ds, ACPI_NOTIFY_EJECT_REQUEST); | ||
| 546 | undock(ds); | ||
| 547 | eject_dock(ds); | ||
| 548 | if (dock_present(ds)) { | ||
| 549 | printk(KERN_ERR PREFIX "Unable to undock!\n"); | ||
| 550 | return -EBUSY; | ||
| 551 | } | ||
| 552 | |||
| 553 | return 0; | ||
| 554 | } | ||
| 555 | |||
| 556 | /** | ||
| 515 | * dock_notify - act upon an acpi dock notification | 557 | * dock_notify - act upon an acpi dock notification |
| 516 | * @handle: the dock station handle | 558 | * @handle: the dock station handle |
| 517 | * @event: the acpi event | 559 | * @event: the acpi event |
| @@ -519,13 +561,11 @@ EXPORT_SYMBOL_GPL(unregister_hotplug_dock_device); | |||
| 519 | * | 561 | * |
| 520 | * If we are notified to dock, then check to see if the dock is | 562 | * If we are notified to dock, then check to see if the dock is |
| 521 | * present and then dock. Notify all drivers of the dock event, | 563 | * present and then dock. Notify all drivers of the dock event, |
| 522 | * and then hotplug and devices that may need hotplugging. For undock | 564 | * and then hotplug and devices that may need hotplugging. |
| 523 | * check to make sure the dock device is still present, then undock | ||
| 524 | * and hotremove all the devices that may need removing. | ||
| 525 | */ | 565 | */ |
| 526 | static void dock_notify(acpi_handle handle, u32 event, void *data) | 566 | static void dock_notify(acpi_handle handle, u32 event, void *data) |
| 527 | { | 567 | { |
| 528 | struct dock_station *ds = (struct dock_station *)data; | 568 | struct dock_station *ds = data; |
| 529 | 569 | ||
| 530 | switch (event) { | 570 | switch (event) { |
| 531 | case ACPI_NOTIFY_BUS_CHECK: | 571 | case ACPI_NOTIFY_BUS_CHECK: |
| @@ -553,19 +593,7 @@ static void dock_notify(acpi_handle handle, u32 event, void *data) | |||
| 553 | * to the driver who wish to hotplug. | 593 | * to the driver who wish to hotplug. |
| 554 | */ | 594 | */ |
| 555 | case ACPI_NOTIFY_EJECT_REQUEST: | 595 | case ACPI_NOTIFY_EJECT_REQUEST: |
| 556 | if (!dock_in_progress(ds) && dock_present(ds)) { | 596 | handle_eject_request(ds, event); |
| 557 | /* | ||
| 558 | * here we need to generate the undock | ||
| 559 | * event prior to actually doing the undock | ||
| 560 | * so that the device struct still exists. | ||
| 561 | */ | ||
| 562 | dock_event(ds, event, UNDOCK_EVENT); | ||
| 563 | hotplug_dock_devices(ds, ACPI_NOTIFY_EJECT_REQUEST); | ||
| 564 | undock(ds); | ||
| 565 | eject_dock(ds); | ||
| 566 | if (dock_present(ds)) | ||
| 567 | printk(KERN_ERR PREFIX "Unable to undock!\n"); | ||
| 568 | } | ||
| 569 | break; | 597 | break; |
| 570 | default: | 598 | default: |
| 571 | printk(KERN_ERR PREFIX "Unknown dock event %d\n", event); | 599 | printk(KERN_ERR PREFIX "Unknown dock event %d\n", event); |
| @@ -588,7 +616,7 @@ find_dock_devices(acpi_handle handle, u32 lvl, void *context, void **rv) | |||
| 588 | { | 616 | { |
| 589 | acpi_status status; | 617 | acpi_status status; |
| 590 | acpi_handle tmp; | 618 | acpi_handle tmp; |
| 591 | struct dock_station *ds = (struct dock_station *)context; | 619 | struct dock_station *ds = context; |
| 592 | struct dock_dependent_device *dd; | 620 | struct dock_dependent_device *dd; |
| 593 | 621 | ||
| 594 | status = acpi_bus_get_ejd(handle, &tmp); | 622 | status = acpi_bus_get_ejd(handle, &tmp); |
| @@ -604,6 +632,33 @@ find_dock_devices(acpi_handle handle, u32 lvl, void *context, void **rv) | |||
| 604 | return AE_OK; | 632 | return AE_OK; |
| 605 | } | 633 | } |
| 606 | 634 | ||
| 635 | /* | ||
| 636 | * show_docked - read method for "docked" file in sysfs | ||
| 637 | */ | ||
| 638 | static ssize_t show_docked(struct device *dev, | ||
| 639 | struct device_attribute *attr, char *buf) | ||
| 640 | { | ||
| 641 | return snprintf(buf, PAGE_SIZE, "%d\n", dock_present(dock_station)); | ||
| 642 | |||
| 643 | } | ||
| 644 | DEVICE_ATTR(docked, S_IRUGO, show_docked, NULL); | ||
| 645 | |||
| 646 | /* | ||
| 647 | * write_undock - write method for "undock" file in sysfs | ||
| 648 | */ | ||
| 649 | static ssize_t write_undock(struct device *dev, struct device_attribute *attr, | ||
| 650 | const char *buf, size_t count) | ||
| 651 | { | ||
| 652 | int ret; | ||
| 653 | |||
| 654 | if (!count) | ||
| 655 | return -EINVAL; | ||
| 656 | |||
| 657 | ret = handle_eject_request(dock_station, ACPI_NOTIFY_EJECT_REQUEST); | ||
| 658 | return ret ? ret: count; | ||
| 659 | } | ||
| 660 | DEVICE_ATTR(undock, S_IWUSR, NULL, write_undock); | ||
| 661 | |||
| 607 | /** | 662 | /** |
| 608 | * dock_add - add a new dock station | 663 | * dock_add - add a new dock station |
| 609 | * @handle: the dock station handle | 664 | * @handle: the dock station handle |
| @@ -626,9 +681,33 @@ static int dock_add(acpi_handle handle) | |||
| 626 | INIT_LIST_HEAD(&dock_station->dependent_devices); | 681 | INIT_LIST_HEAD(&dock_station->dependent_devices); |
| 627 | INIT_LIST_HEAD(&dock_station->hotplug_devices); | 682 | INIT_LIST_HEAD(&dock_station->hotplug_devices); |
| 628 | spin_lock_init(&dock_station->dd_lock); | 683 | spin_lock_init(&dock_station->dd_lock); |
| 629 | spin_lock_init(&dock_station->hp_lock); | 684 | mutex_init(&dock_station->hp_lock); |
| 630 | ATOMIC_INIT_NOTIFIER_HEAD(&dock_notifier_list); | 685 | ATOMIC_INIT_NOTIFIER_HEAD(&dock_notifier_list); |
| 631 | 686 | ||
| 687 | /* initialize platform device stuff */ | ||
| 688 | dock_device.name = dock_device_name; | ||
| 689 | ret = platform_device_register(&dock_device); | ||
| 690 | if (ret) { | ||
| 691 | printk(KERN_ERR PREFIX "Error %d registering dock device\n", ret); | ||
| 692 | kfree(dock_station); | ||
| 693 | return ret; | ||
| 694 | } | ||
| 695 | ret = device_create_file(&dock_device.dev, &dev_attr_docked); | ||
| 696 | if (ret) { | ||
| 697 | printk("Error %d adding sysfs file\n", ret); | ||
| 698 | platform_device_unregister(&dock_device); | ||
| 699 | kfree(dock_station); | ||
| 700 | return ret; | ||
| 701 | } | ||
| 702 | ret = device_create_file(&dock_device.dev, &dev_attr_undock); | ||
| 703 | if (ret) { | ||
| 704 | printk("Error %d adding sysfs file\n", ret); | ||
| 705 | device_remove_file(&dock_device.dev, &dev_attr_docked); | ||
| 706 | platform_device_unregister(&dock_device); | ||
| 707 | kfree(dock_station); | ||
| 708 | return ret; | ||
| 709 | } | ||
| 710 | |||
| 632 | /* Find dependent devices */ | 711 | /* Find dependent devices */ |
| 633 | acpi_walk_namespace(ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT, | 712 | acpi_walk_namespace(ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT, |
| 634 | ACPI_UINT32_MAX, find_dock_devices, dock_station, | 713 | ACPI_UINT32_MAX, find_dock_devices, dock_station, |
| @@ -638,7 +717,8 @@ static int dock_add(acpi_handle handle) | |||
| 638 | dd = alloc_dock_dependent_device(handle); | 717 | dd = alloc_dock_dependent_device(handle); |
| 639 | if (!dd) { | 718 | if (!dd) { |
| 640 | kfree(dock_station); | 719 | kfree(dock_station); |
| 641 | return -ENOMEM; | 720 | ret = -ENOMEM; |
| 721 | goto dock_add_err_unregister; | ||
| 642 | } | 722 | } |
| 643 | add_dock_dependent_device(dock_station, dd); | 723 | add_dock_dependent_device(dock_station, dd); |
| 644 | 724 | ||
| @@ -658,8 +738,12 @@ static int dock_add(acpi_handle handle) | |||
| 658 | return 0; | 738 | return 0; |
| 659 | 739 | ||
| 660 | dock_add_err: | 740 | dock_add_err: |
| 661 | kfree(dock_station); | ||
| 662 | kfree(dd); | 741 | kfree(dd); |
| 742 | dock_add_err_unregister: | ||
| 743 | device_remove_file(&dock_device.dev, &dev_attr_docked); | ||
| 744 | device_remove_file(&dock_device.dev, &dev_attr_undock); | ||
| 745 | platform_device_unregister(&dock_device); | ||
| 746 | kfree(dock_station); | ||
| 663 | return ret; | 747 | return ret; |
| 664 | } | 748 | } |
| 665 | 749 | ||
| @@ -686,6 +770,11 @@ static int dock_remove(void) | |||
| 686 | if (ACPI_FAILURE(status)) | 770 | if (ACPI_FAILURE(status)) |
| 687 | printk(KERN_ERR "Error removing notify handler\n"); | 771 | printk(KERN_ERR "Error removing notify handler\n"); |
| 688 | 772 | ||
| 773 | /* cleanup sysfs */ | ||
| 774 | device_remove_file(&dock_device.dev, &dev_attr_docked); | ||
| 775 | device_remove_file(&dock_device.dev, &dev_attr_undock); | ||
| 776 | platform_device_unregister(&dock_device); | ||
| 777 | |||
| 689 | /* free dock station memory */ | 778 | /* free dock station memory */ |
| 690 | kfree(dock_station); | 779 | kfree(dock_station); |
| 691 | return 0; | 780 | return 0; |
| @@ -703,7 +792,7 @@ static int dock_remove(void) | |||
| 703 | static acpi_status | 792 | static acpi_status |
| 704 | find_dock(acpi_handle handle, u32 lvl, void *context, void **rv) | 793 | find_dock(acpi_handle handle, u32 lvl, void *context, void **rv) |
| 705 | { | 794 | { |
| 706 | int *count = (int *)context; | 795 | int *count = context; |
| 707 | acpi_status status = AE_OK; | 796 | acpi_status status = AE_OK; |
| 708 | 797 | ||
| 709 | if (is_dock(handle)) { | 798 | if (is_dock(handle)) { |
| @@ -726,7 +815,7 @@ static int __init dock_init(void) | |||
| 726 | ACPI_UINT32_MAX, find_dock, &num, NULL); | 815 | ACPI_UINT32_MAX, find_dock, &num, NULL); |
| 727 | 816 | ||
| 728 | if (!num) | 817 | if (!num) |
| 729 | return -ENODEV; | 818 | printk(KERN_INFO "No dock devices found.\n"); |
| 730 | 819 | ||
| 731 | return 0; | 820 | return 0; |
| 732 | } | 821 | } |
diff --git a/drivers/acpi/ec.c b/drivers/acpi/ec.c index e6d4b084dca2..9c52d87d6f04 100644 --- a/drivers/acpi/ec.c +++ b/drivers/acpi/ec.c | |||
| @@ -45,35 +45,34 @@ ACPI_MODULE_NAME("acpi_ec") | |||
| 45 | #define ACPI_EC_DRIVER_NAME "ACPI Embedded Controller Driver" | 45 | #define ACPI_EC_DRIVER_NAME "ACPI Embedded Controller Driver" |
| 46 | #define ACPI_EC_DEVICE_NAME "Embedded Controller" | 46 | #define ACPI_EC_DEVICE_NAME "Embedded Controller" |
| 47 | #define ACPI_EC_FILE_INFO "info" | 47 | #define ACPI_EC_FILE_INFO "info" |
| 48 | 48 | #undef PREFIX | |
| 49 | #define PREFIX "ACPI: EC: " | ||
| 49 | /* EC status register */ | 50 | /* EC status register */ |
| 50 | #define ACPI_EC_FLAG_OBF 0x01 /* Output buffer full */ | 51 | #define ACPI_EC_FLAG_OBF 0x01 /* Output buffer full */ |
| 51 | #define ACPI_EC_FLAG_IBF 0x02 /* Input buffer full */ | 52 | #define ACPI_EC_FLAG_IBF 0x02 /* Input buffer full */ |
| 52 | #define ACPI_EC_FLAG_BURST 0x10 /* burst mode */ | 53 | #define ACPI_EC_FLAG_BURST 0x10 /* burst mode */ |
| 53 | #define ACPI_EC_FLAG_SCI 0x20 /* EC-SCI occurred */ | 54 | #define ACPI_EC_FLAG_SCI 0x20 /* EC-SCI occurred */ |
| 54 | |||
| 55 | /* EC commands */ | 55 | /* EC commands */ |
| 56 | #define ACPI_EC_COMMAND_READ 0x80 | 56 | enum ec_command { |
| 57 | #define ACPI_EC_COMMAND_WRITE 0x81 | 57 | ACPI_EC_COMMAND_READ = 0x80, |
| 58 | #define ACPI_EC_BURST_ENABLE 0x82 | 58 | ACPI_EC_COMMAND_WRITE = 0x81, |
| 59 | #define ACPI_EC_BURST_DISABLE 0x83 | 59 | ACPI_EC_BURST_ENABLE = 0x82, |
| 60 | #define ACPI_EC_COMMAND_QUERY 0x84 | 60 | ACPI_EC_BURST_DISABLE = 0x83, |
| 61 | 61 | ACPI_EC_COMMAND_QUERY = 0x84, | |
| 62 | }; | ||
| 62 | /* EC events */ | 63 | /* EC events */ |
| 63 | enum { | 64 | enum ec_event { |
| 64 | ACPI_EC_EVENT_OBF_1 = 1, /* Output buffer full */ | 65 | ACPI_EC_EVENT_OBF_1 = 1, /* Output buffer full */ |
| 65 | ACPI_EC_EVENT_IBF_0, /* Input buffer empty */ | 66 | ACPI_EC_EVENT_IBF_0, /* Input buffer empty */ |
| 66 | }; | 67 | }; |
| 67 | 68 | ||
| 68 | #define ACPI_EC_DELAY 50 /* Wait 50ms max. during EC ops */ | 69 | #define ACPI_EC_DELAY 500 /* Wait 500ms max. during EC ops */ |
| 69 | #define ACPI_EC_UDELAY_GLK 1000 /* Wait 1ms max. to get global lock */ | 70 | #define ACPI_EC_UDELAY_GLK 1000 /* Wait 1ms max. to get global lock */ |
| 70 | #define ACPI_EC_UDELAY 100 /* Poll @ 100us increments */ | ||
| 71 | #define ACPI_EC_UDELAY_COUNT 1000 /* Wait 10ms max. during EC ops */ | ||
| 72 | 71 | ||
| 73 | enum { | 72 | static enum ec_mode { |
| 74 | EC_INTR = 1, /* Output buffer full */ | 73 | EC_INTR = 1, /* Output buffer full */ |
| 75 | EC_POLL, /* Input buffer empty */ | 74 | EC_POLL, /* Input buffer empty */ |
| 76 | }; | 75 | } acpi_ec_mode = EC_INTR; |
| 77 | 76 | ||
| 78 | static int acpi_ec_remove(struct acpi_device *device, int type); | 77 | static int acpi_ec_remove(struct acpi_device *device, int type); |
| 79 | static int acpi_ec_start(struct acpi_device *device); | 78 | static int acpi_ec_start(struct acpi_device *device); |
| @@ -93,22 +92,21 @@ static struct acpi_driver acpi_ec_driver = { | |||
| 93 | }; | 92 | }; |
| 94 | 93 | ||
| 95 | /* If we find an EC via the ECDT, we need to keep a ptr to its context */ | 94 | /* If we find an EC via the ECDT, we need to keep a ptr to its context */ |
| 96 | struct acpi_ec { | 95 | static struct acpi_ec { |
| 97 | acpi_handle handle; | 96 | acpi_handle handle; |
| 98 | unsigned long uid; | 97 | unsigned long uid; |
| 99 | unsigned long gpe_bit; | 98 | unsigned long gpe; |
| 100 | unsigned long command_addr; | 99 | unsigned long command_addr; |
| 101 | unsigned long data_addr; | 100 | unsigned long data_addr; |
| 102 | unsigned long global_lock; | 101 | unsigned long global_lock; |
| 103 | struct semaphore sem; | 102 | struct mutex lock; |
| 104 | unsigned int expect_event; | 103 | atomic_t query_pending; |
| 105 | atomic_t leaving_burst; /* 0 : No, 1 : Yes, 2: abort */ | 104 | atomic_t leaving_burst; /* 0 : No, 1 : Yes, 2: abort */ |
| 106 | wait_queue_head_t wait; | 105 | wait_queue_head_t wait; |
| 107 | } *ec_ecdt; | 106 | } *ec_ecdt; |
| 108 | 107 | ||
| 109 | /* External interfaces use first EC only, so remember */ | 108 | /* External interfaces use first EC only, so remember */ |
| 110 | static struct acpi_device *first_ec; | 109 | static struct acpi_device *first_ec; |
| 111 | static int acpi_ec_mode = EC_INTR; | ||
| 112 | 110 | ||
| 113 | /* -------------------------------------------------------------------------- | 111 | /* -------------------------------------------------------------------------- |
| 114 | Transaction Management | 112 | Transaction Management |
| @@ -134,54 +132,41 @@ static inline void acpi_ec_write_data(struct acpi_ec *ec, u8 data) | |||
| 134 | outb(data, ec->data_addr); | 132 | outb(data, ec->data_addr); |
| 135 | } | 133 | } |
| 136 | 134 | ||
| 137 | static int acpi_ec_check_status(u8 status, u8 event) | 135 | static inline int acpi_ec_check_status(struct acpi_ec *ec, enum ec_event event) |
| 138 | { | 136 | { |
| 139 | switch (event) { | 137 | u8 status = acpi_ec_read_status(ec); |
| 140 | case ACPI_EC_EVENT_OBF_1: | 138 | |
| 139 | if (event == ACPI_EC_EVENT_OBF_1) { | ||
| 141 | if (status & ACPI_EC_FLAG_OBF) | 140 | if (status & ACPI_EC_FLAG_OBF) |
| 142 | return 1; | 141 | return 1; |
| 143 | break; | 142 | } else if (event == ACPI_EC_EVENT_IBF_0) { |
| 144 | case ACPI_EC_EVENT_IBF_0: | ||
| 145 | if (!(status & ACPI_EC_FLAG_IBF)) | 143 | if (!(status & ACPI_EC_FLAG_IBF)) |
| 146 | return 1; | 144 | return 1; |
| 147 | break; | ||
| 148 | default: | ||
| 149 | break; | ||
| 150 | } | 145 | } |
| 151 | 146 | ||
| 152 | return 0; | 147 | return 0; |
| 153 | } | 148 | } |
| 154 | 149 | ||
| 155 | static int acpi_ec_wait(struct acpi_ec *ec, u8 event) | 150 | static int acpi_ec_wait(struct acpi_ec *ec, enum ec_event event) |
| 156 | { | 151 | { |
| 157 | int i = (acpi_ec_mode == EC_POLL) ? ACPI_EC_UDELAY_COUNT : 0; | 152 | if (acpi_ec_mode == EC_POLL) { |
| 158 | long time_left; | 153 | unsigned long delay = jiffies + msecs_to_jiffies(ACPI_EC_DELAY); |
| 159 | 154 | while (time_before(jiffies, delay)) { | |
| 160 | ec->expect_event = event; | 155 | if (acpi_ec_check_status(ec, event)) |
| 161 | if (acpi_ec_check_status(acpi_ec_read_status(ec), event)) { | ||
| 162 | ec->expect_event = 0; | ||
| 163 | return 0; | ||
| 164 | } | ||
| 165 | |||
| 166 | do { | ||
| 167 | if (acpi_ec_mode == EC_POLL) { | ||
| 168 | udelay(ACPI_EC_UDELAY); | ||
| 169 | } else { | ||
| 170 | time_left = wait_event_timeout(ec->wait, | ||
| 171 | !ec->expect_event, | ||
| 172 | msecs_to_jiffies(ACPI_EC_DELAY)); | ||
| 173 | if (time_left > 0) { | ||
| 174 | ec->expect_event = 0; | ||
| 175 | return 0; | 156 | return 0; |
| 176 | } | ||
| 177 | } | 157 | } |
| 178 | if (acpi_ec_check_status(acpi_ec_read_status(ec), event)) { | 158 | } else { |
| 179 | ec->expect_event = 0; | 159 | if (wait_event_timeout(ec->wait, |
| 160 | acpi_ec_check_status(ec, event), | ||
| 161 | msecs_to_jiffies(ACPI_EC_DELAY)) || | ||
| 162 | acpi_ec_check_status(ec, event)) { | ||
| 180 | return 0; | 163 | return 0; |
| 164 | } else { | ||
| 165 | printk(KERN_ERR PREFIX "acpi_ec_wait timeout," | ||
| 166 | " status = %d, expect_event = %d\n", | ||
| 167 | acpi_ec_read_status(ec), event); | ||
| 181 | } | 168 | } |
| 182 | } while (--i > 0); | 169 | } |
| 183 | |||
| 184 | ec->expect_event = 0; | ||
| 185 | 170 | ||
| 186 | return -ETIME; | 171 | return -ETIME; |
| 187 | } | 172 | } |
| @@ -196,7 +181,6 @@ int acpi_ec_enter_burst_mode(struct acpi_ec *ec) | |||
| 196 | u8 tmp = 0; | 181 | u8 tmp = 0; |
| 197 | u8 status = 0; | 182 | u8 status = 0; |
| 198 | 183 | ||
| 199 | |||
| 200 | status = acpi_ec_read_status(ec); | 184 | status = acpi_ec_read_status(ec); |
| 201 | if (status != -EINVAL && !(status & ACPI_EC_FLAG_BURST)) { | 185 | if (status != -EINVAL && !(status & ACPI_EC_FLAG_BURST)) { |
| 202 | status = acpi_ec_wait(ec, ACPI_EC_EVENT_IBF_0); | 186 | status = acpi_ec_wait(ec, ACPI_EC_EVENT_IBF_0); |
| @@ -212,7 +196,7 @@ int acpi_ec_enter_burst_mode(struct acpi_ec *ec) | |||
| 212 | 196 | ||
| 213 | atomic_set(&ec->leaving_burst, 0); | 197 | atomic_set(&ec->leaving_burst, 0); |
| 214 | return 0; | 198 | return 0; |
| 215 | end: | 199 | end: |
| 216 | ACPI_EXCEPTION((AE_INFO, status, "EC wait, burst mode")); | 200 | ACPI_EXCEPTION((AE_INFO, status, "EC wait, burst mode")); |
| 217 | return -1; | 201 | return -1; |
| 218 | } | 202 | } |
| @@ -221,58 +205,68 @@ int acpi_ec_leave_burst_mode(struct acpi_ec *ec) | |||
| 221 | { | 205 | { |
| 222 | u8 status = 0; | 206 | u8 status = 0; |
| 223 | 207 | ||
| 224 | |||
| 225 | status = acpi_ec_read_status(ec); | 208 | status = acpi_ec_read_status(ec); |
| 226 | if (status != -EINVAL && (status & ACPI_EC_FLAG_BURST)){ | 209 | if (status != -EINVAL && (status & ACPI_EC_FLAG_BURST)) { |
| 227 | status = acpi_ec_wait(ec, ACPI_EC_EVENT_IBF_0); | 210 | status = acpi_ec_wait(ec, ACPI_EC_EVENT_IBF_0); |
| 228 | if(status) | 211 | if (status) |
| 229 | goto end; | 212 | goto end; |
| 230 | acpi_ec_write_cmd(ec, ACPI_EC_BURST_DISABLE); | 213 | acpi_ec_write_cmd(ec, ACPI_EC_BURST_DISABLE); |
| 231 | acpi_ec_wait(ec, ACPI_EC_EVENT_IBF_0); | 214 | acpi_ec_wait(ec, ACPI_EC_EVENT_IBF_0); |
| 232 | } | 215 | } |
| 233 | atomic_set(&ec->leaving_burst, 1); | 216 | atomic_set(&ec->leaving_burst, 1); |
| 234 | return 0; | 217 | return 0; |
| 235 | end: | 218 | end: |
| 236 | ACPI_EXCEPTION((AE_INFO, status, "EC leave burst mode")); | 219 | ACPI_EXCEPTION((AE_INFO, status, "EC leave burst mode")); |
| 237 | return -1; | 220 | return -1; |
| 238 | } | 221 | } |
| 239 | #endif /* ACPI_FUTURE_USAGE */ | 222 | #endif /* ACPI_FUTURE_USAGE */ |
| 240 | 223 | ||
| 241 | static int acpi_ec_transaction_unlocked(struct acpi_ec *ec, u8 command, | 224 | static int acpi_ec_transaction_unlocked(struct acpi_ec *ec, u8 command, |
| 242 | const u8 *wdata, unsigned wdata_len, | 225 | const u8 * wdata, unsigned wdata_len, |
| 243 | u8 *rdata, unsigned rdata_len) | 226 | u8 * rdata, unsigned rdata_len) |
| 244 | { | 227 | { |
| 245 | int result; | 228 | int result = 0; |
| 246 | 229 | ||
| 247 | acpi_ec_write_cmd(ec, command); | 230 | acpi_ec_write_cmd(ec, command); |
| 248 | 231 | ||
| 249 | for (; wdata_len > 0; wdata_len --) { | 232 | for (; wdata_len > 0; --wdata_len) { |
| 250 | result = acpi_ec_wait(ec, ACPI_EC_EVENT_IBF_0); | 233 | result = acpi_ec_wait(ec, ACPI_EC_EVENT_IBF_0); |
| 251 | if (result) | 234 | if (result) { |
| 252 | return result; | 235 | printk(KERN_ERR PREFIX |
| 236 | "write_cmd timeout, command = %d\n", command); | ||
| 237 | goto end; | ||
| 238 | } | ||
| 253 | acpi_ec_write_data(ec, *(wdata++)); | 239 | acpi_ec_write_data(ec, *(wdata++)); |
| 254 | } | 240 | } |
| 255 | 241 | ||
| 256 | if (command == ACPI_EC_COMMAND_WRITE) { | 242 | if (!rdata_len) { |
| 257 | result = acpi_ec_wait(ec, ACPI_EC_EVENT_IBF_0); | 243 | result = acpi_ec_wait(ec, ACPI_EC_EVENT_IBF_0); |
| 258 | if (result) | 244 | if (result) { |
| 259 | return result; | 245 | printk(KERN_ERR PREFIX |
| 246 | "finish-write timeout, command = %d\n", command); | ||
| 247 | goto end; | ||
| 248 | } | ||
| 249 | } else if (command == ACPI_EC_COMMAND_QUERY) { | ||
| 250 | atomic_set(&ec->query_pending, 0); | ||
| 260 | } | 251 | } |
| 261 | 252 | ||
| 262 | for (; rdata_len > 0; rdata_len --) { | 253 | for (; rdata_len > 0; --rdata_len) { |
| 263 | result = acpi_ec_wait(ec, ACPI_EC_EVENT_OBF_1); | 254 | result = acpi_ec_wait(ec, ACPI_EC_EVENT_OBF_1); |
| 264 | if (result) | 255 | if (result) { |
| 265 | return result; | 256 | printk(KERN_ERR PREFIX "read timeout, command = %d\n", |
| 257 | command); | ||
| 258 | goto end; | ||
| 259 | } | ||
| 266 | 260 | ||
| 267 | *(rdata++) = acpi_ec_read_data(ec); | 261 | *(rdata++) = acpi_ec_read_data(ec); |
| 268 | } | 262 | } |
| 269 | 263 | end: | |
| 270 | return 0; | 264 | return result; |
| 271 | } | 265 | } |
| 272 | 266 | ||
| 273 | static int acpi_ec_transaction(struct acpi_ec *ec, u8 command, | 267 | static int acpi_ec_transaction(struct acpi_ec *ec, u8 command, |
| 274 | const u8 *wdata, unsigned wdata_len, | 268 | const u8 * wdata, unsigned wdata_len, |
| 275 | u8 *rdata, unsigned rdata_len) | 269 | u8 * rdata, unsigned rdata_len) |
| 276 | { | 270 | { |
| 277 | int status; | 271 | int status; |
| 278 | u32 glk; | 272 | u32 glk; |
| @@ -280,36 +274,40 @@ static int acpi_ec_transaction(struct acpi_ec *ec, u8 command, | |||
| 280 | if (!ec || (wdata_len && !wdata) || (rdata_len && !rdata)) | 274 | if (!ec || (wdata_len && !wdata) || (rdata_len && !rdata)) |
| 281 | return -EINVAL; | 275 | return -EINVAL; |
| 282 | 276 | ||
| 283 | if (rdata) | 277 | if (rdata) |
| 284 | memset(rdata, 0, rdata_len); | 278 | memset(rdata, 0, rdata_len); |
| 285 | 279 | ||
| 280 | mutex_lock(&ec->lock); | ||
| 286 | if (ec->global_lock) { | 281 | if (ec->global_lock) { |
| 287 | status = acpi_acquire_global_lock(ACPI_EC_UDELAY_GLK, &glk); | 282 | status = acpi_acquire_global_lock(ACPI_EC_UDELAY_GLK, &glk); |
| 288 | if (ACPI_FAILURE(status)) | 283 | if (ACPI_FAILURE(status)) |
| 289 | return -ENODEV; | 284 | return -ENODEV; |
| 290 | } | 285 | } |
| 291 | down(&ec->sem); | 286 | |
| 287 | /* Make sure GPE is enabled before doing transaction */ | ||
| 288 | acpi_enable_gpe(NULL, ec->gpe, ACPI_NOT_ISR); | ||
| 292 | 289 | ||
| 293 | status = acpi_ec_wait(ec, ACPI_EC_EVENT_IBF_0); | 290 | status = acpi_ec_wait(ec, ACPI_EC_EVENT_IBF_0); |
| 294 | if (status) { | 291 | if (status) { |
| 295 | printk(KERN_DEBUG PREFIX "read EC, IB not empty\n"); | 292 | printk(KERN_DEBUG PREFIX |
| 293 | "input buffer is not empty, aborting transaction\n"); | ||
| 296 | goto end; | 294 | goto end; |
| 297 | } | 295 | } |
| 298 | 296 | ||
| 299 | status = acpi_ec_transaction_unlocked(ec, command, | 297 | status = acpi_ec_transaction_unlocked(ec, command, |
| 300 | wdata, wdata_len, | 298 | wdata, wdata_len, |
| 301 | rdata, rdata_len); | 299 | rdata, rdata_len); |
| 302 | 300 | ||
| 303 | end: | 301 | end: |
| 304 | up(&ec->sem); | ||
| 305 | 302 | ||
| 306 | if (ec->global_lock) | 303 | if (ec->global_lock) |
| 307 | acpi_release_global_lock(glk); | 304 | acpi_release_global_lock(glk); |
| 305 | mutex_unlock(&ec->lock); | ||
| 308 | 306 | ||
| 309 | return status; | 307 | return status; |
| 310 | } | 308 | } |
| 311 | 309 | ||
| 312 | static int acpi_ec_read(struct acpi_ec *ec, u8 address, u8 *data) | 310 | static int acpi_ec_read(struct acpi_ec *ec, u8 address, u8 * data) |
| 313 | { | 311 | { |
| 314 | int result; | 312 | int result; |
| 315 | u8 d; | 313 | u8 d; |
| @@ -322,15 +320,15 @@ static int acpi_ec_read(struct acpi_ec *ec, u8 address, u8 *data) | |||
| 322 | 320 | ||
| 323 | static int acpi_ec_write(struct acpi_ec *ec, u8 address, u8 data) | 321 | static int acpi_ec_write(struct acpi_ec *ec, u8 address, u8 data) |
| 324 | { | 322 | { |
| 325 | u8 wdata[2] = { address, data }; | 323 | u8 wdata[2] = { address, data }; |
| 326 | return acpi_ec_transaction(ec, ACPI_EC_COMMAND_WRITE, | 324 | return acpi_ec_transaction(ec, ACPI_EC_COMMAND_WRITE, |
| 327 | wdata, 2, NULL, 0); | 325 | wdata, 2, NULL, 0); |
| 328 | } | 326 | } |
| 329 | 327 | ||
| 330 | /* | 328 | /* |
| 331 | * Externally callable EC access functions. For now, assume 1 EC only | 329 | * Externally callable EC access functions. For now, assume 1 EC only |
| 332 | */ | 330 | */ |
| 333 | int ec_read(u8 addr, u8 *val) | 331 | int ec_read(u8 addr, u8 * val) |
| 334 | { | 332 | { |
| 335 | struct acpi_ec *ec; | 333 | struct acpi_ec *ec; |
| 336 | int err; | 334 | int err; |
| @@ -369,9 +367,9 @@ int ec_write(u8 addr, u8 val) | |||
| 369 | 367 | ||
| 370 | EXPORT_SYMBOL(ec_write); | 368 | EXPORT_SYMBOL(ec_write); |
| 371 | 369 | ||
| 372 | extern int ec_transaction(u8 command, | 370 | int ec_transaction(u8 command, |
| 373 | const u8 *wdata, unsigned wdata_len, | 371 | const u8 * wdata, unsigned wdata_len, |
| 374 | u8 *rdata, unsigned rdata_len) | 372 | u8 * rdata, unsigned rdata_len) |
| 375 | { | 373 | { |
| 376 | struct acpi_ec *ec; | 374 | struct acpi_ec *ec; |
| 377 | 375 | ||
| @@ -386,65 +384,49 @@ extern int ec_transaction(u8 command, | |||
| 386 | 384 | ||
| 387 | EXPORT_SYMBOL(ec_transaction); | 385 | EXPORT_SYMBOL(ec_transaction); |
| 388 | 386 | ||
| 389 | static int acpi_ec_query(struct acpi_ec *ec, u8 *data) | 387 | static int acpi_ec_query(struct acpi_ec *ec, u8 * data) |
| 390 | { | 388 | { |
| 391 | int result; | 389 | int result; |
| 392 | u8 d; | 390 | u8 d; |
| 393 | 391 | ||
| 394 | if (!ec || !data) | 392 | if (!ec || !data) |
| 395 | return -EINVAL; | 393 | return -EINVAL; |
| 396 | 394 | ||
| 397 | /* | 395 | /* |
| 398 | * Query the EC to find out which _Qxx method we need to evaluate. | 396 | * Query the EC to find out which _Qxx method we need to evaluate. |
| 399 | * Note that successful completion of the query causes the ACPI_EC_SCI | 397 | * Note that successful completion of the query causes the ACPI_EC_SCI |
| 400 | * bit to be cleared (and thus clearing the interrupt source). | 398 | * bit to be cleared (and thus clearing the interrupt source). |
| 401 | */ | 399 | */ |
| 402 | 400 | ||
| 403 | result = acpi_ec_transaction(ec, ACPI_EC_COMMAND_QUERY, NULL, 0, &d, 1); | 401 | result = acpi_ec_transaction(ec, ACPI_EC_COMMAND_QUERY, NULL, 0, &d, 1); |
| 404 | if (result) | 402 | if (result) |
| 405 | return result; | 403 | return result; |
| 406 | 404 | ||
| 407 | if (!d) | 405 | if (!d) |
| 408 | return -ENODATA; | 406 | return -ENODATA; |
| 409 | 407 | ||
| 410 | *data = d; | 408 | *data = d; |
| 411 | return 0; | 409 | return 0; |
| 412 | } | 410 | } |
| 413 | 411 | ||
| 414 | /* -------------------------------------------------------------------------- | 412 | /* -------------------------------------------------------------------------- |
| 415 | Event Management | 413 | Event Management |
| 416 | -------------------------------------------------------------------------- */ | 414 | -------------------------------------------------------------------------- */ |
| 417 | 415 | ||
| 418 | struct acpi_ec_query_data { | ||
| 419 | acpi_handle handle; | ||
| 420 | u8 data; | ||
| 421 | }; | ||
| 422 | |||
| 423 | static void acpi_ec_gpe_query(void *ec_cxt) | 416 | static void acpi_ec_gpe_query(void *ec_cxt) |
| 424 | { | 417 | { |
| 425 | struct acpi_ec *ec = (struct acpi_ec *)ec_cxt; | 418 | struct acpi_ec *ec = (struct acpi_ec *)ec_cxt; |
| 426 | u8 value = 0; | 419 | u8 value = 0; |
| 427 | static char object_name[8]; | 420 | char object_name[8]; |
| 428 | 421 | ||
| 429 | if (!ec) | 422 | if (!ec || acpi_ec_query(ec, &value)) |
| 430 | goto end; | 423 | return; |
| 431 | |||
| 432 | value = acpi_ec_read_status(ec); | ||
| 433 | |||
| 434 | if (!(value & ACPI_EC_FLAG_SCI)) | ||
| 435 | goto end; | ||
| 436 | |||
| 437 | if (acpi_ec_query(ec, &value)) | ||
| 438 | goto end; | ||
| 439 | 424 | ||
| 440 | snprintf(object_name, 8, "_Q%2.2X", value); | 425 | snprintf(object_name, 8, "_Q%2.2X", value); |
| 441 | 426 | ||
| 442 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Evaluating %s", object_name)); | 427 | printk(KERN_INFO PREFIX "evaluating %s\n", object_name); |
| 443 | 428 | ||
| 444 | acpi_evaluate_object(ec->handle, object_name, NULL, NULL); | 429 | acpi_evaluate_object(ec->handle, object_name, NULL, NULL); |
| 445 | |||
| 446 | end: | ||
| 447 | acpi_enable_gpe(NULL, ec->gpe_bit, ACPI_NOT_ISR); | ||
| 448 | } | 430 | } |
| 449 | 431 | ||
| 450 | static u32 acpi_ec_gpe_handler(void *data) | 432 | static u32 acpi_ec_gpe_handler(void *data) |
| @@ -453,22 +435,18 @@ static u32 acpi_ec_gpe_handler(void *data) | |||
| 453 | u8 value; | 435 | u8 value; |
| 454 | struct acpi_ec *ec = (struct acpi_ec *)data; | 436 | struct acpi_ec *ec = (struct acpi_ec *)data; |
| 455 | 437 | ||
| 456 | acpi_clear_gpe(NULL, ec->gpe_bit, ACPI_ISR); | ||
| 457 | value = acpi_ec_read_status(ec); | ||
| 458 | |||
| 459 | if (acpi_ec_mode == EC_INTR) { | 438 | if (acpi_ec_mode == EC_INTR) { |
| 460 | if (acpi_ec_check_status(value, ec->expect_event)) { | 439 | wake_up(&ec->wait); |
| 461 | ec->expect_event = 0; | ||
| 462 | wake_up(&ec->wait); | ||
| 463 | } | ||
| 464 | } | 440 | } |
| 465 | 441 | ||
| 466 | if (value & ACPI_EC_FLAG_SCI) { | 442 | value = acpi_ec_read_status(ec); |
| 467 | status = acpi_os_execute(OSL_EC_BURST_HANDLER, acpi_ec_gpe_query, ec); | 443 | if ((value & ACPI_EC_FLAG_SCI) && !atomic_read(&ec->query_pending)) { |
| 468 | return status == AE_OK ? | 444 | atomic_set(&ec->query_pending, 1); |
| 469 | ACPI_INTERRUPT_HANDLED : ACPI_INTERRUPT_NOT_HANDLED; | 445 | status = |
| 446 | acpi_os_execute(OSL_EC_BURST_HANDLER, acpi_ec_gpe_query, | ||
| 447 | ec); | ||
| 470 | } | 448 | } |
| 471 | acpi_enable_gpe(NULL, ec->gpe_bit, ACPI_ISR); | 449 | |
| 472 | return status == AE_OK ? | 450 | return status == AE_OK ? |
| 473 | ACPI_INTERRUPT_HANDLED : ACPI_INTERRUPT_NOT_HANDLED; | 451 | ACPI_INTERRUPT_HANDLED : ACPI_INTERRUPT_NOT_HANDLED; |
| 474 | } | 452 | } |
| @@ -504,7 +482,6 @@ acpi_ec_space_handler(u32 function, | |||
| 504 | acpi_integer f_v = 0; | 482 | acpi_integer f_v = 0; |
| 505 | int i = 0; | 483 | int i = 0; |
| 506 | 484 | ||
| 507 | |||
| 508 | if ((address > 0xFF) || !value || !handler_context) | 485 | if ((address > 0xFF) || !value || !handler_context) |
| 509 | return AE_BAD_PARAMETER; | 486 | return AE_BAD_PARAMETER; |
| 510 | 487 | ||
| @@ -518,7 +495,7 @@ acpi_ec_space_handler(u32 function, | |||
| 518 | switch (function) { | 495 | switch (function) { |
| 519 | case ACPI_READ: | 496 | case ACPI_READ: |
| 520 | temp = 0; | 497 | temp = 0; |
| 521 | result = acpi_ec_read(ec, (u8) address, (u8 *) &temp); | 498 | result = acpi_ec_read(ec, (u8) address, (u8 *) & temp); |
| 522 | break; | 499 | break; |
| 523 | case ACPI_WRITE: | 500 | case ACPI_WRITE: |
| 524 | result = acpi_ec_write(ec, (u8) address, (u8) temp); | 501 | result = acpi_ec_write(ec, (u8) address, (u8) temp); |
| @@ -571,18 +548,15 @@ static int acpi_ec_read_info(struct seq_file *seq, void *offset) | |||
| 571 | { | 548 | { |
| 572 | struct acpi_ec *ec = (struct acpi_ec *)seq->private; | 549 | struct acpi_ec *ec = (struct acpi_ec *)seq->private; |
| 573 | 550 | ||
| 574 | |||
| 575 | if (!ec) | 551 | if (!ec) |
| 576 | goto end; | 552 | goto end; |
| 577 | 553 | ||
| 578 | seq_printf(seq, "gpe bit: 0x%02x\n", | 554 | seq_printf(seq, "gpe: 0x%02x\n", (u32) ec->gpe); |
| 579 | (u32) ec->gpe_bit); | ||
| 580 | seq_printf(seq, "ports: 0x%02x, 0x%02x\n", | 555 | seq_printf(seq, "ports: 0x%02x, 0x%02x\n", |
| 581 | (u32) ec->command_addr, | 556 | (u32) ec->command_addr, (u32) ec->data_addr); |
| 582 | (u32) ec->data_addr); | ||
| 583 | seq_printf(seq, "use global lock: %s\n", | 557 | seq_printf(seq, "use global lock: %s\n", |
| 584 | ec->global_lock ? "yes" : "no"); | 558 | ec->global_lock ? "yes" : "no"); |
| 585 | acpi_enable_gpe(NULL, ec->gpe_bit, ACPI_NOT_ISR); | 559 | acpi_enable_gpe(NULL, ec->gpe, ACPI_NOT_ISR); |
| 586 | 560 | ||
| 587 | end: | 561 | end: |
| 588 | return 0; | 562 | return 0; |
| @@ -605,7 +579,6 @@ static int acpi_ec_add_fs(struct acpi_device *device) | |||
| 605 | { | 579 | { |
| 606 | struct proc_dir_entry *entry = NULL; | 580 | struct proc_dir_entry *entry = NULL; |
| 607 | 581 | ||
| 608 | |||
| 609 | if (!acpi_device_dir(device)) { | 582 | if (!acpi_device_dir(device)) { |
| 610 | acpi_device_dir(device) = proc_mkdir(acpi_device_bid(device), | 583 | acpi_device_dir(device) = proc_mkdir(acpi_device_bid(device), |
| 611 | acpi_ec_dir); | 584 | acpi_ec_dir); |
| @@ -648,18 +621,17 @@ static int acpi_ec_add(struct acpi_device *device) | |||
| 648 | acpi_status status = AE_OK; | 621 | acpi_status status = AE_OK; |
| 649 | struct acpi_ec *ec = NULL; | 622 | struct acpi_ec *ec = NULL; |
| 650 | 623 | ||
| 651 | |||
| 652 | if (!device) | 624 | if (!device) |
| 653 | return -EINVAL; | 625 | return -EINVAL; |
| 654 | 626 | ||
| 655 | ec = kmalloc(sizeof(struct acpi_ec), GFP_KERNEL); | 627 | ec = kzalloc(sizeof(struct acpi_ec), GFP_KERNEL); |
| 656 | if (!ec) | 628 | if (!ec) |
| 657 | return -ENOMEM; | 629 | return -ENOMEM; |
| 658 | memset(ec, 0, sizeof(struct acpi_ec)); | ||
| 659 | 630 | ||
| 660 | ec->handle = device->handle; | 631 | ec->handle = device->handle; |
| 661 | ec->uid = -1; | 632 | ec->uid = -1; |
| 662 | init_MUTEX(&ec->sem); | 633 | mutex_init(&ec->lock); |
| 634 | atomic_set(&ec->query_pending, 0); | ||
| 663 | if (acpi_ec_mode == EC_INTR) { | 635 | if (acpi_ec_mode == EC_INTR) { |
| 664 | atomic_set(&ec->leaving_burst, 1); | 636 | atomic_set(&ec->leaving_burst, 1); |
| 665 | init_waitqueue_head(&ec->wait); | 637 | init_waitqueue_head(&ec->wait); |
| @@ -669,8 +641,7 @@ static int acpi_ec_add(struct acpi_device *device) | |||
| 669 | acpi_driver_data(device) = ec; | 641 | acpi_driver_data(device) = ec; |
| 670 | 642 | ||
| 671 | /* Use the global lock for all EC transactions? */ | 643 | /* Use the global lock for all EC transactions? */ |
| 672 | acpi_evaluate_integer(ec->handle, "_GLK", NULL, | 644 | acpi_evaluate_integer(ec->handle, "_GLK", NULL, &ec->global_lock); |
| 673 | &ec->global_lock); | ||
| 674 | 645 | ||
| 675 | /* XXX we don't test uids, because on some boxes ecdt uid = 0, see: | 646 | /* XXX we don't test uids, because on some boxes ecdt uid = 0, see: |
| 676 | http://bugzilla.kernel.org/show_bug.cgi?id=6111 */ | 647 | http://bugzilla.kernel.org/show_bug.cgi?id=6111 */ |
| @@ -679,7 +650,7 @@ static int acpi_ec_add(struct acpi_device *device) | |||
| 679 | ACPI_ADR_SPACE_EC, | 650 | ACPI_ADR_SPACE_EC, |
| 680 | &acpi_ec_space_handler); | 651 | &acpi_ec_space_handler); |
| 681 | 652 | ||
| 682 | acpi_remove_gpe_handler(NULL, ec_ecdt->gpe_bit, | 653 | acpi_remove_gpe_handler(NULL, ec_ecdt->gpe, |
| 683 | &acpi_ec_gpe_handler); | 654 | &acpi_ec_gpe_handler); |
| 684 | 655 | ||
| 685 | kfree(ec_ecdt); | 656 | kfree(ec_ecdt); |
| @@ -687,11 +658,10 @@ static int acpi_ec_add(struct acpi_device *device) | |||
| 687 | 658 | ||
| 688 | /* Get GPE bit assignment (EC events). */ | 659 | /* Get GPE bit assignment (EC events). */ |
| 689 | /* TODO: Add support for _GPE returning a package */ | 660 | /* TODO: Add support for _GPE returning a package */ |
| 690 | status = | 661 | status = acpi_evaluate_integer(ec->handle, "_GPE", NULL, &ec->gpe); |
| 691 | acpi_evaluate_integer(ec->handle, "_GPE", NULL, | ||
| 692 | &ec->gpe_bit); | ||
| 693 | if (ACPI_FAILURE(status)) { | 662 | if (ACPI_FAILURE(status)) { |
| 694 | ACPI_EXCEPTION((AE_INFO, status, "Obtaining GPE bit assignment")); | 663 | ACPI_EXCEPTION((AE_INFO, status, |
| 664 | "Obtaining GPE bit assignment")); | ||
| 695 | result = -ENODEV; | 665 | result = -ENODEV; |
| 696 | goto end; | 666 | goto end; |
| 697 | } | 667 | } |
| @@ -701,13 +671,13 @@ static int acpi_ec_add(struct acpi_device *device) | |||
| 701 | goto end; | 671 | goto end; |
| 702 | 672 | ||
| 703 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, "%s [%s] (gpe %d) interrupt mode.", | 673 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, "%s [%s] (gpe %d) interrupt mode.", |
| 704 | acpi_device_name(device), acpi_device_bid(device), | 674 | acpi_device_name(device), acpi_device_bid(device), |
| 705 | (u32) ec->gpe_bit)); | 675 | (u32) ec->gpe)); |
| 706 | 676 | ||
| 707 | if (!first_ec) | 677 | if (!first_ec) |
| 708 | first_ec = device; | 678 | first_ec = device; |
| 709 | 679 | ||
| 710 | end: | 680 | end: |
| 711 | if (result) | 681 | if (result) |
| 712 | kfree(ec); | 682 | kfree(ec); |
| 713 | 683 | ||
| @@ -718,7 +688,6 @@ static int acpi_ec_remove(struct acpi_device *device, int type) | |||
| 718 | { | 688 | { |
| 719 | struct acpi_ec *ec = NULL; | 689 | struct acpi_ec *ec = NULL; |
| 720 | 690 | ||
| 721 | |||
| 722 | if (!device) | 691 | if (!device) |
| 723 | return -EINVAL; | 692 | return -EINVAL; |
| 724 | 693 | ||
| @@ -761,7 +730,6 @@ static int acpi_ec_start(struct acpi_device *device) | |||
| 761 | acpi_status status = AE_OK; | 730 | acpi_status status = AE_OK; |
| 762 | struct acpi_ec *ec = NULL; | 731 | struct acpi_ec *ec = NULL; |
| 763 | 732 | ||
| 764 | |||
| 765 | if (!device) | 733 | if (!device) |
| 766 | return -EINVAL; | 734 | return -EINVAL; |
| 767 | 735 | ||
| @@ -782,27 +750,26 @@ static int acpi_ec_start(struct acpi_device *device) | |||
| 782 | } | 750 | } |
| 783 | 751 | ||
| 784 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, "gpe=0x%02lx, ports=0x%2lx,0x%2lx", | 752 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, "gpe=0x%02lx, ports=0x%2lx,0x%2lx", |
| 785 | ec->gpe_bit, ec->command_addr, ec->data_addr)); | 753 | ec->gpe, ec->command_addr, ec->data_addr)); |
| 786 | 754 | ||
| 787 | /* | 755 | /* |
| 788 | * Install GPE handler | 756 | * Install GPE handler |
| 789 | */ | 757 | */ |
| 790 | status = acpi_install_gpe_handler(NULL, ec->gpe_bit, | 758 | status = acpi_install_gpe_handler(NULL, ec->gpe, |
| 791 | ACPI_GPE_EDGE_TRIGGERED, | 759 | ACPI_GPE_EDGE_TRIGGERED, |
| 792 | &acpi_ec_gpe_handler, ec); | 760 | &acpi_ec_gpe_handler, ec); |
| 793 | if (ACPI_FAILURE(status)) { | 761 | if (ACPI_FAILURE(status)) { |
| 794 | return -ENODEV; | 762 | return -ENODEV; |
| 795 | } | 763 | } |
| 796 | acpi_set_gpe_type(NULL, ec->gpe_bit, ACPI_GPE_TYPE_RUNTIME); | 764 | acpi_set_gpe_type(NULL, ec->gpe, ACPI_GPE_TYPE_RUNTIME); |
| 797 | acpi_enable_gpe(NULL, ec->gpe_bit, ACPI_NOT_ISR); | 765 | acpi_enable_gpe(NULL, ec->gpe, ACPI_NOT_ISR); |
| 798 | 766 | ||
| 799 | status = acpi_install_address_space_handler(ec->handle, | 767 | status = acpi_install_address_space_handler(ec->handle, |
| 800 | ACPI_ADR_SPACE_EC, | 768 | ACPI_ADR_SPACE_EC, |
| 801 | &acpi_ec_space_handler, | 769 | &acpi_ec_space_handler, |
| 802 | &acpi_ec_space_setup, ec); | 770 | &acpi_ec_space_setup, ec); |
| 803 | if (ACPI_FAILURE(status)) { | 771 | if (ACPI_FAILURE(status)) { |
| 804 | acpi_remove_gpe_handler(NULL, ec->gpe_bit, | 772 | acpi_remove_gpe_handler(NULL, ec->gpe, &acpi_ec_gpe_handler); |
| 805 | &acpi_ec_gpe_handler); | ||
| 806 | return -ENODEV; | 773 | return -ENODEV; |
| 807 | } | 774 | } |
| 808 | 775 | ||
| @@ -814,7 +781,6 @@ static int acpi_ec_stop(struct acpi_device *device, int type) | |||
| 814 | acpi_status status = AE_OK; | 781 | acpi_status status = AE_OK; |
| 815 | struct acpi_ec *ec = NULL; | 782 | struct acpi_ec *ec = NULL; |
| 816 | 783 | ||
| 817 | |||
| 818 | if (!device) | 784 | if (!device) |
| 819 | return -EINVAL; | 785 | return -EINVAL; |
| 820 | 786 | ||
| @@ -826,9 +792,7 @@ static int acpi_ec_stop(struct acpi_device *device, int type) | |||
| 826 | if (ACPI_FAILURE(status)) | 792 | if (ACPI_FAILURE(status)) |
| 827 | return -ENODEV; | 793 | return -ENODEV; |
| 828 | 794 | ||
| 829 | status = | 795 | status = acpi_remove_gpe_handler(NULL, ec->gpe, &acpi_ec_gpe_handler); |
| 830 | acpi_remove_gpe_handler(NULL, ec->gpe_bit, | ||
| 831 | &acpi_ec_gpe_handler); | ||
| 832 | if (ACPI_FAILURE(status)) | 796 | if (ACPI_FAILURE(status)) |
| 833 | return -ENODEV; | 797 | return -ENODEV; |
| 834 | 798 | ||
| @@ -841,7 +805,7 @@ acpi_fake_ecdt_callback(acpi_handle handle, | |||
| 841 | { | 805 | { |
| 842 | acpi_status status; | 806 | acpi_status status; |
| 843 | 807 | ||
| 844 | init_MUTEX(&ec_ecdt->sem); | 808 | mutex_init(&ec_ecdt->lock); |
| 845 | if (acpi_ec_mode == EC_INTR) { | 809 | if (acpi_ec_mode == EC_INTR) { |
| 846 | init_waitqueue_head(&ec_ecdt->wait); | 810 | init_waitqueue_head(&ec_ecdt->wait); |
| 847 | } | 811 | } |
| @@ -853,16 +817,15 @@ acpi_fake_ecdt_callback(acpi_handle handle, | |||
| 853 | ec_ecdt->uid = -1; | 817 | ec_ecdt->uid = -1; |
| 854 | acpi_evaluate_integer(handle, "_UID", NULL, &ec_ecdt->uid); | 818 | acpi_evaluate_integer(handle, "_UID", NULL, &ec_ecdt->uid); |
| 855 | 819 | ||
| 856 | status = | 820 | status = acpi_evaluate_integer(handle, "_GPE", NULL, &ec_ecdt->gpe); |
| 857 | acpi_evaluate_integer(handle, "_GPE", NULL, | ||
| 858 | &ec_ecdt->gpe_bit); | ||
| 859 | if (ACPI_FAILURE(status)) | 821 | if (ACPI_FAILURE(status)) |
| 860 | return status; | 822 | return status; |
| 861 | ec_ecdt->global_lock = TRUE; | 823 | ec_ecdt->global_lock = TRUE; |
| 862 | ec_ecdt->handle = handle; | 824 | ec_ecdt->handle = handle; |
| 863 | 825 | ||
| 864 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, "GPE=0x%02lx, ports=0x%2lx, 0x%2lx", | 826 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, "GPE=0x%02lx, ports=0x%2lx, 0x%2lx", |
| 865 | ec_ecdt->gpe_bit, ec_ecdt->command_addr, ec_ecdt->data_addr)); | 827 | ec_ecdt->gpe, ec_ecdt->command_addr, |
| 828 | ec_ecdt->data_addr)); | ||
| 866 | 829 | ||
| 867 | return AE_CTRL_TERMINATE; | 830 | return AE_CTRL_TERMINATE; |
| 868 | } | 831 | } |
| @@ -884,12 +847,11 @@ static int __init acpi_ec_fake_ecdt(void) | |||
| 884 | 847 | ||
| 885 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Try to make an fake ECDT")); | 848 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Try to make an fake ECDT")); |
| 886 | 849 | ||
| 887 | ec_ecdt = kmalloc(sizeof(struct acpi_ec), GFP_KERNEL); | 850 | ec_ecdt = kzalloc(sizeof(struct acpi_ec), GFP_KERNEL); |
| 888 | if (!ec_ecdt) { | 851 | if (!ec_ecdt) { |
| 889 | ret = -ENOMEM; | 852 | ret = -ENOMEM; |
| 890 | goto error; | 853 | goto error; |
| 891 | } | 854 | } |
| 892 | memset(ec_ecdt, 0, sizeof(struct acpi_ec)); | ||
| 893 | 855 | ||
| 894 | status = acpi_get_devices(ACPI_EC_HID, | 856 | status = acpi_get_devices(ACPI_EC_HID, |
| 895 | acpi_fake_ecdt_callback, NULL, NULL); | 857 | acpi_fake_ecdt_callback, NULL, NULL); |
| @@ -901,7 +863,7 @@ static int __init acpi_ec_fake_ecdt(void) | |||
| 901 | goto error; | 863 | goto error; |
| 902 | } | 864 | } |
| 903 | return 0; | 865 | return 0; |
| 904 | error: | 866 | error: |
| 905 | return ret; | 867 | return ret; |
| 906 | } | 868 | } |
| 907 | 869 | ||
| @@ -921,30 +883,28 @@ static int __init acpi_ec_get_real_ecdt(void) | |||
| 921 | /* | 883 | /* |
| 922 | * Generate a temporary ec context to use until the namespace is scanned | 884 | * Generate a temporary ec context to use until the namespace is scanned |
| 923 | */ | 885 | */ |
| 924 | ec_ecdt = kmalloc(sizeof(struct acpi_ec), GFP_KERNEL); | 886 | ec_ecdt = kzalloc(sizeof(struct acpi_ec), GFP_KERNEL); |
| 925 | if (!ec_ecdt) | 887 | if (!ec_ecdt) |
| 926 | return -ENOMEM; | 888 | return -ENOMEM; |
| 927 | memset(ec_ecdt, 0, sizeof(struct acpi_ec)); | ||
| 928 | 889 | ||
| 929 | init_MUTEX(&ec_ecdt->sem); | 890 | mutex_init(&ec_ecdt->lock); |
| 930 | if (acpi_ec_mode == EC_INTR) { | 891 | if (acpi_ec_mode == EC_INTR) { |
| 931 | init_waitqueue_head(&ec_ecdt->wait); | 892 | init_waitqueue_head(&ec_ecdt->wait); |
| 932 | } | 893 | } |
| 933 | ec_ecdt->command_addr = ecdt_ptr->ec_control.address; | 894 | ec_ecdt->command_addr = ecdt_ptr->ec_control.address; |
| 934 | ec_ecdt->data_addr = ecdt_ptr->ec_data.address; | 895 | ec_ecdt->data_addr = ecdt_ptr->ec_data.address; |
| 935 | ec_ecdt->gpe_bit = ecdt_ptr->gpe_bit; | 896 | ec_ecdt->gpe = ecdt_ptr->gpe_bit; |
| 936 | /* use the GL just to be safe */ | 897 | /* use the GL just to be safe */ |
| 937 | ec_ecdt->global_lock = TRUE; | 898 | ec_ecdt->global_lock = TRUE; |
| 938 | ec_ecdt->uid = ecdt_ptr->uid; | 899 | ec_ecdt->uid = ecdt_ptr->uid; |
| 939 | 900 | ||
| 940 | status = | 901 | status = acpi_get_handle(NULL, ecdt_ptr->ec_id, &ec_ecdt->handle); |
| 941 | acpi_get_handle(NULL, ecdt_ptr->ec_id, &ec_ecdt->handle); | ||
| 942 | if (ACPI_FAILURE(status)) { | 902 | if (ACPI_FAILURE(status)) { |
| 943 | goto error; | 903 | goto error; |
| 944 | } | 904 | } |
| 945 | 905 | ||
| 946 | return 0; | 906 | return 0; |
| 947 | error: | 907 | error: |
| 948 | ACPI_EXCEPTION((AE_INFO, status, "Could not use ECDT")); | 908 | ACPI_EXCEPTION((AE_INFO, status, "Could not use ECDT")); |
| 949 | kfree(ec_ecdt); | 909 | kfree(ec_ecdt); |
| 950 | ec_ecdt = NULL; | 910 | ec_ecdt = NULL; |
| @@ -970,14 +930,14 @@ int __init acpi_ec_ecdt_probe(void) | |||
| 970 | /* | 930 | /* |
| 971 | * Install GPE handler | 931 | * Install GPE handler |
| 972 | */ | 932 | */ |
| 973 | status = acpi_install_gpe_handler(NULL, ec_ecdt->gpe_bit, | 933 | status = acpi_install_gpe_handler(NULL, ec_ecdt->gpe, |
| 974 | ACPI_GPE_EDGE_TRIGGERED, | 934 | ACPI_GPE_EDGE_TRIGGERED, |
| 975 | &acpi_ec_gpe_handler, ec_ecdt); | 935 | &acpi_ec_gpe_handler, ec_ecdt); |
| 976 | if (ACPI_FAILURE(status)) { | 936 | if (ACPI_FAILURE(status)) { |
| 977 | goto error; | 937 | goto error; |
| 978 | } | 938 | } |
| 979 | acpi_set_gpe_type(NULL, ec_ecdt->gpe_bit, ACPI_GPE_TYPE_RUNTIME); | 939 | acpi_set_gpe_type(NULL, ec_ecdt->gpe, ACPI_GPE_TYPE_RUNTIME); |
| 980 | acpi_enable_gpe(NULL, ec_ecdt->gpe_bit, ACPI_NOT_ISR); | 940 | acpi_enable_gpe(NULL, ec_ecdt->gpe, ACPI_NOT_ISR); |
| 981 | 941 | ||
| 982 | status = acpi_install_address_space_handler(ACPI_ROOT_OBJECT, | 942 | status = acpi_install_address_space_handler(ACPI_ROOT_OBJECT, |
| 983 | ACPI_ADR_SPACE_EC, | 943 | ACPI_ADR_SPACE_EC, |
| @@ -985,7 +945,7 @@ int __init acpi_ec_ecdt_probe(void) | |||
| 985 | &acpi_ec_space_setup, | 945 | &acpi_ec_space_setup, |
| 986 | ec_ecdt); | 946 | ec_ecdt); |
| 987 | if (ACPI_FAILURE(status)) { | 947 | if (ACPI_FAILURE(status)) { |
| 988 | acpi_remove_gpe_handler(NULL, ec_ecdt->gpe_bit, | 948 | acpi_remove_gpe_handler(NULL, ec_ecdt->gpe, |
| 989 | &acpi_ec_gpe_handler); | 949 | &acpi_ec_gpe_handler); |
| 990 | goto error; | 950 | goto error; |
| 991 | } | 951 | } |
| @@ -1004,7 +964,6 @@ static int __init acpi_ec_init(void) | |||
| 1004 | { | 964 | { |
| 1005 | int result = 0; | 965 | int result = 0; |
| 1006 | 966 | ||
| 1007 | |||
| 1008 | if (acpi_disabled) | 967 | if (acpi_disabled) |
| 1009 | return 0; | 968 | return 0; |
| 1010 | 969 | ||
| @@ -1057,7 +1016,8 @@ static int __init acpi_ec_set_intr_mode(char *str) | |||
| 1057 | acpi_ec_mode = EC_POLL; | 1016 | acpi_ec_mode = EC_POLL; |
| 1058 | } | 1017 | } |
| 1059 | acpi_ec_driver.ops.add = acpi_ec_add; | 1018 | acpi_ec_driver.ops.add = acpi_ec_add; |
| 1060 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, "EC %s mode.\n", intr ? "interrupt" : "polling")); | 1019 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, "EC %s mode.\n", |
| 1020 | intr ? "interrupt" : "polling")); | ||
| 1061 | 1021 | ||
| 1062 | return 1; | 1022 | return 1; |
| 1063 | } | 1023 | } |
diff --git a/drivers/acpi/events/evmisc.c b/drivers/acpi/events/evmisc.c index ee2a10bf9077..bf63edc6608d 100644 --- a/drivers/acpi/events/evmisc.c +++ b/drivers/acpi/events/evmisc.c | |||
| @@ -331,7 +331,6 @@ static void ACPI_SYSTEM_XFACE acpi_ev_global_lock_thread(void *context) | |||
| 331 | static u32 acpi_ev_global_lock_handler(void *context) | 331 | static u32 acpi_ev_global_lock_handler(void *context) |
| 332 | { | 332 | { |
| 333 | u8 acquired = FALSE; | 333 | u8 acquired = FALSE; |
| 334 | acpi_status status; | ||
| 335 | 334 | ||
| 336 | /* | 335 | /* |
| 337 | * Attempt to get the lock | 336 | * Attempt to get the lock |
diff --git a/drivers/acpi/executer/exmutex.c b/drivers/acpi/executer/exmutex.c index 3a39c2e8e104..bf90f04f2c60 100644 --- a/drivers/acpi/executer/exmutex.c +++ b/drivers/acpi/executer/exmutex.c | |||
| @@ -266,10 +266,10 @@ acpi_ex_release_mutex(union acpi_operand_object *obj_desc, | |||
| 266 | walk_state->thread->thread_id) | 266 | walk_state->thread->thread_id) |
| 267 | && (obj_desc->mutex.os_mutex != ACPI_GLOBAL_LOCK)) { | 267 | && (obj_desc->mutex.os_mutex != ACPI_GLOBAL_LOCK)) { |
| 268 | ACPI_ERROR((AE_INFO, | 268 | ACPI_ERROR((AE_INFO, |
| 269 | "Thread %X cannot release Mutex [%4.4s] acquired by thread %X", | 269 | "Thread %lX cannot release Mutex [%4.4s] acquired by thread %lX", |
| 270 | (u32) walk_state->thread->thread_id, | 270 | (unsigned long)walk_state->thread->thread_id, |
| 271 | acpi_ut_get_node_name(obj_desc->mutex.node), | 271 | acpi_ut_get_node_name(obj_desc->mutex.node), |
| 272 | (u32) obj_desc->mutex.owner_thread->thread_id)); | 272 | (unsigned long)obj_desc->mutex.owner_thread->thread_id)); |
| 273 | return_ACPI_STATUS(AE_AML_NOT_OWNER); | 273 | return_ACPI_STATUS(AE_AML_NOT_OWNER); |
| 274 | } | 274 | } |
| 275 | 275 | ||
diff --git a/drivers/acpi/fan.c b/drivers/acpi/fan.c index 045c89477e59..f305a826ca2d 100644 --- a/drivers/acpi/fan.c +++ b/drivers/acpi/fan.c | |||
| @@ -99,8 +99,8 @@ acpi_fan_write_state(struct file *file, const char __user * buffer, | |||
| 99 | size_t count, loff_t * ppos) | 99 | size_t count, loff_t * ppos) |
| 100 | { | 100 | { |
| 101 | int result = 0; | 101 | int result = 0; |
| 102 | struct seq_file *m = (struct seq_file *)file->private_data; | 102 | struct seq_file *m = file->private_data; |
| 103 | struct acpi_fan *fan = (struct acpi_fan *)m->private; | 103 | struct acpi_fan *fan = m->private; |
| 104 | char state_string[12] = { '\0' }; | 104 | char state_string[12] = { '\0' }; |
| 105 | 105 | ||
| 106 | 106 | ||
| @@ -186,10 +186,9 @@ static int acpi_fan_add(struct acpi_device *device) | |||
| 186 | if (!device) | 186 | if (!device) |
| 187 | return -EINVAL; | 187 | return -EINVAL; |
| 188 | 188 | ||
| 189 | fan = kmalloc(sizeof(struct acpi_fan), GFP_KERNEL); | 189 | fan = kzalloc(sizeof(struct acpi_fan), GFP_KERNEL); |
| 190 | if (!fan) | 190 | if (!fan) |
| 191 | return -ENOMEM; | 191 | return -ENOMEM; |
| 192 | memset(fan, 0, sizeof(struct acpi_fan)); | ||
| 193 | 192 | ||
| 194 | fan->device = device; | 193 | fan->device = device; |
| 195 | strcpy(acpi_device_name(device), "Fan"); | 194 | strcpy(acpi_device_name(device), "Fan"); |
| @@ -229,7 +228,7 @@ static int acpi_fan_remove(struct acpi_device *device, int type) | |||
| 229 | if (!device || !acpi_driver_data(device)) | 228 | if (!device || !acpi_driver_data(device)) |
| 230 | return -EINVAL; | 229 | return -EINVAL; |
| 231 | 230 | ||
| 232 | fan = (struct acpi_fan *)acpi_driver_data(device); | 231 | fan = acpi_driver_data(device); |
| 233 | 232 | ||
| 234 | acpi_fan_remove_fs(device); | 233 | acpi_fan_remove_fs(device); |
| 235 | 234 | ||
diff --git a/drivers/acpi/glue.c b/drivers/acpi/glue.c index a2f46d587d55..8a0324b43e53 100644 --- a/drivers/acpi/glue.c +++ b/drivers/acpi/glue.c | |||
| @@ -96,7 +96,7 @@ struct acpi_find_pci_root { | |||
| 96 | static acpi_status | 96 | static acpi_status |
| 97 | do_root_bridge_busnr_callback(struct acpi_resource *resource, void *data) | 97 | do_root_bridge_busnr_callback(struct acpi_resource *resource, void *data) |
| 98 | { | 98 | { |
| 99 | unsigned long *busnr = (unsigned long *)data; | 99 | unsigned long *busnr = data; |
| 100 | struct acpi_resource_address64 address; | 100 | struct acpi_resource_address64 address; |
| 101 | 101 | ||
| 102 | if (resource->type != ACPI_RESOURCE_TYPE_ADDRESS16 && | 102 | if (resource->type != ACPI_RESOURCE_TYPE_ADDRESS16 && |
| @@ -189,8 +189,12 @@ find_pci_rootbridge(acpi_handle handle, u32 lvl, void *context, void **rv) | |||
| 189 | bus = tmp; | 189 | bus = tmp; |
| 190 | 190 | ||
| 191 | if (seg == find->seg && bus == find->bus) | 191 | if (seg == find->seg && bus == find->bus) |
| 192 | { | ||
| 192 | find->handle = handle; | 193 | find->handle = handle; |
| 193 | status = AE_OK; | 194 | status = AE_CTRL_TERMINATE; |
| 195 | } | ||
| 196 | else | ||
| 197 | status = AE_OK; | ||
| 194 | exit: | 198 | exit: |
| 195 | kfree(buffer.pointer); | 199 | kfree(buffer.pointer); |
| 196 | return status; | 200 | return status; |
| @@ -217,7 +221,7 @@ do_acpi_find_child(acpi_handle handle, u32 lvl, void *context, void **rv) | |||
| 217 | acpi_status status; | 221 | acpi_status status; |
| 218 | struct acpi_device_info *info; | 222 | struct acpi_device_info *info; |
| 219 | struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL }; | 223 | struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL }; |
| 220 | struct acpi_find_child *find = (struct acpi_find_child *)context; | 224 | struct acpi_find_child *find = context; |
| 221 | 225 | ||
| 222 | status = acpi_get_object_info(handle, &buffer); | 226 | status = acpi_get_object_info(handle, &buffer); |
| 223 | if (ACPI_SUCCESS(status)) { | 227 | if (ACPI_SUCCESS(status)) { |
diff --git a/drivers/acpi/hotkey.c b/drivers/acpi/hotkey.c index 1ba2db671865..8edfb92f7ede 100644 --- a/drivers/acpi/hotkey.c +++ b/drivers/acpi/hotkey.c | |||
| @@ -265,8 +265,7 @@ static char *format_result(union acpi_object *object) | |||
| 265 | 265 | ||
| 266 | static int hotkey_polling_seq_show(struct seq_file *seq, void *offset) | 266 | static int hotkey_polling_seq_show(struct seq_file *seq, void *offset) |
| 267 | { | 267 | { |
| 268 | struct acpi_polling_hotkey *poll_hotkey = | 268 | struct acpi_polling_hotkey *poll_hotkey = seq->private; |
| 269 | (struct acpi_polling_hotkey *)seq->private; | ||
| 270 | char *buf; | 269 | char *buf; |
| 271 | 270 | ||
| 272 | 271 | ||
| @@ -577,7 +576,7 @@ init_poll_hotkey_device(union acpi_hotkey *key, char **config_entry, | |||
| 577 | if (ACPI_FAILURE(status)) | 576 | if (ACPI_FAILURE(status)) |
| 578 | goto do_fail_zero; | 577 | goto do_fail_zero; |
| 579 | key->poll_hotkey.poll_result = | 578 | key->poll_hotkey.poll_result = |
| 580 | (union acpi_object *)kmalloc(sizeof(union acpi_object), GFP_KERNEL); | 579 | kmalloc(sizeof(union acpi_object), GFP_KERNEL); |
| 581 | if (!key->poll_hotkey.poll_result) | 580 | if (!key->poll_hotkey.poll_result) |
| 582 | goto do_fail_zero; | 581 | goto do_fail_zero; |
| 583 | return AE_OK; | 582 | return AE_OK; |
diff --git a/drivers/acpi/i2c_ec.c b/drivers/acpi/i2c_ec.c index 6342e612c203..8338be0990bc 100644 --- a/drivers/acpi/i2c_ec.c +++ b/drivers/acpi/i2c_ec.c | |||
| @@ -309,18 +309,16 @@ static int acpi_ec_hc_add(struct acpi_device *device) | |||
| 309 | return -EINVAL; | 309 | return -EINVAL; |
| 310 | } | 310 | } |
| 311 | 311 | ||
| 312 | ec_hc = kmalloc(sizeof(struct acpi_ec_hc), GFP_KERNEL); | 312 | ec_hc = kzalloc(sizeof(struct acpi_ec_hc), GFP_KERNEL); |
| 313 | if (!ec_hc) { | 313 | if (!ec_hc) { |
| 314 | return -ENOMEM; | 314 | return -ENOMEM; |
| 315 | } | 315 | } |
| 316 | memset(ec_hc, 0, sizeof(struct acpi_ec_hc)); | ||
| 317 | 316 | ||
| 318 | smbus = kmalloc(sizeof(struct acpi_ec_smbus), GFP_KERNEL); | 317 | smbus = kzalloc(sizeof(struct acpi_ec_smbus), GFP_KERNEL); |
| 319 | if (!smbus) { | 318 | if (!smbus) { |
| 320 | kfree(ec_hc); | 319 | kfree(ec_hc); |
| 321 | return -ENOMEM; | 320 | return -ENOMEM; |
| 322 | } | 321 | } |
| 323 | memset(smbus, 0, sizeof(struct acpi_ec_smbus)); | ||
| 324 | 322 | ||
| 325 | ec_hc->handle = device->handle; | 323 | ec_hc->handle = device->handle; |
| 326 | strcpy(acpi_device_name(device), ACPI_EC_HC_DEVICE_NAME); | 324 | strcpy(acpi_device_name(device), ACPI_EC_HC_DEVICE_NAME); |
| @@ -393,7 +391,7 @@ static void __exit acpi_ec_hc_exit(void) | |||
| 393 | 391 | ||
| 394 | struct acpi_ec_hc *acpi_get_ec_hc(struct acpi_device *device) | 392 | struct acpi_ec_hc *acpi_get_ec_hc(struct acpi_device *device) |
| 395 | { | 393 | { |
| 396 | return ((struct acpi_ec_hc *)acpi_driver_data(device->parent)); | 394 | return acpi_driver_data(device->parent); |
| 397 | } | 395 | } |
| 398 | 396 | ||
| 399 | EXPORT_SYMBOL(acpi_get_ec_hc); | 397 | EXPORT_SYMBOL(acpi_get_ec_hc); |
diff --git a/drivers/acpi/ibm_acpi.c b/drivers/acpi/ibm_acpi.c index 5a8445959f67..b72d13d11a27 100644 --- a/drivers/acpi/ibm_acpi.c +++ b/drivers/acpi/ibm_acpi.c | |||
| @@ -3,6 +3,7 @@ | |||
| 3 | * | 3 | * |
| 4 | * | 4 | * |
| 5 | * Copyright (C) 2004-2005 Borislav Deianov <borislav@users.sf.net> | 5 | * Copyright (C) 2004-2005 Borislav Deianov <borislav@users.sf.net> |
| 6 | * Copyright (C) 2006 Henrique de Moraes Holschuh <hmh@hmh.eng.br> | ||
| 6 | * | 7 | * |
| 7 | * This program is free software; you can redistribute it and/or modify | 8 | * 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 | * it under the terms of the GNU General Public License as published by |
| @@ -19,10 +20,14 @@ | |||
| 19 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | 20 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 20 | */ | 21 | */ |
| 21 | 22 | ||
| 22 | #define IBM_VERSION "0.12a" | 23 | #define IBM_VERSION "0.13" |
| 23 | 24 | ||
| 24 | /* | 25 | /* |
| 25 | * Changelog: | 26 | * Changelog: |
| 27 | * | ||
| 28 | * 2006-11-22 0.13 new maintainer | ||
| 29 | * changelog now lives in git commit history, and will | ||
| 30 | * not be updated further in-file. | ||
| 26 | * | 31 | * |
| 27 | * 2005-08-17 0.12 fix compilation on 2.6.13-rc kernels | 32 | * 2005-08-17 0.12 fix compilation on 2.6.13-rc kernels |
| 28 | * 2005-03-17 0.11 support for 600e, 770x | 33 | * 2005-03-17 0.11 support for 600e, 770x |
| @@ -77,9 +82,16 @@ | |||
| 77 | #include <linux/module.h> | 82 | #include <linux/module.h> |
| 78 | #include <linux/init.h> | 83 | #include <linux/init.h> |
| 79 | #include <linux/types.h> | 84 | #include <linux/types.h> |
| 85 | #include <linux/string.h> | ||
| 86 | |||
| 80 | #include <linux/proc_fs.h> | 87 | #include <linux/proc_fs.h> |
| 88 | #include <linux/backlight.h> | ||
| 81 | #include <asm/uaccess.h> | 89 | #include <asm/uaccess.h> |
| 82 | 90 | ||
| 91 | #include <linux/dmi.h> | ||
| 92 | #include <linux/jiffies.h> | ||
| 93 | #include <linux/workqueue.h> | ||
| 94 | |||
| 83 | #include <acpi/acpi_drivers.h> | 95 | #include <acpi/acpi_drivers.h> |
| 84 | #include <acpi/acnamesp.h> | 96 | #include <acpi/acnamesp.h> |
| 85 | 97 | ||
| @@ -88,7 +100,7 @@ | |||
| 88 | #define IBM_FILE "ibm_acpi" | 100 | #define IBM_FILE "ibm_acpi" |
| 89 | #define IBM_URL "http://ibm-acpi.sf.net/" | 101 | #define IBM_URL "http://ibm-acpi.sf.net/" |
| 90 | 102 | ||
| 91 | MODULE_AUTHOR("Borislav Deianov"); | 103 | MODULE_AUTHOR("Borislav Deianov, Henrique de Moraes Holschuh"); |
| 92 | MODULE_DESCRIPTION(IBM_DESC); | 104 | MODULE_DESCRIPTION(IBM_DESC); |
| 93 | MODULE_VERSION(IBM_VERSION); | 105 | MODULE_VERSION(IBM_VERSION); |
| 94 | MODULE_LICENSE("GPL"); | 106 | MODULE_LICENSE("GPL"); |
| @@ -116,28 +128,6 @@ static acpi_handle root_handle = NULL; | |||
| 116 | static char *object##_path; \ | 128 | static char *object##_path; \ |
| 117 | static char *object##_paths[] = { paths } | 129 | static char *object##_paths[] = { paths } |
| 118 | 130 | ||
| 119 | /* | ||
| 120 | * The following models are supported to various degrees: | ||
| 121 | * | ||
| 122 | * 570, 600e, 600x, 770e, 770x | ||
| 123 | * A20m, A21e, A21m, A21p, A22p, A30, A30p, A31, A31p | ||
| 124 | * G40, G41 | ||
| 125 | * R30, R31, R32, R40, R40e, R50, R50e, R50p, R51 | ||
| 126 | * T20, T21, T22, T23, T30, T40, T40p, T41, T41p, T42, T42p, T43 | ||
| 127 | * X20, X21, X22, X23, X24, X30, X31, X40 | ||
| 128 | * | ||
| 129 | * The following models have no supported features: | ||
| 130 | * | ||
| 131 | * 240, 240x, i1400 | ||
| 132 | * | ||
| 133 | * Still missing DSDTs for the following models: | ||
| 134 | * | ||
| 135 | * A20p, A22e, A22m | ||
| 136 | * R52 | ||
| 137 | * S31 | ||
| 138 | * T43p | ||
| 139 | */ | ||
| 140 | |||
| 141 | IBM_HANDLE(ec, root, "\\_SB.PCI0.ISA.EC0", /* 240, 240x */ | 131 | IBM_HANDLE(ec, root, "\\_SB.PCI0.ISA.EC0", /* 240, 240x */ |
| 142 | "\\_SB.PCI.ISA.EC", /* 570 */ | 132 | "\\_SB.PCI.ISA.EC", /* 570 */ |
| 143 | "\\_SB.PCI0.ISA0.EC0", /* 600e/x, 770e, 770x */ | 133 | "\\_SB.PCI0.ISA0.EC0", /* 600e/x, 770e, 770x */ |
| @@ -167,8 +157,10 @@ IBM_HANDLE(dock, root, "\\_SB.GDCK", /* X30, X31, X40 */ | |||
| 167 | "\\_SB.PCI.ISA.SLCE", /* 570 */ | 157 | "\\_SB.PCI.ISA.SLCE", /* 570 */ |
| 168 | ); /* A21e,G4x,R30,R31,R32,R40,R40e,R50e */ | 158 | ); /* A21e,G4x,R30,R31,R32,R40,R40e,R50e */ |
| 169 | #endif | 159 | #endif |
| 160 | #ifdef CONFIG_ACPI_IBM_BAY | ||
| 170 | IBM_HANDLE(bay, root, "\\_SB.PCI.IDE.SECN.MAST", /* 570 */ | 161 | IBM_HANDLE(bay, root, "\\_SB.PCI.IDE.SECN.MAST", /* 570 */ |
| 171 | "\\_SB.PCI0.IDE0.IDES.IDSM", /* 600e/x, 770e, 770x */ | 162 | "\\_SB.PCI0.IDE0.IDES.IDSM", /* 600e/x, 770e, 770x */ |
| 163 | "\\_SB.PCI0.SATA.SCND.MSTR", /* T60, X60, Z60 */ | ||
| 172 | "\\_SB.PCI0.IDE0.SCND.MSTR", /* all others */ | 164 | "\\_SB.PCI0.IDE0.SCND.MSTR", /* all others */ |
| 173 | ); /* A21e, R30, R31 */ | 165 | ); /* A21e, R30, R31 */ |
| 174 | 166 | ||
| @@ -183,6 +175,7 @@ IBM_HANDLE(bay2, root, "\\_SB.PCI0.IDE0.PRIM.SLAV", /* A3x, R32 */ | |||
| 183 | IBM_HANDLE(bay2_ej, bay2, "_EJ3", /* 600e/x, 770e, A3x */ | 175 | IBM_HANDLE(bay2_ej, bay2, "_EJ3", /* 600e/x, 770e, A3x */ |
| 184 | "_EJ0", /* 770x */ | 176 | "_EJ0", /* 770x */ |
| 185 | ); /* all others */ | 177 | ); /* all others */ |
| 178 | #endif | ||
| 186 | 179 | ||
| 187 | /* don't list other alternatives as we install a notify handler on the 570 */ | 180 | /* don't list other alternatives as we install a notify handler on the 570 */ |
| 188 | IBM_HANDLE(pci, root, "\\_SB.PCI"); /* 570 */ | 181 | IBM_HANDLE(pci, root, "\\_SB.PCI"); /* 570 */ |
| @@ -203,7 +196,7 @@ IBM_HANDLE(led, ec, "SLED", /* 570 */ | |||
| 203 | IBM_HANDLE(beep, ec, "BEEP"); /* all except R30, R31 */ | 196 | IBM_HANDLE(beep, ec, "BEEP"); /* all except R30, R31 */ |
| 204 | IBM_HANDLE(ecrd, ec, "ECRD"); /* 570 */ | 197 | IBM_HANDLE(ecrd, ec, "ECRD"); /* 570 */ |
| 205 | IBM_HANDLE(ecwr, ec, "ECWR"); /* 570 */ | 198 | IBM_HANDLE(ecwr, ec, "ECWR"); /* 570 */ |
| 206 | IBM_HANDLE(fans, ec, "FANS"); /* X31, X40 */ | 199 | IBM_HANDLE(fans, ec, "FANS"); /* X31, X40, X41 */ |
| 207 | 200 | ||
| 208 | IBM_HANDLE(gfan, ec, "GFAN", /* 570 */ | 201 | IBM_HANDLE(gfan, ec, "GFAN", /* 570 */ |
| 209 | "\\FSPD", /* 600e/x, 770e, 770x */ | 202 | "\\FSPD", /* 600e/x, 770e, 770x */ |
| @@ -216,6 +209,152 @@ IBM_HANDLE(sfan, ec, "SFAN", /* 570 */ | |||
| 216 | #define IBM_HKEY_HID "IBM0068" | 209 | #define IBM_HKEY_HID "IBM0068" |
| 217 | #define IBM_PCI_HID "PNP0A03" | 210 | #define IBM_PCI_HID "PNP0A03" |
| 218 | 211 | ||
| 212 | enum thermal_access_mode { | ||
| 213 | IBMACPI_THERMAL_NONE = 0, /* No thermal support */ | ||
| 214 | IBMACPI_THERMAL_ACPI_TMP07, /* Use ACPI TMP0-7 */ | ||
| 215 | IBMACPI_THERMAL_ACPI_UPDT, /* Use ACPI TMP0-7 with UPDT */ | ||
| 216 | IBMACPI_THERMAL_TPEC_8, /* Use ACPI EC regs, 8 sensors */ | ||
| 217 | IBMACPI_THERMAL_TPEC_16, /* Use ACPI EC regs, 16 sensors */ | ||
| 218 | }; | ||
| 219 | |||
| 220 | #define IBMACPI_MAX_THERMAL_SENSORS 16 /* Max thermal sensors supported */ | ||
| 221 | struct ibm_thermal_sensors_struct { | ||
| 222 | s32 temp[IBMACPI_MAX_THERMAL_SENSORS]; | ||
| 223 | }; | ||
| 224 | |||
| 225 | /* | ||
| 226 | * FAN ACCESS MODES | ||
| 227 | * | ||
| 228 | * IBMACPI_FAN_RD_ACPI_GFAN: | ||
| 229 | * ACPI GFAN method: returns fan level | ||
| 230 | * | ||
| 231 | * see IBMACPI_FAN_WR_ACPI_SFAN | ||
| 232 | * EC 0x2f not available if GFAN exists | ||
| 233 | * | ||
| 234 | * IBMACPI_FAN_WR_ACPI_SFAN: | ||
| 235 | * ACPI SFAN method: sets fan level, 0 (stop) to 7 (max) | ||
| 236 | * | ||
| 237 | * EC 0x2f might be available *for reading*, but never for writing. | ||
| 238 | * | ||
| 239 | * IBMACPI_FAN_WR_TPEC: | ||
| 240 | * ThinkPad EC register 0x2f (HFSP): fan control loop mode Supported | ||
| 241 | * on almost all ThinkPads | ||
| 242 | * | ||
| 243 | * Fan speed changes of any sort (including those caused by the | ||
| 244 | * disengaged mode) are usually done slowly by the firmware as the | ||
| 245 | * maximum ammount of fan duty cycle change per second seems to be | ||
| 246 | * limited. | ||
| 247 | * | ||
| 248 | * Reading is not available if GFAN exists. | ||
| 249 | * Writing is not available if SFAN exists. | ||
| 250 | * | ||
| 251 | * Bits | ||
| 252 | * 7 automatic mode engaged; | ||
| 253 | * (default operation mode of the ThinkPad) | ||
| 254 | * fan level is ignored in this mode. | ||
| 255 | * 6 disengage mode (takes precedence over bit 7); | ||
| 256 | * not available on all thinkpads. May disable | ||
| 257 | * the tachometer, and speeds up fan to 100% duty-cycle, | ||
| 258 | * which speeds it up far above the standard RPM | ||
| 259 | * levels. It is not impossible that it could cause | ||
| 260 | * hardware damage. | ||
| 261 | * 5-3 unused in some models. Extra bits for fan level | ||
| 262 | * in others, but still useless as all values above | ||
| 263 | * 7 map to the same speed as level 7 in these models. | ||
| 264 | * 2-0 fan level (0..7 usually) | ||
| 265 | * 0x00 = stop | ||
| 266 | * 0x07 = max (set when temperatures critical) | ||
| 267 | * Some ThinkPads may have other levels, see | ||
| 268 | * IBMACPI_FAN_WR_ACPI_FANS (X31/X40/X41) | ||
| 269 | * | ||
| 270 | * FIRMWARE BUG: on some models, EC 0x2f might not be initialized at | ||
| 271 | * boot. Apparently the EC does not intialize it, so unless ACPI DSDT | ||
| 272 | * does so, its initial value is meaningless (0x07). | ||
| 273 | * | ||
| 274 | * For firmware bugs, refer to: | ||
| 275 | * http://thinkwiki.org/wiki/Embedded_Controller_Firmware#Firmware_Issues | ||
| 276 | * | ||
| 277 | * ---- | ||
| 278 | * | ||
| 279 | * ThinkPad EC register 0x84 (LSB), 0x85 (MSB): | ||
| 280 | * Main fan tachometer reading (in RPM) | ||
| 281 | * | ||
| 282 | * This register is present on all ThinkPads with a new-style EC, and | ||
| 283 | * it is known not to be present on the A21m/e, and T22, as there is | ||
| 284 | * something else in offset 0x84 according to the ACPI DSDT. Other | ||
| 285 | * ThinkPads from this same time period (and earlier) probably lack the | ||
| 286 | * tachometer as well. | ||
| 287 | * | ||
| 288 | * Unfortunately a lot of ThinkPads with new-style ECs but whose firwmare | ||
| 289 | * was never fixed by IBM to report the EC firmware version string | ||
| 290 | * probably support the tachometer (like the early X models), so | ||
| 291 | * detecting it is quite hard. We need more data to know for sure. | ||
| 292 | * | ||
| 293 | * FIRMWARE BUG: always read 0x84 first, otherwise incorrect readings | ||
| 294 | * might result. | ||
| 295 | * | ||
| 296 | * FIRMWARE BUG: when EC 0x2f bit 6 is set (disengaged mode), this | ||
| 297 | * register is not invalidated in ThinkPads that disable tachometer | ||
| 298 | * readings. Thus, the tachometer readings go stale. | ||
| 299 | * | ||
| 300 | * For firmware bugs, refer to: | ||
| 301 | * http://thinkwiki.org/wiki/Embedded_Controller_Firmware#Firmware_Issues | ||
| 302 | * | ||
| 303 | * IBMACPI_FAN_WR_ACPI_FANS: | ||
| 304 | * ThinkPad X31, X40, X41. Not available in the X60. | ||
| 305 | * | ||
| 306 | * FANS ACPI handle: takes three arguments: low speed, medium speed, | ||
| 307 | * high speed. ACPI DSDT seems to map these three speeds to levels | ||
| 308 | * as follows: STOP LOW LOW MED MED HIGH HIGH HIGH HIGH | ||
| 309 | * (this map is stored on FAN0..FAN8 as "0,1,1,2,2,3,3,3,3") | ||
| 310 | * | ||
| 311 | * The speeds are stored on handles | ||
| 312 | * (FANA:FAN9), (FANC:FANB), (FANE:FAND). | ||
| 313 | * | ||
| 314 | * There are three default speed sets, acessible as handles: | ||
| 315 | * FS1L,FS1M,FS1H; FS2L,FS2M,FS2H; FS3L,FS3M,FS3H | ||
| 316 | * | ||
| 317 | * ACPI DSDT switches which set is in use depending on various | ||
| 318 | * factors. | ||
| 319 | * | ||
| 320 | * IBMACPI_FAN_WR_TPEC is also available and should be used to | ||
| 321 | * command the fan. The X31/X40/X41 seems to have 8 fan levels, | ||
| 322 | * but the ACPI tables just mention level 7. | ||
| 323 | */ | ||
| 324 | |||
| 325 | enum fan_status_access_mode { | ||
| 326 | IBMACPI_FAN_NONE = 0, /* No fan status or control */ | ||
| 327 | IBMACPI_FAN_RD_ACPI_GFAN, /* Use ACPI GFAN */ | ||
| 328 | IBMACPI_FAN_RD_TPEC, /* Use ACPI EC regs 0x2f, 0x84-0x85 */ | ||
| 329 | }; | ||
| 330 | |||
| 331 | enum fan_control_access_mode { | ||
| 332 | IBMACPI_FAN_WR_NONE = 0, /* No fan control */ | ||
| 333 | IBMACPI_FAN_WR_ACPI_SFAN, /* Use ACPI SFAN */ | ||
| 334 | IBMACPI_FAN_WR_TPEC, /* Use ACPI EC reg 0x2f */ | ||
| 335 | IBMACPI_FAN_WR_ACPI_FANS, /* Use ACPI FANS and EC reg 0x2f */ | ||
| 336 | }; | ||
| 337 | |||
| 338 | enum fan_control_commands { | ||
| 339 | IBMACPI_FAN_CMD_SPEED = 0x0001, /* speed command */ | ||
| 340 | IBMACPI_FAN_CMD_LEVEL = 0x0002, /* level command */ | ||
| 341 | IBMACPI_FAN_CMD_ENABLE = 0x0004, /* enable/disable cmd, | ||
| 342 | * and also watchdog cmd */ | ||
| 343 | }; | ||
| 344 | |||
| 345 | enum { /* Fan control constants */ | ||
| 346 | fan_status_offset = 0x2f, /* EC register 0x2f */ | ||
| 347 | fan_rpm_offset = 0x84, /* EC register 0x84: LSB, 0x85 MSB (RPM) | ||
| 348 | * 0x84 must be read before 0x85 */ | ||
| 349 | |||
| 350 | IBMACPI_FAN_EC_DISENGAGED = 0x40, /* EC mode: tachometer | ||
| 351 | * disengaged */ | ||
| 352 | IBMACPI_FAN_EC_AUTO = 0x80, /* EC mode: auto fan | ||
| 353 | * control */ | ||
| 354 | }; | ||
| 355 | |||
| 356 | static char *ibm_thinkpad_ec_found = NULL; | ||
| 357 | |||
| 219 | struct ibm_struct { | 358 | struct ibm_struct { |
| 220 | char *name; | 359 | char *name; |
| 221 | char param[32]; | 360 | char param[32]; |
| @@ -243,6 +382,8 @@ struct ibm_struct { | |||
| 243 | 382 | ||
| 244 | static struct proc_dir_entry *proc_dir = NULL; | 383 | static struct proc_dir_entry *proc_dir = NULL; |
| 245 | 384 | ||
| 385 | static struct backlight_device *ibm_backlight_device = NULL; | ||
| 386 | |||
| 246 | #define onoff(status,bit) ((status) & (1 << (bit)) ? "on" : "off") | 387 | #define onoff(status,bit) ((status) & (1 << (bit)) ? "on" : "off") |
| 247 | #define enabled(status,bit) ((status) & (1 << (bit)) ? "enabled" : "disabled") | 388 | #define enabled(status,bit) ((status) & (1 << (bit)) ? "enabled" : "disabled") |
| 248 | #define strlencmp(a,b) (strncmp((a), (b), strlen(b))) | 389 | #define strlencmp(a,b) (strncmp((a), (b), strlen(b))) |
| @@ -581,8 +722,7 @@ static int wan_status(void) | |||
| 581 | { | 722 | { |
| 582 | int status; | 723 | int status; |
| 583 | 724 | ||
| 584 | if (!wan_supported || | 725 | if (!wan_supported || !acpi_evalf(hkey_handle, &status, "GWAN", "d")) |
| 585 | !acpi_evalf(hkey_handle, &status, "GWAN", "d")) | ||
| 586 | status = 0; | 726 | status = 0; |
| 587 | 727 | ||
| 588 | return status; | 728 | return status; |
| @@ -630,12 +770,15 @@ static int wan_write(char *buf) | |||
| 630 | return 0; | 770 | return 0; |
| 631 | } | 771 | } |
| 632 | 772 | ||
| 633 | static int video_supported; | 773 | enum video_access_mode { |
| 634 | static int video_orig_autosw; | 774 | IBMACPI_VIDEO_NONE = 0, |
| 775 | IBMACPI_VIDEO_570, /* 570 */ | ||
| 776 | IBMACPI_VIDEO_770, /* 600e/x, 770e, 770x */ | ||
| 777 | IBMACPI_VIDEO_NEW, /* all others */ | ||
| 778 | }; | ||
| 635 | 779 | ||
| 636 | #define VIDEO_570 1 | 780 | static enum video_access_mode video_supported; |
| 637 | #define VIDEO_770 2 | 781 | static int video_orig_autosw; |
| 638 | #define VIDEO_NEW 3 | ||
| 639 | 782 | ||
| 640 | static int video_init(void) | 783 | static int video_init(void) |
| 641 | { | 784 | { |
| @@ -647,16 +790,16 @@ static int video_init(void) | |||
| 647 | 790 | ||
| 648 | if (!vid_handle) | 791 | if (!vid_handle) |
| 649 | /* video switching not supported on R30, R31 */ | 792 | /* video switching not supported on R30, R31 */ |
| 650 | video_supported = 0; | 793 | video_supported = IBMACPI_VIDEO_NONE; |
| 651 | else if (acpi_evalf(vid_handle, &video_orig_autosw, "SWIT", "qd")) | 794 | else if (acpi_evalf(vid_handle, &video_orig_autosw, "SWIT", "qd")) |
| 652 | /* 570 */ | 795 | /* 570 */ |
| 653 | video_supported = VIDEO_570; | 796 | video_supported = IBMACPI_VIDEO_570; |
| 654 | else if (acpi_evalf(vid_handle, &video_orig_autosw, "^VADL", "qd")) | 797 | else if (acpi_evalf(vid_handle, &video_orig_autosw, "^VADL", "qd")) |
| 655 | /* 600e/x, 770e, 770x */ | 798 | /* 600e/x, 770e, 770x */ |
| 656 | video_supported = VIDEO_770; | 799 | video_supported = IBMACPI_VIDEO_770; |
| 657 | else | 800 | else |
| 658 | /* all others */ | 801 | /* all others */ |
| 659 | video_supported = VIDEO_NEW; | 802 | video_supported = IBMACPI_VIDEO_NEW; |
| 660 | 803 | ||
| 661 | return 0; | 804 | return 0; |
| 662 | } | 805 | } |
| @@ -666,15 +809,15 @@ static int video_status(void) | |||
| 666 | int status = 0; | 809 | int status = 0; |
| 667 | int i; | 810 | int i; |
| 668 | 811 | ||
| 669 | if (video_supported == VIDEO_570) { | 812 | if (video_supported == IBMACPI_VIDEO_570) { |
| 670 | if (acpi_evalf(NULL, &i, "\\_SB.PHS", "dd", 0x87)) | 813 | if (acpi_evalf(NULL, &i, "\\_SB.PHS", "dd", 0x87)) |
| 671 | status = i & 3; | 814 | status = i & 3; |
| 672 | } else if (video_supported == VIDEO_770) { | 815 | } else if (video_supported == IBMACPI_VIDEO_770) { |
| 673 | if (acpi_evalf(NULL, &i, "\\VCDL", "d")) | 816 | if (acpi_evalf(NULL, &i, "\\VCDL", "d")) |
| 674 | status |= 0x01 * i; | 817 | status |= 0x01 * i; |
| 675 | if (acpi_evalf(NULL, &i, "\\VCDC", "d")) | 818 | if (acpi_evalf(NULL, &i, "\\VCDC", "d")) |
| 676 | status |= 0x02 * i; | 819 | status |= 0x02 * i; |
| 677 | } else if (video_supported == VIDEO_NEW) { | 820 | } else if (video_supported == IBMACPI_VIDEO_NEW) { |
| 678 | acpi_evalf(NULL, NULL, "\\VUPS", "vd", 1); | 821 | acpi_evalf(NULL, NULL, "\\VUPS", "vd", 1); |
| 679 | if (acpi_evalf(NULL, &i, "\\VCDC", "d")) | 822 | if (acpi_evalf(NULL, &i, "\\VCDC", "d")) |
| 680 | status |= 0x02 * i; | 823 | status |= 0x02 * i; |
| @@ -693,9 +836,10 @@ static int video_autosw(void) | |||
| 693 | { | 836 | { |
| 694 | int autosw = 0; | 837 | int autosw = 0; |
| 695 | 838 | ||
| 696 | if (video_supported == VIDEO_570) | 839 | if (video_supported == IBMACPI_VIDEO_570) |
| 697 | acpi_evalf(vid_handle, &autosw, "SWIT", "d"); | 840 | acpi_evalf(vid_handle, &autosw, "SWIT", "d"); |
| 698 | else if (video_supported == VIDEO_770 || video_supported == VIDEO_NEW) | 841 | else if (video_supported == IBMACPI_VIDEO_770 || |
| 842 | video_supported == IBMACPI_VIDEO_NEW) | ||
| 699 | acpi_evalf(vid_handle, &autosw, "^VDEE", "d"); | 843 | acpi_evalf(vid_handle, &autosw, "^VDEE", "d"); |
| 700 | 844 | ||
| 701 | return autosw & 1; | 845 | return autosw & 1; |
| @@ -715,12 +859,12 @@ static int video_read(char *p) | |||
| 715 | len += sprintf(p + len, "status:\t\tsupported\n"); | 859 | len += sprintf(p + len, "status:\t\tsupported\n"); |
| 716 | len += sprintf(p + len, "lcd:\t\t%s\n", enabled(status, 0)); | 860 | len += sprintf(p + len, "lcd:\t\t%s\n", enabled(status, 0)); |
| 717 | len += sprintf(p + len, "crt:\t\t%s\n", enabled(status, 1)); | 861 | len += sprintf(p + len, "crt:\t\t%s\n", enabled(status, 1)); |
| 718 | if (video_supported == VIDEO_NEW) | 862 | if (video_supported == IBMACPI_VIDEO_NEW) |
| 719 | len += sprintf(p + len, "dvi:\t\t%s\n", enabled(status, 3)); | 863 | len += sprintf(p + len, "dvi:\t\t%s\n", enabled(status, 3)); |
| 720 | len += sprintf(p + len, "auto:\t\t%s\n", enabled(autosw, 0)); | 864 | len += sprintf(p + len, "auto:\t\t%s\n", enabled(autosw, 0)); |
| 721 | len += sprintf(p + len, "commands:\tlcd_enable, lcd_disable\n"); | 865 | len += sprintf(p + len, "commands:\tlcd_enable, lcd_disable\n"); |
| 722 | len += sprintf(p + len, "commands:\tcrt_enable, crt_disable\n"); | 866 | len += sprintf(p + len, "commands:\tcrt_enable, crt_disable\n"); |
| 723 | if (video_supported == VIDEO_NEW) | 867 | if (video_supported == IBMACPI_VIDEO_NEW) |
| 724 | len += sprintf(p + len, "commands:\tdvi_enable, dvi_disable\n"); | 868 | len += sprintf(p + len, "commands:\tdvi_enable, dvi_disable\n"); |
| 725 | len += sprintf(p + len, "commands:\tauto_enable, auto_disable\n"); | 869 | len += sprintf(p + len, "commands:\tauto_enable, auto_disable\n"); |
| 726 | len += sprintf(p + len, "commands:\tvideo_switch, expand_toggle\n"); | 870 | len += sprintf(p + len, "commands:\tvideo_switch, expand_toggle\n"); |
| @@ -735,7 +879,7 @@ static int video_switch(void) | |||
| 735 | 879 | ||
| 736 | if (!acpi_evalf(vid_handle, NULL, "_DOS", "vd", 1)) | 880 | if (!acpi_evalf(vid_handle, NULL, "_DOS", "vd", 1)) |
| 737 | return -EIO; | 881 | return -EIO; |
| 738 | ret = video_supported == VIDEO_570 ? | 882 | ret = video_supported == IBMACPI_VIDEO_570 ? |
| 739 | acpi_evalf(ec_handle, NULL, "_Q16", "v") : | 883 | acpi_evalf(ec_handle, NULL, "_Q16", "v") : |
| 740 | acpi_evalf(vid_handle, NULL, "VSWT", "v"); | 884 | acpi_evalf(vid_handle, NULL, "VSWT", "v"); |
| 741 | acpi_evalf(vid_handle, NULL, "_DOS", "vd", autosw); | 885 | acpi_evalf(vid_handle, NULL, "_DOS", "vd", autosw); |
| @@ -745,9 +889,9 @@ static int video_switch(void) | |||
| 745 | 889 | ||
| 746 | static int video_expand(void) | 890 | static int video_expand(void) |
| 747 | { | 891 | { |
| 748 | if (video_supported == VIDEO_570) | 892 | if (video_supported == IBMACPI_VIDEO_570) |
| 749 | return acpi_evalf(ec_handle, NULL, "_Q17", "v"); | 893 | return acpi_evalf(ec_handle, NULL, "_Q17", "v"); |
| 750 | else if (video_supported == VIDEO_770) | 894 | else if (video_supported == IBMACPI_VIDEO_770) |
| 751 | return acpi_evalf(vid_handle, NULL, "VEXP", "v"); | 895 | return acpi_evalf(vid_handle, NULL, "VEXP", "v"); |
| 752 | else | 896 | else |
| 753 | return acpi_evalf(NULL, NULL, "\\VEXP", "v"); | 897 | return acpi_evalf(NULL, NULL, "\\VEXP", "v"); |
| @@ -757,10 +901,10 @@ static int video_switch2(int status) | |||
| 757 | { | 901 | { |
| 758 | int ret; | 902 | int ret; |
| 759 | 903 | ||
| 760 | if (video_supported == VIDEO_570) { | 904 | if (video_supported == IBMACPI_VIDEO_570) { |
| 761 | ret = acpi_evalf(NULL, NULL, | 905 | ret = acpi_evalf(NULL, NULL, |
| 762 | "\\_SB.PHS2", "vdd", 0x8b, status | 0x80); | 906 | "\\_SB.PHS2", "vdd", 0x8b, status | 0x80); |
| 763 | } else if (video_supported == VIDEO_770) { | 907 | } else if (video_supported == IBMACPI_VIDEO_770) { |
| 764 | int autosw = video_autosw(); | 908 | int autosw = video_autosw(); |
| 765 | if (!acpi_evalf(vid_handle, NULL, "_DOS", "vd", 1)) | 909 | if (!acpi_evalf(vid_handle, NULL, "_DOS", "vd", 1)) |
| 766 | return -EIO; | 910 | return -EIO; |
| @@ -796,10 +940,10 @@ static int video_write(char *buf) | |||
| 796 | enable |= 0x02; | 940 | enable |= 0x02; |
| 797 | } else if (strlencmp(cmd, "crt_disable") == 0) { | 941 | } else if (strlencmp(cmd, "crt_disable") == 0) { |
| 798 | disable |= 0x02; | 942 | disable |= 0x02; |
| 799 | } else if (video_supported == VIDEO_NEW && | 943 | } else if (video_supported == IBMACPI_VIDEO_NEW && |
| 800 | strlencmp(cmd, "dvi_enable") == 0) { | 944 | strlencmp(cmd, "dvi_enable") == 0) { |
| 801 | enable |= 0x08; | 945 | enable |= 0x08; |
| 802 | } else if (video_supported == VIDEO_NEW && | 946 | } else if (video_supported == IBMACPI_VIDEO_NEW && |
| 803 | strlencmp(cmd, "dvi_disable") == 0) { | 947 | strlencmp(cmd, "dvi_disable") == 0) { |
| 804 | disable |= 0x08; | 948 | disable |= 0x08; |
| 805 | } else if (strlencmp(cmd, "auto_enable") == 0) { | 949 | } else if (strlencmp(cmd, "auto_enable") == 0) { |
| @@ -898,6 +1042,7 @@ static int light_write(char *buf) | |||
| 898 | return 0; | 1042 | return 0; |
| 899 | } | 1043 | } |
| 900 | 1044 | ||
| 1045 | #if defined(CONFIG_ACPI_IBM_DOCK) || defined(CONFIG_ACPI_IBM_BAY) | ||
| 901 | static int _sta(acpi_handle handle) | 1046 | static int _sta(acpi_handle handle) |
| 902 | { | 1047 | { |
| 903 | int status; | 1048 | int status; |
| @@ -907,6 +1052,7 @@ static int _sta(acpi_handle handle) | |||
| 907 | 1052 | ||
| 908 | return status; | 1053 | return status; |
| 909 | } | 1054 | } |
| 1055 | #endif | ||
| 910 | #ifdef CONFIG_ACPI_IBM_DOCK | 1056 | #ifdef CONFIG_ACPI_IBM_DOCK |
| 911 | #define dock_docked() (_sta(dock_handle) & 1) | 1057 | #define dock_docked() (_sta(dock_handle) & 1) |
| 912 | 1058 | ||
| @@ -972,6 +1118,7 @@ static void dock_notify(struct ibm_struct *ibm, u32 event) | |||
| 972 | } | 1118 | } |
| 973 | #endif | 1119 | #endif |
| 974 | 1120 | ||
| 1121 | #ifdef CONFIG_ACPI_IBM_BAY | ||
| 975 | static int bay_status_supported; | 1122 | static int bay_status_supported; |
| 976 | static int bay_status2_supported; | 1123 | static int bay_status2_supported; |
| 977 | static int bay_eject_supported; | 1124 | static int bay_eject_supported; |
| @@ -1047,6 +1194,7 @@ static void bay_notify(struct ibm_struct *ibm, u32 event) | |||
| 1047 | { | 1194 | { |
| 1048 | acpi_bus_generate_event(ibm->device, event, 0); | 1195 | acpi_bus_generate_event(ibm->device, event, 0); |
| 1049 | } | 1196 | } |
| 1197 | #endif | ||
| 1050 | 1198 | ||
| 1051 | static int cmos_read(char *p) | 1199 | static int cmos_read(char *p) |
| 1052 | { | 1200 | { |
| @@ -1094,26 +1242,28 @@ static int cmos_write(char *buf) | |||
| 1094 | return 0; | 1242 | return 0; |
| 1095 | } | 1243 | } |
| 1096 | 1244 | ||
| 1097 | static int led_supported; | 1245 | enum led_access_mode { |
| 1098 | 1246 | IBMACPI_LED_NONE = 0, | |
| 1099 | #define LED_570 1 | 1247 | IBMACPI_LED_570, /* 570 */ |
| 1100 | #define LED_OLD 2 | 1248 | IBMACPI_LED_OLD, /* 600e/x, 770e, 770x, A21e, A2xm/p, T20-22, X20-21 */ |
| 1101 | #define LED_NEW 3 | 1249 | IBMACPI_LED_NEW, /* all others */ |
| 1250 | }; | ||
| 1251 | static enum led_access_mode led_supported; | ||
| 1102 | 1252 | ||
| 1103 | static int led_init(void) | 1253 | static int led_init(void) |
| 1104 | { | 1254 | { |
| 1105 | if (!led_handle) | 1255 | if (!led_handle) |
| 1106 | /* led not supported on R30, R31 */ | 1256 | /* led not supported on R30, R31 */ |
| 1107 | led_supported = 0; | 1257 | led_supported = IBMACPI_LED_NONE; |
| 1108 | else if (strlencmp(led_path, "SLED") == 0) | 1258 | else if (strlencmp(led_path, "SLED") == 0) |
| 1109 | /* 570 */ | 1259 | /* 570 */ |
| 1110 | led_supported = LED_570; | 1260 | led_supported = IBMACPI_LED_570; |
| 1111 | else if (strlencmp(led_path, "SYSL") == 0) | 1261 | else if (strlencmp(led_path, "SYSL") == 0) |
| 1112 | /* 600e/x, 770e, 770x, A21e, A2xm/p, T20-22, X20-21 */ | 1262 | /* 600e/x, 770e, 770x, A21e, A2xm/p, T20-22, X20-21 */ |
| 1113 | led_supported = LED_OLD; | 1263 | led_supported = IBMACPI_LED_OLD; |
| 1114 | else | 1264 | else |
| 1115 | /* all others */ | 1265 | /* all others */ |
| 1116 | led_supported = LED_NEW; | 1266 | led_supported = IBMACPI_LED_NEW; |
| 1117 | 1267 | ||
| 1118 | return 0; | 1268 | return 0; |
| 1119 | } | 1269 | } |
| @@ -1130,7 +1280,7 @@ static int led_read(char *p) | |||
| 1130 | } | 1280 | } |
| 1131 | len += sprintf(p + len, "status:\t\tsupported\n"); | 1281 | len += sprintf(p + len, "status:\t\tsupported\n"); |
| 1132 | 1282 | ||
| 1133 | if (led_supported == LED_570) { | 1283 | if (led_supported == IBMACPI_LED_570) { |
| 1134 | /* 570 */ | 1284 | /* 570 */ |
| 1135 | int i, status; | 1285 | int i, status; |
| 1136 | for (i = 0; i < 8; i++) { | 1286 | for (i = 0; i < 8; i++) { |
| @@ -1179,13 +1329,13 @@ static int led_write(char *buf) | |||
| 1179 | } else | 1329 | } else |
| 1180 | return -EINVAL; | 1330 | return -EINVAL; |
| 1181 | 1331 | ||
| 1182 | if (led_supported == LED_570) { | 1332 | if (led_supported == IBMACPI_LED_570) { |
| 1183 | /* 570 */ | 1333 | /* 570 */ |
| 1184 | led = 1 << led; | 1334 | led = 1 << led; |
| 1185 | if (!acpi_evalf(led_handle, NULL, NULL, "vdd", | 1335 | if (!acpi_evalf(led_handle, NULL, NULL, "vdd", |
| 1186 | led, led_sled_arg1[ind])) | 1336 | led, led_sled_arg1[ind])) |
| 1187 | return -EIO; | 1337 | return -EIO; |
| 1188 | } else if (led_supported == LED_OLD) { | 1338 | } else if (led_supported == IBMACPI_LED_OLD) { |
| 1189 | /* 600e/x, 770e, 770x, A21e, A2xm/p, T20-22, X20 */ | 1339 | /* 600e/x, 770e, 770x, A21e, A2xm/p, T20-22, X20 */ |
| 1190 | led = 1 << led; | 1340 | led = 1 << led; |
| 1191 | ret = ec_write(EC_HLMS, led); | 1341 | ret = ec_write(EC_HLMS, led); |
| @@ -1272,50 +1422,142 @@ static int acpi_ec_write(int i, u8 v) | |||
| 1272 | return 1; | 1422 | return 1; |
| 1273 | } | 1423 | } |
| 1274 | 1424 | ||
| 1275 | static int thermal_tmp_supported; | 1425 | static enum thermal_access_mode thermal_read_mode; |
| 1276 | static int thermal_updt_supported; | ||
| 1277 | 1426 | ||
| 1278 | static int thermal_init(void) | 1427 | static int thermal_init(void) |
| 1279 | { | 1428 | { |
| 1280 | /* temperatures not supported on 570, G4x, R30, R31, R32 */ | 1429 | u8 t, ta1, ta2; |
| 1281 | thermal_tmp_supported = acpi_evalf(ec_handle, NULL, "TMP7", "qv"); | 1430 | int i; |
| 1431 | int acpi_tmp7 = acpi_evalf(ec_handle, NULL, "TMP7", "qv"); | ||
| 1432 | |||
| 1433 | if (ibm_thinkpad_ec_found && experimental) { | ||
| 1434 | /* | ||
| 1435 | * Direct EC access mode: sensors at registers | ||
| 1436 | * 0x78-0x7F, 0xC0-0xC7. Registers return 0x00 for | ||
| 1437 | * non-implemented, thermal sensors return 0x80 when | ||
| 1438 | * not available | ||
| 1439 | */ | ||
| 1282 | 1440 | ||
| 1283 | /* 600e/x, 770e, 770x */ | 1441 | ta1 = ta2 = 0; |
| 1284 | thermal_updt_supported = acpi_evalf(ec_handle, NULL, "UPDT", "qv"); | 1442 | for (i = 0; i < 8; i++) { |
| 1443 | if (likely(acpi_ec_read(0x78 + i, &t))) { | ||
| 1444 | ta1 |= t; | ||
| 1445 | } else { | ||
| 1446 | ta1 = 0; | ||
| 1447 | break; | ||
| 1448 | } | ||
| 1449 | if (likely(acpi_ec_read(0xC0 + i, &t))) { | ||
| 1450 | ta2 |= t; | ||
| 1451 | } else { | ||
| 1452 | ta1 = 0; | ||
| 1453 | break; | ||
| 1454 | } | ||
| 1455 | } | ||
| 1456 | if (ta1 == 0) { | ||
| 1457 | /* This is sheer paranoia, but we handle it anyway */ | ||
| 1458 | if (acpi_tmp7) { | ||
| 1459 | printk(IBM_ERR | ||
| 1460 | "ThinkPad ACPI EC access misbehaving, " | ||
| 1461 | "falling back to ACPI TMPx access mode\n"); | ||
| 1462 | thermal_read_mode = IBMACPI_THERMAL_ACPI_TMP07; | ||
| 1463 | } else { | ||
| 1464 | printk(IBM_ERR | ||
| 1465 | "ThinkPad ACPI EC access misbehaving, " | ||
| 1466 | "disabling thermal sensors access\n"); | ||
| 1467 | thermal_read_mode = IBMACPI_THERMAL_NONE; | ||
| 1468 | } | ||
| 1469 | } else { | ||
| 1470 | thermal_read_mode = | ||
| 1471 | (ta2 != 0) ? | ||
| 1472 | IBMACPI_THERMAL_TPEC_16 : IBMACPI_THERMAL_TPEC_8; | ||
| 1473 | } | ||
| 1474 | } else if (acpi_tmp7) { | ||
| 1475 | if (acpi_evalf(ec_handle, NULL, "UPDT", "qv")) { | ||
| 1476 | /* 600e/x, 770e, 770x */ | ||
| 1477 | thermal_read_mode = IBMACPI_THERMAL_ACPI_UPDT; | ||
| 1478 | } else { | ||
| 1479 | /* Standard ACPI TMPx access, max 8 sensors */ | ||
| 1480 | thermal_read_mode = IBMACPI_THERMAL_ACPI_TMP07; | ||
| 1481 | } | ||
| 1482 | } else { | ||
| 1483 | /* temperatures not supported on 570, G4x, R30, R31, R32 */ | ||
| 1484 | thermal_read_mode = IBMACPI_THERMAL_NONE; | ||
| 1485 | } | ||
| 1285 | 1486 | ||
| 1286 | return 0; | 1487 | return 0; |
| 1287 | } | 1488 | } |
| 1288 | 1489 | ||
| 1289 | static int thermal_read(char *p) | 1490 | static int thermal_get_sensors(struct ibm_thermal_sensors_struct *s) |
| 1290 | { | 1491 | { |
| 1291 | int len = 0; | 1492 | int i, t; |
| 1493 | s8 tmp; | ||
| 1494 | char tmpi[] = "TMPi"; | ||
| 1292 | 1495 | ||
| 1293 | if (!thermal_tmp_supported) | 1496 | if (!s) |
| 1294 | len += sprintf(p + len, "temperatures:\tnot supported\n"); | 1497 | return -EINVAL; |
| 1295 | else { | ||
| 1296 | int i, t; | ||
| 1297 | char tmpi[] = "TMPi"; | ||
| 1298 | s8 tmp[8]; | ||
| 1299 | 1498 | ||
| 1300 | if (thermal_updt_supported) | 1499 | switch (thermal_read_mode) { |
| 1301 | if (!acpi_evalf(ec_handle, NULL, "UPDT", "v")) | 1500 | #if IBMACPI_MAX_THERMAL_SENSORS >= 16 |
| 1501 | case IBMACPI_THERMAL_TPEC_16: | ||
| 1502 | for (i = 0; i < 8; i++) { | ||
| 1503 | if (!acpi_ec_read(0xC0 + i, &tmp)) | ||
| 1504 | return -EIO; | ||
| 1505 | s->temp[i + 8] = tmp * 1000; | ||
| 1506 | } | ||
| 1507 | /* fallthrough */ | ||
| 1508 | #endif | ||
| 1509 | case IBMACPI_THERMAL_TPEC_8: | ||
| 1510 | for (i = 0; i < 8; i++) { | ||
| 1511 | if (!acpi_ec_read(0x78 + i, &tmp)) | ||
| 1302 | return -EIO; | 1512 | return -EIO; |
| 1513 | s->temp[i] = tmp * 1000; | ||
| 1514 | } | ||
| 1515 | return (thermal_read_mode == IBMACPI_THERMAL_TPEC_16) ? 16 : 8; | ||
| 1303 | 1516 | ||
| 1517 | case IBMACPI_THERMAL_ACPI_UPDT: | ||
| 1518 | if (!acpi_evalf(ec_handle, NULL, "UPDT", "v")) | ||
| 1519 | return -EIO; | ||
| 1304 | for (i = 0; i < 8; i++) { | 1520 | for (i = 0; i < 8; i++) { |
| 1305 | tmpi[3] = '0' + i; | 1521 | tmpi[3] = '0' + i; |
| 1306 | if (!acpi_evalf(ec_handle, &t, tmpi, "d")) | 1522 | if (!acpi_evalf(ec_handle, &t, tmpi, "d")) |
| 1307 | return -EIO; | 1523 | return -EIO; |
| 1308 | if (thermal_updt_supported) | 1524 | s->temp[i] = (t - 2732) * 100; |
| 1309 | tmp[i] = (t - 2732 + 5) / 10; | ||
| 1310 | else | ||
| 1311 | tmp[i] = t; | ||
| 1312 | } | 1525 | } |
| 1526 | return 8; | ||
| 1313 | 1527 | ||
| 1314 | len += sprintf(p + len, | 1528 | case IBMACPI_THERMAL_ACPI_TMP07: |
| 1315 | "temperatures:\t%d %d %d %d %d %d %d %d\n", | 1529 | for (i = 0; i < 8; i++) { |
| 1316 | tmp[0], tmp[1], tmp[2], tmp[3], | 1530 | tmpi[3] = '0' + i; |
| 1317 | tmp[4], tmp[5], tmp[6], tmp[7]); | 1531 | if (!acpi_evalf(ec_handle, &t, tmpi, "d")) |
| 1532 | return -EIO; | ||
| 1533 | s->temp[i] = t * 1000; | ||
| 1534 | } | ||
| 1535 | return 8; | ||
| 1536 | |||
| 1537 | case IBMACPI_THERMAL_NONE: | ||
| 1538 | default: | ||
| 1539 | return 0; | ||
| 1318 | } | 1540 | } |
| 1541 | } | ||
| 1542 | |||
| 1543 | static int thermal_read(char *p) | ||
| 1544 | { | ||
| 1545 | int len = 0; | ||
| 1546 | int n, i; | ||
| 1547 | struct ibm_thermal_sensors_struct t; | ||
| 1548 | |||
| 1549 | n = thermal_get_sensors(&t); | ||
| 1550 | if (unlikely(n < 0)) | ||
| 1551 | return n; | ||
| 1552 | |||
| 1553 | len += sprintf(p + len, "temperatures:\t"); | ||
| 1554 | |||
| 1555 | if (n > 0) { | ||
| 1556 | for (i = 0; i < (n - 1); i++) | ||
| 1557 | len += sprintf(p + len, "%d ", t.temp[i] / 1000); | ||
| 1558 | len += sprintf(p + len, "%d\n", t.temp[i] / 1000); | ||
| 1559 | } else | ||
| 1560 | len += sprintf(p + len, "not supported\n"); | ||
| 1319 | 1561 | ||
| 1320 | return len; | 1562 | return len; |
| 1321 | } | 1563 | } |
| @@ -1381,12 +1623,23 @@ static int ecdump_write(char *buf) | |||
| 1381 | 1623 | ||
| 1382 | static int brightness_offset = 0x31; | 1624 | static int brightness_offset = 0x31; |
| 1383 | 1625 | ||
| 1626 | static int brightness_get(struct backlight_device *bd) | ||
| 1627 | { | ||
| 1628 | u8 level; | ||
| 1629 | if (!acpi_ec_read(brightness_offset, &level)) | ||
| 1630 | return -EIO; | ||
| 1631 | |||
| 1632 | level &= 0x7; | ||
| 1633 | |||
| 1634 | return level; | ||
| 1635 | } | ||
| 1636 | |||
| 1384 | static int brightness_read(char *p) | 1637 | static int brightness_read(char *p) |
| 1385 | { | 1638 | { |
| 1386 | int len = 0; | 1639 | int len = 0; |
| 1387 | u8 level; | 1640 | int level; |
| 1388 | 1641 | ||
| 1389 | if (!acpi_ec_read(brightness_offset, &level)) { | 1642 | if ((level = brightness_get(NULL)) < 0) { |
| 1390 | len += sprintf(p + len, "level:\t\tunreadable\n"); | 1643 | len += sprintf(p + len, "level:\t\tunreadable\n"); |
| 1391 | } else { | 1644 | } else { |
| 1392 | len += sprintf(p + len, "level:\t\t%d\n", level & 0x7); | 1645 | len += sprintf(p + len, "level:\t\t%d\n", level & 0x7); |
| @@ -1401,16 +1654,34 @@ static int brightness_read(char *p) | |||
| 1401 | #define BRIGHTNESS_UP 4 | 1654 | #define BRIGHTNESS_UP 4 |
| 1402 | #define BRIGHTNESS_DOWN 5 | 1655 | #define BRIGHTNESS_DOWN 5 |
| 1403 | 1656 | ||
| 1404 | static int brightness_write(char *buf) | 1657 | static int brightness_set(int value) |
| 1405 | { | 1658 | { |
| 1406 | int cmos_cmd, inc, i; | 1659 | int cmos_cmd, inc, i; |
| 1407 | u8 level; | 1660 | int current_value = brightness_get(NULL); |
| 1661 | |||
| 1662 | value &= 7; | ||
| 1663 | |||
| 1664 | cmos_cmd = value > current_value ? BRIGHTNESS_UP : BRIGHTNESS_DOWN; | ||
| 1665 | inc = value > current_value ? 1 : -1; | ||
| 1666 | for (i = current_value; i != value; i += inc) { | ||
| 1667 | if (!cmos_eval(cmos_cmd)) | ||
| 1668 | return -EIO; | ||
| 1669 | if (!acpi_ec_write(brightness_offset, i + inc)) | ||
| 1670 | return -EIO; | ||
| 1671 | } | ||
| 1672 | |||
| 1673 | return 0; | ||
| 1674 | } | ||
| 1675 | |||
| 1676 | static int brightness_write(char *buf) | ||
| 1677 | { | ||
| 1678 | int level; | ||
| 1408 | int new_level; | 1679 | int new_level; |
| 1409 | char *cmd; | 1680 | char *cmd; |
| 1410 | 1681 | ||
| 1411 | while ((cmd = next_cmd(&buf))) { | 1682 | while ((cmd = next_cmd(&buf))) { |
| 1412 | if (!acpi_ec_read(brightness_offset, &level)) | 1683 | if ((level = brightness_get(NULL)) < 0) |
| 1413 | return -EIO; | 1684 | return level; |
| 1414 | level &= 7; | 1685 | level &= 7; |
| 1415 | 1686 | ||
| 1416 | if (strlencmp(cmd, "up") == 0) { | 1687 | if (strlencmp(cmd, "up") == 0) { |
| @@ -1423,19 +1694,44 @@ static int brightness_write(char *buf) | |||
| 1423 | } else | 1694 | } else |
| 1424 | return -EINVAL; | 1695 | return -EINVAL; |
| 1425 | 1696 | ||
| 1426 | cmos_cmd = new_level > level ? BRIGHTNESS_UP : BRIGHTNESS_DOWN; | 1697 | brightness_set(new_level); |
| 1427 | inc = new_level > level ? 1 : -1; | ||
| 1428 | for (i = level; i != new_level; i += inc) { | ||
| 1429 | if (!cmos_eval(cmos_cmd)) | ||
| 1430 | return -EIO; | ||
| 1431 | if (!acpi_ec_write(brightness_offset, i + inc)) | ||
| 1432 | return -EIO; | ||
| 1433 | } | ||
| 1434 | } | 1698 | } |
| 1435 | 1699 | ||
| 1436 | return 0; | 1700 | return 0; |
| 1437 | } | 1701 | } |
| 1438 | 1702 | ||
| 1703 | static int brightness_update_status(struct backlight_device *bd) | ||
| 1704 | { | ||
| 1705 | return brightness_set(bd->props->brightness); | ||
| 1706 | } | ||
| 1707 | |||
| 1708 | static struct backlight_properties ibm_backlight_data = { | ||
| 1709 | .owner = THIS_MODULE, | ||
| 1710 | .get_brightness = brightness_get, | ||
| 1711 | .update_status = brightness_update_status, | ||
| 1712 | .max_brightness = 7, | ||
| 1713 | }; | ||
| 1714 | |||
| 1715 | static int brightness_init(void) | ||
| 1716 | { | ||
| 1717 | ibm_backlight_device = backlight_device_register("ibm", NULL, NULL, | ||
| 1718 | &ibm_backlight_data); | ||
| 1719 | if (IS_ERR(ibm_backlight_device)) { | ||
| 1720 | printk(IBM_ERR "Could not register backlight device\n"); | ||
| 1721 | return PTR_ERR(ibm_backlight_device); | ||
| 1722 | } | ||
| 1723 | |||
| 1724 | return 0; | ||
| 1725 | } | ||
| 1726 | |||
| 1727 | static void brightness_exit(void) | ||
| 1728 | { | ||
| 1729 | if (ibm_backlight_device) { | ||
| 1730 | backlight_device_unregister(ibm_backlight_device); | ||
| 1731 | ibm_backlight_device = NULL; | ||
| 1732 | } | ||
| 1733 | } | ||
| 1734 | |||
| 1439 | static int volume_offset = 0x30; | 1735 | static int volume_offset = 0x30; |
| 1440 | 1736 | ||
| 1441 | static int volume_read(char *p) | 1737 | static int volume_read(char *p) |
| @@ -1522,86 +1818,482 @@ static int volume_write(char *buf) | |||
| 1522 | return 0; | 1818 | return 0; |
| 1523 | } | 1819 | } |
| 1524 | 1820 | ||
| 1525 | static int fan_status_offset = 0x2f; | 1821 | static enum fan_status_access_mode fan_status_access_mode; |
| 1526 | static int fan_rpm_offset = 0x84; | 1822 | static enum fan_control_access_mode fan_control_access_mode; |
| 1823 | static enum fan_control_commands fan_control_commands; | ||
| 1527 | 1824 | ||
| 1528 | static int fan_read(char *p) | 1825 | static int fan_control_status_known; |
| 1826 | static u8 fan_control_initial_status; | ||
| 1827 | |||
| 1828 | static void fan_watchdog_fire(struct work_struct *ignored); | ||
| 1829 | static int fan_watchdog_maxinterval; | ||
| 1830 | static DECLARE_DELAYED_WORK(fan_watchdog_task, fan_watchdog_fire); | ||
| 1831 | |||
| 1832 | static int fan_init(void) | ||
| 1529 | { | 1833 | { |
| 1530 | int len = 0; | 1834 | fan_status_access_mode = IBMACPI_FAN_NONE; |
| 1531 | int s; | 1835 | fan_control_access_mode = IBMACPI_FAN_WR_NONE; |
| 1532 | u8 lo, hi, status; | 1836 | fan_control_commands = 0; |
| 1837 | fan_control_status_known = 1; | ||
| 1838 | fan_watchdog_maxinterval = 0; | ||
| 1533 | 1839 | ||
| 1534 | if (gfan_handle) { | 1840 | if (gfan_handle) { |
| 1535 | /* 570, 600e/x, 770e, 770x */ | 1841 | /* 570, 600e/x, 770e, 770x */ |
| 1536 | if (!acpi_evalf(gfan_handle, &s, NULL, "d")) | 1842 | fan_status_access_mode = IBMACPI_FAN_RD_ACPI_GFAN; |
| 1537 | return -EIO; | 1843 | } else { |
| 1844 | /* all other ThinkPads: note that even old-style | ||
| 1845 | * ThinkPad ECs supports the fan control register */ | ||
| 1846 | if (likely(acpi_ec_read(fan_status_offset, | ||
| 1847 | &fan_control_initial_status))) { | ||
| 1848 | fan_status_access_mode = IBMACPI_FAN_RD_TPEC; | ||
| 1849 | |||
| 1850 | /* In some ThinkPads, neither the EC nor the ACPI | ||
| 1851 | * DSDT initialize the fan status, and it ends up | ||
| 1852 | * being set to 0x07 when it *could* be either | ||
| 1853 | * 0x07 or 0x80. | ||
| 1854 | * | ||
| 1855 | * Enable for TP-1Y (T43), TP-78 (R51e), | ||
| 1856 | * TP-76 (R52), TP-70 (T43, R52), which are known | ||
| 1857 | * to be buggy. */ | ||
| 1858 | if (fan_control_initial_status == 0x07 && | ||
| 1859 | ibm_thinkpad_ec_found && | ||
| 1860 | ((ibm_thinkpad_ec_found[0] == '1' && | ||
| 1861 | ibm_thinkpad_ec_found[1] == 'Y') || | ||
| 1862 | (ibm_thinkpad_ec_found[0] == '7' && | ||
| 1863 | (ibm_thinkpad_ec_found[1] == '6' || | ||
| 1864 | ibm_thinkpad_ec_found[1] == '8' || | ||
| 1865 | ibm_thinkpad_ec_found[1] == '0')) | ||
| 1866 | )) { | ||
| 1867 | printk(IBM_NOTICE | ||
| 1868 | "fan_init: initial fan status is " | ||
| 1869 | "unknown, assuming it is in auto " | ||
| 1870 | "mode\n"); | ||
| 1871 | fan_control_status_known = 0; | ||
| 1872 | } | ||
| 1873 | } else { | ||
| 1874 | printk(IBM_ERR | ||
| 1875 | "ThinkPad ACPI EC access misbehaving, " | ||
| 1876 | "fan status and control unavailable\n"); | ||
| 1877 | return 0; | ||
| 1878 | } | ||
| 1879 | } | ||
| 1538 | 1880 | ||
| 1539 | len += sprintf(p + len, "level:\t\t%d\n", s); | 1881 | if (sfan_handle) { |
| 1882 | /* 570, 770x-JL */ | ||
| 1883 | fan_control_access_mode = IBMACPI_FAN_WR_ACPI_SFAN; | ||
| 1884 | fan_control_commands |= | ||
| 1885 | IBMACPI_FAN_CMD_LEVEL | IBMACPI_FAN_CMD_ENABLE; | ||
| 1540 | } else { | 1886 | } else { |
| 1887 | if (!gfan_handle) { | ||
| 1888 | /* gfan without sfan means no fan control */ | ||
| 1889 | /* all other models implement TP EC 0x2f control */ | ||
| 1890 | |||
| 1891 | if (fans_handle) { | ||
| 1892 | /* X31, X40, X41 */ | ||
| 1893 | fan_control_access_mode = | ||
| 1894 | IBMACPI_FAN_WR_ACPI_FANS; | ||
| 1895 | fan_control_commands |= | ||
| 1896 | IBMACPI_FAN_CMD_SPEED | | ||
| 1897 | IBMACPI_FAN_CMD_LEVEL | | ||
| 1898 | IBMACPI_FAN_CMD_ENABLE; | ||
| 1899 | } else { | ||
| 1900 | fan_control_access_mode = IBMACPI_FAN_WR_TPEC; | ||
| 1901 | fan_control_commands |= | ||
| 1902 | IBMACPI_FAN_CMD_LEVEL | | ||
| 1903 | IBMACPI_FAN_CMD_ENABLE; | ||
| 1904 | } | ||
| 1905 | } | ||
| 1906 | } | ||
| 1907 | |||
| 1908 | return 0; | ||
| 1909 | } | ||
| 1910 | |||
| 1911 | static int fan_get_status(u8 *status) | ||
| 1912 | { | ||
| 1913 | u8 s; | ||
| 1914 | |||
| 1915 | /* TODO: | ||
| 1916 | * Add IBMACPI_FAN_RD_ACPI_FANS ? */ | ||
| 1917 | |||
| 1918 | switch (fan_status_access_mode) { | ||
| 1919 | case IBMACPI_FAN_RD_ACPI_GFAN: | ||
| 1920 | /* 570, 600e/x, 770e, 770x */ | ||
| 1921 | |||
| 1922 | if (unlikely(!acpi_evalf(gfan_handle, &s, NULL, "d"))) | ||
| 1923 | return -EIO; | ||
| 1924 | |||
| 1925 | if (likely(status)) | ||
| 1926 | *status = s & 0x07; | ||
| 1927 | |||
| 1928 | break; | ||
| 1929 | |||
| 1930 | case IBMACPI_FAN_RD_TPEC: | ||
| 1541 | /* all except 570, 600e/x, 770e, 770x */ | 1931 | /* all except 570, 600e/x, 770e, 770x */ |
| 1542 | if (!acpi_ec_read(fan_status_offset, &status)) | 1932 | if (unlikely(!acpi_ec_read(fan_status_offset, &s))) |
| 1543 | len += sprintf(p + len, "status:\t\tunreadable\n"); | 1933 | return -EIO; |
| 1544 | else | ||
| 1545 | len += sprintf(p + len, "status:\t\t%s\n", | ||
| 1546 | enabled(status, 7)); | ||
| 1547 | 1934 | ||
| 1548 | if (!acpi_ec_read(fan_rpm_offset, &lo) || | 1935 | if (likely(status)) |
| 1549 | !acpi_ec_read(fan_rpm_offset + 1, &hi)) | 1936 | *status = s; |
| 1550 | len += sprintf(p + len, "speed:\t\tunreadable\n"); | 1937 | |
| 1551 | else | 1938 | break; |
| 1552 | len += sprintf(p + len, "speed:\t\t%d\n", | 1939 | |
| 1553 | (hi << 8) + lo); | 1940 | default: |
| 1941 | return -ENXIO; | ||
| 1554 | } | 1942 | } |
| 1555 | 1943 | ||
| 1556 | if (sfan_handle) | 1944 | return 0; |
| 1557 | /* 570, 770x-JL */ | 1945 | } |
| 1558 | len += sprintf(p + len, "commands:\tlevel <level>" | 1946 | |
| 1559 | " (<level> is 0-7)\n"); | 1947 | static int fan_get_speed(unsigned int *speed) |
| 1560 | if (!gfan_handle) | 1948 | { |
| 1949 | u8 hi, lo; | ||
| 1950 | |||
| 1951 | switch (fan_status_access_mode) { | ||
| 1952 | case IBMACPI_FAN_RD_TPEC: | ||
| 1561 | /* all except 570, 600e/x, 770e, 770x */ | 1953 | /* all except 570, 600e/x, 770e, 770x */ |
| 1562 | len += sprintf(p + len, "commands:\tenable, disable\n"); | 1954 | if (unlikely(!acpi_ec_read(fan_rpm_offset, &lo) || |
| 1563 | if (fans_handle) | 1955 | !acpi_ec_read(fan_rpm_offset + 1, &hi))) |
| 1564 | /* X31, X40 */ | 1956 | return -EIO; |
| 1957 | |||
| 1958 | if (likely(speed)) | ||
| 1959 | *speed = (hi << 8) | lo; | ||
| 1960 | |||
| 1961 | break; | ||
| 1962 | |||
| 1963 | default: | ||
| 1964 | return -ENXIO; | ||
| 1965 | } | ||
| 1966 | |||
| 1967 | return 0; | ||
| 1968 | } | ||
| 1969 | |||
| 1970 | static void fan_exit(void) | ||
| 1971 | { | ||
| 1972 | cancel_delayed_work(&fan_watchdog_task); | ||
| 1973 | flush_scheduled_work(); | ||
| 1974 | } | ||
| 1975 | |||
| 1976 | static void fan_watchdog_reset(void) | ||
| 1977 | { | ||
| 1978 | static int fan_watchdog_active = 0; | ||
| 1979 | |||
| 1980 | if (fan_watchdog_active) | ||
| 1981 | cancel_delayed_work(&fan_watchdog_task); | ||
| 1982 | |||
| 1983 | if (fan_watchdog_maxinterval > 0) { | ||
| 1984 | fan_watchdog_active = 1; | ||
| 1985 | if (!schedule_delayed_work(&fan_watchdog_task, | ||
| 1986 | msecs_to_jiffies(fan_watchdog_maxinterval | ||
| 1987 | * 1000))) { | ||
| 1988 | printk(IBM_ERR "failed to schedule the fan watchdog, " | ||
| 1989 | "watchdog will not trigger\n"); | ||
| 1990 | } | ||
| 1991 | } else | ||
| 1992 | fan_watchdog_active = 0; | ||
| 1993 | } | ||
| 1994 | |||
| 1995 | static int fan_read(char *p) | ||
| 1996 | { | ||
| 1997 | int len = 0; | ||
| 1998 | int rc; | ||
| 1999 | u8 status; | ||
| 2000 | unsigned int speed = 0; | ||
| 2001 | |||
| 2002 | switch (fan_status_access_mode) { | ||
| 2003 | case IBMACPI_FAN_RD_ACPI_GFAN: | ||
| 2004 | /* 570, 600e/x, 770e, 770x */ | ||
| 2005 | if ((rc = fan_get_status(&status)) < 0) | ||
| 2006 | return rc; | ||
| 2007 | |||
| 2008 | len += sprintf(p + len, "status:\t\t%s\n" | ||
| 2009 | "level:\t\t%d\n", | ||
| 2010 | (status != 0) ? "enabled" : "disabled", status); | ||
| 2011 | break; | ||
| 2012 | |||
| 2013 | case IBMACPI_FAN_RD_TPEC: | ||
| 2014 | /* all except 570, 600e/x, 770e, 770x */ | ||
| 2015 | if ((rc = fan_get_status(&status)) < 0) | ||
| 2016 | return rc; | ||
| 2017 | |||
| 2018 | if (unlikely(!fan_control_status_known)) { | ||
| 2019 | if (status != fan_control_initial_status) | ||
| 2020 | fan_control_status_known = 1; | ||
| 2021 | else | ||
| 2022 | /* Return most likely status. In fact, it | ||
| 2023 | * might be the only possible status */ | ||
| 2024 | status = IBMACPI_FAN_EC_AUTO; | ||
| 2025 | } | ||
| 2026 | |||
| 2027 | len += sprintf(p + len, "status:\t\t%s\n", | ||
| 2028 | (status != 0) ? "enabled" : "disabled"); | ||
| 2029 | |||
| 2030 | /* No ThinkPad boots on disengaged mode, we can safely | ||
| 2031 | * assume the tachometer is online if fan control status | ||
| 2032 | * was unknown */ | ||
| 2033 | if ((rc = fan_get_speed(&speed)) < 0) | ||
| 2034 | return rc; | ||
| 2035 | |||
| 2036 | len += sprintf(p + len, "speed:\t\t%d\n", speed); | ||
| 2037 | |||
| 2038 | if (status & IBMACPI_FAN_EC_DISENGAGED) | ||
| 2039 | /* Disengaged mode takes precedence */ | ||
| 2040 | len += sprintf(p + len, "level:\t\tdisengaged\n"); | ||
| 2041 | else if (status & IBMACPI_FAN_EC_AUTO) | ||
| 2042 | len += sprintf(p + len, "level:\t\tauto\n"); | ||
| 2043 | else | ||
| 2044 | len += sprintf(p + len, "level:\t\t%d\n", status); | ||
| 2045 | break; | ||
| 2046 | |||
| 2047 | case IBMACPI_FAN_NONE: | ||
| 2048 | default: | ||
| 2049 | len += sprintf(p + len, "status:\t\tnot supported\n"); | ||
| 2050 | } | ||
| 2051 | |||
| 2052 | if (fan_control_commands & IBMACPI_FAN_CMD_LEVEL) { | ||
| 2053 | len += sprintf(p + len, "commands:\tlevel <level>"); | ||
| 2054 | |||
| 2055 | switch (fan_control_access_mode) { | ||
| 2056 | case IBMACPI_FAN_WR_ACPI_SFAN: | ||
| 2057 | len += sprintf(p + len, " (<level> is 0-7)\n"); | ||
| 2058 | break; | ||
| 2059 | |||
| 2060 | default: | ||
| 2061 | len += sprintf(p + len, " (<level> is 0-7, " | ||
| 2062 | "auto, disengaged)\n"); | ||
| 2063 | break; | ||
| 2064 | } | ||
| 2065 | } | ||
| 2066 | |||
| 2067 | if (fan_control_commands & IBMACPI_FAN_CMD_ENABLE) | ||
| 2068 | len += sprintf(p + len, "commands:\tenable, disable\n" | ||
| 2069 | "commands:\twatchdog <timeout> (<timeout> is 0 (off), " | ||
| 2070 | "1-120 (seconds))\n"); | ||
| 2071 | |||
| 2072 | if (fan_control_commands & IBMACPI_FAN_CMD_SPEED) | ||
| 1565 | len += sprintf(p + len, "commands:\tspeed <speed>" | 2073 | len += sprintf(p + len, "commands:\tspeed <speed>" |
| 1566 | " (<speed> is 0-65535)\n"); | 2074 | " (<speed> is 0-65535)\n"); |
| 1567 | 2075 | ||
| 1568 | return len; | 2076 | return len; |
| 1569 | } | 2077 | } |
| 1570 | 2078 | ||
| 1571 | static int fan_write(char *buf) | 2079 | static int fan_set_level(int level) |
| 1572 | { | 2080 | { |
| 1573 | char *cmd; | 2081 | switch (fan_control_access_mode) { |
| 1574 | int level, speed; | 2082 | case IBMACPI_FAN_WR_ACPI_SFAN: |
| 1575 | 2083 | if (level >= 0 && level <= 7) { | |
| 1576 | while ((cmd = next_cmd(&buf))) { | ||
| 1577 | if (sfan_handle && | ||
| 1578 | sscanf(cmd, "level %d", &level) == 1 && | ||
| 1579 | level >= 0 && level <= 7) { | ||
| 1580 | /* 570, 770x-JL */ | ||
| 1581 | if (!acpi_evalf(sfan_handle, NULL, NULL, "vd", level)) | 2084 | if (!acpi_evalf(sfan_handle, NULL, NULL, "vd", level)) |
| 1582 | return -EIO; | 2085 | return -EIO; |
| 1583 | } else if (!gfan_handle && strlencmp(cmd, "enable") == 0) { | 2086 | } else |
| 1584 | /* all except 570, 600e/x, 770e, 770x */ | 2087 | return -EINVAL; |
| 1585 | if (!acpi_ec_write(fan_status_offset, 0x80)) | 2088 | break; |
| 1586 | return -EIO; | 2089 | |
| 1587 | } else if (!gfan_handle && strlencmp(cmd, "disable") == 0) { | 2090 | case IBMACPI_FAN_WR_ACPI_FANS: |
| 1588 | /* all except 570, 600e/x, 770e, 770x */ | 2091 | case IBMACPI_FAN_WR_TPEC: |
| 1589 | if (!acpi_ec_write(fan_status_offset, 0x00)) | 2092 | if ((level != IBMACPI_FAN_EC_AUTO) && |
| 1590 | return -EIO; | 2093 | (level != IBMACPI_FAN_EC_DISENGAGED) && |
| 1591 | } else if (fans_handle && | 2094 | ((level < 0) || (level > 7))) |
| 1592 | sscanf(cmd, "speed %d", &speed) == 1 && | 2095 | return -EINVAL; |
| 1593 | speed >= 0 && speed <= 65535) { | 2096 | |
| 1594 | /* X31, X40 */ | 2097 | if (!acpi_ec_write(fan_status_offset, level)) |
| 2098 | return -EIO; | ||
| 2099 | else | ||
| 2100 | fan_control_status_known = 1; | ||
| 2101 | break; | ||
| 2102 | |||
| 2103 | default: | ||
| 2104 | return -ENXIO; | ||
| 2105 | } | ||
| 2106 | return 0; | ||
| 2107 | } | ||
| 2108 | |||
| 2109 | static int fan_set_enable(void) | ||
| 2110 | { | ||
| 2111 | u8 s; | ||
| 2112 | int rc; | ||
| 2113 | |||
| 2114 | switch (fan_control_access_mode) { | ||
| 2115 | case IBMACPI_FAN_WR_ACPI_FANS: | ||
| 2116 | case IBMACPI_FAN_WR_TPEC: | ||
| 2117 | if ((rc = fan_get_status(&s)) < 0) | ||
| 2118 | return rc; | ||
| 2119 | |||
| 2120 | /* Don't go out of emergency fan mode */ | ||
| 2121 | if (s != 7) | ||
| 2122 | s = IBMACPI_FAN_EC_AUTO; | ||
| 2123 | |||
| 2124 | if (!acpi_ec_write(fan_status_offset, s)) | ||
| 2125 | return -EIO; | ||
| 2126 | else | ||
| 2127 | fan_control_status_known = 1; | ||
| 2128 | break; | ||
| 2129 | |||
| 2130 | case IBMACPI_FAN_WR_ACPI_SFAN: | ||
| 2131 | if ((rc = fan_get_status(&s)) < 0) | ||
| 2132 | return rc; | ||
| 2133 | |||
| 2134 | s &= 0x07; | ||
| 2135 | |||
| 2136 | /* Set fan to at least level 4 */ | ||
| 2137 | if (s < 4) | ||
| 2138 | s = 4; | ||
| 2139 | |||
| 2140 | if (!acpi_evalf(sfan_handle, NULL, NULL, "vd", s)) | ||
| 2141 | return -EIO; | ||
| 2142 | break; | ||
| 2143 | |||
| 2144 | default: | ||
| 2145 | return -ENXIO; | ||
| 2146 | } | ||
| 2147 | return 0; | ||
| 2148 | } | ||
| 2149 | |||
| 2150 | static int fan_set_disable(void) | ||
| 2151 | { | ||
| 2152 | switch (fan_control_access_mode) { | ||
| 2153 | case IBMACPI_FAN_WR_ACPI_FANS: | ||
| 2154 | case IBMACPI_FAN_WR_TPEC: | ||
| 2155 | if (!acpi_ec_write(fan_status_offset, 0x00)) | ||
| 2156 | return -EIO; | ||
| 2157 | else | ||
| 2158 | fan_control_status_known = 1; | ||
| 2159 | break; | ||
| 2160 | |||
| 2161 | case IBMACPI_FAN_WR_ACPI_SFAN: | ||
| 2162 | if (!acpi_evalf(sfan_handle, NULL, NULL, "vd", 0x00)) | ||
| 2163 | return -EIO; | ||
| 2164 | break; | ||
| 2165 | |||
| 2166 | default: | ||
| 2167 | return -ENXIO; | ||
| 2168 | } | ||
| 2169 | return 0; | ||
| 2170 | } | ||
| 2171 | |||
| 2172 | static int fan_set_speed(int speed) | ||
| 2173 | { | ||
| 2174 | switch (fan_control_access_mode) { | ||
| 2175 | case IBMACPI_FAN_WR_ACPI_FANS: | ||
| 2176 | if (speed >= 0 && speed <= 65535) { | ||
| 1595 | if (!acpi_evalf(fans_handle, NULL, NULL, "vddd", | 2177 | if (!acpi_evalf(fans_handle, NULL, NULL, "vddd", |
| 1596 | speed, speed, speed)) | 2178 | speed, speed, speed)) |
| 1597 | return -EIO; | 2179 | return -EIO; |
| 1598 | } else | 2180 | } else |
| 1599 | return -EINVAL; | 2181 | return -EINVAL; |
| 1600 | } | 2182 | break; |
| 1601 | 2183 | ||
| 2184 | default: | ||
| 2185 | return -ENXIO; | ||
| 2186 | } | ||
| 1602 | return 0; | 2187 | return 0; |
| 1603 | } | 2188 | } |
| 1604 | 2189 | ||
| 2190 | static int fan_write_cmd_level(const char *cmd, int *rc) | ||
| 2191 | { | ||
| 2192 | int level; | ||
| 2193 | |||
| 2194 | if (strlencmp(cmd, "level auto") == 0) | ||
| 2195 | level = IBMACPI_FAN_EC_AUTO; | ||
| 2196 | else if (strlencmp(cmd, "level disengaged") == 0) | ||
| 2197 | level = IBMACPI_FAN_EC_DISENGAGED; | ||
| 2198 | else if (sscanf(cmd, "level %d", &level) != 1) | ||
| 2199 | return 0; | ||
| 2200 | |||
| 2201 | if ((*rc = fan_set_level(level)) == -ENXIO) | ||
| 2202 | printk(IBM_ERR "level command accepted for unsupported " | ||
| 2203 | "access mode %d", fan_control_access_mode); | ||
| 2204 | |||
| 2205 | return 1; | ||
| 2206 | } | ||
| 2207 | |||
| 2208 | static int fan_write_cmd_enable(const char *cmd, int *rc) | ||
| 2209 | { | ||
| 2210 | if (strlencmp(cmd, "enable") != 0) | ||
| 2211 | return 0; | ||
| 2212 | |||
| 2213 | if ((*rc = fan_set_enable()) == -ENXIO) | ||
| 2214 | printk(IBM_ERR "enable command accepted for unsupported " | ||
| 2215 | "access mode %d", fan_control_access_mode); | ||
| 2216 | |||
| 2217 | return 1; | ||
| 2218 | } | ||
| 2219 | |||
| 2220 | static int fan_write_cmd_disable(const char *cmd, int *rc) | ||
| 2221 | { | ||
| 2222 | if (strlencmp(cmd, "disable") != 0) | ||
| 2223 | return 0; | ||
| 2224 | |||
| 2225 | if ((*rc = fan_set_disable()) == -ENXIO) | ||
| 2226 | printk(IBM_ERR "disable command accepted for unsupported " | ||
| 2227 | "access mode %d", fan_control_access_mode); | ||
| 2228 | |||
| 2229 | return 1; | ||
| 2230 | } | ||
| 2231 | |||
| 2232 | static int fan_write_cmd_speed(const char *cmd, int *rc) | ||
| 2233 | { | ||
| 2234 | int speed; | ||
| 2235 | |||
| 2236 | /* TODO: | ||
| 2237 | * Support speed <low> <medium> <high> ? */ | ||
| 2238 | |||
| 2239 | if (sscanf(cmd, "speed %d", &speed) != 1) | ||
| 2240 | return 0; | ||
| 2241 | |||
| 2242 | if ((*rc = fan_set_speed(speed)) == -ENXIO) | ||
| 2243 | printk(IBM_ERR "speed command accepted for unsupported " | ||
| 2244 | "access mode %d", fan_control_access_mode); | ||
| 2245 | |||
| 2246 | return 1; | ||
| 2247 | } | ||
| 2248 | |||
| 2249 | static int fan_write_cmd_watchdog(const char *cmd, int *rc) | ||
| 2250 | { | ||
| 2251 | int interval; | ||
| 2252 | |||
| 2253 | if (sscanf(cmd, "watchdog %d", &interval) != 1) | ||
| 2254 | return 0; | ||
| 2255 | |||
| 2256 | if (interval < 0 || interval > 120) | ||
| 2257 | *rc = -EINVAL; | ||
| 2258 | else | ||
| 2259 | fan_watchdog_maxinterval = interval; | ||
| 2260 | |||
| 2261 | return 1; | ||
| 2262 | } | ||
| 2263 | |||
| 2264 | static int fan_write(char *buf) | ||
| 2265 | { | ||
| 2266 | char *cmd; | ||
| 2267 | int rc = 0; | ||
| 2268 | |||
| 2269 | while (!rc && (cmd = next_cmd(&buf))) { | ||
| 2270 | if (!((fan_control_commands & IBMACPI_FAN_CMD_LEVEL) && | ||
| 2271 | fan_write_cmd_level(cmd, &rc)) && | ||
| 2272 | !((fan_control_commands & IBMACPI_FAN_CMD_ENABLE) && | ||
| 2273 | (fan_write_cmd_enable(cmd, &rc) || | ||
| 2274 | fan_write_cmd_disable(cmd, &rc) || | ||
| 2275 | fan_write_cmd_watchdog(cmd, &rc))) && | ||
| 2276 | !((fan_control_commands & IBMACPI_FAN_CMD_SPEED) && | ||
| 2277 | fan_write_cmd_speed(cmd, &rc)) | ||
| 2278 | ) | ||
| 2279 | rc = -EINVAL; | ||
| 2280 | else if (!rc) | ||
| 2281 | fan_watchdog_reset(); | ||
| 2282 | } | ||
| 2283 | |||
| 2284 | return rc; | ||
| 2285 | } | ||
| 2286 | |||
| 2287 | static void fan_watchdog_fire(struct work_struct *ignored) | ||
| 2288 | { | ||
| 2289 | printk(IBM_NOTICE "fan watchdog: enabling fan\n"); | ||
| 2290 | if (fan_set_enable()) { | ||
| 2291 | printk(IBM_ERR "fan watchdog: error while enabling fan\n"); | ||
| 2292 | /* reschedule for later */ | ||
| 2293 | fan_watchdog_reset(); | ||
| 2294 | } | ||
| 2295 | } | ||
| 2296 | |||
| 1605 | static struct ibm_struct ibms[] = { | 2297 | static struct ibm_struct ibms[] = { |
| 1606 | { | 2298 | { |
| 1607 | .name = "driver", | 2299 | .name = "driver", |
| @@ -1662,6 +2354,7 @@ static struct ibm_struct ibms[] = { | |||
| 1662 | .type = ACPI_SYSTEM_NOTIFY, | 2354 | .type = ACPI_SYSTEM_NOTIFY, |
| 1663 | }, | 2355 | }, |
| 1664 | #endif | 2356 | #endif |
| 2357 | #ifdef CONFIG_ACPI_IBM_BAY | ||
| 1665 | { | 2358 | { |
| 1666 | .name = "bay", | 2359 | .name = "bay", |
| 1667 | .init = bay_init, | 2360 | .init = bay_init, |
| @@ -1671,6 +2364,7 @@ static struct ibm_struct ibms[] = { | |||
| 1671 | .handle = &bay_handle, | 2364 | .handle = &bay_handle, |
| 1672 | .type = ACPI_SYSTEM_NOTIFY, | 2365 | .type = ACPI_SYSTEM_NOTIFY, |
| 1673 | }, | 2366 | }, |
| 2367 | #endif | ||
| 1674 | { | 2368 | { |
| 1675 | .name = "cmos", | 2369 | .name = "cmos", |
| 1676 | .read = cmos_read, | 2370 | .read = cmos_read, |
| @@ -1702,6 +2396,8 @@ static struct ibm_struct ibms[] = { | |||
| 1702 | .name = "brightness", | 2396 | .name = "brightness", |
| 1703 | .read = brightness_read, | 2397 | .read = brightness_read, |
| 1704 | .write = brightness_write, | 2398 | .write = brightness_write, |
| 2399 | .init = brightness_init, | ||
| 2400 | .exit = brightness_exit, | ||
| 1705 | }, | 2401 | }, |
| 1706 | { | 2402 | { |
| 1707 | .name = "volume", | 2403 | .name = "volume", |
| @@ -1712,6 +2408,8 @@ static struct ibm_struct ibms[] = { | |||
| 1712 | .name = "fan", | 2408 | .name = "fan", |
| 1713 | .read = fan_read, | 2409 | .read = fan_read, |
| 1714 | .write = fan_write, | 2410 | .write = fan_write, |
| 2411 | .init = fan_init, | ||
| 2412 | .exit = fan_exit, | ||
| 1715 | .experimental = 1, | 2413 | .experimental = 1, |
| 1716 | }, | 2414 | }, |
| 1717 | }; | 2415 | }; |
| @@ -1719,7 +2417,7 @@ static struct ibm_struct ibms[] = { | |||
| 1719 | static int dispatch_read(char *page, char **start, off_t off, int count, | 2417 | static int dispatch_read(char *page, char **start, off_t off, int count, |
| 1720 | int *eof, void *data) | 2418 | int *eof, void *data) |
| 1721 | { | 2419 | { |
| 1722 | struct ibm_struct *ibm = (struct ibm_struct *)data; | 2420 | struct ibm_struct *ibm = data; |
| 1723 | int len; | 2421 | int len; |
| 1724 | 2422 | ||
| 1725 | if (!ibm || !ibm->read) | 2423 | if (!ibm || !ibm->read) |
| @@ -1744,7 +2442,7 @@ static int dispatch_read(char *page, char **start, off_t off, int count, | |||
| 1744 | static int dispatch_write(struct file *file, const char __user * userbuf, | 2442 | static int dispatch_write(struct file *file, const char __user * userbuf, |
| 1745 | unsigned long count, void *data) | 2443 | unsigned long count, void *data) |
| 1746 | { | 2444 | { |
| 1747 | struct ibm_struct *ibm = (struct ibm_struct *)data; | 2445 | struct ibm_struct *ibm = data; |
| 1748 | char *kernbuf; | 2446 | char *kernbuf; |
| 1749 | int ret; | 2447 | int ret; |
| 1750 | 2448 | ||
| @@ -1773,7 +2471,7 @@ static int dispatch_write(struct file *file, const char __user * userbuf, | |||
| 1773 | 2471 | ||
| 1774 | static void dispatch_notify(acpi_handle handle, u32 event, void *data) | 2472 | static void dispatch_notify(acpi_handle handle, u32 event, void *data) |
| 1775 | { | 2473 | { |
| 1776 | struct ibm_struct *ibm = (struct ibm_struct *)data; | 2474 | struct ibm_struct *ibm = data; |
| 1777 | 2475 | ||
| 1778 | if (!ibm || !ibm->notify) | 2476 | if (!ibm || !ibm->notify) |
| 1779 | return; | 2477 | return; |
| @@ -1805,7 +2503,7 @@ static int __init setup_notify(struct ibm_struct *ibm) | |||
| 1805 | ibm->name, status); | 2503 | ibm->name, status); |
| 1806 | return -ENODEV; | 2504 | return -ENODEV; |
| 1807 | } | 2505 | } |
| 1808 | 2506 | ibm->notify_installed = 1; | |
| 1809 | return 0; | 2507 | return 0; |
| 1810 | } | 2508 | } |
| 1811 | 2509 | ||
| @@ -1818,14 +2516,13 @@ static int __init register_driver(struct ibm_struct *ibm) | |||
| 1818 | { | 2516 | { |
| 1819 | int ret; | 2517 | int ret; |
| 1820 | 2518 | ||
| 1821 | ibm->driver = kmalloc(sizeof(struct acpi_driver), GFP_KERNEL); | 2519 | ibm->driver = kzalloc(sizeof(struct acpi_driver), GFP_KERNEL); |
| 1822 | if (!ibm->driver) { | 2520 | if (!ibm->driver) { |
| 1823 | printk(IBM_ERR "kmalloc(ibm->driver) failed\n"); | 2521 | printk(IBM_ERR "kmalloc(ibm->driver) failed\n"); |
| 1824 | return -1; | 2522 | return -1; |
| 1825 | } | 2523 | } |
| 1826 | 2524 | ||
| 1827 | memset(ibm->driver, 0, sizeof(struct acpi_driver)); | 2525 | sprintf(ibm->driver->name, "%s_%s", IBM_NAME, ibm->name); |
| 1828 | sprintf(ibm->driver->name, "%s/%s", IBM_NAME, ibm->name); | ||
| 1829 | ibm->driver->ids = ibm->hid; | 2526 | ibm->driver->ids = ibm->hid; |
| 1830 | ibm->driver->ops.add = &ibm_device_add; | 2527 | ibm->driver->ops.add = &ibm_device_add; |
| 1831 | 2528 | ||
| @@ -1882,7 +2579,6 @@ static int __init ibm_init(struct ibm_struct *ibm) | |||
| 1882 | ret = setup_notify(ibm); | 2579 | ret = setup_notify(ibm); |
| 1883 | if (ret < 0) | 2580 | if (ret < 0) |
| 1884 | return ret; | 2581 | return ret; |
| 1885 | ibm->notify_installed = 1; | ||
| 1886 | } | 2582 | } |
| 1887 | 2583 | ||
| 1888 | return 0; | 2584 | return 0; |
| @@ -1954,7 +2650,9 @@ IBM_PARAM(light); | |||
| 1954 | #ifdef CONFIG_ACPI_IBM_DOCK | 2650 | #ifdef CONFIG_ACPI_IBM_DOCK |
| 1955 | IBM_PARAM(dock); | 2651 | IBM_PARAM(dock); |
| 1956 | #endif | 2652 | #endif |
| 2653 | #ifdef CONFIG_ACPI_IBM_BAY | ||
| 1957 | IBM_PARAM(bay); | 2654 | IBM_PARAM(bay); |
| 2655 | #endif | ||
| 1958 | IBM_PARAM(cmos); | 2656 | IBM_PARAM(cmos); |
| 1959 | IBM_PARAM(led); | 2657 | IBM_PARAM(led); |
| 1960 | IBM_PARAM(beep); | 2658 | IBM_PARAM(beep); |
| @@ -1971,6 +2669,33 @@ static void acpi_ibm_exit(void) | |||
| 1971 | ibm_exit(&ibms[i]); | 2669 | ibm_exit(&ibms[i]); |
| 1972 | 2670 | ||
| 1973 | remove_proc_entry(IBM_DIR, acpi_root_dir); | 2671 | remove_proc_entry(IBM_DIR, acpi_root_dir); |
| 2672 | |||
| 2673 | if (ibm_thinkpad_ec_found) | ||
| 2674 | kfree(ibm_thinkpad_ec_found); | ||
| 2675 | } | ||
| 2676 | |||
| 2677 | static char* __init check_dmi_for_ec(void) | ||
| 2678 | { | ||
| 2679 | struct dmi_device *dev = NULL; | ||
| 2680 | char ec_fw_string[18]; | ||
| 2681 | |||
| 2682 | /* | ||
| 2683 | * ThinkPad T23 or newer, A31 or newer, R50e or newer, | ||
| 2684 | * X32 or newer, all Z series; Some models must have an | ||
| 2685 | * up-to-date BIOS or they will not be detected. | ||
| 2686 | * | ||
| 2687 | * See http://thinkwiki.org/wiki/List_of_DMI_IDs | ||
| 2688 | */ | ||
| 2689 | while ((dev = dmi_find_device(DMI_DEV_TYPE_OEM_STRING, NULL, dev))) { | ||
| 2690 | if (sscanf(dev->name, | ||
| 2691 | "IBM ThinkPad Embedded Controller -[%17c", | ||
| 2692 | ec_fw_string) == 1) { | ||
| 2693 | ec_fw_string[sizeof(ec_fw_string) - 1] = 0; | ||
| 2694 | ec_fw_string[strcspn(ec_fw_string, " ]")] = 0; | ||
| 2695 | return kstrdup(ec_fw_string, GFP_KERNEL); | ||
| 2696 | } | ||
| 2697 | } | ||
| 2698 | return NULL; | ||
| 1974 | } | 2699 | } |
| 1975 | 2700 | ||
| 1976 | static int __init acpi_ibm_init(void) | 2701 | static int __init acpi_ibm_init(void) |
| @@ -1992,6 +2717,12 @@ static int __init acpi_ibm_init(void) | |||
| 1992 | return -ENODEV; | 2717 | return -ENODEV; |
| 1993 | } | 2718 | } |
| 1994 | 2719 | ||
| 2720 | /* Models with newer firmware report the EC in DMI */ | ||
| 2721 | ibm_thinkpad_ec_found = check_dmi_for_ec(); | ||
| 2722 | if (ibm_thinkpad_ec_found) | ||
| 2723 | printk(IBM_INFO "ThinkPad EC firmware %s\n", | ||
| 2724 | ibm_thinkpad_ec_found); | ||
| 2725 | |||
| 1995 | /* these handles are not required */ | 2726 | /* these handles are not required */ |
| 1996 | IBM_HANDLE_INIT(vid); | 2727 | IBM_HANDLE_INIT(vid); |
| 1997 | IBM_HANDLE_INIT(vid2); | 2728 | IBM_HANDLE_INIT(vid2); |
| @@ -2004,12 +2735,14 @@ static int __init acpi_ibm_init(void) | |||
| 2004 | IBM_HANDLE_INIT(dock); | 2735 | IBM_HANDLE_INIT(dock); |
| 2005 | #endif | 2736 | #endif |
| 2006 | IBM_HANDLE_INIT(pci); | 2737 | IBM_HANDLE_INIT(pci); |
| 2738 | #ifdef CONFIG_ACPI_IBM_BAY | ||
| 2007 | IBM_HANDLE_INIT(bay); | 2739 | IBM_HANDLE_INIT(bay); |
| 2008 | if (bay_handle) | 2740 | if (bay_handle) |
| 2009 | IBM_HANDLE_INIT(bay_ej); | 2741 | IBM_HANDLE_INIT(bay_ej); |
| 2010 | IBM_HANDLE_INIT(bay2); | 2742 | IBM_HANDLE_INIT(bay2); |
| 2011 | if (bay2_handle) | 2743 | if (bay2_handle) |
| 2012 | IBM_HANDLE_INIT(bay2_ej); | 2744 | IBM_HANDLE_INIT(bay2_ej); |
| 2745 | #endif | ||
| 2013 | IBM_HANDLE_INIT(beep); | 2746 | IBM_HANDLE_INIT(beep); |
| 2014 | IBM_HANDLE_INIT(ecrd); | 2747 | IBM_HANDLE_INIT(ecrd); |
| 2015 | IBM_HANDLE_INIT(ecwr); | 2748 | IBM_HANDLE_INIT(ecwr); |
diff --git a/drivers/acpi/namespace/nsxfobj.c b/drivers/acpi/namespace/nsxfobj.c index a163e1d3708d..a18b1c223129 100644 --- a/drivers/acpi/namespace/nsxfobj.c +++ b/drivers/acpi/namespace/nsxfobj.c | |||
| @@ -50,6 +50,50 @@ ACPI_MODULE_NAME("nsxfobj") | |||
| 50 | 50 | ||
| 51 | /******************************************************************************* | 51 | /******************************************************************************* |
| 52 | * | 52 | * |
| 53 | * FUNCTION: acpi_get_id | ||
| 54 | * | ||
| 55 | * PARAMETERS: Handle - Handle of object whose id is desired | ||
| 56 | * ret_id - Where the id will be placed | ||
| 57 | * | ||
| 58 | * RETURN: Status | ||
| 59 | * | ||
| 60 | * DESCRIPTION: This routine returns the owner id associated with a handle | ||
| 61 | * | ||
| 62 | ******************************************************************************/ | ||
| 63 | acpi_status acpi_get_id(acpi_handle handle, acpi_owner_id * ret_id) | ||
| 64 | { | ||
| 65 | struct acpi_namespace_node *node; | ||
| 66 | acpi_status status; | ||
| 67 | |||
| 68 | /* Parameter Validation */ | ||
| 69 | |||
| 70 | if (!ret_id) { | ||
| 71 | return (AE_BAD_PARAMETER); | ||
| 72 | } | ||
| 73 | |||
| 74 | status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE); | ||
| 75 | if (ACPI_FAILURE(status)) { | ||
| 76 | return (status); | ||
| 77 | } | ||
| 78 | |||
| 79 | /* Convert and validate the handle */ | ||
| 80 | |||
| 81 | node = acpi_ns_map_handle_to_node(handle); | ||
| 82 | if (!node) { | ||
| 83 | (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE); | ||
| 84 | return (AE_BAD_PARAMETER); | ||
| 85 | } | ||
| 86 | |||
| 87 | *ret_id = node->owner_id; | ||
| 88 | |||
| 89 | status = acpi_ut_release_mutex(ACPI_MTX_NAMESPACE); | ||
| 90 | return (status); | ||
| 91 | } | ||
| 92 | |||
| 93 | ACPI_EXPORT_SYMBOL(acpi_get_id) | ||
| 94 | |||
| 95 | /******************************************************************************* | ||
| 96 | * | ||
| 53 | * FUNCTION: acpi_get_type | 97 | * FUNCTION: acpi_get_type |
| 54 | * | 98 | * |
| 55 | * PARAMETERS: Handle - Handle of object whose type is desired | 99 | * PARAMETERS: Handle - Handle of object whose type is desired |
diff --git a/drivers/acpi/numa.c b/drivers/acpi/numa.c index e5e448edca41..bd96a7045925 100644 --- a/drivers/acpi/numa.c +++ b/drivers/acpi/numa.c | |||
| @@ -248,7 +248,7 @@ int acpi_get_pxm(acpi_handle h) | |||
| 248 | handle = phandle; | 248 | handle = phandle; |
| 249 | status = acpi_evaluate_integer(handle, "_PXM", NULL, &pxm); | 249 | status = acpi_evaluate_integer(handle, "_PXM", NULL, &pxm); |
| 250 | if (ACPI_SUCCESS(status)) | 250 | if (ACPI_SUCCESS(status)) |
| 251 | return (int)pxm; | 251 | return pxm; |
| 252 | status = acpi_get_parent(handle, &phandle); | 252 | status = acpi_get_parent(handle, &phandle); |
| 253 | } while (ACPI_SUCCESS(status)); | 253 | } while (ACPI_SUCCESS(status)); |
| 254 | return -1; | 254 | return -1; |
diff --git a/drivers/acpi/osl.c b/drivers/acpi/osl.c index 02b30ae6a68e..57ae1e5cde0a 100644 --- a/drivers/acpi/osl.c +++ b/drivers/acpi/osl.c | |||
| @@ -568,6 +568,7 @@ void acpi_os_derive_pci_id(acpi_handle rhandle, /* upper bound */ | |||
| 568 | static void acpi_os_execute_deferred(struct work_struct *work) | 568 | static void acpi_os_execute_deferred(struct work_struct *work) |
| 569 | { | 569 | { |
| 570 | struct acpi_os_dpc *dpc = container_of(work, struct acpi_os_dpc, work); | 570 | struct acpi_os_dpc *dpc = container_of(work, struct acpi_os_dpc, work); |
| 571 | |||
| 571 | if (!dpc) { | 572 | if (!dpc) { |
| 572 | printk(KERN_ERR PREFIX "Invalid (NULL) context\n"); | 573 | printk(KERN_ERR PREFIX "Invalid (NULL) context\n"); |
| 573 | return; | 574 | return; |
| @@ -1031,7 +1032,7 @@ acpi_status | |||
| 1031 | acpi_os_create_cache(char *name, u16 size, u16 depth, acpi_cache_t ** cache) | 1032 | acpi_os_create_cache(char *name, u16 size, u16 depth, acpi_cache_t ** cache) |
| 1032 | { | 1033 | { |
| 1033 | *cache = kmem_cache_create(name, size, 0, 0, NULL, NULL); | 1034 | *cache = kmem_cache_create(name, size, 0, 0, NULL, NULL); |
| 1034 | if (cache == NULL) | 1035 | if (*cache == NULL) |
| 1035 | return AE_ERROR; | 1036 | return AE_ERROR; |
| 1036 | else | 1037 | else |
| 1037 | return AE_OK; | 1038 | return AE_OK; |
| @@ -1051,7 +1052,7 @@ acpi_os_create_cache(char *name, u16 size, u16 depth, acpi_cache_t ** cache) | |||
| 1051 | 1052 | ||
| 1052 | acpi_status acpi_os_purge_cache(acpi_cache_t * cache) | 1053 | acpi_status acpi_os_purge_cache(acpi_cache_t * cache) |
| 1053 | { | 1054 | { |
| 1054 | (void)kmem_cache_shrink(cache); | 1055 | kmem_cache_shrink(cache); |
| 1055 | return (AE_OK); | 1056 | return (AE_OK); |
| 1056 | } | 1057 | } |
| 1057 | 1058 | ||
diff --git a/drivers/acpi/pci_bind.c b/drivers/acpi/pci_bind.c index 1e2ae6e7a7e4..55f57a61c55e 100644 --- a/drivers/acpi/pci_bind.c +++ b/drivers/acpi/pci_bind.c | |||
| @@ -122,19 +122,17 @@ int acpi_pci_bind(struct acpi_device *device) | |||
| 122 | if (!device || !device->parent) | 122 | if (!device || !device->parent) |
| 123 | return -EINVAL; | 123 | return -EINVAL; |
| 124 | 124 | ||
| 125 | pathname = kmalloc(ACPI_PATHNAME_MAX, GFP_KERNEL); | 125 | pathname = kzalloc(ACPI_PATHNAME_MAX, GFP_KERNEL); |
| 126 | if (!pathname) | 126 | if (!pathname) |
| 127 | return -ENOMEM; | 127 | return -ENOMEM; |
| 128 | memset(pathname, 0, ACPI_PATHNAME_MAX); | ||
| 129 | buffer.length = ACPI_PATHNAME_MAX; | 128 | buffer.length = ACPI_PATHNAME_MAX; |
| 130 | buffer.pointer = pathname; | 129 | buffer.pointer = pathname; |
| 131 | 130 | ||
| 132 | data = kmalloc(sizeof(struct acpi_pci_data), GFP_KERNEL); | 131 | data = kzalloc(sizeof(struct acpi_pci_data), GFP_KERNEL); |
| 133 | if (!data) { | 132 | if (!data) { |
| 134 | kfree(pathname); | 133 | kfree(pathname); |
| 135 | return -ENOMEM; | 134 | return -ENOMEM; |
| 136 | } | 135 | } |
| 137 | memset(data, 0, sizeof(struct acpi_pci_data)); | ||
| 138 | 136 | ||
| 139 | acpi_get_name(device->handle, ACPI_FULL_PATHNAME, &buffer); | 137 | acpi_get_name(device->handle, ACPI_FULL_PATHNAME, &buffer); |
| 140 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Binding PCI device [%s]...\n", | 138 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Binding PCI device [%s]...\n", |
| @@ -281,10 +279,9 @@ int acpi_pci_unbind(struct acpi_device *device) | |||
| 281 | if (!device || !device->parent) | 279 | if (!device || !device->parent) |
| 282 | return -EINVAL; | 280 | return -EINVAL; |
| 283 | 281 | ||
| 284 | pathname = (char *)kmalloc(ACPI_PATHNAME_MAX, GFP_KERNEL); | 282 | pathname = kzalloc(ACPI_PATHNAME_MAX, GFP_KERNEL); |
| 285 | if (!pathname) | 283 | if (!pathname) |
| 286 | return -ENOMEM; | 284 | return -ENOMEM; |
| 287 | memset(pathname, 0, ACPI_PATHNAME_MAX); | ||
| 288 | 285 | ||
| 289 | buffer.length = ACPI_PATHNAME_MAX; | 286 | buffer.length = ACPI_PATHNAME_MAX; |
| 290 | buffer.pointer = pathname; | 287 | buffer.pointer = pathname; |
| @@ -331,11 +328,9 @@ acpi_pci_bind_root(struct acpi_device *device, | |||
| 331 | char *pathname = NULL; | 328 | char *pathname = NULL; |
| 332 | struct acpi_buffer buffer = { 0, NULL }; | 329 | struct acpi_buffer buffer = { 0, NULL }; |
| 333 | 330 | ||
| 334 | 331 | pathname = kzalloc(ACPI_PATHNAME_MAX, GFP_KERNEL); | |
| 335 | pathname = (char *)kmalloc(ACPI_PATHNAME_MAX, GFP_KERNEL); | ||
| 336 | if (!pathname) | 332 | if (!pathname) |
| 337 | return -ENOMEM; | 333 | return -ENOMEM; |
| 338 | memset(pathname, 0, ACPI_PATHNAME_MAX); | ||
| 339 | 334 | ||
| 340 | buffer.length = ACPI_PATHNAME_MAX; | 335 | buffer.length = ACPI_PATHNAME_MAX; |
| 341 | buffer.pointer = pathname; | 336 | buffer.pointer = pathname; |
| @@ -345,12 +340,11 @@ acpi_pci_bind_root(struct acpi_device *device, | |||
| 345 | return -EINVAL; | 340 | return -EINVAL; |
| 346 | } | 341 | } |
| 347 | 342 | ||
| 348 | data = kmalloc(sizeof(struct acpi_pci_data), GFP_KERNEL); | 343 | data = kzalloc(sizeof(struct acpi_pci_data), GFP_KERNEL); |
| 349 | if (!data) { | 344 | if (!data) { |
| 350 | kfree(pathname); | 345 | kfree(pathname); |
| 351 | return -ENOMEM; | 346 | return -ENOMEM; |
| 352 | } | 347 | } |
| 353 | memset(data, 0, sizeof(struct acpi_pci_data)); | ||
| 354 | 348 | ||
| 355 | data->id = *id; | 349 | data->id = *id; |
| 356 | data->bus = bus; | 350 | data->bus = bus; |
diff --git a/drivers/acpi/pci_irq.c b/drivers/acpi/pci_irq.c index feda0341f5a7..fe7d007833ad 100644 --- a/drivers/acpi/pci_irq.c +++ b/drivers/acpi/pci_irq.c | |||
| @@ -89,10 +89,9 @@ acpi_pci_irq_add_entry(acpi_handle handle, | |||
| 89 | if (!prt) | 89 | if (!prt) |
| 90 | return -EINVAL; | 90 | return -EINVAL; |
| 91 | 91 | ||
| 92 | entry = kmalloc(sizeof(struct acpi_prt_entry), GFP_KERNEL); | 92 | entry = kzalloc(sizeof(struct acpi_prt_entry), GFP_KERNEL); |
| 93 | if (!entry) | 93 | if (!entry) |
| 94 | return -ENOMEM; | 94 | return -ENOMEM; |
| 95 | memset(entry, 0, sizeof(struct acpi_prt_entry)); | ||
| 96 | 95 | ||
| 97 | entry->id.segment = segment; | 96 | entry->id.segment = segment; |
| 98 | entry->id.bus = bus; | 97 | entry->id.bus = bus; |
| @@ -161,10 +160,9 @@ int acpi_pci_irq_add_prt(acpi_handle handle, int segment, int bus) | |||
| 161 | static int first_time = 1; | 160 | static int first_time = 1; |
| 162 | 161 | ||
| 163 | 162 | ||
| 164 | pathname = (char *)kmalloc(ACPI_PATHNAME_MAX, GFP_KERNEL); | 163 | pathname = kzalloc(ACPI_PATHNAME_MAX, GFP_KERNEL); |
| 165 | if (!pathname) | 164 | if (!pathname) |
| 166 | return -ENOMEM; | 165 | return -ENOMEM; |
| 167 | memset(pathname, 0, ACPI_PATHNAME_MAX); | ||
| 168 | 166 | ||
| 169 | if (first_time) { | 167 | if (first_time) { |
| 170 | acpi_prt.count = 0; | 168 | acpi_prt.count = 0; |
| @@ -198,11 +196,10 @@ int acpi_pci_irq_add_prt(acpi_handle handle, int segment, int bus) | |||
| 198 | return -ENODEV; | 196 | return -ENODEV; |
| 199 | } | 197 | } |
| 200 | 198 | ||
| 201 | prt = kmalloc(buffer.length, GFP_KERNEL); | 199 | prt = kzalloc(buffer.length, GFP_KERNEL); |
| 202 | if (!prt) { | 200 | if (!prt) { |
| 203 | return -ENOMEM; | 201 | return -ENOMEM; |
| 204 | } | 202 | } |
| 205 | memset(prt, 0, buffer.length); | ||
| 206 | buffer.pointer = prt; | 203 | buffer.pointer = prt; |
| 207 | 204 | ||
| 208 | status = acpi_get_irq_routing_table(handle, &buffer); | 205 | status = acpi_get_irq_routing_table(handle, &buffer); |
diff --git a/drivers/acpi/pci_link.c b/drivers/acpi/pci_link.c index d53bd9878ca2..481e633bbf41 100644 --- a/drivers/acpi/pci_link.c +++ b/drivers/acpi/pci_link.c | |||
| @@ -103,7 +103,7 @@ DEFINE_MUTEX(acpi_link_lock); | |||
| 103 | static acpi_status | 103 | static acpi_status |
| 104 | acpi_pci_link_check_possible(struct acpi_resource *resource, void *context) | 104 | acpi_pci_link_check_possible(struct acpi_resource *resource, void *context) |
| 105 | { | 105 | { |
| 106 | struct acpi_pci_link *link = (struct acpi_pci_link *)context; | 106 | struct acpi_pci_link *link = context; |
| 107 | u32 i = 0; | 107 | u32 i = 0; |
| 108 | 108 | ||
| 109 | 109 | ||
| @@ -307,11 +307,10 @@ static int acpi_pci_link_set(struct acpi_pci_link *link, int irq) | |||
| 307 | if (!link || !irq) | 307 | if (!link || !irq) |
| 308 | return -EINVAL; | 308 | return -EINVAL; |
| 309 | 309 | ||
| 310 | resource = kmalloc(sizeof(*resource) + 1, irqs_disabled() ? GFP_ATOMIC: GFP_KERNEL); | 310 | resource = kzalloc(sizeof(*resource) + 1, irqs_disabled() ? GFP_ATOMIC: GFP_KERNEL); |
| 311 | if (!resource) | 311 | if (!resource) |
| 312 | return -ENOMEM; | 312 | return -ENOMEM; |
| 313 | 313 | ||
| 314 | memset(resource, 0, sizeof(*resource) + 1); | ||
| 315 | buffer.length = sizeof(*resource) + 1; | 314 | buffer.length = sizeof(*resource) + 1; |
| 316 | buffer.pointer = resource; | 315 | buffer.pointer = resource; |
| 317 | 316 | ||
| @@ -613,7 +612,7 @@ acpi_pci_link_allocate_irq(acpi_handle handle, | |||
| 613 | return -1; | 612 | return -1; |
| 614 | } | 613 | } |
| 615 | 614 | ||
| 616 | link = (struct acpi_pci_link *)acpi_driver_data(device); | 615 | link = acpi_driver_data(device); |
| 617 | if (!link) { | 616 | if (!link) { |
| 618 | printk(KERN_ERR PREFIX "Invalid link context\n"); | 617 | printk(KERN_ERR PREFIX "Invalid link context\n"); |
| 619 | return -1; | 618 | return -1; |
| @@ -668,7 +667,7 @@ int acpi_pci_link_free_irq(acpi_handle handle) | |||
| 668 | return -1; | 667 | return -1; |
| 669 | } | 668 | } |
| 670 | 669 | ||
| 671 | link = (struct acpi_pci_link *)acpi_driver_data(device); | 670 | link = acpi_driver_data(device); |
| 672 | if (!link) { | 671 | if (!link) { |
| 673 | printk(KERN_ERR PREFIX "Invalid link context\n"); | 672 | printk(KERN_ERR PREFIX "Invalid link context\n"); |
| 674 | return -1; | 673 | return -1; |
| @@ -718,10 +717,9 @@ static int acpi_pci_link_add(struct acpi_device *device) | |||
| 718 | if (!device) | 717 | if (!device) |
| 719 | return -EINVAL; | 718 | return -EINVAL; |
| 720 | 719 | ||
| 721 | link = kmalloc(sizeof(struct acpi_pci_link), GFP_KERNEL); | 720 | link = kzalloc(sizeof(struct acpi_pci_link), GFP_KERNEL); |
| 722 | if (!link) | 721 | if (!link) |
| 723 | return -ENOMEM; | 722 | return -ENOMEM; |
| 724 | memset(link, 0, sizeof(struct acpi_pci_link)); | ||
| 725 | 723 | ||
| 726 | link->device = device; | 724 | link->device = device; |
| 727 | strcpy(acpi_device_name(device), ACPI_PCI_LINK_DEVICE_NAME); | 725 | strcpy(acpi_device_name(device), ACPI_PCI_LINK_DEVICE_NAME); |
| @@ -808,7 +806,7 @@ static int acpi_pci_link_remove(struct acpi_device *device, int type) | |||
| 808 | if (!device || !acpi_driver_data(device)) | 806 | if (!device || !acpi_driver_data(device)) |
| 809 | return -EINVAL; | 807 | return -EINVAL; |
| 810 | 808 | ||
| 811 | link = (struct acpi_pci_link *)acpi_driver_data(device); | 809 | link = acpi_driver_data(device); |
| 812 | 810 | ||
| 813 | mutex_lock(&acpi_link_lock); | 811 | mutex_lock(&acpi_link_lock); |
| 814 | list_del(&link->node); | 812 | list_del(&link->node); |
diff --git a/drivers/acpi/pci_root.c b/drivers/acpi/pci_root.c index 0984a1ee24ed..a860efa2c562 100644 --- a/drivers/acpi/pci_root.c +++ b/drivers/acpi/pci_root.c | |||
| @@ -98,11 +98,12 @@ void acpi_pci_unregister_driver(struct acpi_pci_driver *driver) | |||
| 98 | 98 | ||
| 99 | struct acpi_pci_driver **pptr = &sub_driver; | 99 | struct acpi_pci_driver **pptr = &sub_driver; |
| 100 | while (*pptr) { | 100 | while (*pptr) { |
| 101 | if (*pptr != driver) | 101 | if (*pptr == driver) |
| 102 | continue; | 102 | break; |
| 103 | *pptr = (*pptr)->next; | 103 | pptr = &(*pptr)->next; |
| 104 | break; | ||
| 105 | } | 104 | } |
| 105 | BUG_ON(!*pptr); | ||
| 106 | *pptr = (*pptr)->next; | ||
| 106 | 107 | ||
| 107 | if (!driver->remove) | 108 | if (!driver->remove) |
| 108 | return; | 109 | return; |
| @@ -119,7 +120,7 @@ EXPORT_SYMBOL(acpi_pci_unregister_driver); | |||
| 119 | static acpi_status | 120 | static acpi_status |
| 120 | get_root_bridge_busnr_callback(struct acpi_resource *resource, void *data) | 121 | get_root_bridge_busnr_callback(struct acpi_resource *resource, void *data) |
| 121 | { | 122 | { |
| 122 | int *busnr = (int *)data; | 123 | int *busnr = data; |
| 123 | struct acpi_resource_address64 address; | 124 | struct acpi_resource_address64 address; |
| 124 | 125 | ||
| 125 | if (resource->type != ACPI_RESOURCE_TYPE_ADDRESS16 && | 126 | if (resource->type != ACPI_RESOURCE_TYPE_ADDRESS16 && |
| @@ -164,10 +165,9 @@ static int acpi_pci_root_add(struct acpi_device *device) | |||
| 164 | if (!device) | 165 | if (!device) |
| 165 | return -EINVAL; | 166 | return -EINVAL; |
| 166 | 167 | ||
| 167 | root = kmalloc(sizeof(struct acpi_pci_root), GFP_KERNEL); | 168 | root = kzalloc(sizeof(struct acpi_pci_root), GFP_KERNEL); |
| 168 | if (!root) | 169 | if (!root) |
| 169 | return -ENOMEM; | 170 | return -ENOMEM; |
| 170 | memset(root, 0, sizeof(struct acpi_pci_root)); | ||
| 171 | INIT_LIST_HEAD(&root->node); | 171 | INIT_LIST_HEAD(&root->node); |
| 172 | 172 | ||
| 173 | root->device = device; | 173 | root->device = device; |
| @@ -331,7 +331,7 @@ static int acpi_pci_root_remove(struct acpi_device *device, int type) | |||
| 331 | if (!device || !acpi_driver_data(device)) | 331 | if (!device || !acpi_driver_data(device)) |
| 332 | return -EINVAL; | 332 | return -EINVAL; |
| 333 | 333 | ||
| 334 | root = (struct acpi_pci_root *)acpi_driver_data(device); | 334 | root = acpi_driver_data(device); |
| 335 | 335 | ||
| 336 | kfree(root); | 336 | kfree(root); |
| 337 | 337 | ||
diff --git a/drivers/acpi/power.c b/drivers/acpi/power.c index fe67a8af520e..0ba7dfbbb2ee 100644 --- a/drivers/acpi/power.c +++ b/drivers/acpi/power.c | |||
| @@ -108,7 +108,7 @@ acpi_power_get_context(acpi_handle handle, | |||
| 108 | return result; | 108 | return result; |
| 109 | } | 109 | } |
| 110 | 110 | ||
| 111 | *resource = (struct acpi_power_resource *)acpi_driver_data(device); | 111 | *resource = acpi_driver_data(device); |
| 112 | if (!resource) | 112 | if (!resource) |
| 113 | return -ENODEV; | 113 | return -ENODEV; |
| 114 | 114 | ||
| @@ -442,7 +442,7 @@ static int acpi_power_seq_show(struct seq_file *seq, void *offset) | |||
| 442 | struct acpi_power_resource *resource = NULL; | 442 | struct acpi_power_resource *resource = NULL; |
| 443 | 443 | ||
| 444 | 444 | ||
| 445 | resource = (struct acpi_power_resource *)seq->private; | 445 | resource = seq->private; |
| 446 | 446 | ||
| 447 | if (!resource) | 447 | if (!resource) |
| 448 | goto end; | 448 | goto end; |
| @@ -532,10 +532,9 @@ static int acpi_power_add(struct acpi_device *device) | |||
| 532 | if (!device) | 532 | if (!device) |
| 533 | return -EINVAL; | 533 | return -EINVAL; |
| 534 | 534 | ||
| 535 | resource = kmalloc(sizeof(struct acpi_power_resource), GFP_KERNEL); | 535 | resource = kzalloc(sizeof(struct acpi_power_resource), GFP_KERNEL); |
| 536 | if (!resource) | 536 | if (!resource) |
| 537 | return -ENOMEM; | 537 | return -ENOMEM; |
| 538 | memset(resource, 0, sizeof(struct acpi_power_resource)); | ||
| 539 | 538 | ||
| 540 | resource->device = device; | 539 | resource->device = device; |
| 541 | strcpy(resource->name, device->pnp.bus_id); | 540 | strcpy(resource->name, device->pnp.bus_id); |
| @@ -590,7 +589,7 @@ static int acpi_power_remove(struct acpi_device *device, int type) | |||
| 590 | if (!device || !acpi_driver_data(device)) | 589 | if (!device || !acpi_driver_data(device)) |
| 591 | return -EINVAL; | 590 | return -EINVAL; |
| 592 | 591 | ||
| 593 | resource = (struct acpi_power_resource *)acpi_driver_data(device); | 592 | resource = acpi_driver_data(device); |
| 594 | 593 | ||
| 595 | acpi_power_remove_fs(device); | 594 | acpi_power_remove_fs(device); |
| 596 | 595 | ||
diff --git a/drivers/acpi/processor_core.c b/drivers/acpi/processor_core.c index 1908e0d20222..25718fed39f1 100644 --- a/drivers/acpi/processor_core.c +++ b/drivers/acpi/processor_core.c | |||
| @@ -277,7 +277,7 @@ static struct proc_dir_entry *acpi_processor_dir = NULL; | |||
| 277 | 277 | ||
| 278 | static int acpi_processor_info_seq_show(struct seq_file *seq, void *offset) | 278 | static int acpi_processor_info_seq_show(struct seq_file *seq, void *offset) |
| 279 | { | 279 | { |
| 280 | struct acpi_processor *pr = (struct acpi_processor *)seq->private; | 280 | struct acpi_processor *pr = seq->private; |
| 281 | 281 | ||
| 282 | 282 | ||
| 283 | if (!pr) | 283 | if (!pr) |
| @@ -542,12 +542,12 @@ static int __cpuinit acpi_processor_start(struct acpi_device *device) | |||
| 542 | * Don't trust it blindly | 542 | * Don't trust it blindly |
| 543 | */ | 543 | */ |
| 544 | if (processor_device_array[pr->id] != NULL && | 544 | if (processor_device_array[pr->id] != NULL && |
| 545 | processor_device_array[pr->id] != (void *)device) { | 545 | processor_device_array[pr->id] != device) { |
| 546 | printk(KERN_WARNING "BIOS reported wrong ACPI id" | 546 | printk(KERN_WARNING "BIOS reported wrong ACPI id" |
| 547 | "for the processor\n"); | 547 | "for the processor\n"); |
| 548 | return -ENODEV; | 548 | return -ENODEV; |
| 549 | } | 549 | } |
| 550 | processor_device_array[pr->id] = (void *)device; | 550 | processor_device_array[pr->id] = device; |
| 551 | 551 | ||
| 552 | processors[pr->id] = pr; | 552 | processors[pr->id] = pr; |
| 553 | 553 | ||
| @@ -578,7 +578,7 @@ static int __cpuinit acpi_processor_start(struct acpi_device *device) | |||
| 578 | 578 | ||
| 579 | static void acpi_processor_notify(acpi_handle handle, u32 event, void *data) | 579 | static void acpi_processor_notify(acpi_handle handle, u32 event, void *data) |
| 580 | { | 580 | { |
| 581 | struct acpi_processor *pr = (struct acpi_processor *)data; | 581 | struct acpi_processor *pr = data; |
| 582 | struct acpi_device *device = NULL; | 582 | struct acpi_device *device = NULL; |
| 583 | 583 | ||
| 584 | 584 | ||
| @@ -615,10 +615,9 @@ static int acpi_processor_add(struct acpi_device *device) | |||
| 615 | if (!device) | 615 | if (!device) |
| 616 | return -EINVAL; | 616 | return -EINVAL; |
| 617 | 617 | ||
| 618 | pr = kmalloc(sizeof(struct acpi_processor), GFP_KERNEL); | 618 | pr = kzalloc(sizeof(struct acpi_processor), GFP_KERNEL); |
| 619 | if (!pr) | 619 | if (!pr) |
| 620 | return -ENOMEM; | 620 | return -ENOMEM; |
| 621 | memset(pr, 0, sizeof(struct acpi_processor)); | ||
| 622 | 621 | ||
| 623 | pr->handle = device->handle; | 622 | pr->handle = device->handle; |
| 624 | strcpy(acpi_device_name(device), ACPI_PROCESSOR_DEVICE_NAME); | 623 | strcpy(acpi_device_name(device), ACPI_PROCESSOR_DEVICE_NAME); |
| @@ -637,7 +636,7 @@ static int acpi_processor_remove(struct acpi_device *device, int type) | |||
| 637 | if (!device || !acpi_driver_data(device)) | 636 | if (!device || !acpi_driver_data(device)) |
| 638 | return -EINVAL; | 637 | return -EINVAL; |
| 639 | 638 | ||
| 640 | pr = (struct acpi_processor *)acpi_driver_data(device); | 639 | pr = acpi_driver_data(device); |
| 641 | 640 | ||
| 642 | if (pr->id >= NR_CPUS) { | 641 | if (pr->id >= NR_CPUS) { |
| 643 | kfree(pr); | 642 | kfree(pr); |
| @@ -901,13 +900,13 @@ static int __init acpi_processor_init(void) | |||
| 901 | 900 | ||
| 902 | acpi_processor_dir = proc_mkdir(ACPI_PROCESSOR_CLASS, acpi_root_dir); | 901 | acpi_processor_dir = proc_mkdir(ACPI_PROCESSOR_CLASS, acpi_root_dir); |
| 903 | if (!acpi_processor_dir) | 902 | if (!acpi_processor_dir) |
| 904 | return 0; | 903 | return -ENOMEM; |
| 905 | acpi_processor_dir->owner = THIS_MODULE; | 904 | acpi_processor_dir->owner = THIS_MODULE; |
| 906 | 905 | ||
| 907 | result = acpi_bus_register_driver(&acpi_processor_driver); | 906 | result = acpi_bus_register_driver(&acpi_processor_driver); |
| 908 | if (result < 0) { | 907 | if (result < 0) { |
| 909 | remove_proc_entry(ACPI_PROCESSOR_CLASS, acpi_root_dir); | 908 | remove_proc_entry(ACPI_PROCESSOR_CLASS, acpi_root_dir); |
| 910 | return 0; | 909 | return result; |
| 911 | } | 910 | } |
| 912 | 911 | ||
| 913 | acpi_processor_install_hotplug_notify(); | 912 | acpi_processor_install_hotplug_notify(); |
diff --git a/drivers/acpi/processor_idle.c b/drivers/acpi/processor_idle.c index 6dac6050bb5a..3f30af21574e 100644 --- a/drivers/acpi/processor_idle.c +++ b/drivers/acpi/processor_idle.c | |||
| @@ -681,7 +681,7 @@ static int acpi_processor_get_power_info_cst(struct acpi_processor *pr) | |||
| 681 | return -ENODEV; | 681 | return -ENODEV; |
| 682 | } | 682 | } |
| 683 | 683 | ||
| 684 | cst = (union acpi_object *)buffer.pointer; | 684 | cst = buffer.pointer; |
| 685 | 685 | ||
| 686 | /* There must be at least 2 elements */ | 686 | /* There must be at least 2 elements */ |
| 687 | if (!cst || (cst->type != ACPI_TYPE_PACKAGE) || cst->package.count < 2) { | 687 | if (!cst || (cst->type != ACPI_TYPE_PACKAGE) || cst->package.count < 2) { |
| @@ -710,14 +710,14 @@ static int acpi_processor_get_power_info_cst(struct acpi_processor *pr) | |||
| 710 | 710 | ||
| 711 | memset(&cx, 0, sizeof(cx)); | 711 | memset(&cx, 0, sizeof(cx)); |
| 712 | 712 | ||
| 713 | element = (union acpi_object *)&(cst->package.elements[i]); | 713 | element = &(cst->package.elements[i]); |
| 714 | if (element->type != ACPI_TYPE_PACKAGE) | 714 | if (element->type != ACPI_TYPE_PACKAGE) |
| 715 | continue; | 715 | continue; |
| 716 | 716 | ||
| 717 | if (element->package.count != 4) | 717 | if (element->package.count != 4) |
| 718 | continue; | 718 | continue; |
| 719 | 719 | ||
| 720 | obj = (union acpi_object *)&(element->package.elements[0]); | 720 | obj = &(element->package.elements[0]); |
| 721 | 721 | ||
| 722 | if (obj->type != ACPI_TYPE_BUFFER) | 722 | if (obj->type != ACPI_TYPE_BUFFER) |
| 723 | continue; | 723 | continue; |
| @@ -729,7 +729,7 @@ static int acpi_processor_get_power_info_cst(struct acpi_processor *pr) | |||
| 729 | continue; | 729 | continue; |
| 730 | 730 | ||
| 731 | /* There should be an easy way to extract an integer... */ | 731 | /* There should be an easy way to extract an integer... */ |
| 732 | obj = (union acpi_object *)&(element->package.elements[1]); | 732 | obj = &(element->package.elements[1]); |
| 733 | if (obj->type != ACPI_TYPE_INTEGER) | 733 | if (obj->type != ACPI_TYPE_INTEGER) |
| 734 | continue; | 734 | continue; |
| 735 | 735 | ||
| @@ -762,13 +762,13 @@ static int acpi_processor_get_power_info_cst(struct acpi_processor *pr) | |||
| 762 | } | 762 | } |
| 763 | } | 763 | } |
| 764 | 764 | ||
| 765 | obj = (union acpi_object *)&(element->package.elements[2]); | 765 | obj = &(element->package.elements[2]); |
| 766 | if (obj->type != ACPI_TYPE_INTEGER) | 766 | if (obj->type != ACPI_TYPE_INTEGER) |
| 767 | continue; | 767 | continue; |
| 768 | 768 | ||
| 769 | cx.latency = obj->integer.value; | 769 | cx.latency = obj->integer.value; |
| 770 | 770 | ||
| 771 | obj = (union acpi_object *)&(element->package.elements[3]); | 771 | obj = &(element->package.elements[3]); |
| 772 | if (obj->type != ACPI_TYPE_INTEGER) | 772 | if (obj->type != ACPI_TYPE_INTEGER) |
| 773 | continue; | 773 | continue; |
| 774 | 774 | ||
| @@ -1037,7 +1037,7 @@ int acpi_processor_cst_has_changed(struct acpi_processor *pr) | |||
| 1037 | 1037 | ||
| 1038 | static int acpi_processor_power_seq_show(struct seq_file *seq, void *offset) | 1038 | static int acpi_processor_power_seq_show(struct seq_file *seq, void *offset) |
| 1039 | { | 1039 | { |
| 1040 | struct acpi_processor *pr = (struct acpi_processor *)seq->private; | 1040 | struct acpi_processor *pr = seq->private; |
| 1041 | unsigned int i; | 1041 | unsigned int i; |
| 1042 | 1042 | ||
| 1043 | 1043 | ||
diff --git a/drivers/acpi/processor_perflib.c b/drivers/acpi/processor_perflib.c index 6fd174a37149..0e60382714bb 100644 --- a/drivers/acpi/processor_perflib.c +++ b/drivers/acpi/processor_perflib.c | |||
| @@ -236,7 +236,7 @@ static int acpi_processor_get_performance_states(struct acpi_processor *pr) | |||
| 236 | return -ENODEV; | 236 | return -ENODEV; |
| 237 | } | 237 | } |
| 238 | 238 | ||
| 239 | pss = (union acpi_object *)buffer.pointer; | 239 | pss = buffer.pointer; |
| 240 | if (!pss || (pss->type != ACPI_TYPE_PACKAGE)) { | 240 | if (!pss || (pss->type != ACPI_TYPE_PACKAGE)) { |
| 241 | printk(KERN_ERR PREFIX "Invalid _PSS data\n"); | 241 | printk(KERN_ERR PREFIX "Invalid _PSS data\n"); |
| 242 | result = -EFAULT; | 242 | result = -EFAULT; |
| @@ -410,7 +410,7 @@ static struct file_operations acpi_processor_perf_fops = { | |||
| 410 | 410 | ||
| 411 | static int acpi_processor_perf_seq_show(struct seq_file *seq, void *offset) | 411 | static int acpi_processor_perf_seq_show(struct seq_file *seq, void *offset) |
| 412 | { | 412 | { |
| 413 | struct acpi_processor *pr = (struct acpi_processor *)seq->private; | 413 | struct acpi_processor *pr = seq->private; |
| 414 | int i; | 414 | int i; |
| 415 | 415 | ||
| 416 | 416 | ||
| @@ -451,8 +451,8 @@ acpi_processor_write_performance(struct file *file, | |||
| 451 | size_t count, loff_t * data) | 451 | size_t count, loff_t * data) |
| 452 | { | 452 | { |
| 453 | int result = 0; | 453 | int result = 0; |
| 454 | struct seq_file *m = (struct seq_file *)file->private_data; | 454 | struct seq_file *m = file->private_data; |
| 455 | struct acpi_processor *pr = (struct acpi_processor *)m->private; | 455 | struct acpi_processor *pr = m->private; |
| 456 | struct acpi_processor_performance *perf; | 456 | struct acpi_processor_performance *perf; |
| 457 | char state_string[12] = { '\0' }; | 457 | char state_string[12] = { '\0' }; |
| 458 | unsigned int new_state = 0; | 458 | unsigned int new_state = 0; |
| @@ -551,7 +551,7 @@ static int acpi_processor_get_psd(struct acpi_processor *pr) | |||
| 551 | return -ENODEV; | 551 | return -ENODEV; |
| 552 | } | 552 | } |
| 553 | 553 | ||
| 554 | psd = (union acpi_object *) buffer.pointer; | 554 | psd = buffer.pointer; |
| 555 | if (!psd || (psd->type != ACPI_TYPE_PACKAGE)) { | 555 | if (!psd || (psd->type != ACPI_TYPE_PACKAGE)) { |
| 556 | ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid _PSD data\n")); | 556 | ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid _PSD data\n")); |
| 557 | result = -EFAULT; | 557 | result = -EFAULT; |
diff --git a/drivers/acpi/processor_thermal.c b/drivers/acpi/processor_thermal.c index ef5e0f6efdba..40fecd67ad83 100644 --- a/drivers/acpi/processor_thermal.c +++ b/drivers/acpi/processor_thermal.c | |||
| @@ -208,7 +208,7 @@ int acpi_processor_set_thermal_limit(acpi_handle handle, int type) | |||
| 208 | if (result) | 208 | if (result) |
| 209 | return result; | 209 | return result; |
| 210 | 210 | ||
| 211 | pr = (struct acpi_processor *)acpi_driver_data(device); | 211 | pr = acpi_driver_data(device); |
| 212 | if (!pr) | 212 | if (!pr) |
| 213 | return -ENODEV; | 213 | return -ENODEV; |
| 214 | 214 | ||
| @@ -348,8 +348,8 @@ static ssize_t acpi_processor_write_limit(struct file * file, | |||
| 348 | size_t count, loff_t * data) | 348 | size_t count, loff_t * data) |
| 349 | { | 349 | { |
| 350 | int result = 0; | 350 | int result = 0; |
| 351 | struct seq_file *m = (struct seq_file *)file->private_data; | 351 | struct seq_file *m = file->private_data; |
| 352 | struct acpi_processor *pr = (struct acpi_processor *)m->private; | 352 | struct acpi_processor *pr = m->private; |
| 353 | char limit_string[25] = { '\0' }; | 353 | char limit_string[25] = { '\0' }; |
| 354 | int px = 0; | 354 | int px = 0; |
| 355 | int tx = 0; | 355 | int tx = 0; |
diff --git a/drivers/acpi/processor_throttling.c b/drivers/acpi/processor_throttling.c index d044ec519db0..0ec7dcde0063 100644 --- a/drivers/acpi/processor_throttling.c +++ b/drivers/acpi/processor_throttling.c | |||
| @@ -259,7 +259,7 @@ int acpi_processor_get_throttling_info(struct acpi_processor *pr) | |||
| 259 | static int acpi_processor_throttling_seq_show(struct seq_file *seq, | 259 | static int acpi_processor_throttling_seq_show(struct seq_file *seq, |
| 260 | void *offset) | 260 | void *offset) |
| 261 | { | 261 | { |
| 262 | struct acpi_processor *pr = (struct acpi_processor *)seq->private; | 262 | struct acpi_processor *pr = seq->private; |
| 263 | int i = 0; | 263 | int i = 0; |
| 264 | int result = 0; | 264 | int result = 0; |
| 265 | 265 | ||
| @@ -307,8 +307,8 @@ static ssize_t acpi_processor_write_throttling(struct file * file, | |||
| 307 | size_t count, loff_t * data) | 307 | size_t count, loff_t * data) |
| 308 | { | 308 | { |
| 309 | int result = 0; | 309 | int result = 0; |
| 310 | struct seq_file *m = (struct seq_file *)file->private_data; | 310 | struct seq_file *m = file->private_data; |
| 311 | struct acpi_processor *pr = (struct acpi_processor *)m->private; | 311 | struct acpi_processor *pr = m->private; |
| 312 | char state_string[12] = { '\0' }; | 312 | char state_string[12] = { '\0' }; |
| 313 | 313 | ||
| 314 | 314 | ||
diff --git a/drivers/acpi/sbs.c b/drivers/acpi/sbs.c index 8908a975e575..f58fc7447ab4 100644 --- a/drivers/acpi/sbs.c +++ b/drivers/acpi/sbs.c | |||
| @@ -923,7 +923,7 @@ static struct proc_dir_entry *acpi_battery_dir = NULL; | |||
| 923 | 923 | ||
| 924 | static int acpi_battery_read_info(struct seq_file *seq, void *offset) | 924 | static int acpi_battery_read_info(struct seq_file *seq, void *offset) |
| 925 | { | 925 | { |
| 926 | struct acpi_battery *battery = (struct acpi_battery *)seq->private; | 926 | struct acpi_battery *battery = seq->private; |
| 927 | int cscale; | 927 | int cscale; |
| 928 | int result = 0; | 928 | int result = 0; |
| 929 | 929 | ||
| @@ -1076,7 +1076,7 @@ static int acpi_battery_state_open_fs(struct inode *inode, struct file *file) | |||
| 1076 | 1076 | ||
| 1077 | static int acpi_battery_read_alarm(struct seq_file *seq, void *offset) | 1077 | static int acpi_battery_read_alarm(struct seq_file *seq, void *offset) |
| 1078 | { | 1078 | { |
| 1079 | struct acpi_battery *battery = (struct acpi_battery *)seq->private; | 1079 | struct acpi_battery *battery = seq->private; |
| 1080 | int result = 0; | 1080 | int result = 0; |
| 1081 | int cscale; | 1081 | int cscale; |
| 1082 | 1082 | ||
| @@ -1125,8 +1125,8 @@ static ssize_t | |||
| 1125 | acpi_battery_write_alarm(struct file *file, const char __user * buffer, | 1125 | acpi_battery_write_alarm(struct file *file, const char __user * buffer, |
| 1126 | size_t count, loff_t * ppos) | 1126 | size_t count, loff_t * ppos) |
| 1127 | { | 1127 | { |
| 1128 | struct seq_file *seq = (struct seq_file *)file->private_data; | 1128 | struct seq_file *seq = file->private_data; |
| 1129 | struct acpi_battery *battery = (struct acpi_battery *)seq->private; | 1129 | struct acpi_battery *battery = seq->private; |
| 1130 | char alarm_string[12] = { '\0' }; | 1130 | char alarm_string[12] = { '\0' }; |
| 1131 | int result, old_alarm, new_alarm; | 1131 | int result, old_alarm, new_alarm; |
| 1132 | 1132 | ||
| @@ -1160,14 +1160,14 @@ acpi_battery_write_alarm(struct file *file, const char __user * buffer, | |||
| 1160 | if (result) { | 1160 | if (result) { |
| 1161 | ACPI_DEBUG_PRINT((ACPI_DB_ERROR, | 1161 | ACPI_DEBUG_PRINT((ACPI_DB_ERROR, |
| 1162 | "acpi_battery_set_alarm() failed\n")); | 1162 | "acpi_battery_set_alarm() failed\n")); |
| 1163 | (void)acpi_battery_set_alarm(battery, old_alarm); | 1163 | acpi_battery_set_alarm(battery, old_alarm); |
| 1164 | goto end; | 1164 | goto end; |
| 1165 | } | 1165 | } |
| 1166 | result = acpi_battery_get_alarm(battery); | 1166 | result = acpi_battery_get_alarm(battery); |
| 1167 | if (result) { | 1167 | if (result) { |
| 1168 | ACPI_DEBUG_PRINT((ACPI_DB_ERROR, | 1168 | ACPI_DEBUG_PRINT((ACPI_DB_ERROR, |
| 1169 | "acpi_battery_get_alarm() failed\n")); | 1169 | "acpi_battery_get_alarm() failed\n")); |
| 1170 | (void)acpi_battery_set_alarm(battery, old_alarm); | 1170 | acpi_battery_set_alarm(battery, old_alarm); |
| 1171 | goto end; | 1171 | goto end; |
| 1172 | } | 1172 | } |
| 1173 | 1173 | ||
| @@ -1217,7 +1217,7 @@ static struct proc_dir_entry *acpi_ac_dir = NULL; | |||
| 1217 | 1217 | ||
| 1218 | static int acpi_ac_read_state(struct seq_file *seq, void *offset) | 1218 | static int acpi_ac_read_state(struct seq_file *seq, void *offset) |
| 1219 | { | 1219 | { |
| 1220 | struct acpi_sbs *sbs = (struct acpi_sbs *)seq->private; | 1220 | struct acpi_sbs *sbs = seq->private; |
| 1221 | int result; | 1221 | int result; |
| 1222 | 1222 | ||
| 1223 | if (sbs->zombie) { | 1223 | if (sbs->zombie) { |
| @@ -1302,7 +1302,7 @@ static int acpi_battery_add(struct acpi_sbs *sbs, int id) | |||
| 1302 | battery->init_state = 1; | 1302 | battery->init_state = 1; |
| 1303 | } | 1303 | } |
| 1304 | 1304 | ||
| 1305 | (void)sprintf(dir_name, ACPI_BATTERY_DIR_NAME, id); | 1305 | sprintf(dir_name, ACPI_BATTERY_DIR_NAME, id); |
| 1306 | 1306 | ||
| 1307 | result = acpi_sbs_generic_add_fs(&battery->battery_entry, | 1307 | result = acpi_sbs_generic_add_fs(&battery->battery_entry, |
| 1308 | acpi_battery_dir, | 1308 | acpi_battery_dir, |
| @@ -1485,7 +1485,7 @@ static int acpi_sbs_update_run(struct acpi_sbs *sbs, int data_type) | |||
| 1485 | } | 1485 | } |
| 1486 | 1486 | ||
| 1487 | if (old_battery_present != new_battery_present) { | 1487 | if (old_battery_present != new_battery_present) { |
| 1488 | (void)sprintf(dir_name, ACPI_BATTERY_DIR_NAME, id); | 1488 | sprintf(dir_name, ACPI_BATTERY_DIR_NAME, id); |
| 1489 | result = acpi_sbs_generate_event(sbs->device, | 1489 | result = acpi_sbs_generate_event(sbs->device, |
| 1490 | ACPI_SBS_BATTERY_NOTIFY_STATUS, | 1490 | ACPI_SBS_BATTERY_NOTIFY_STATUS, |
| 1491 | new_battery_present, | 1491 | new_battery_present, |
| @@ -1498,7 +1498,7 @@ static int acpi_sbs_update_run(struct acpi_sbs *sbs, int data_type) | |||
| 1498 | } | 1498 | } |
| 1499 | } | 1499 | } |
| 1500 | if (old_remaining_capacity != battery->state.remaining_capacity) { | 1500 | if (old_remaining_capacity != battery->state.remaining_capacity) { |
| 1501 | (void)sprintf(dir_name, ACPI_BATTERY_DIR_NAME, id); | 1501 | sprintf(dir_name, ACPI_BATTERY_DIR_NAME, id); |
| 1502 | result = acpi_sbs_generate_event(sbs->device, | 1502 | result = acpi_sbs_generate_event(sbs->device, |
| 1503 | ACPI_SBS_BATTERY_NOTIFY_STATUS, | 1503 | ACPI_SBS_BATTERY_NOTIFY_STATUS, |
| 1504 | new_battery_present, | 1504 | new_battery_present, |
| @@ -1576,12 +1576,11 @@ static int acpi_sbs_add(struct acpi_device *device) | |||
| 1576 | int id, cnt; | 1576 | int id, cnt; |
| 1577 | acpi_status status = AE_OK; | 1577 | acpi_status status = AE_OK; |
| 1578 | 1578 | ||
| 1579 | sbs = kmalloc(sizeof(struct acpi_sbs), GFP_KERNEL); | 1579 | sbs = kzalloc(sizeof(struct acpi_sbs), GFP_KERNEL); |
| 1580 | if (!sbs) { | 1580 | if (!sbs) { |
| 1581 | ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "kmalloc() failed\n")); | 1581 | ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "kmalloc() failed\n")); |
| 1582 | return -ENOMEM; | 1582 | return -ENOMEM; |
| 1583 | } | 1583 | } |
| 1584 | memset(sbs, 0, sizeof(struct acpi_sbs)); | ||
| 1585 | 1584 | ||
| 1586 | cnt = 0; | 1585 | cnt = 0; |
| 1587 | while (cnt < 10) { | 1586 | while (cnt < 10) { |
| @@ -1659,7 +1658,7 @@ static int acpi_sbs_add(struct acpi_device *device) | |||
| 1659 | init_timer(&sbs->update_timer); | 1658 | init_timer(&sbs->update_timer); |
| 1660 | if (update_mode == QUEUE_UPDATE_MODE) { | 1659 | if (update_mode == QUEUE_UPDATE_MODE) { |
| 1661 | status = acpi_os_execute(OSL_GPE_HANDLER, | 1660 | status = acpi_os_execute(OSL_GPE_HANDLER, |
| 1662 | acpi_sbs_update_queue, (void *)sbs); | 1661 | acpi_sbs_update_queue, sbs); |
| 1663 | if (status != AE_OK) { | 1662 | if (status != AE_OK) { |
| 1664 | ACPI_DEBUG_PRINT((ACPI_DB_ERROR, | 1663 | ACPI_DEBUG_PRINT((ACPI_DB_ERROR, |
| 1665 | "acpi_os_execute() failed\n")); | 1664 | "acpi_os_execute() failed\n")); |
| @@ -1685,7 +1684,7 @@ static int acpi_sbs_add(struct acpi_device *device) | |||
| 1685 | 1684 | ||
| 1686 | int acpi_sbs_remove(struct acpi_device *device, int type) | 1685 | int acpi_sbs_remove(struct acpi_device *device, int type) |
| 1687 | { | 1686 | { |
| 1688 | struct acpi_sbs *sbs = NULL; | 1687 | struct acpi_sbs *sbs; |
| 1689 | int id; | 1688 | int id; |
| 1690 | 1689 | ||
| 1691 | if (!device) { | 1690 | if (!device) { |
diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c index 698a1540e303..283d87522c5d 100644 --- a/drivers/acpi/scan.c +++ b/drivers/acpi/scan.c | |||
| @@ -984,12 +984,11 @@ acpi_add_single_object(struct acpi_device **child, | |||
| 984 | if (!child) | 984 | if (!child) |
| 985 | return -EINVAL; | 985 | return -EINVAL; |
| 986 | 986 | ||
| 987 | device = kmalloc(sizeof(struct acpi_device), GFP_KERNEL); | 987 | device = kzalloc(sizeof(struct acpi_device), GFP_KERNEL); |
| 988 | if (!device) { | 988 | if (!device) { |
| 989 | printk(KERN_ERR PREFIX "Memory allocation error\n"); | 989 | printk(KERN_ERR PREFIX "Memory allocation error\n"); |
| 990 | return -ENOMEM; | 990 | return -ENOMEM; |
| 991 | } | 991 | } |
| 992 | memset(device, 0, sizeof(struct acpi_device)); | ||
| 993 | 992 | ||
| 994 | device->handle = handle; | 993 | device->handle = handle; |
| 995 | device->parent = parent; | 994 | device->parent = parent; |
diff --git a/drivers/acpi/sleep/wakeup.c b/drivers/acpi/sleep/wakeup.c index af1dbabaf0b1..fab8f2694f03 100644 --- a/drivers/acpi/sleep/wakeup.c +++ b/drivers/acpi/sleep/wakeup.c | |||
| @@ -183,11 +183,11 @@ late_initcall(acpi_wakeup_device_init); | |||
| 183 | #endif | 183 | #endif |
| 184 | 184 | ||
| 185 | /* | 185 | /* |
| 186 | * Disable all wakeup GPEs before power off. | 186 | * Disable all wakeup GPEs before entering requested sleep state. |
| 187 | * | 187 | * @sleep_state: ACPI state |
| 188 | * Since acpi_enter_sleep_state() will disable all | 188 | * Since acpi_enter_sleep_state() will disable all |
| 189 | * RUNTIME GPEs, we simply mark all GPES that | 189 | * RUNTIME GPEs, we simply mark all GPES that |
| 190 | * are not enabled for wakeup from S5 as RUNTIME. | 190 | * are not enabled for wakeup from requested state as RUNTIME. |
| 191 | */ | 191 | */ |
| 192 | void acpi_gpe_sleep_prepare(u32 sleep_state) | 192 | void acpi_gpe_sleep_prepare(u32 sleep_state) |
| 193 | { | 193 | { |
diff --git a/drivers/acpi/tables.c b/drivers/acpi/tables.c index bfb3bfcf9e91..ffa30c9fccbf 100644 --- a/drivers/acpi/tables.c +++ b/drivers/acpi/tables.c | |||
| @@ -228,7 +228,7 @@ void acpi_table_print_madt_entry(acpi_table_entry_header * header) | |||
| 228 | static int | 228 | static int |
| 229 | acpi_table_compute_checksum(void *table_pointer, unsigned long length) | 229 | acpi_table_compute_checksum(void *table_pointer, unsigned long length) |
| 230 | { | 230 | { |
| 231 | u8 *p = (u8 *) table_pointer; | 231 | u8 *p = table_pointer; |
| 232 | unsigned long remains = length; | 232 | unsigned long remains = length; |
| 233 | unsigned long sum = 0; | 233 | unsigned long sum = 0; |
| 234 | 234 | ||
diff --git a/drivers/acpi/tables/tbxface.c b/drivers/acpi/tables/tbxface.c index 7767987be15a..5ba9303293ad 100644 --- a/drivers/acpi/tables/tbxface.c +++ b/drivers/acpi/tables/tbxface.c | |||
| @@ -123,7 +123,6 @@ acpi_status acpi_load_tables(void) | |||
| 123 | 123 | ||
| 124 | ACPI_EXPORT_SYMBOL(acpi_load_tables) | 124 | ACPI_EXPORT_SYMBOL(acpi_load_tables) |
| 125 | 125 | ||
| 126 | #ifdef ACPI_FUTURE_USAGE | ||
| 127 | /******************************************************************************* | 126 | /******************************************************************************* |
| 128 | * | 127 | * |
| 129 | * FUNCTION: acpi_load_table | 128 | * FUNCTION: acpi_load_table |
| @@ -221,6 +220,59 @@ ACPI_EXPORT_SYMBOL(acpi_load_table) | |||
| 221 | 220 | ||
| 222 | /******************************************************************************* | 221 | /******************************************************************************* |
| 223 | * | 222 | * |
| 223 | * FUNCTION: acpi_unload_table_id | ||
| 224 | * | ||
| 225 | * PARAMETERS: table_type - Type of table to be unloaded | ||
| 226 | * id - Owner ID of the table to be removed. | ||
| 227 | * | ||
| 228 | * RETURN: Status | ||
| 229 | * | ||
| 230 | * DESCRIPTION: This routine is used to force the unload of a table (by id) | ||
| 231 | * | ||
| 232 | ******************************************************************************/ | ||
| 233 | acpi_status acpi_unload_table_id(acpi_table_type table_type, acpi_owner_id id) | ||
| 234 | { | ||
| 235 | struct acpi_table_desc *table_desc; | ||
| 236 | acpi_status status; | ||
| 237 | |||
| 238 | ACPI_FUNCTION_TRACE(acpi_unload_table); | ||
| 239 | |||
| 240 | /* Parameter validation */ | ||
| 241 | if (table_type > ACPI_TABLE_ID_MAX) | ||
| 242 | return_ACPI_STATUS(AE_BAD_PARAMETER); | ||
| 243 | |||
| 244 | /* Find table from the requested type list */ | ||
| 245 | table_desc = acpi_gbl_table_lists[table_type].next; | ||
| 246 | while (table_desc && table_desc->owner_id != id) | ||
| 247 | table_desc = table_desc->next; | ||
| 248 | |||
| 249 | if (!table_desc) | ||
| 250 | return_ACPI_STATUS(AE_NOT_EXIST); | ||
| 251 | |||
| 252 | /* | ||
| 253 | * Delete all namespace objects owned by this table. Note that these | ||
| 254 | * objects can appear anywhere in the namespace by virtue of the AML | ||
| 255 | * "Scope" operator. Thus, we need to track ownership by an ID, not | ||
| 256 | * simply a position within the hierarchy | ||
| 257 | */ | ||
| 258 | acpi_ns_delete_namespace_by_owner(table_desc->owner_id); | ||
| 259 | |||
| 260 | status = acpi_ut_acquire_mutex(ACPI_MTX_TABLES); | ||
| 261 | if (ACPI_FAILURE(status)) | ||
| 262 | return_ACPI_STATUS(status); | ||
| 263 | |||
| 264 | (void)acpi_tb_uninstall_table(table_desc); | ||
| 265 | |||
| 266 | (void)acpi_ut_release_mutex(ACPI_MTX_TABLES); | ||
| 267 | |||
| 268 | return_ACPI_STATUS(AE_OK); | ||
| 269 | } | ||
| 270 | |||
| 271 | ACPI_EXPORT_SYMBOL(acpi_unload_table_id) | ||
| 272 | |||
| 273 | #ifdef ACPI_FUTURE_USAGE | ||
| 274 | /******************************************************************************* | ||
| 275 | * | ||
| 224 | * FUNCTION: acpi_unload_table | 276 | * FUNCTION: acpi_unload_table |
| 225 | * | 277 | * |
| 226 | * PARAMETERS: table_type - Type of table to be unloaded | 278 | * PARAMETERS: table_type - Type of table to be unloaded |
diff --git a/drivers/acpi/thermal.c b/drivers/acpi/thermal.c index 5753d06b7860..40ddb4dd9631 100644 --- a/drivers/acpi/thermal.c +++ b/drivers/acpi/thermal.c | |||
| @@ -663,7 +663,7 @@ static void acpi_thermal_run(unsigned long data) | |||
| 663 | static void acpi_thermal_check(void *data) | 663 | static void acpi_thermal_check(void *data) |
| 664 | { | 664 | { |
| 665 | int result = 0; | 665 | int result = 0; |
| 666 | struct acpi_thermal *tz = (struct acpi_thermal *)data; | 666 | struct acpi_thermal *tz = data; |
| 667 | unsigned long sleep_time = 0; | 667 | unsigned long sleep_time = 0; |
| 668 | int i = 0; | 668 | int i = 0; |
| 669 | struct acpi_thermal_state state; | 669 | struct acpi_thermal_state state; |
| @@ -778,7 +778,7 @@ static struct proc_dir_entry *acpi_thermal_dir; | |||
| 778 | 778 | ||
| 779 | static int acpi_thermal_state_seq_show(struct seq_file *seq, void *offset) | 779 | static int acpi_thermal_state_seq_show(struct seq_file *seq, void *offset) |
| 780 | { | 780 | { |
| 781 | struct acpi_thermal *tz = (struct acpi_thermal *)seq->private; | 781 | struct acpi_thermal *tz = seq->private; |
| 782 | 782 | ||
| 783 | 783 | ||
| 784 | if (!tz) | 784 | if (!tz) |
| @@ -813,7 +813,7 @@ static int acpi_thermal_state_open_fs(struct inode *inode, struct file *file) | |||
| 813 | static int acpi_thermal_temp_seq_show(struct seq_file *seq, void *offset) | 813 | static int acpi_thermal_temp_seq_show(struct seq_file *seq, void *offset) |
| 814 | { | 814 | { |
| 815 | int result = 0; | 815 | int result = 0; |
| 816 | struct acpi_thermal *tz = (struct acpi_thermal *)seq->private; | 816 | struct acpi_thermal *tz = seq->private; |
| 817 | 817 | ||
| 818 | 818 | ||
| 819 | if (!tz) | 819 | if (!tz) |
| @@ -837,7 +837,7 @@ static int acpi_thermal_temp_open_fs(struct inode *inode, struct file *file) | |||
| 837 | 837 | ||
| 838 | static int acpi_thermal_trip_seq_show(struct seq_file *seq, void *offset) | 838 | static int acpi_thermal_trip_seq_show(struct seq_file *seq, void *offset) |
| 839 | { | 839 | { |
| 840 | struct acpi_thermal *tz = (struct acpi_thermal *)seq->private; | 840 | struct acpi_thermal *tz = seq->private; |
| 841 | int i = 0; | 841 | int i = 0; |
| 842 | int j = 0; | 842 | int j = 0; |
| 843 | 843 | ||
| @@ -893,8 +893,8 @@ acpi_thermal_write_trip_points(struct file *file, | |||
| 893 | const char __user * buffer, | 893 | const char __user * buffer, |
| 894 | size_t count, loff_t * ppos) | 894 | size_t count, loff_t * ppos) |
| 895 | { | 895 | { |
| 896 | struct seq_file *m = (struct seq_file *)file->private_data; | 896 | struct seq_file *m = file->private_data; |
| 897 | struct acpi_thermal *tz = (struct acpi_thermal *)m->private; | 897 | struct acpi_thermal *tz = m->private; |
| 898 | 898 | ||
| 899 | char *limit_string; | 899 | char *limit_string; |
| 900 | int num, critical, hot, passive; | 900 | int num, critical, hot, passive; |
| @@ -902,12 +902,10 @@ acpi_thermal_write_trip_points(struct file *file, | |||
| 902 | int i = 0; | 902 | int i = 0; |
| 903 | 903 | ||
| 904 | 904 | ||
| 905 | limit_string = kmalloc(ACPI_THERMAL_MAX_LIMIT_STR_LEN, GFP_KERNEL); | 905 | limit_string = kzalloc(ACPI_THERMAL_MAX_LIMIT_STR_LEN, GFP_KERNEL); |
| 906 | if (!limit_string) | 906 | if (!limit_string) |
| 907 | return -ENOMEM; | 907 | return -ENOMEM; |
| 908 | 908 | ||
| 909 | memset(limit_string, 0, ACPI_THERMAL_MAX_LIMIT_STR_LEN); | ||
| 910 | |||
| 911 | active = kmalloc(ACPI_THERMAL_MAX_ACTIVE * sizeof(int), GFP_KERNEL); | 909 | active = kmalloc(ACPI_THERMAL_MAX_ACTIVE * sizeof(int), GFP_KERNEL); |
| 912 | if (!active) { | 910 | if (!active) { |
| 913 | kfree(limit_string); | 911 | kfree(limit_string); |
| @@ -953,7 +951,7 @@ acpi_thermal_write_trip_points(struct file *file, | |||
| 953 | 951 | ||
| 954 | static int acpi_thermal_cooling_seq_show(struct seq_file *seq, void *offset) | 952 | static int acpi_thermal_cooling_seq_show(struct seq_file *seq, void *offset) |
| 955 | { | 953 | { |
| 956 | struct acpi_thermal *tz = (struct acpi_thermal *)seq->private; | 954 | struct acpi_thermal *tz = seq->private; |
| 957 | 955 | ||
| 958 | 956 | ||
| 959 | if (!tz) | 957 | if (!tz) |
| @@ -984,8 +982,8 @@ acpi_thermal_write_cooling_mode(struct file *file, | |||
| 984 | const char __user * buffer, | 982 | const char __user * buffer, |
| 985 | size_t count, loff_t * ppos) | 983 | size_t count, loff_t * ppos) |
| 986 | { | 984 | { |
| 987 | struct seq_file *m = (struct seq_file *)file->private_data; | 985 | struct seq_file *m = file->private_data; |
| 988 | struct acpi_thermal *tz = (struct acpi_thermal *)m->private; | 986 | struct acpi_thermal *tz = m->private; |
| 989 | int result = 0; | 987 | int result = 0; |
| 990 | char mode_string[12] = { '\0' }; | 988 | char mode_string[12] = { '\0' }; |
| 991 | 989 | ||
| @@ -1014,7 +1012,7 @@ acpi_thermal_write_cooling_mode(struct file *file, | |||
| 1014 | 1012 | ||
| 1015 | static int acpi_thermal_polling_seq_show(struct seq_file *seq, void *offset) | 1013 | static int acpi_thermal_polling_seq_show(struct seq_file *seq, void *offset) |
| 1016 | { | 1014 | { |
| 1017 | struct acpi_thermal *tz = (struct acpi_thermal *)seq->private; | 1015 | struct acpi_thermal *tz = seq->private; |
| 1018 | 1016 | ||
| 1019 | 1017 | ||
| 1020 | if (!tz) | 1018 | if (!tz) |
| @@ -1043,8 +1041,8 @@ acpi_thermal_write_polling(struct file *file, | |||
| 1043 | const char __user * buffer, | 1041 | const char __user * buffer, |
| 1044 | size_t count, loff_t * ppos) | 1042 | size_t count, loff_t * ppos) |
| 1045 | { | 1043 | { |
| 1046 | struct seq_file *m = (struct seq_file *)file->private_data; | 1044 | struct seq_file *m = file->private_data; |
| 1047 | struct acpi_thermal *tz = (struct acpi_thermal *)m->private; | 1045 | struct acpi_thermal *tz = m->private; |
| 1048 | int result = 0; | 1046 | int result = 0; |
| 1049 | char polling_string[12] = { '\0' }; | 1047 | char polling_string[12] = { '\0' }; |
| 1050 | int seconds = 0; | 1048 | int seconds = 0; |
| @@ -1170,7 +1168,7 @@ static int acpi_thermal_remove_fs(struct acpi_device *device) | |||
| 1170 | 1168 | ||
| 1171 | static void acpi_thermal_notify(acpi_handle handle, u32 event, void *data) | 1169 | static void acpi_thermal_notify(acpi_handle handle, u32 event, void *data) |
| 1172 | { | 1170 | { |
| 1173 | struct acpi_thermal *tz = (struct acpi_thermal *)data; | 1171 | struct acpi_thermal *tz = data; |
| 1174 | struct acpi_device *device = NULL; | 1172 | struct acpi_device *device = NULL; |
| 1175 | 1173 | ||
| 1176 | 1174 | ||
| @@ -1271,10 +1269,9 @@ static int acpi_thermal_add(struct acpi_device *device) | |||
| 1271 | if (!device) | 1269 | if (!device) |
| 1272 | return -EINVAL; | 1270 | return -EINVAL; |
| 1273 | 1271 | ||
| 1274 | tz = kmalloc(sizeof(struct acpi_thermal), GFP_KERNEL); | 1272 | tz = kzalloc(sizeof(struct acpi_thermal), GFP_KERNEL); |
| 1275 | if (!tz) | 1273 | if (!tz) |
| 1276 | return -ENOMEM; | 1274 | return -ENOMEM; |
| 1277 | memset(tz, 0, sizeof(struct acpi_thermal)); | ||
| 1278 | 1275 | ||
| 1279 | tz->device = device; | 1276 | tz->device = device; |
| 1280 | strcpy(tz->name, device->pnp.bus_id); | 1277 | strcpy(tz->name, device->pnp.bus_id); |
| @@ -1324,7 +1321,7 @@ static int acpi_thermal_remove(struct acpi_device *device, int type) | |||
| 1324 | if (!device || !acpi_driver_data(device)) | 1321 | if (!device || !acpi_driver_data(device)) |
| 1325 | return -EINVAL; | 1322 | return -EINVAL; |
| 1326 | 1323 | ||
| 1327 | tz = (struct acpi_thermal *)acpi_driver_data(device); | 1324 | tz = acpi_driver_data(device); |
| 1328 | 1325 | ||
| 1329 | /* avoid timer adding new defer task */ | 1326 | /* avoid timer adding new defer task */ |
| 1330 | tz->zombie = 1; | 1327 | tz->zombie = 1; |
| @@ -1364,7 +1361,7 @@ static int acpi_thermal_resume(struct acpi_device *device, int state) | |||
| 1364 | if (!device || !acpi_driver_data(device)) | 1361 | if (!device || !acpi_driver_data(device)) |
| 1365 | return -EINVAL; | 1362 | return -EINVAL; |
| 1366 | 1363 | ||
| 1367 | tz = (struct acpi_thermal *)acpi_driver_data(device); | 1364 | tz = acpi_driver_data(device); |
| 1368 | 1365 | ||
| 1369 | acpi_thermal_get_temperature(tz); | 1366 | acpi_thermal_get_temperature(tz); |
| 1370 | 1367 | ||
diff --git a/drivers/acpi/toshiba_acpi.c b/drivers/acpi/toshiba_acpi.c index 7fe0b7ae9733..88aeccbafaaf 100644 --- a/drivers/acpi/toshiba_acpi.c +++ b/drivers/acpi/toshiba_acpi.c | |||
| @@ -41,6 +41,8 @@ | |||
| 41 | #include <linux/init.h> | 41 | #include <linux/init.h> |
| 42 | #include <linux/types.h> | 42 | #include <linux/types.h> |
| 43 | #include <linux/proc_fs.h> | 43 | #include <linux/proc_fs.h> |
| 44 | #include <linux/backlight.h> | ||
| 45 | |||
| 44 | #include <asm/uaccess.h> | 46 | #include <asm/uaccess.h> |
| 45 | 47 | ||
| 46 | #include <acpi/acpi_drivers.h> | 48 | #include <acpi/acpi_drivers.h> |
| @@ -210,6 +212,7 @@ static acpi_status hci_read1(u32 reg, u32 * out1, u32 * result) | |||
| 210 | } | 212 | } |
| 211 | 213 | ||
| 212 | static struct proc_dir_entry *toshiba_proc_dir /*= 0*/ ; | 214 | static struct proc_dir_entry *toshiba_proc_dir /*= 0*/ ; |
| 215 | static struct backlight_device *toshiba_backlight_device; | ||
| 213 | static int force_fan; | 216 | static int force_fan; |
| 214 | static int last_key_event; | 217 | static int last_key_event; |
| 215 | static int key_event_valid; | 218 | static int key_event_valid; |
| @@ -271,14 +274,23 @@ dispatch_write(struct file *file, const char __user * buffer, | |||
| 271 | return result; | 274 | return result; |
| 272 | } | 275 | } |
| 273 | 276 | ||
| 274 | static char *read_lcd(char *p) | 277 | static int get_lcd(struct backlight_device *bd) |
| 275 | { | 278 | { |
| 276 | u32 hci_result; | 279 | u32 hci_result; |
| 277 | u32 value; | 280 | u32 value; |
| 278 | 281 | ||
| 279 | hci_read1(HCI_LCD_BRIGHTNESS, &value, &hci_result); | 282 | hci_read1(HCI_LCD_BRIGHTNESS, &value, &hci_result); |
| 280 | if (hci_result == HCI_SUCCESS) { | 283 | if (hci_result == HCI_SUCCESS) { |
| 281 | value = value >> HCI_LCD_BRIGHTNESS_SHIFT; | 284 | return (value >> HCI_LCD_BRIGHTNESS_SHIFT); |
| 285 | } else | ||
| 286 | return -EFAULT; | ||
| 287 | } | ||
| 288 | |||
| 289 | static char *read_lcd(char *p) | ||
| 290 | { | ||
| 291 | int value = get_lcd(NULL); | ||
| 292 | |||
| 293 | if (value >= 0) { | ||
| 282 | p += sprintf(p, "brightness: %d\n", value); | 294 | p += sprintf(p, "brightness: %d\n", value); |
| 283 | p += sprintf(p, "brightness_levels: %d\n", | 295 | p += sprintf(p, "brightness_levels: %d\n", |
| 284 | HCI_LCD_BRIGHTNESS_LEVELS); | 296 | HCI_LCD_BRIGHTNESS_LEVELS); |
| @@ -289,22 +301,34 @@ static char *read_lcd(char *p) | |||
| 289 | return p; | 301 | return p; |
| 290 | } | 302 | } |
| 291 | 303 | ||
| 304 | static int set_lcd(int value) | ||
| 305 | { | ||
| 306 | u32 hci_result; | ||
| 307 | |||
| 308 | value = value << HCI_LCD_BRIGHTNESS_SHIFT; | ||
| 309 | hci_write1(HCI_LCD_BRIGHTNESS, value, &hci_result); | ||
| 310 | if (hci_result != HCI_SUCCESS) | ||
| 311 | return -EFAULT; | ||
| 312 | |||
| 313 | return 0; | ||
| 314 | } | ||
| 315 | |||
| 316 | static int set_lcd_status(struct backlight_device *bd) | ||
| 317 | { | ||
| 318 | return set_lcd(bd->props->brightness); | ||
| 319 | } | ||
| 320 | |||
| 292 | static unsigned long write_lcd(const char *buffer, unsigned long count) | 321 | static unsigned long write_lcd(const char *buffer, unsigned long count) |
| 293 | { | 322 | { |
| 294 | int value; | 323 | int value; |
| 295 | u32 hci_result; | 324 | int ret = count; |
| 296 | 325 | ||
| 297 | if (sscanf(buffer, " brightness : %i", &value) == 1 && | 326 | if (sscanf(buffer, " brightness : %i", &value) == 1 && |
| 298 | value >= 0 && value < HCI_LCD_BRIGHTNESS_LEVELS) { | 327 | value >= 0 && value < HCI_LCD_BRIGHTNESS_LEVELS) |
| 299 | value = value << HCI_LCD_BRIGHTNESS_SHIFT; | 328 | ret = set_lcd(value); |
| 300 | hci_write1(HCI_LCD_BRIGHTNESS, value, &hci_result); | 329 | else |
| 301 | if (hci_result != HCI_SUCCESS) | 330 | ret = -EINVAL; |
| 302 | return -EFAULT; | 331 | return ret; |
| 303 | } else { | ||
| 304 | return -EINVAL; | ||
| 305 | } | ||
| 306 | |||
| 307 | return count; | ||
| 308 | } | 332 | } |
| 309 | 333 | ||
| 310 | static char *read_video(char *p) | 334 | static char *read_video(char *p) |
| @@ -506,6 +530,26 @@ static acpi_status __exit remove_device(void) | |||
| 506 | return AE_OK; | 530 | return AE_OK; |
| 507 | } | 531 | } |
| 508 | 532 | ||
| 533 | static struct backlight_properties toshiba_backlight_data = { | ||
| 534 | .owner = THIS_MODULE, | ||
| 535 | .get_brightness = get_lcd, | ||
| 536 | .update_status = set_lcd_status, | ||
| 537 | .max_brightness = HCI_LCD_BRIGHTNESS_LEVELS - 1, | ||
| 538 | }; | ||
| 539 | |||
| 540 | static void __exit toshiba_acpi_exit(void) | ||
| 541 | { | ||
| 542 | if (toshiba_backlight_device) | ||
| 543 | backlight_device_unregister(toshiba_backlight_device); | ||
| 544 | |||
| 545 | remove_device(); | ||
| 546 | |||
| 547 | if (toshiba_proc_dir) | ||
| 548 | remove_proc_entry(PROC_TOSHIBA, acpi_root_dir); | ||
| 549 | |||
| 550 | return; | ||
| 551 | } | ||
| 552 | |||
| 509 | static int __init toshiba_acpi_init(void) | 553 | static int __init toshiba_acpi_init(void) |
| 510 | { | 554 | { |
| 511 | acpi_status status = AE_OK; | 555 | acpi_status status = AE_OK; |
| @@ -546,17 +590,16 @@ static int __init toshiba_acpi_init(void) | |||
| 546 | remove_proc_entry(PROC_TOSHIBA, acpi_root_dir); | 590 | remove_proc_entry(PROC_TOSHIBA, acpi_root_dir); |
| 547 | } | 591 | } |
| 548 | 592 | ||
| 549 | return (ACPI_SUCCESS(status)) ? 0 : -ENODEV; | 593 | toshiba_backlight_device = backlight_device_register("toshiba",NULL, |
| 550 | } | 594 | NULL, |
| 551 | 595 | &toshiba_backlight_data); | |
| 552 | static void __exit toshiba_acpi_exit(void) | 596 | if (IS_ERR(toshiba_backlight_device)) { |
| 553 | { | 597 | printk(KERN_ERR "Could not register toshiba backlight device\n"); |
| 554 | remove_device(); | 598 | toshiba_backlight_device = NULL; |
| 555 | 599 | toshiba_acpi_exit(); | |
| 556 | if (toshiba_proc_dir) | 600 | } |
| 557 | remove_proc_entry(PROC_TOSHIBA, acpi_root_dir); | ||
| 558 | 601 | ||
| 559 | return; | 602 | return (ACPI_SUCCESS(status)) ? 0 : -ENODEV; |
| 560 | } | 603 | } |
| 561 | 604 | ||
| 562 | module_init(toshiba_acpi_init); | 605 | module_init(toshiba_acpi_init); |
diff --git a/drivers/acpi/utilities/utdebug.c b/drivers/acpi/utilities/utdebug.c index bb1eaf9aa653..9e9054e155c1 100644 --- a/drivers/acpi/utilities/utdebug.c +++ b/drivers/acpi/utilities/utdebug.c | |||
| @@ -180,8 +180,9 @@ acpi_ut_debug_print(u32 requested_debug_level, | |||
| 180 | if (thread_id != acpi_gbl_prev_thread_id) { | 180 | if (thread_id != acpi_gbl_prev_thread_id) { |
| 181 | if (ACPI_LV_THREADS & acpi_dbg_level) { | 181 | if (ACPI_LV_THREADS & acpi_dbg_level) { |
| 182 | acpi_os_printf | 182 | acpi_os_printf |
| 183 | ("\n**** Context Switch from TID %X to TID %X ****\n\n", | 183 | ("\n**** Context Switch from TID %lX to TID %lX ****\n\n", |
| 184 | (u32) acpi_gbl_prev_thread_id, (u32) thread_id); | 184 | (unsigned long) acpi_gbl_prev_thread_id, |
| 185 | (unsigned long) thread_id); | ||
| 185 | } | 186 | } |
| 186 | 187 | ||
| 187 | acpi_gbl_prev_thread_id = thread_id; | 188 | acpi_gbl_prev_thread_id = thread_id; |
diff --git a/drivers/acpi/utilities/utmutex.c b/drivers/acpi/utilities/utmutex.c index c39062a047cd..180e73ceb6e2 100644 --- a/drivers/acpi/utilities/utmutex.c +++ b/drivers/acpi/utilities/utmutex.c | |||
| @@ -243,23 +243,24 @@ acpi_status acpi_ut_acquire_mutex(acpi_mutex_handle mutex_id) | |||
| 243 | #endif | 243 | #endif |
| 244 | 244 | ||
| 245 | ACPI_DEBUG_PRINT((ACPI_DB_MUTEX, | 245 | ACPI_DEBUG_PRINT((ACPI_DB_MUTEX, |
| 246 | "Thread %X attempting to acquire Mutex [%s]\n", | 246 | "Thread %lX attempting to acquire Mutex [%s]\n", |
| 247 | (u32) this_thread_id, acpi_ut_get_mutex_name(mutex_id))); | 247 | (unsigned long) this_thread_id, |
| 248 | acpi_ut_get_mutex_name(mutex_id))); | ||
| 248 | 249 | ||
| 249 | status = acpi_os_acquire_mutex(acpi_gbl_mutex_info[mutex_id].mutex, | 250 | status = acpi_os_acquire_mutex(acpi_gbl_mutex_info[mutex_id].mutex, |
| 250 | ACPI_WAIT_FOREVER); | 251 | ACPI_WAIT_FOREVER); |
| 251 | if (ACPI_SUCCESS(status)) { | 252 | if (ACPI_SUCCESS(status)) { |
| 252 | ACPI_DEBUG_PRINT((ACPI_DB_MUTEX, | 253 | ACPI_DEBUG_PRINT((ACPI_DB_MUTEX, |
| 253 | "Thread %X acquired Mutex [%s]\n", | 254 | "Thread %lX acquired Mutex [%s]\n", |
| 254 | (u32) this_thread_id, | 255 | (unsigned long) this_thread_id, |
| 255 | acpi_ut_get_mutex_name(mutex_id))); | 256 | acpi_ut_get_mutex_name(mutex_id))); |
| 256 | 257 | ||
| 257 | acpi_gbl_mutex_info[mutex_id].use_count++; | 258 | acpi_gbl_mutex_info[mutex_id].use_count++; |
| 258 | acpi_gbl_mutex_info[mutex_id].thread_id = this_thread_id; | 259 | acpi_gbl_mutex_info[mutex_id].thread_id = this_thread_id; |
| 259 | } else { | 260 | } else { |
| 260 | ACPI_EXCEPTION((AE_INFO, status, | 261 | ACPI_EXCEPTION((AE_INFO, status, |
| 261 | "Thread %X could not acquire Mutex [%X]", | 262 | "Thread %lX could not acquire Mutex [%X]", |
| 262 | (u32) this_thread_id, mutex_id)); | 263 | (unsigned long) this_thread_id, mutex_id)); |
| 263 | } | 264 | } |
| 264 | 265 | ||
| 265 | return (status); | 266 | return (status); |
| @@ -285,7 +286,8 @@ acpi_status acpi_ut_release_mutex(acpi_mutex_handle mutex_id) | |||
| 285 | 286 | ||
| 286 | this_thread_id = acpi_os_get_thread_id(); | 287 | this_thread_id = acpi_os_get_thread_id(); |
| 287 | ACPI_DEBUG_PRINT((ACPI_DB_MUTEX, | 288 | ACPI_DEBUG_PRINT((ACPI_DB_MUTEX, |
| 288 | "Thread %X releasing Mutex [%s]\n", (u32) this_thread_id, | 289 | "Thread %lX releasing Mutex [%s]\n", |
| 290 | (unsigned long) this_thread_id, | ||
| 289 | acpi_ut_get_mutex_name(mutex_id))); | 291 | acpi_ut_get_mutex_name(mutex_id))); |
| 290 | 292 | ||
| 291 | if (mutex_id > ACPI_MAX_MUTEX) { | 293 | if (mutex_id > ACPI_MAX_MUTEX) { |
diff --git a/drivers/acpi/utils.c b/drivers/acpi/utils.c index d0d84c43a9d4..68a809fa7b19 100644 --- a/drivers/acpi/utils.c +++ b/drivers/acpi/utils.c | |||
| @@ -83,7 +83,7 @@ acpi_extract_package(union acpi_object *package, | |||
| 83 | return AE_BAD_DATA; | 83 | return AE_BAD_DATA; |
| 84 | } | 84 | } |
| 85 | 85 | ||
| 86 | format_string = (char *)format->pointer; | 86 | format_string = format->pointer; |
| 87 | 87 | ||
| 88 | /* | 88 | /* |
| 89 | * Calculate size_required. | 89 | * Calculate size_required. |
| @@ -262,11 +262,10 @@ acpi_evaluate_integer(acpi_handle handle, | |||
| 262 | if (!data) | 262 | if (!data) |
| 263 | return AE_BAD_PARAMETER; | 263 | return AE_BAD_PARAMETER; |
| 264 | 264 | ||
| 265 | element = kmalloc(sizeof(union acpi_object), irqs_disabled() ? GFP_ATOMIC: GFP_KERNEL); | 265 | element = kzalloc(sizeof(union acpi_object), irqs_disabled() ? GFP_ATOMIC: GFP_KERNEL); |
| 266 | if (!element) | 266 | if (!element) |
| 267 | return AE_NO_MEMORY; | 267 | return AE_NO_MEMORY; |
| 268 | 268 | ||
| 269 | memset(element, 0, sizeof(union acpi_object)); | ||
| 270 | buffer.length = sizeof(union acpi_object); | 269 | buffer.length = sizeof(union acpi_object); |
| 271 | buffer.pointer = element; | 270 | buffer.pointer = element; |
| 272 | status = acpi_evaluate_object(handle, pathname, arguments, &buffer); | 271 | status = acpi_evaluate_object(handle, pathname, arguments, &buffer); |
| @@ -321,12 +320,11 @@ acpi_evaluate_string(acpi_handle handle, | |||
| 321 | return AE_BAD_DATA; | 320 | return AE_BAD_DATA; |
| 322 | } | 321 | } |
| 323 | 322 | ||
| 324 | *data = kmalloc(element->string.length + 1, GFP_KERNEL); | 323 | *data = kzalloc(element->string.length + 1, GFP_KERNEL); |
| 325 | if (!data) { | 324 | if (!data) { |
| 326 | printk(KERN_ERR PREFIX "Memory allocation\n"); | 325 | printk(KERN_ERR PREFIX "Memory allocation\n"); |
| 327 | return -ENOMEM; | 326 | return -ENOMEM; |
| 328 | } | 327 | } |
| 329 | memset(*data, 0, element->string.length + 1); | ||
| 330 | 328 | ||
| 331 | memcpy(*data, element->string.pointer, element->string.length); | 329 | memcpy(*data, element->string.pointer, element->string.length); |
| 332 | 330 | ||
| @@ -361,7 +359,7 @@ acpi_evaluate_reference(acpi_handle handle, | |||
| 361 | if (ACPI_FAILURE(status)) | 359 | if (ACPI_FAILURE(status)) |
| 362 | goto end; | 360 | goto end; |
| 363 | 361 | ||
| 364 | package = (union acpi_object *)buffer.pointer; | 362 | package = buffer.pointer; |
| 365 | 363 | ||
| 366 | if ((buffer.length == 0) || !package) { | 364 | if ((buffer.length == 0) || !package) { |
| 367 | printk(KERN_ERR PREFIX "No return object (len %X ptr %p)\n", | 365 | printk(KERN_ERR PREFIX "No return object (len %X ptr %p)\n", |
diff --git a/drivers/acpi/video.c b/drivers/acpi/video.c index 56666a982476..36b37d755dbc 100644 --- a/drivers/acpi/video.c +++ b/drivers/acpi/video.c | |||
| @@ -3,6 +3,7 @@ | |||
| 3 | * | 3 | * |
| 4 | * Copyright (C) 2004 Luming Yu <luming.yu@intel.com> | 4 | * Copyright (C) 2004 Luming Yu <luming.yu@intel.com> |
| 5 | * Copyright (C) 2004 Bruno Ducrot <ducrot@poupinou.org> | 5 | * Copyright (C) 2004 Bruno Ducrot <ducrot@poupinou.org> |
| 6 | * Copyright (C) 2006 Thomas Tuttle <linux-kernel@ttuttle.net> | ||
| 6 | * | 7 | * |
| 7 | * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | 8 | * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 8 | * | 9 | * |
| @@ -47,11 +48,11 @@ | |||
| 47 | #define ACPI_VIDEO_NOTIFY_NEXT_OUTPUT 0x83 | 48 | #define ACPI_VIDEO_NOTIFY_NEXT_OUTPUT 0x83 |
| 48 | #define ACPI_VIDEO_NOTIFY_PREV_OUTPUT 0x84 | 49 | #define ACPI_VIDEO_NOTIFY_PREV_OUTPUT 0x84 |
| 49 | 50 | ||
| 50 | #define ACPI_VIDEO_NOTIFY_CYCLE_BRIGHTNESS 0x82 | 51 | #define ACPI_VIDEO_NOTIFY_CYCLE_BRIGHTNESS 0x85 |
| 51 | #define ACPI_VIDEO_NOTIFY_INC_BRIGHTNESS 0x83 | 52 | #define ACPI_VIDEO_NOTIFY_INC_BRIGHTNESS 0x86 |
| 52 | #define ACPI_VIDEO_NOTIFY_DEC_BRIGHTNESS 0x84 | 53 | #define ACPI_VIDEO_NOTIFY_DEC_BRIGHTNESS 0x87 |
| 53 | #define ACPI_VIDEO_NOTIFY_ZERO_BRIGHTNESS 0x85 | 54 | #define ACPI_VIDEO_NOTIFY_ZERO_BRIGHTNESS 0x88 |
| 54 | #define ACPI_VIDEO_NOTIFY_DISPLAY_OFF 0x86 | 55 | #define ACPI_VIDEO_NOTIFY_DISPLAY_OFF 0x89 |
| 55 | 56 | ||
| 56 | #define ACPI_VIDEO_HEAD_INVALID (~0u - 1) | 57 | #define ACPI_VIDEO_HEAD_INVALID (~0u - 1) |
| 57 | #define ACPI_VIDEO_HEAD_END (~0u) | 58 | #define ACPI_VIDEO_HEAD_END (~0u) |
| @@ -386,7 +387,7 @@ acpi_video_device_EDID(struct acpi_video_device *device, | |||
| 386 | if (ACPI_FAILURE(status)) | 387 | if (ACPI_FAILURE(status)) |
| 387 | return -ENODEV; | 388 | return -ENODEV; |
| 388 | 389 | ||
| 389 | obj = (union acpi_object *)buffer.pointer; | 390 | obj = buffer.pointer; |
| 390 | 391 | ||
| 391 | if (obj && obj->type == ACPI_TYPE_BUFFER) | 392 | if (obj && obj->type == ACPI_TYPE_BUFFER) |
| 392 | *edid = obj; | 393 | *edid = obj; |
| @@ -532,11 +533,10 @@ static void acpi_video_device_find_cap(struct acpi_video_device *device) | |||
| 532 | int count = 0; | 533 | int count = 0; |
| 533 | union acpi_object *o; | 534 | union acpi_object *o; |
| 534 | 535 | ||
| 535 | br = kmalloc(sizeof(*br), GFP_KERNEL); | 536 | br = kzalloc(sizeof(*br), GFP_KERNEL); |
| 536 | if (!br) { | 537 | if (!br) { |
| 537 | printk(KERN_ERR "can't allocate memory\n"); | 538 | printk(KERN_ERR "can't allocate memory\n"); |
| 538 | } else { | 539 | } else { |
| 539 | memset(br, 0, sizeof(*br)); | ||
| 540 | br->levels = kmalloc(obj->package.count * | 540 | br->levels = kmalloc(obj->package.count * |
| 541 | sizeof *(br->levels), GFP_KERNEL); | 541 | sizeof *(br->levels), GFP_KERNEL); |
| 542 | if (!br->levels) | 542 | if (!br->levels) |
| @@ -654,8 +654,7 @@ static struct proc_dir_entry *acpi_video_dir; | |||
| 654 | 654 | ||
| 655 | static int acpi_video_device_info_seq_show(struct seq_file *seq, void *offset) | 655 | static int acpi_video_device_info_seq_show(struct seq_file *seq, void *offset) |
| 656 | { | 656 | { |
| 657 | struct acpi_video_device *dev = | 657 | struct acpi_video_device *dev = seq->private; |
| 658 | (struct acpi_video_device *)seq->private; | ||
| 659 | 658 | ||
| 660 | 659 | ||
| 661 | if (!dev) | 660 | if (!dev) |
| @@ -688,8 +687,7 @@ acpi_video_device_info_open_fs(struct inode *inode, struct file *file) | |||
| 688 | static int acpi_video_device_state_seq_show(struct seq_file *seq, void *offset) | 687 | static int acpi_video_device_state_seq_show(struct seq_file *seq, void *offset) |
| 689 | { | 688 | { |
| 690 | int status; | 689 | int status; |
| 691 | struct acpi_video_device *dev = | 690 | struct acpi_video_device *dev = seq->private; |
| 692 | (struct acpi_video_device *)seq->private; | ||
| 693 | unsigned long state; | 691 | unsigned long state; |
| 694 | 692 | ||
| 695 | 693 | ||
| @@ -727,8 +725,8 @@ acpi_video_device_write_state(struct file *file, | |||
| 727 | size_t count, loff_t * data) | 725 | size_t count, loff_t * data) |
| 728 | { | 726 | { |
| 729 | int status; | 727 | int status; |
| 730 | struct seq_file *m = (struct seq_file *)file->private_data; | 728 | struct seq_file *m = file->private_data; |
| 731 | struct acpi_video_device *dev = (struct acpi_video_device *)m->private; | 729 | struct acpi_video_device *dev = m->private; |
| 732 | char str[12] = { 0 }; | 730 | char str[12] = { 0 }; |
| 733 | u32 state = 0; | 731 | u32 state = 0; |
| 734 | 732 | ||
| @@ -754,8 +752,7 @@ acpi_video_device_write_state(struct file *file, | |||
| 754 | static int | 752 | static int |
| 755 | acpi_video_device_brightness_seq_show(struct seq_file *seq, void *offset) | 753 | acpi_video_device_brightness_seq_show(struct seq_file *seq, void *offset) |
| 756 | { | 754 | { |
| 757 | struct acpi_video_device *dev = | 755 | struct acpi_video_device *dev = seq->private; |
| 758 | (struct acpi_video_device *)seq->private; | ||
| 759 | int i; | 756 | int i; |
| 760 | 757 | ||
| 761 | 758 | ||
| @@ -784,8 +781,8 @@ acpi_video_device_write_brightness(struct file *file, | |||
| 784 | const char __user * buffer, | 781 | const char __user * buffer, |
| 785 | size_t count, loff_t * data) | 782 | size_t count, loff_t * data) |
| 786 | { | 783 | { |
| 787 | struct seq_file *m = (struct seq_file *)file->private_data; | 784 | struct seq_file *m = file->private_data; |
| 788 | struct acpi_video_device *dev = (struct acpi_video_device *)m->private; | 785 | struct acpi_video_device *dev = m->private; |
| 789 | char str[4] = { 0 }; | 786 | char str[4] = { 0 }; |
| 790 | unsigned int level = 0; | 787 | unsigned int level = 0; |
| 791 | int i; | 788 | int i; |
| @@ -817,8 +814,7 @@ acpi_video_device_write_brightness(struct file *file, | |||
| 817 | 814 | ||
| 818 | static int acpi_video_device_EDID_seq_show(struct seq_file *seq, void *offset) | 815 | static int acpi_video_device_EDID_seq_show(struct seq_file *seq, void *offset) |
| 819 | { | 816 | { |
| 820 | struct acpi_video_device *dev = | 817 | struct acpi_video_device *dev = seq->private; |
| 821 | (struct acpi_video_device *)seq->private; | ||
| 822 | int status; | 818 | int status; |
| 823 | int i; | 819 | int i; |
| 824 | union acpi_object *edid = NULL; | 820 | union acpi_object *edid = NULL; |
| @@ -866,7 +862,7 @@ static int acpi_video_device_add_fs(struct acpi_device *device) | |||
| 866 | if (!device) | 862 | if (!device) |
| 867 | return -ENODEV; | 863 | return -ENODEV; |
| 868 | 864 | ||
| 869 | vid_dev = (struct acpi_video_device *)acpi_driver_data(device); | 865 | vid_dev = acpi_driver_data(device); |
| 870 | if (!vid_dev) | 866 | if (!vid_dev) |
| 871 | return -ENODEV; | 867 | return -ENODEV; |
| 872 | 868 | ||
| @@ -931,7 +927,7 @@ static int acpi_video_device_remove_fs(struct acpi_device *device) | |||
| 931 | { | 927 | { |
| 932 | struct acpi_video_device *vid_dev; | 928 | struct acpi_video_device *vid_dev; |
| 933 | 929 | ||
| 934 | vid_dev = (struct acpi_video_device *)acpi_driver_data(device); | 930 | vid_dev = acpi_driver_data(device); |
| 935 | if (!vid_dev || !vid_dev->video || !vid_dev->video->dir) | 931 | if (!vid_dev || !vid_dev->video || !vid_dev->video->dir) |
| 936 | return -ENODEV; | 932 | return -ENODEV; |
| 937 | 933 | ||
| @@ -950,7 +946,7 @@ static int acpi_video_device_remove_fs(struct acpi_device *device) | |||
| 950 | /* video bus */ | 946 | /* video bus */ |
| 951 | static int acpi_video_bus_info_seq_show(struct seq_file *seq, void *offset) | 947 | static int acpi_video_bus_info_seq_show(struct seq_file *seq, void *offset) |
| 952 | { | 948 | { |
| 953 | struct acpi_video_bus *video = (struct acpi_video_bus *)seq->private; | 949 | struct acpi_video_bus *video = seq->private; |
| 954 | 950 | ||
| 955 | 951 | ||
| 956 | if (!video) | 952 | if (!video) |
| @@ -975,7 +971,7 @@ static int acpi_video_bus_info_open_fs(struct inode *inode, struct file *file) | |||
| 975 | 971 | ||
| 976 | static int acpi_video_bus_ROM_seq_show(struct seq_file *seq, void *offset) | 972 | static int acpi_video_bus_ROM_seq_show(struct seq_file *seq, void *offset) |
| 977 | { | 973 | { |
| 978 | struct acpi_video_bus *video = (struct acpi_video_bus *)seq->private; | 974 | struct acpi_video_bus *video = seq->private; |
| 979 | 975 | ||
| 980 | 976 | ||
| 981 | if (!video) | 977 | if (!video) |
| @@ -995,7 +991,7 @@ static int acpi_video_bus_ROM_open_fs(struct inode *inode, struct file *file) | |||
| 995 | 991 | ||
| 996 | static int acpi_video_bus_POST_info_seq_show(struct seq_file *seq, void *offset) | 992 | static int acpi_video_bus_POST_info_seq_show(struct seq_file *seq, void *offset) |
| 997 | { | 993 | { |
| 998 | struct acpi_video_bus *video = (struct acpi_video_bus *)seq->private; | 994 | struct acpi_video_bus *video = seq->private; |
| 999 | unsigned long options; | 995 | unsigned long options; |
| 1000 | int status; | 996 | int status; |
| 1001 | 997 | ||
| @@ -1033,7 +1029,7 @@ acpi_video_bus_POST_info_open_fs(struct inode *inode, struct file *file) | |||
| 1033 | 1029 | ||
| 1034 | static int acpi_video_bus_POST_seq_show(struct seq_file *seq, void *offset) | 1030 | static int acpi_video_bus_POST_seq_show(struct seq_file *seq, void *offset) |
| 1035 | { | 1031 | { |
| 1036 | struct acpi_video_bus *video = (struct acpi_video_bus *)seq->private; | 1032 | struct acpi_video_bus *video = seq->private; |
| 1037 | int status; | 1033 | int status; |
| 1038 | unsigned long id; | 1034 | unsigned long id; |
| 1039 | 1035 | ||
| @@ -1054,7 +1050,7 @@ static int acpi_video_bus_POST_seq_show(struct seq_file *seq, void *offset) | |||
| 1054 | 1050 | ||
| 1055 | static int acpi_video_bus_DOS_seq_show(struct seq_file *seq, void *offset) | 1051 | static int acpi_video_bus_DOS_seq_show(struct seq_file *seq, void *offset) |
| 1056 | { | 1052 | { |
| 1057 | struct acpi_video_bus *video = (struct acpi_video_bus *)seq->private; | 1053 | struct acpi_video_bus *video = seq->private; |
| 1058 | 1054 | ||
| 1059 | 1055 | ||
| 1060 | seq_printf(seq, "DOS setting: <%d>\n", video->dos_setting); | 1056 | seq_printf(seq, "DOS setting: <%d>\n", video->dos_setting); |
| @@ -1079,8 +1075,8 @@ acpi_video_bus_write_POST(struct file *file, | |||
| 1079 | size_t count, loff_t * data) | 1075 | size_t count, loff_t * data) |
| 1080 | { | 1076 | { |
| 1081 | int status; | 1077 | int status; |
| 1082 | struct seq_file *m = (struct seq_file *)file->private_data; | 1078 | struct seq_file *m = file->private_data; |
| 1083 | struct acpi_video_bus *video = (struct acpi_video_bus *)m->private; | 1079 | struct acpi_video_bus *video = m->private; |
| 1084 | char str[12] = { 0 }; | 1080 | char str[12] = { 0 }; |
| 1085 | unsigned long opt, options; | 1081 | unsigned long opt, options; |
| 1086 | 1082 | ||
| @@ -1119,8 +1115,8 @@ acpi_video_bus_write_DOS(struct file *file, | |||
| 1119 | size_t count, loff_t * data) | 1115 | size_t count, loff_t * data) |
| 1120 | { | 1116 | { |
| 1121 | int status; | 1117 | int status; |
| 1122 | struct seq_file *m = (struct seq_file *)file->private_data; | 1118 | struct seq_file *m = file->private_data; |
| 1123 | struct acpi_video_bus *video = (struct acpi_video_bus *)m->private; | 1119 | struct acpi_video_bus *video = m->private; |
| 1124 | char str[12] = { 0 }; | 1120 | char str[12] = { 0 }; |
| 1125 | unsigned long opt; | 1121 | unsigned long opt; |
| 1126 | 1122 | ||
| @@ -1150,7 +1146,7 @@ static int acpi_video_bus_add_fs(struct acpi_device *device) | |||
| 1150 | struct acpi_video_bus *video; | 1146 | struct acpi_video_bus *video; |
| 1151 | 1147 | ||
| 1152 | 1148 | ||
| 1153 | video = (struct acpi_video_bus *)acpi_driver_data(device); | 1149 | video = acpi_driver_data(device); |
| 1154 | 1150 | ||
| 1155 | if (!acpi_device_dir(device)) { | 1151 | if (!acpi_device_dir(device)) { |
| 1156 | acpi_device_dir(device) = proc_mkdir(acpi_device_bid(device), | 1152 | acpi_device_dir(device) = proc_mkdir(acpi_device_bid(device), |
| @@ -1226,7 +1222,7 @@ static int acpi_video_bus_remove_fs(struct acpi_device *device) | |||
| 1226 | struct acpi_video_bus *video; | 1222 | struct acpi_video_bus *video; |
| 1227 | 1223 | ||
| 1228 | 1224 | ||
| 1229 | video = (struct acpi_video_bus *)acpi_driver_data(device); | 1225 | video = acpi_driver_data(device); |
| 1230 | 1226 | ||
| 1231 | if (acpi_device_dir(device)) { | 1227 | if (acpi_device_dir(device)) { |
| 1232 | remove_proc_entry("info", acpi_device_dir(device)); | 1228 | remove_proc_entry("info", acpi_device_dir(device)); |
| @@ -1263,12 +1259,10 @@ acpi_video_bus_get_one_device(struct acpi_device *device, | |||
| 1263 | acpi_evaluate_integer(device->handle, "_ADR", NULL, &device_id); | 1259 | acpi_evaluate_integer(device->handle, "_ADR", NULL, &device_id); |
| 1264 | if (ACPI_SUCCESS(status)) { | 1260 | if (ACPI_SUCCESS(status)) { |
| 1265 | 1261 | ||
| 1266 | data = kmalloc(sizeof(struct acpi_video_device), GFP_KERNEL); | 1262 | data = kzalloc(sizeof(struct acpi_video_device), GFP_KERNEL); |
| 1267 | if (!data) | 1263 | if (!data) |
| 1268 | return -ENOMEM; | 1264 | return -ENOMEM; |
| 1269 | 1265 | ||
| 1270 | memset(data, 0, sizeof(struct acpi_video_device)); | ||
| 1271 | |||
| 1272 | strcpy(acpi_device_name(device), ACPI_VIDEO_DEVICE_NAME); | 1266 | strcpy(acpi_device_name(device), ACPI_VIDEO_DEVICE_NAME); |
| 1273 | strcpy(acpi_device_class(device), ACPI_VIDEO_CLASS); | 1267 | strcpy(acpi_device_class(device), ACPI_VIDEO_CLASS); |
| 1274 | acpi_driver_data(device) = data; | 1268 | acpi_driver_data(device) = data; |
| @@ -1403,7 +1397,7 @@ static int acpi_video_device_enumerate(struct acpi_video_bus *video) | |||
| 1403 | return status; | 1397 | return status; |
| 1404 | } | 1398 | } |
| 1405 | 1399 | ||
| 1406 | dod = (union acpi_object *)buffer.pointer; | 1400 | dod = buffer.pointer; |
| 1407 | if (!dod || (dod->type != ACPI_TYPE_PACKAGE)) { | 1401 | if (!dod || (dod->type != ACPI_TYPE_PACKAGE)) { |
| 1408 | ACPI_EXCEPTION((AE_INFO, status, "Invalid _DOD data")); | 1402 | ACPI_EXCEPTION((AE_INFO, status, "Invalid _DOD data")); |
| 1409 | status = -EFAULT; | 1403 | status = -EFAULT; |
| @@ -1426,7 +1420,7 @@ static int acpi_video_device_enumerate(struct acpi_video_bus *video) | |||
| 1426 | 1420 | ||
| 1427 | count = 0; | 1421 | count = 0; |
| 1428 | for (i = 0; i < dod->package.count; i++) { | 1422 | for (i = 0; i < dod->package.count; i++) { |
| 1429 | obj = (union acpi_object *)&dod->package.elements[i]; | 1423 | obj = &dod->package.elements[i]; |
| 1430 | 1424 | ||
| 1431 | if (obj->type != ACPI_TYPE_INTEGER) { | 1425 | if (obj->type != ACPI_TYPE_INTEGER) { |
| 1432 | printk(KERN_ERR PREFIX "Invalid _DOD data\n"); | 1426 | printk(KERN_ERR PREFIX "Invalid _DOD data\n"); |
| @@ -1509,8 +1503,34 @@ static int | |||
| 1509 | acpi_video_get_next_level(struct acpi_video_device *device, | 1503 | acpi_video_get_next_level(struct acpi_video_device *device, |
| 1510 | u32 level_current, u32 event) | 1504 | u32 level_current, u32 event) |
| 1511 | { | 1505 | { |
| 1512 | /*Fix me */ | 1506 | int min, max, min_above, max_below, i, l; |
| 1513 | return level_current; | 1507 | max = max_below = 0; |
| 1508 | min = min_above = 255; | ||
| 1509 | for (i = 0; i < device->brightness->count; i++) { | ||
| 1510 | l = device->brightness->levels[i]; | ||
| 1511 | if (l < min) | ||
| 1512 | min = l; | ||
| 1513 | if (l > max) | ||
| 1514 | max = l; | ||
| 1515 | if (l < min_above && l > level_current) | ||
| 1516 | min_above = l; | ||
| 1517 | if (l > max_below && l < level_current) | ||
| 1518 | max_below = l; | ||
| 1519 | } | ||
| 1520 | |||
| 1521 | switch (event) { | ||
| 1522 | case ACPI_VIDEO_NOTIFY_CYCLE_BRIGHTNESS: | ||
| 1523 | return (level_current < max) ? min_above : min; | ||
| 1524 | case ACPI_VIDEO_NOTIFY_INC_BRIGHTNESS: | ||
| 1525 | return (level_current < max) ? min_above : max; | ||
| 1526 | case ACPI_VIDEO_NOTIFY_DEC_BRIGHTNESS: | ||
| 1527 | return (level_current > min) ? max_below : min; | ||
| 1528 | case ACPI_VIDEO_NOTIFY_ZERO_BRIGHTNESS: | ||
| 1529 | case ACPI_VIDEO_NOTIFY_DISPLAY_OFF: | ||
| 1530 | return 0; | ||
| 1531 | default: | ||
| 1532 | return level_current; | ||
| 1533 | } | ||
| 1514 | } | 1534 | } |
| 1515 | 1535 | ||
| 1516 | static void | 1536 | static void |
| @@ -1612,7 +1632,7 @@ static int acpi_video_bus_stop_devices(struct acpi_video_bus *video) | |||
| 1612 | 1632 | ||
| 1613 | static void acpi_video_bus_notify(acpi_handle handle, u32 event, void *data) | 1633 | static void acpi_video_bus_notify(acpi_handle handle, u32 event, void *data) |
| 1614 | { | 1634 | { |
| 1615 | struct acpi_video_bus *video = (struct acpi_video_bus *)data; | 1635 | struct acpi_video_bus *video = data; |
| 1616 | struct acpi_device *device = NULL; | 1636 | struct acpi_device *device = NULL; |
| 1617 | 1637 | ||
| 1618 | printk("video bus notify\n"); | 1638 | printk("video bus notify\n"); |
| @@ -1654,8 +1674,7 @@ static void acpi_video_bus_notify(acpi_handle handle, u32 event, void *data) | |||
| 1654 | 1674 | ||
| 1655 | static void acpi_video_device_notify(acpi_handle handle, u32 event, void *data) | 1675 | static void acpi_video_device_notify(acpi_handle handle, u32 event, void *data) |
| 1656 | { | 1676 | { |
| 1657 | struct acpi_video_device *video_device = | 1677 | struct acpi_video_device *video_device = data; |
| 1658 | (struct acpi_video_device *)data; | ||
| 1659 | struct acpi_device *device = NULL; | 1678 | struct acpi_device *device = NULL; |
| 1660 | 1679 | ||
| 1661 | 1680 | ||
| @@ -1696,10 +1715,9 @@ static int acpi_video_bus_add(struct acpi_device *device) | |||
| 1696 | if (!device) | 1715 | if (!device) |
| 1697 | return -EINVAL; | 1716 | return -EINVAL; |
| 1698 | 1717 | ||
| 1699 | video = kmalloc(sizeof(struct acpi_video_bus), GFP_KERNEL); | 1718 | video = kzalloc(sizeof(struct acpi_video_bus), GFP_KERNEL); |
| 1700 | if (!video) | 1719 | if (!video) |
| 1701 | return -ENOMEM; | 1720 | return -ENOMEM; |
| 1702 | memset(video, 0, sizeof(struct acpi_video_bus)); | ||
| 1703 | 1721 | ||
| 1704 | video->device = device; | 1722 | video->device = device; |
| 1705 | strcpy(acpi_device_name(device), ACPI_VIDEO_BUS_NAME); | 1723 | strcpy(acpi_device_name(device), ACPI_VIDEO_BUS_NAME); |
| @@ -1757,7 +1775,7 @@ static int acpi_video_bus_remove(struct acpi_device *device, int type) | |||
| 1757 | if (!device || !acpi_driver_data(device)) | 1775 | if (!device || !acpi_driver_data(device)) |
| 1758 | return -EINVAL; | 1776 | return -EINVAL; |
| 1759 | 1777 | ||
| 1760 | video = (struct acpi_video_bus *)acpi_driver_data(device); | 1778 | video = acpi_driver_data(device); |
| 1761 | 1779 | ||
| 1762 | acpi_video_bus_stop_devices(video); | 1780 | acpi_video_bus_stop_devices(video); |
| 1763 | 1781 | ||
diff --git a/drivers/misc/msi-laptop.c b/drivers/misc/msi-laptop.c index fdb7153f4426..8e5e07e4c1cf 100644 --- a/drivers/misc/msi-laptop.c +++ b/drivers/misc/msi-laptop.c | |||
| @@ -317,7 +317,8 @@ static int __init msi_init(void) | |||
| 317 | 317 | ||
| 318 | /* Register backlight stuff */ | 318 | /* Register backlight stuff */ |
| 319 | 319 | ||
| 320 | msibl_device = backlight_device_register("msi-laptop-bl", NULL, &msibl_props); | 320 | msibl_device = backlight_device_register("msi-laptop-bl", NULL, NULL, |
| 321 | &msibl_props); | ||
| 321 | if (IS_ERR(msibl_device)) | 322 | if (IS_ERR(msibl_device)) |
| 322 | return PTR_ERR(msibl_device); | 323 | return PTR_ERR(msibl_device); |
| 323 | 324 | ||
diff --git a/drivers/pci/hotplug/acpiphp_ibm.c b/drivers/pci/hotplug/acpiphp_ibm.c index bd40aee10e16..7f03881a8b68 100644 --- a/drivers/pci/hotplug/acpiphp_ibm.c +++ b/drivers/pci/hotplug/acpiphp_ibm.c | |||
| @@ -319,13 +319,12 @@ static int ibm_get_table_from_acpi(char **bufp) | |||
| 319 | if (bufp == NULL) | 319 | if (bufp == NULL) |
| 320 | goto read_table_done; | 320 | goto read_table_done; |
| 321 | 321 | ||
| 322 | lbuf = kmalloc(size, GFP_KERNEL); | 322 | lbuf = kzalloc(size, GFP_KERNEL); |
| 323 | dbg("%s: element count: %i, ASL table size: %i, &table = 0x%p\n", | 323 | dbg("%s: element count: %i, ASL table size: %i, &table = 0x%p\n", |
| 324 | __FUNCTION__, package->package.count, size, lbuf); | 324 | __FUNCTION__, package->package.count, size, lbuf); |
| 325 | 325 | ||
| 326 | if (lbuf) { | 326 | if (lbuf) { |
| 327 | *bufp = lbuf; | 327 | *bufp = lbuf; |
| 328 | memset(lbuf, 0, size); | ||
| 329 | } else { | 328 | } else { |
| 330 | size = -ENOMEM; | 329 | size = -ENOMEM; |
| 331 | goto read_table_done; | 330 | goto read_table_done; |
diff --git a/drivers/usb/misc/appledisplay.c b/drivers/usb/misc/appledisplay.c index 02cbb7fff24f..a7932a72d298 100644 --- a/drivers/usb/misc/appledisplay.c +++ b/drivers/usb/misc/appledisplay.c | |||
| @@ -281,7 +281,7 @@ static int appledisplay_probe(struct usb_interface *iface, | |||
| 281 | /* Register backlight device */ | 281 | /* Register backlight device */ |
| 282 | snprintf(bl_name, sizeof(bl_name), "appledisplay%d", | 282 | snprintf(bl_name, sizeof(bl_name), "appledisplay%d", |
| 283 | atomic_inc_return(&count_displays) - 1); | 283 | atomic_inc_return(&count_displays) - 1); |
| 284 | pdata->bd = backlight_device_register(bl_name, pdata, | 284 | pdata->bd = backlight_device_register(bl_name, NULL, NULL, |
| 285 | &appledisplay_bl_data); | 285 | &appledisplay_bl_data); |
| 286 | if (IS_ERR(pdata->bd)) { | 286 | if (IS_ERR(pdata->bd)) { |
| 287 | err("appledisplay: Backlight registration failed"); | 287 | err("appledisplay: Backlight registration failed"); |
diff --git a/drivers/video/aty/aty128fb.c b/drivers/video/aty/aty128fb.c index 3feddf89d100..2e976ffcde0f 100644 --- a/drivers/video/aty/aty128fb.c +++ b/drivers/video/aty/aty128fb.c | |||
| @@ -1834,7 +1834,7 @@ static void aty128_bl_init(struct aty128fb_par *par) | |||
| 1834 | 1834 | ||
| 1835 | snprintf(name, sizeof(name), "aty128bl%d", info->node); | 1835 | snprintf(name, sizeof(name), "aty128bl%d", info->node); |
| 1836 | 1836 | ||
| 1837 | bd = backlight_device_register(name, par, &aty128_bl_data); | 1837 | bd = backlight_device_register(name, info->dev, par, &aty128_bl_data); |
| 1838 | if (IS_ERR(bd)) { | 1838 | if (IS_ERR(bd)) { |
| 1839 | info->bl_dev = NULL; | 1839 | info->bl_dev = NULL; |
| 1840 | printk(KERN_WARNING "aty128: Backlight registration failed\n"); | 1840 | printk(KERN_WARNING "aty128: Backlight registration failed\n"); |
diff --git a/drivers/video/aty/atyfb_base.c b/drivers/video/aty/atyfb_base.c index 09684d7a7ce9..f2ebdd880085 100644 --- a/drivers/video/aty/atyfb_base.c +++ b/drivers/video/aty/atyfb_base.c | |||
| @@ -2211,7 +2211,7 @@ static void aty_bl_init(struct atyfb_par *par) | |||
| 2211 | 2211 | ||
| 2212 | snprintf(name, sizeof(name), "atybl%d", info->node); | 2212 | snprintf(name, sizeof(name), "atybl%d", info->node); |
| 2213 | 2213 | ||
| 2214 | bd = backlight_device_register(name, par, &aty_bl_data); | 2214 | bd = backlight_device_register(name, info->dev, par, &aty_bl_data); |
| 2215 | if (IS_ERR(bd)) { | 2215 | if (IS_ERR(bd)) { |
| 2216 | info->bl_dev = NULL; | 2216 | info->bl_dev = NULL; |
| 2217 | printk(KERN_WARNING "aty: Backlight registration failed\n"); | 2217 | printk(KERN_WARNING "aty: Backlight registration failed\n"); |
diff --git a/drivers/video/aty/radeon_backlight.c b/drivers/video/aty/radeon_backlight.c index 585eb7b9e636..3abfd4a380cc 100644 --- a/drivers/video/aty/radeon_backlight.c +++ b/drivers/video/aty/radeon_backlight.c | |||
| @@ -163,7 +163,7 @@ void radeonfb_bl_init(struct radeonfb_info *rinfo) | |||
| 163 | 163 | ||
| 164 | snprintf(name, sizeof(name), "radeonbl%d", rinfo->info->node); | 164 | snprintf(name, sizeof(name), "radeonbl%d", rinfo->info->node); |
| 165 | 165 | ||
| 166 | bd = backlight_device_register(name, pdata, &radeon_bl_data); | 166 | bd = backlight_device_register(name, rinfo->info->dev, pdata, &radeon_bl_data); |
| 167 | if (IS_ERR(bd)) { | 167 | if (IS_ERR(bd)) { |
| 168 | rinfo->info->bl_dev = NULL; | 168 | rinfo->info->bl_dev = NULL; |
| 169 | printk("radeonfb: Backlight registration failed\n"); | 169 | printk("radeonfb: Backlight registration failed\n"); |
diff --git a/drivers/video/backlight/backlight.c b/drivers/video/backlight/backlight.c index db8c191b1201..9601bfe309ac 100644 --- a/drivers/video/backlight/backlight.c +++ b/drivers/video/backlight/backlight.c | |||
| @@ -216,8 +216,10 @@ static const struct class_device_attribute bl_class_device_attributes[] = { | |||
| 216 | * Creates and registers new backlight class_device. Returns either an | 216 | * Creates and registers new backlight class_device. Returns either an |
| 217 | * ERR_PTR() or a pointer to the newly allocated device. | 217 | * ERR_PTR() or a pointer to the newly allocated device. |
| 218 | */ | 218 | */ |
| 219 | struct backlight_device *backlight_device_register(const char *name, void *devdata, | 219 | struct backlight_device *backlight_device_register(const char *name, |
| 220 | struct backlight_properties *bp) | 220 | struct device *dev, |
| 221 | void *devdata, | ||
| 222 | struct backlight_properties *bp) | ||
| 221 | { | 223 | { |
| 222 | int i, rc; | 224 | int i, rc; |
| 223 | struct backlight_device *new_bd; | 225 | struct backlight_device *new_bd; |
| @@ -232,6 +234,7 @@ struct backlight_device *backlight_device_register(const char *name, void *devda | |||
| 232 | new_bd->props = bp; | 234 | new_bd->props = bp; |
| 233 | memset(&new_bd->class_dev, 0, sizeof(new_bd->class_dev)); | 235 | memset(&new_bd->class_dev, 0, sizeof(new_bd->class_dev)); |
| 234 | new_bd->class_dev.class = &backlight_class; | 236 | new_bd->class_dev.class = &backlight_class; |
| 237 | new_bd->class_dev.dev = dev; | ||
| 235 | strlcpy(new_bd->class_dev.class_id, name, KOBJ_NAME_LEN); | 238 | strlcpy(new_bd->class_dev.class_id, name, KOBJ_NAME_LEN); |
| 236 | class_set_devdata(&new_bd->class_dev, devdata); | 239 | class_set_devdata(&new_bd->class_dev, devdata); |
| 237 | 240 | ||
diff --git a/drivers/video/nvidia/nv_backlight.c b/drivers/video/nvidia/nv_backlight.c index 5b75ae4e9457..df934bd21899 100644 --- a/drivers/video/nvidia/nv_backlight.c +++ b/drivers/video/nvidia/nv_backlight.c | |||
| @@ -141,7 +141,7 @@ void nvidia_bl_init(struct nvidia_par *par) | |||
| 141 | 141 | ||
| 142 | snprintf(name, sizeof(name), "nvidiabl%d", info->node); | 142 | snprintf(name, sizeof(name), "nvidiabl%d", info->node); |
| 143 | 143 | ||
| 144 | bd = backlight_device_register(name, par, &nvidia_bl_data); | 144 | bd = backlight_device_register(name, info->dev, par, &nvidia_bl_data); |
| 145 | if (IS_ERR(bd)) { | 145 | if (IS_ERR(bd)) { |
| 146 | info->bl_dev = NULL; | 146 | info->bl_dev = NULL; |
| 147 | printk(KERN_WARNING "nvidia: Backlight registration failed\n"); | 147 | printk(KERN_WARNING "nvidia: Backlight registration failed\n"); |
diff --git a/drivers/video/riva/fbdev.c b/drivers/video/riva/fbdev.c index 345e8b1c1af8..1a13966b7d5b 100644 --- a/drivers/video/riva/fbdev.c +++ b/drivers/video/riva/fbdev.c | |||
| @@ -384,7 +384,7 @@ static void riva_bl_init(struct riva_par *par) | |||
| 384 | 384 | ||
| 385 | snprintf(name, sizeof(name), "rivabl%d", info->node); | 385 | snprintf(name, sizeof(name), "rivabl%d", info->node); |
| 386 | 386 | ||
| 387 | bd = backlight_device_register(name, par, &riva_bl_data); | 387 | bd = backlight_device_register(name, info->dev, par, &riva_bl_data); |
| 388 | if (IS_ERR(bd)) { | 388 | if (IS_ERR(bd)) { |
| 389 | info->bl_dev = NULL; | 389 | info->bl_dev = NULL; |
| 390 | printk(KERN_WARNING "riva: Backlight registration failed\n"); | 390 | printk(KERN_WARNING "riva: Backlight registration failed\n"); |
