aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/acpi/ac.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/acpi/ac.c')
-rw-r--r--drivers/acpi/ac.c40
1 files changed, 39 insertions, 1 deletions
diff --git a/drivers/acpi/ac.c b/drivers/acpi/ac.c
index e03de37a750d..30238f6ff232 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,15 @@ MODULE_AUTHOR("Paul Diefenbaugh");
49MODULE_DESCRIPTION("ACPI AC Adapter Driver"); 51MODULE_DESCRIPTION("ACPI AC Adapter Driver");
50MODULE_LICENSE("GPL"); 52MODULE_LICENSE("GPL");
51 53
54#ifdef CONFIG_ACPI_PROCFS
52extern struct proc_dir_entry *acpi_lock_ac_dir(void); 55extern struct proc_dir_entry *acpi_lock_ac_dir(void);
53extern void *acpi_unlock_ac_dir(struct proc_dir_entry *acpi_ac_dir); 56extern void *acpi_unlock_ac_dir(struct proc_dir_entry *acpi_ac_dir);
57static int acpi_ac_open_fs(struct inode *inode, struct file *file);
58#endif
54 59
55static int acpi_ac_add(struct acpi_device *device); 60static int acpi_ac_add(struct acpi_device *device);
56static int acpi_ac_remove(struct acpi_device *device, int type); 61static int acpi_ac_remove(struct acpi_device *device, int type);
57static int acpi_ac_open_fs(struct inode *inode, struct file *file); 62static int acpi_ac_resume(struct acpi_device *device);
58 63
59const static struct acpi_device_id ac_device_ids[] = { 64const static struct acpi_device_id ac_device_ids[] = {
60 {"ACPI0003", 0}, 65 {"ACPI0003", 0},
@@ -69,6 +74,7 @@ static struct acpi_driver acpi_ac_driver = {
69 .ops = { 74 .ops = {
70 .add = acpi_ac_add, 75 .add = acpi_ac_add,
71 .remove = acpi_ac_remove, 76 .remove = acpi_ac_remove,
77 .resume = acpi_ac_resume,
72 }, 78 },
73}; 79};
74 80
@@ -80,12 +86,15 @@ struct acpi_ac {
80 86
81#define to_acpi_ac(x) container_of(x, struct acpi_ac, charger); 87#define to_acpi_ac(x) container_of(x, struct acpi_ac, charger);
82 88
89#ifdef CONFIG_ACPI_PROCFS
83static const struct file_operations acpi_ac_fops = { 90static const struct file_operations acpi_ac_fops = {
84 .open = acpi_ac_open_fs, 91 .open = acpi_ac_open_fs,
85 .read = seq_read, 92 .read = seq_read,
86 .llseek = seq_lseek, 93 .llseek = seq_lseek,
87 .release = single_release, 94 .release = single_release,
88}; 95};
96#endif
97
89static int get_ac_property(struct power_supply *psy, 98static int get_ac_property(struct power_supply *psy,
90 enum power_supply_property psp, 99 enum power_supply_property psp,
91 union power_supply_propval *val) 100 union power_supply_propval *val)
@@ -127,6 +136,7 @@ static int acpi_ac_get_state(struct acpi_ac *ac)
127 return 0; 136 return 0;
128} 137}
129 138
139#ifdef CONFIG_ACPI_PROCFS
130/* -------------------------------------------------------------------------- 140/* --------------------------------------------------------------------------
131 FS Interface (/proc) 141 FS Interface (/proc)
132 -------------------------------------------------------------------------- */ 142 -------------------------------------------------------------------------- */
@@ -206,6 +216,7 @@ static int acpi_ac_remove_fs(struct acpi_device *device)
206 216
207 return 0; 217 return 0;
208} 218}
219#endif
209 220
210/* -------------------------------------------------------------------------- 221/* --------------------------------------------------------------------------
211 Driver Model 222 Driver Model
@@ -264,7 +275,9 @@ static int acpi_ac_add(struct acpi_device *device)
264 if (result) 275 if (result)
265 goto end; 276 goto end;
266 277
278#ifdef CONFIG_ACPI_PROCFS
267 result = acpi_ac_add_fs(device); 279 result = acpi_ac_add_fs(device);
280#endif
268 if (result) 281 if (result)
269 goto end; 282 goto end;
270 ac->charger.name = acpi_device_bid(device); 283 ac->charger.name = acpi_device_bid(device);
@@ -287,13 +300,30 @@ static int acpi_ac_add(struct acpi_device *device)
287 300
288 end: 301 end:
289 if (result) { 302 if (result) {
303#ifdef CONFIG_ACPI_PROCFS
290 acpi_ac_remove_fs(device); 304 acpi_ac_remove_fs(device);
305#endif
291 kfree(ac); 306 kfree(ac);
292 } 307 }
293 308
294 return result; 309 return result;
295} 310}
296 311
312static int acpi_ac_resume(struct acpi_device *device)
313{
314 struct acpi_ac *ac;
315 unsigned old_state;
316 if (!device || !acpi_driver_data(device))
317 return -EINVAL;
318 ac = acpi_driver_data(device);
319 old_state = ac->state;
320 if (acpi_ac_get_state(ac))
321 return 0;
322 if (old_state != ac->state)
323 kobject_uevent(&ac->charger.dev->kobj, KOBJ_CHANGE);
324 return 0;
325}
326
297static int acpi_ac_remove(struct acpi_device *device, int type) 327static int acpi_ac_remove(struct acpi_device *device, int type)
298{ 328{
299 acpi_status status = AE_OK; 329 acpi_status status = AE_OK;
@@ -309,7 +339,9 @@ static int acpi_ac_remove(struct acpi_device *device, int type)
309 ACPI_ALL_NOTIFY, acpi_ac_notify); 339 ACPI_ALL_NOTIFY, acpi_ac_notify);
310 if (ac->charger.dev) 340 if (ac->charger.dev)
311 power_supply_unregister(&ac->charger); 341 power_supply_unregister(&ac->charger);
342#ifdef CONFIG_ACPI_PROCFS
312 acpi_ac_remove_fs(device); 343 acpi_ac_remove_fs(device);
344#endif
313 345
314 kfree(ac); 346 kfree(ac);
315 347
@@ -323,13 +355,17 @@ static int __init acpi_ac_init(void)
323 if (acpi_disabled) 355 if (acpi_disabled)
324 return -ENODEV; 356 return -ENODEV;
325 357
358#ifdef CONFIG_ACPI_PROCFS
326 acpi_ac_dir = acpi_lock_ac_dir(); 359 acpi_ac_dir = acpi_lock_ac_dir();
327 if (!acpi_ac_dir) 360 if (!acpi_ac_dir)
328 return -ENODEV; 361 return -ENODEV;
362#endif
329 363
330 result = acpi_bus_register_driver(&acpi_ac_driver); 364 result = acpi_bus_register_driver(&acpi_ac_driver);
331 if (result < 0) { 365 if (result < 0) {
366#ifdef CONFIG_ACPI_PROCFS
332 acpi_unlock_ac_dir(acpi_ac_dir); 367 acpi_unlock_ac_dir(acpi_ac_dir);
368#endif
333 return -ENODEV; 369 return -ENODEV;
334 } 370 }
335 371
@@ -341,7 +377,9 @@ static void __exit acpi_ac_exit(void)
341 377
342 acpi_bus_unregister_driver(&acpi_ac_driver); 378 acpi_bus_unregister_driver(&acpi_ac_driver);
343 379
380#ifdef CONFIG_ACPI_PROCFS
344 acpi_unlock_ac_dir(acpi_ac_dir); 381 acpi_unlock_ac_dir(acpi_ac_dir);
382#endif
345 383
346 return; 384 return;
347} 385}