diff options
-rw-r--r-- | drivers/acpi/ac.c | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/drivers/acpi/ac.c b/drivers/acpi/ac.c index e03de37a750d..1461dc9944a3 100644 --- a/drivers/acpi/ac.c +++ b/drivers/acpi/ac.c | |||
@@ -27,8 +27,10 @@ | |||
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 | #include <linux/proc_fs.h> | 31 | #include <linux/proc_fs.h> |
31 | #include <linux/seq_file.h> | 32 | #include <linux/seq_file.h> |
33 | #endif | ||
32 | #include <linux/power_supply.h> | 34 | #include <linux/power_supply.h> |
33 | #include <acpi/acpi_bus.h> | 35 | #include <acpi/acpi_bus.h> |
34 | #include <acpi/acpi_drivers.h> | 36 | #include <acpi/acpi_drivers.h> |
@@ -49,12 +51,14 @@ MODULE_AUTHOR("Paul Diefenbaugh"); | |||
49 | MODULE_DESCRIPTION("ACPI AC Adapter Driver"); | 51 | MODULE_DESCRIPTION("ACPI AC Adapter Driver"); |
50 | MODULE_LICENSE("GPL"); | 52 | MODULE_LICENSE("GPL"); |
51 | 53 | ||
54 | #ifdef CONFIG_ACPI_PROCFS | ||
52 | extern struct proc_dir_entry *acpi_lock_ac_dir(void); | 55 | extern struct proc_dir_entry *acpi_lock_ac_dir(void); |
53 | extern void *acpi_unlock_ac_dir(struct proc_dir_entry *acpi_ac_dir); | 56 | 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); | ||
58 | #endif | ||
54 | 59 | ||
55 | static int acpi_ac_add(struct acpi_device *device); | 60 | static int acpi_ac_add(struct acpi_device *device); |
56 | static int acpi_ac_remove(struct acpi_device *device, int type); | 61 | static int acpi_ac_remove(struct acpi_device *device, int type); |
57 | static int acpi_ac_open_fs(struct inode *inode, struct file *file); | ||
58 | 62 | ||
59 | const static struct acpi_device_id ac_device_ids[] = { | 63 | const static struct acpi_device_id ac_device_ids[] = { |
60 | {"ACPI0003", 0}, | 64 | {"ACPI0003", 0}, |
@@ -80,12 +84,15 @@ struct acpi_ac { | |||
80 | 84 | ||
81 | #define to_acpi_ac(x) container_of(x, struct acpi_ac, charger); | 85 | #define to_acpi_ac(x) container_of(x, struct acpi_ac, charger); |
82 | 86 | ||
87 | #ifdef CONFIG_ACPI_PROCFS | ||
83 | static const struct file_operations acpi_ac_fops = { | 88 | static const struct file_operations acpi_ac_fops = { |
84 | .open = acpi_ac_open_fs, | 89 | .open = acpi_ac_open_fs, |
85 | .read = seq_read, | 90 | .read = seq_read, |
86 | .llseek = seq_lseek, | 91 | .llseek = seq_lseek, |
87 | .release = single_release, | 92 | .release = single_release, |
88 | }; | 93 | }; |
94 | #endif | ||
95 | |||
89 | static int get_ac_property(struct power_supply *psy, | 96 | static int get_ac_property(struct power_supply *psy, |
90 | enum power_supply_property psp, | 97 | enum power_supply_property psp, |
91 | union power_supply_propval *val) | 98 | union power_supply_propval *val) |
@@ -127,6 +134,7 @@ static int acpi_ac_get_state(struct acpi_ac *ac) | |||
127 | return 0; | 134 | return 0; |
128 | } | 135 | } |
129 | 136 | ||
137 | #ifdef CONFIG_ACPI_PROCFS | ||
130 | /* -------------------------------------------------------------------------- | 138 | /* -------------------------------------------------------------------------- |
131 | FS Interface (/proc) | 139 | FS Interface (/proc) |
132 | -------------------------------------------------------------------------- */ | 140 | -------------------------------------------------------------------------- */ |
@@ -206,6 +214,7 @@ static int acpi_ac_remove_fs(struct acpi_device *device) | |||
206 | 214 | ||
207 | return 0; | 215 | return 0; |
208 | } | 216 | } |
217 | #endif | ||
209 | 218 | ||
210 | /* -------------------------------------------------------------------------- | 219 | /* -------------------------------------------------------------------------- |
211 | Driver Model | 220 | Driver Model |
@@ -264,7 +273,9 @@ static int acpi_ac_add(struct acpi_device *device) | |||
264 | if (result) | 273 | if (result) |
265 | goto end; | 274 | goto end; |
266 | 275 | ||
276 | #ifdef CONFIG_ACPI_PROCFS | ||
267 | result = acpi_ac_add_fs(device); | 277 | result = acpi_ac_add_fs(device); |
278 | #endif | ||
268 | if (result) | 279 | if (result) |
269 | goto end; | 280 | goto end; |
270 | ac->charger.name = acpi_device_bid(device); | 281 | ac->charger.name = acpi_device_bid(device); |
@@ -287,7 +298,9 @@ static int acpi_ac_add(struct acpi_device *device) | |||
287 | 298 | ||
288 | end: | 299 | end: |
289 | if (result) { | 300 | if (result) { |
301 | #ifdef CONFIG_ACPI_PROCFS | ||
290 | acpi_ac_remove_fs(device); | 302 | acpi_ac_remove_fs(device); |
303 | #endif | ||
291 | kfree(ac); | 304 | kfree(ac); |
292 | } | 305 | } |
293 | 306 | ||
@@ -309,7 +322,9 @@ static int acpi_ac_remove(struct acpi_device *device, int type) | |||
309 | ACPI_ALL_NOTIFY, acpi_ac_notify); | 322 | ACPI_ALL_NOTIFY, acpi_ac_notify); |
310 | if (ac->charger.dev) | 323 | if (ac->charger.dev) |
311 | power_supply_unregister(&ac->charger); | 324 | power_supply_unregister(&ac->charger); |
325 | #ifdef CONFIG_ACPI_PROCFS | ||
312 | acpi_ac_remove_fs(device); | 326 | acpi_ac_remove_fs(device); |
327 | #endif | ||
313 | 328 | ||
314 | kfree(ac); | 329 | kfree(ac); |
315 | 330 | ||
@@ -323,13 +338,17 @@ static int __init acpi_ac_init(void) | |||
323 | if (acpi_disabled) | 338 | if (acpi_disabled) |
324 | return -ENODEV; | 339 | return -ENODEV; |
325 | 340 | ||
341 | #ifdef CONFIG_ACPI_PROCFS | ||
326 | acpi_ac_dir = acpi_lock_ac_dir(); | 342 | acpi_ac_dir = acpi_lock_ac_dir(); |
327 | if (!acpi_ac_dir) | 343 | if (!acpi_ac_dir) |
328 | return -ENODEV; | 344 | return -ENODEV; |
345 | #endif | ||
329 | 346 | ||
330 | result = acpi_bus_register_driver(&acpi_ac_driver); | 347 | result = acpi_bus_register_driver(&acpi_ac_driver); |
331 | if (result < 0) { | 348 | if (result < 0) { |
349 | #ifdef CONFIG_ACPI_PROCFS | ||
332 | acpi_unlock_ac_dir(acpi_ac_dir); | 350 | acpi_unlock_ac_dir(acpi_ac_dir); |
351 | #endif | ||
333 | return -ENODEV; | 352 | return -ENODEV; |
334 | } | 353 | } |
335 | 354 | ||
@@ -341,7 +360,9 @@ static void __exit acpi_ac_exit(void) | |||
341 | 360 | ||
342 | acpi_bus_unregister_driver(&acpi_ac_driver); | 361 | acpi_bus_unregister_driver(&acpi_ac_driver); |
343 | 362 | ||
363 | #ifdef CONFIG_ACPI_PROCFS | ||
344 | acpi_unlock_ac_dir(acpi_ac_dir); | 364 | acpi_unlock_ac_dir(acpi_ac_dir); |
365 | #endif | ||
345 | 366 | ||
346 | return; | 367 | return; |
347 | } | 368 | } |