diff options
Diffstat (limited to 'drivers/acpi/ac.c')
| -rw-r--r-- | drivers/acpi/ac.c | 32 |
1 files changed, 17 insertions, 15 deletions
diff --git a/drivers/acpi/ac.c b/drivers/acpi/ac.c index 36ca365bcead..24ccf81d135f 100644 --- a/drivers/acpi/ac.c +++ b/drivers/acpi/ac.c | |||
| @@ -50,6 +50,9 @@ ACPI_MODULE_NAME("acpi_ac") | |||
| 50 | MODULE_DESCRIPTION(ACPI_AC_DRIVER_NAME); | 50 | MODULE_DESCRIPTION(ACPI_AC_DRIVER_NAME); |
| 51 | MODULE_LICENSE("GPL"); | 51 | MODULE_LICENSE("GPL"); |
| 52 | 52 | ||
| 53 | extern struct proc_dir_entry *acpi_lock_ac_dir(void); | ||
| 54 | extern void *acpi_unlock_ac_dir(struct proc_dir_entry *acpi_ac_dir); | ||
| 55 | |||
| 53 | static int acpi_ac_add(struct acpi_device *device); | 56 | static int acpi_ac_add(struct acpi_device *device); |
| 54 | static int acpi_ac_remove(struct acpi_device *device, int type); | 57 | static int acpi_ac_remove(struct acpi_device *device, int type); |
| 55 | static int acpi_ac_open_fs(struct inode *inode, struct file *file); | 58 | static int acpi_ac_open_fs(struct inode *inode, struct file *file); |
| @@ -65,7 +68,7 @@ static struct acpi_driver acpi_ac_driver = { | |||
| 65 | }; | 68 | }; |
| 66 | 69 | ||
| 67 | struct acpi_ac { | 70 | struct acpi_ac { |
| 68 | acpi_handle handle; | 71 | struct acpi_device * device; |
| 69 | unsigned long state; | 72 | unsigned long state; |
| 70 | }; | 73 | }; |
| 71 | 74 | ||
| @@ -88,7 +91,7 @@ static int acpi_ac_get_state(struct acpi_ac *ac) | |||
| 88 | if (!ac) | 91 | if (!ac) |
| 89 | return -EINVAL; | 92 | return -EINVAL; |
| 90 | 93 | ||
| 91 | status = acpi_evaluate_integer(ac->handle, "_PSR", NULL, &ac->state); | 94 | status = acpi_evaluate_integer(ac->device->handle, "_PSR", NULL, &ac->state); |
| 92 | if (ACPI_FAILURE(status)) { | 95 | if (ACPI_FAILURE(status)) { |
| 93 | ACPI_EXCEPTION((AE_INFO, status, "Error reading AC Adapter state")); | 96 | ACPI_EXCEPTION((AE_INFO, status, "Error reading AC Adapter state")); |
| 94 | ac->state = ACPI_AC_STATUS_UNKNOWN; | 97 | ac->state = ACPI_AC_STATUS_UNKNOWN; |
| @@ -191,11 +194,11 @@ static void acpi_ac_notify(acpi_handle handle, u32 event, void *data) | |||
| 191 | if (!ac) | 194 | if (!ac) |
| 192 | return; | 195 | return; |
| 193 | 196 | ||
| 194 | if (acpi_bus_get_device(ac->handle, &device)) | 197 | device = ac->device; |
| 195 | return; | ||
| 196 | |||
| 197 | switch (event) { | 198 | switch (event) { |
| 198 | case ACPI_AC_NOTIFY_STATUS: | 199 | case ACPI_AC_NOTIFY_STATUS: |
| 200 | case ACPI_NOTIFY_BUS_CHECK: | ||
| 201 | case ACPI_NOTIFY_DEVICE_CHECK: | ||
| 199 | acpi_ac_get_state(ac); | 202 | acpi_ac_get_state(ac); |
| 200 | acpi_bus_generate_event(device, event, (u32) ac->state); | 203 | acpi_bus_generate_event(device, event, (u32) ac->state); |
| 201 | break; | 204 | break; |
| @@ -223,7 +226,7 @@ static int acpi_ac_add(struct acpi_device *device) | |||
| 223 | return -ENOMEM; | 226 | return -ENOMEM; |
| 224 | memset(ac, 0, sizeof(struct acpi_ac)); | 227 | memset(ac, 0, sizeof(struct acpi_ac)); |
| 225 | 228 | ||
| 226 | ac->handle = device->handle; | 229 | ac->device = device; |
| 227 | strcpy(acpi_device_name(device), ACPI_AC_DEVICE_NAME); | 230 | strcpy(acpi_device_name(device), ACPI_AC_DEVICE_NAME); |
| 228 | strcpy(acpi_device_class(device), ACPI_AC_CLASS); | 231 | strcpy(acpi_device_class(device), ACPI_AC_CLASS); |
| 229 | acpi_driver_data(device) = ac; | 232 | acpi_driver_data(device) = ac; |
| @@ -236,8 +239,8 @@ static int acpi_ac_add(struct acpi_device *device) | |||
| 236 | if (result) | 239 | if (result) |
| 237 | goto end; | 240 | goto end; |
| 238 | 241 | ||
| 239 | status = acpi_install_notify_handler(ac->handle, | 242 | status = acpi_install_notify_handler(device->handle, |
| 240 | ACPI_DEVICE_NOTIFY, acpi_ac_notify, | 243 | ACPI_ALL_NOTIFY, acpi_ac_notify, |
| 241 | ac); | 244 | ac); |
| 242 | if (ACPI_FAILURE(status)) { | 245 | if (ACPI_FAILURE(status)) { |
| 243 | result = -ENODEV; | 246 | result = -ENODEV; |
| @@ -268,8 +271,8 @@ static int acpi_ac_remove(struct acpi_device *device, int type) | |||
| 268 | 271 | ||
| 269 | ac = (struct acpi_ac *)acpi_driver_data(device); | 272 | ac = (struct acpi_ac *)acpi_driver_data(device); |
| 270 | 273 | ||
| 271 | status = acpi_remove_notify_handler(ac->handle, | 274 | status = acpi_remove_notify_handler(device->handle, |
| 272 | ACPI_DEVICE_NOTIFY, acpi_ac_notify); | 275 | ACPI_ALL_NOTIFY, acpi_ac_notify); |
| 273 | 276 | ||
| 274 | acpi_ac_remove_fs(device); | 277 | acpi_ac_remove_fs(device); |
| 275 | 278 | ||
| @@ -280,17 +283,16 @@ static int acpi_ac_remove(struct acpi_device *device, int type) | |||
| 280 | 283 | ||
| 281 | static int __init acpi_ac_init(void) | 284 | static int __init acpi_ac_init(void) |
| 282 | { | 285 | { |
| 283 | int result = 0; | 286 | int result; |
| 284 | 287 | ||
| 285 | 288 | ||
| 286 | acpi_ac_dir = proc_mkdir(ACPI_AC_CLASS, acpi_root_dir); | 289 | acpi_ac_dir = acpi_lock_ac_dir(); |
| 287 | if (!acpi_ac_dir) | 290 | if (!acpi_ac_dir) |
| 288 | return -ENODEV; | 291 | return -ENODEV; |
| 289 | acpi_ac_dir->owner = THIS_MODULE; | ||
| 290 | 292 | ||
| 291 | result = acpi_bus_register_driver(&acpi_ac_driver); | 293 | result = acpi_bus_register_driver(&acpi_ac_driver); |
| 292 | if (result < 0) { | 294 | if (result < 0) { |
| 293 | remove_proc_entry(ACPI_AC_CLASS, acpi_root_dir); | 295 | acpi_unlock_ac_dir(acpi_ac_dir); |
| 294 | return -ENODEV; | 296 | return -ENODEV; |
| 295 | } | 297 | } |
| 296 | 298 | ||
| @@ -302,7 +304,7 @@ static void __exit acpi_ac_exit(void) | |||
| 302 | 304 | ||
| 303 | acpi_bus_unregister_driver(&acpi_ac_driver); | 305 | acpi_bus_unregister_driver(&acpi_ac_driver); |
| 304 | 306 | ||
| 305 | remove_proc_entry(ACPI_AC_CLASS, acpi_root_dir); | 307 | acpi_unlock_ac_dir(acpi_ac_dir); |
| 306 | 308 | ||
| 307 | return; | 309 | return; |
| 308 | } | 310 | } |
