diff options
Diffstat (limited to 'drivers/acpi/ac.c')
-rw-r--r-- | drivers/acpi/ac.c | 22 |
1 files changed, 7 insertions, 15 deletions
diff --git a/drivers/acpi/ac.c b/drivers/acpi/ac.c index 88e42abf5d88..98b9690b0159 100644 --- a/drivers/acpi/ac.c +++ b/drivers/acpi/ac.c | |||
@@ -37,6 +37,8 @@ | |||
37 | #include <acpi/acpi_bus.h> | 37 | #include <acpi/acpi_bus.h> |
38 | #include <acpi/acpi_drivers.h> | 38 | #include <acpi/acpi_drivers.h> |
39 | 39 | ||
40 | #define PREFIX "ACPI: " | ||
41 | |||
40 | #define ACPI_AC_CLASS "ac_adapter" | 42 | #define ACPI_AC_CLASS "ac_adapter" |
41 | #define ACPI_AC_DEVICE_NAME "AC Adapter" | 43 | #define ACPI_AC_DEVICE_NAME "AC Adapter" |
42 | #define ACPI_AC_FILE_STATE "state" | 44 | #define ACPI_AC_FILE_STATE "state" |
@@ -61,6 +63,7 @@ static int acpi_ac_open_fs(struct inode *inode, struct file *file); | |||
61 | static int acpi_ac_add(struct acpi_device *device); | 63 | static int acpi_ac_add(struct acpi_device *device); |
62 | static int acpi_ac_remove(struct acpi_device *device, int type); | 64 | static int acpi_ac_remove(struct acpi_device *device, int type); |
63 | static int acpi_ac_resume(struct acpi_device *device); | 65 | static int acpi_ac_resume(struct acpi_device *device); |
66 | static void acpi_ac_notify(struct acpi_device *device, u32 event); | ||
64 | 67 | ||
65 | static const struct acpi_device_id ac_device_ids[] = { | 68 | static const struct acpi_device_id ac_device_ids[] = { |
66 | {"ACPI0003", 0}, | 69 | {"ACPI0003", 0}, |
@@ -72,10 +75,12 @@ static struct acpi_driver acpi_ac_driver = { | |||
72 | .name = "ac", | 75 | .name = "ac", |
73 | .class = ACPI_AC_CLASS, | 76 | .class = ACPI_AC_CLASS, |
74 | .ids = ac_device_ids, | 77 | .ids = ac_device_ids, |
78 | .flags = ACPI_DRIVER_ALL_NOTIFY_EVENTS, | ||
75 | .ops = { | 79 | .ops = { |
76 | .add = acpi_ac_add, | 80 | .add = acpi_ac_add, |
77 | .remove = acpi_ac_remove, | 81 | .remove = acpi_ac_remove, |
78 | .resume = acpi_ac_resume, | 82 | .resume = acpi_ac_resume, |
83 | .notify = acpi_ac_notify, | ||
79 | }, | 84 | }, |
80 | }; | 85 | }; |
81 | 86 | ||
@@ -220,16 +225,14 @@ static int acpi_ac_remove_fs(struct acpi_device *device) | |||
220 | Driver Model | 225 | Driver Model |
221 | -------------------------------------------------------------------------- */ | 226 | -------------------------------------------------------------------------- */ |
222 | 227 | ||
223 | static void acpi_ac_notify(acpi_handle handle, u32 event, void *data) | 228 | static void acpi_ac_notify(struct acpi_device *device, u32 event) |
224 | { | 229 | { |
225 | struct acpi_ac *ac = data; | 230 | struct acpi_ac *ac = acpi_driver_data(device); |
226 | struct acpi_device *device = NULL; | ||
227 | 231 | ||
228 | 232 | ||
229 | if (!ac) | 233 | if (!ac) |
230 | return; | 234 | return; |
231 | 235 | ||
232 | device = ac->device; | ||
233 | switch (event) { | 236 | switch (event) { |
234 | default: | 237 | default: |
235 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, | 238 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, |
@@ -253,7 +256,6 @@ static void acpi_ac_notify(acpi_handle handle, u32 event, void *data) | |||
253 | static int acpi_ac_add(struct acpi_device *device) | 256 | static int acpi_ac_add(struct acpi_device *device) |
254 | { | 257 | { |
255 | int result = 0; | 258 | int result = 0; |
256 | acpi_status status = AE_OK; | ||
257 | struct acpi_ac *ac = NULL; | 259 | struct acpi_ac *ac = NULL; |
258 | 260 | ||
259 | 261 | ||
@@ -286,13 +288,6 @@ static int acpi_ac_add(struct acpi_device *device) | |||
286 | ac->charger.get_property = get_ac_property; | 288 | ac->charger.get_property = get_ac_property; |
287 | power_supply_register(&ac->device->dev, &ac->charger); | 289 | power_supply_register(&ac->device->dev, &ac->charger); |
288 | #endif | 290 | #endif |
289 | status = acpi_install_notify_handler(device->handle, | ||
290 | ACPI_ALL_NOTIFY, acpi_ac_notify, | ||
291 | ac); | ||
292 | if (ACPI_FAILURE(status)) { | ||
293 | result = -ENODEV; | ||
294 | goto end; | ||
295 | } | ||
296 | 291 | ||
297 | printk(KERN_INFO PREFIX "%s [%s] (%s)\n", | 292 | printk(KERN_INFO PREFIX "%s [%s] (%s)\n", |
298 | acpi_device_name(device), acpi_device_bid(device), | 293 | acpi_device_name(device), acpi_device_bid(device), |
@@ -328,7 +323,6 @@ static int acpi_ac_resume(struct acpi_device *device) | |||
328 | 323 | ||
329 | static int acpi_ac_remove(struct acpi_device *device, int type) | 324 | static int acpi_ac_remove(struct acpi_device *device, int type) |
330 | { | 325 | { |
331 | acpi_status status = AE_OK; | ||
332 | struct acpi_ac *ac = NULL; | 326 | struct acpi_ac *ac = NULL; |
333 | 327 | ||
334 | 328 | ||
@@ -337,8 +331,6 @@ static int acpi_ac_remove(struct acpi_device *device, int type) | |||
337 | 331 | ||
338 | ac = acpi_driver_data(device); | 332 | ac = acpi_driver_data(device); |
339 | 333 | ||
340 | status = acpi_remove_notify_handler(device->handle, | ||
341 | ACPI_ALL_NOTIFY, acpi_ac_notify); | ||
342 | #ifdef CONFIG_ACPI_SYSFS_POWER | 334 | #ifdef CONFIG_ACPI_SYSFS_POWER |
343 | if (ac->charger.dev) | 335 | if (ac->charger.dev) |
344 | power_supply_unregister(&ac->charger); | 336 | power_supply_unregister(&ac->charger); |