diff options
Diffstat (limited to 'drivers/acpi/ac.c')
-rw-r--r-- | drivers/acpi/ac.c | 36 |
1 files changed, 24 insertions, 12 deletions
diff --git a/drivers/acpi/ac.c b/drivers/acpi/ac.c index 30238f6ff232..76b9bea98b6d 100644 --- a/drivers/acpi/ac.c +++ b/drivers/acpi/ac.c | |||
@@ -27,11 +27,13 @@ | |||
27 | #include <linux/module.h> | 27 | #include <linux/module.h> |
28 | #include <linux/init.h> | 28 | #include <linux/init.h> |
29 | #include <linux/types.h> | 29 | #include <linux/types.h> |
30 | #ifdef CONFIG_ACPI_PROCFS | 30 | #ifdef CONFIG_ACPI_PROCFS_POWER |
31 | #include <linux/proc_fs.h> | 31 | #include <linux/proc_fs.h> |
32 | #include <linux/seq_file.h> | 32 | #include <linux/seq_file.h> |
33 | #endif | 33 | #endif |
34 | #ifdef CONFIG_ACPI_SYSFS_POWER | ||
34 | #include <linux/power_supply.h> | 35 | #include <linux/power_supply.h> |
36 | #endif | ||
35 | #include <acpi/acpi_bus.h> | 37 | #include <acpi/acpi_bus.h> |
36 | #include <acpi/acpi_drivers.h> | 38 | #include <acpi/acpi_drivers.h> |
37 | 39 | ||
@@ -51,7 +53,7 @@ MODULE_AUTHOR("Paul Diefenbaugh"); | |||
51 | MODULE_DESCRIPTION("ACPI AC Adapter Driver"); | 53 | MODULE_DESCRIPTION("ACPI AC Adapter Driver"); |
52 | MODULE_LICENSE("GPL"); | 54 | MODULE_LICENSE("GPL"); |
53 | 55 | ||
54 | #ifdef CONFIG_ACPI_PROCFS | 56 | #ifdef CONFIG_ACPI_PROCFS_POWER |
55 | extern struct proc_dir_entry *acpi_lock_ac_dir(void); | 57 | extern struct proc_dir_entry *acpi_lock_ac_dir(void); |
56 | extern void *acpi_unlock_ac_dir(struct proc_dir_entry *acpi_ac_dir); | 58 | extern void *acpi_unlock_ac_dir(struct proc_dir_entry *acpi_ac_dir); |
57 | static int acpi_ac_open_fs(struct inode *inode, struct file *file); | 59 | static int acpi_ac_open_fs(struct inode *inode, struct file *file); |
@@ -79,14 +81,16 @@ static struct acpi_driver acpi_ac_driver = { | |||
79 | }; | 81 | }; |
80 | 82 | ||
81 | struct acpi_ac { | 83 | struct acpi_ac { |
84 | #ifdef CONFIG_ACPI_SYSFS_POWER | ||
82 | struct power_supply charger; | 85 | struct power_supply charger; |
86 | #endif | ||
83 | struct acpi_device * device; | 87 | struct acpi_device * device; |
84 | unsigned long state; | 88 | unsigned long state; |
85 | }; | 89 | }; |
86 | 90 | ||
87 | #define to_acpi_ac(x) container_of(x, struct acpi_ac, charger); | 91 | #define to_acpi_ac(x) container_of(x, struct acpi_ac, charger); |
88 | 92 | ||
89 | #ifdef CONFIG_ACPI_PROCFS | 93 | #ifdef CONFIG_ACPI_PROCFS_POWER |
90 | static const struct file_operations acpi_ac_fops = { | 94 | static const struct file_operations acpi_ac_fops = { |
91 | .open = acpi_ac_open_fs, | 95 | .open = acpi_ac_open_fs, |
92 | .read = seq_read, | 96 | .read = seq_read, |
@@ -94,7 +98,7 @@ static const struct file_operations acpi_ac_fops = { | |||
94 | .release = single_release, | 98 | .release = single_release, |
95 | }; | 99 | }; |
96 | #endif | 100 | #endif |
97 | 101 | #ifdef CONFIG_ACPI_SYSFS_POWER | |
98 | static int get_ac_property(struct power_supply *psy, | 102 | static int get_ac_property(struct power_supply *psy, |
99 | enum power_supply_property psp, | 103 | enum power_supply_property psp, |
100 | union power_supply_propval *val) | 104 | union power_supply_propval *val) |
@@ -113,7 +117,7 @@ static int get_ac_property(struct power_supply *psy, | |||
113 | static enum power_supply_property ac_props[] = { | 117 | static enum power_supply_property ac_props[] = { |
114 | POWER_SUPPLY_PROP_ONLINE, | 118 | POWER_SUPPLY_PROP_ONLINE, |
115 | }; | 119 | }; |
116 | 120 | #endif | |
117 | /* -------------------------------------------------------------------------- | 121 | /* -------------------------------------------------------------------------- |
118 | AC Adapter Management | 122 | AC Adapter Management |
119 | -------------------------------------------------------------------------- */ | 123 | -------------------------------------------------------------------------- */ |
@@ -136,7 +140,7 @@ static int acpi_ac_get_state(struct acpi_ac *ac) | |||
136 | return 0; | 140 | return 0; |
137 | } | 141 | } |
138 | 142 | ||
139 | #ifdef CONFIG_ACPI_PROCFS | 143 | #ifdef CONFIG_ACPI_PROCFS_POWER |
140 | /* -------------------------------------------------------------------------- | 144 | /* -------------------------------------------------------------------------- |
141 | FS Interface (/proc) | 145 | FS Interface (/proc) |
142 | -------------------------------------------------------------------------- */ | 146 | -------------------------------------------------------------------------- */ |
@@ -241,7 +245,9 @@ static void acpi_ac_notify(acpi_handle handle, u32 event, void *data) | |||
241 | acpi_bus_generate_netlink_event(device->pnp.device_class, | 245 | acpi_bus_generate_netlink_event(device->pnp.device_class, |
242 | device->dev.bus_id, event, | 246 | device->dev.bus_id, event, |
243 | (u32) ac->state); | 247 | (u32) ac->state); |
248 | #ifdef CONFIG_ACPI_SYSFS_POWER | ||
244 | kobject_uevent(&ac->charger.dev->kobj, KOBJ_CHANGE); | 249 | kobject_uevent(&ac->charger.dev->kobj, KOBJ_CHANGE); |
250 | #endif | ||
245 | break; | 251 | break; |
246 | default: | 252 | default: |
247 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, | 253 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, |
@@ -275,17 +281,19 @@ static int acpi_ac_add(struct acpi_device *device) | |||
275 | if (result) | 281 | if (result) |
276 | goto end; | 282 | goto end; |
277 | 283 | ||
278 | #ifdef CONFIG_ACPI_PROCFS | 284 | #ifdef CONFIG_ACPI_PROCFS_POWER |
279 | result = acpi_ac_add_fs(device); | 285 | result = acpi_ac_add_fs(device); |
280 | #endif | 286 | #endif |
281 | if (result) | 287 | if (result) |
282 | goto end; | 288 | goto end; |
289 | #ifdef CONFIG_ACPI_SYSFS_POWER | ||
283 | ac->charger.name = acpi_device_bid(device); | 290 | ac->charger.name = acpi_device_bid(device); |
284 | ac->charger.type = POWER_SUPPLY_TYPE_MAINS; | 291 | ac->charger.type = POWER_SUPPLY_TYPE_MAINS; |
285 | ac->charger.properties = ac_props; | 292 | ac->charger.properties = ac_props; |
286 | ac->charger.num_properties = ARRAY_SIZE(ac_props); | 293 | ac->charger.num_properties = ARRAY_SIZE(ac_props); |
287 | ac->charger.get_property = get_ac_property; | 294 | ac->charger.get_property = get_ac_property; |
288 | power_supply_register(&ac->device->dev, &ac->charger); | 295 | power_supply_register(&ac->device->dev, &ac->charger); |
296 | #endif | ||
289 | status = acpi_install_notify_handler(device->handle, | 297 | status = acpi_install_notify_handler(device->handle, |
290 | ACPI_ALL_NOTIFY, acpi_ac_notify, | 298 | ACPI_ALL_NOTIFY, acpi_ac_notify, |
291 | ac); | 299 | ac); |
@@ -300,7 +308,7 @@ static int acpi_ac_add(struct acpi_device *device) | |||
300 | 308 | ||
301 | end: | 309 | end: |
302 | if (result) { | 310 | if (result) { |
303 | #ifdef CONFIG_ACPI_PROCFS | 311 | #ifdef CONFIG_ACPI_PROCFS_POWER |
304 | acpi_ac_remove_fs(device); | 312 | acpi_ac_remove_fs(device); |
305 | #endif | 313 | #endif |
306 | kfree(ac); | 314 | kfree(ac); |
@@ -319,8 +327,10 @@ static int acpi_ac_resume(struct acpi_device *device) | |||
319 | old_state = ac->state; | 327 | old_state = ac->state; |
320 | if (acpi_ac_get_state(ac)) | 328 | if (acpi_ac_get_state(ac)) |
321 | return 0; | 329 | return 0; |
330 | #ifdef CONFIG_ACPI_SYSFS_POWER | ||
322 | if (old_state != ac->state) | 331 | if (old_state != ac->state) |
323 | kobject_uevent(&ac->charger.dev->kobj, KOBJ_CHANGE); | 332 | kobject_uevent(&ac->charger.dev->kobj, KOBJ_CHANGE); |
333 | #endif | ||
324 | return 0; | 334 | return 0; |
325 | } | 335 | } |
326 | 336 | ||
@@ -337,9 +347,11 @@ static int acpi_ac_remove(struct acpi_device *device, int type) | |||
337 | 347 | ||
338 | status = acpi_remove_notify_handler(device->handle, | 348 | status = acpi_remove_notify_handler(device->handle, |
339 | ACPI_ALL_NOTIFY, acpi_ac_notify); | 349 | ACPI_ALL_NOTIFY, acpi_ac_notify); |
350 | #ifdef CONFIG_ACPI_SYSFS_POWER | ||
340 | if (ac->charger.dev) | 351 | if (ac->charger.dev) |
341 | power_supply_unregister(&ac->charger); | 352 | power_supply_unregister(&ac->charger); |
342 | #ifdef CONFIG_ACPI_PROCFS | 353 | #endif |
354 | #ifdef CONFIG_ACPI_PROCFS_POWER | ||
343 | acpi_ac_remove_fs(device); | 355 | acpi_ac_remove_fs(device); |
344 | #endif | 356 | #endif |
345 | 357 | ||
@@ -355,7 +367,7 @@ static int __init acpi_ac_init(void) | |||
355 | if (acpi_disabled) | 367 | if (acpi_disabled) |
356 | return -ENODEV; | 368 | return -ENODEV; |
357 | 369 | ||
358 | #ifdef CONFIG_ACPI_PROCFS | 370 | #ifdef CONFIG_ACPI_PROCFS_POWER |
359 | acpi_ac_dir = acpi_lock_ac_dir(); | 371 | acpi_ac_dir = acpi_lock_ac_dir(); |
360 | if (!acpi_ac_dir) | 372 | if (!acpi_ac_dir) |
361 | return -ENODEV; | 373 | return -ENODEV; |
@@ -363,7 +375,7 @@ static int __init acpi_ac_init(void) | |||
363 | 375 | ||
364 | result = acpi_bus_register_driver(&acpi_ac_driver); | 376 | result = acpi_bus_register_driver(&acpi_ac_driver); |
365 | if (result < 0) { | 377 | if (result < 0) { |
366 | #ifdef CONFIG_ACPI_PROCFS | 378 | #ifdef CONFIG_ACPI_PROCFS_POWER |
367 | acpi_unlock_ac_dir(acpi_ac_dir); | 379 | acpi_unlock_ac_dir(acpi_ac_dir); |
368 | #endif | 380 | #endif |
369 | return -ENODEV; | 381 | return -ENODEV; |
@@ -377,7 +389,7 @@ static void __exit acpi_ac_exit(void) | |||
377 | 389 | ||
378 | acpi_bus_unregister_driver(&acpi_ac_driver); | 390 | acpi_bus_unregister_driver(&acpi_ac_driver); |
379 | 391 | ||
380 | #ifdef CONFIG_ACPI_PROCFS | 392 | #ifdef CONFIG_ACPI_PROCFS_POWER |
381 | acpi_unlock_ac_dir(acpi_ac_dir); | 393 | acpi_unlock_ac_dir(acpi_ac_dir); |
382 | #endif | 394 | #endif |
383 | 395 | ||