aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/acpi/ac.c
diff options
context:
space:
mode:
authorIngo Molnar <mingo@elte.hu>2011-01-04 03:43:42 -0500
committerIngo Molnar <mingo@elte.hu>2011-01-04 03:43:42 -0500
commitbc030d6cb9532877c1c5a3f5e7123344fa24a285 (patch)
treed223d410b868b80d4c0deec192d354a5d06b201a /drivers/acpi/ac.c
parentd3bd058826aa8b79590cca6c8e6d1557bf576ada (diff)
parent387c31c7e5c9805b0aef8833d1731a5fe7bdea14 (diff)
Merge commit 'v2.6.37-rc8' into x86/apic
Conflicts: arch/x86/include/asm/io_apic.h Merge reason: move to a fresh -rc, resolve the conflict. Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'drivers/acpi/ac.c')
-rw-r--r--drivers/acpi/ac.c60
1 files changed, 29 insertions, 31 deletions
diff --git a/drivers/acpi/ac.c b/drivers/acpi/ac.c
index 56205a0b85df..25d3aaebc10d 100644
--- a/drivers/acpi/ac.c
+++ b/drivers/acpi/ac.c
@@ -32,9 +32,7 @@
32#include <linux/proc_fs.h> 32#include <linux/proc_fs.h>
33#include <linux/seq_file.h> 33#include <linux/seq_file.h>
34#endif 34#endif
35#ifdef CONFIG_ACPI_SYSFS_POWER
36#include <linux/power_supply.h> 35#include <linux/power_supply.h>
37#endif
38#include <acpi/acpi_bus.h> 36#include <acpi/acpi_bus.h>
39#include <acpi/acpi_drivers.h> 37#include <acpi/acpi_drivers.h>
40 38
@@ -86,9 +84,7 @@ static struct acpi_driver acpi_ac_driver = {
86}; 84};
87 85
88struct acpi_ac { 86struct acpi_ac {
89#ifdef CONFIG_ACPI_SYSFS_POWER
90 struct power_supply charger; 87 struct power_supply charger;
91#endif
92 struct acpi_device * device; 88 struct acpi_device * device;
93 unsigned long long state; 89 unsigned long long state;
94}; 90};
@@ -104,26 +100,7 @@ static const struct file_operations acpi_ac_fops = {
104 .release = single_release, 100 .release = single_release,
105}; 101};
106#endif 102#endif
107#ifdef CONFIG_ACPI_SYSFS_POWER
108static int get_ac_property(struct power_supply *psy,
109 enum power_supply_property psp,
110 union power_supply_propval *val)
111{
112 struct acpi_ac *ac = to_acpi_ac(psy);
113 switch (psp) {
114 case POWER_SUPPLY_PROP_ONLINE:
115 val->intval = ac->state;
116 break;
117 default:
118 return -EINVAL;
119 }
120 return 0;
121}
122 103
123static enum power_supply_property ac_props[] = {
124 POWER_SUPPLY_PROP_ONLINE,
125};
126#endif
127/* -------------------------------------------------------------------------- 104/* --------------------------------------------------------------------------
128 AC Adapter Management 105 AC Adapter Management
129 -------------------------------------------------------------------------- */ 106 -------------------------------------------------------------------------- */
@@ -146,6 +123,35 @@ static int acpi_ac_get_state(struct acpi_ac *ac)
146 return 0; 123 return 0;
147} 124}
148 125
126/* --------------------------------------------------------------------------
127 sysfs I/F
128 -------------------------------------------------------------------------- */
129static int get_ac_property(struct power_supply *psy,
130 enum power_supply_property psp,
131 union power_supply_propval *val)
132{
133 struct acpi_ac *ac = to_acpi_ac(psy);
134
135 if (!ac)
136 return -ENODEV;
137
138 if (acpi_ac_get_state(ac))
139 return -ENODEV;
140
141 switch (psp) {
142 case POWER_SUPPLY_PROP_ONLINE:
143 val->intval = ac->state;
144 break;
145 default:
146 return -EINVAL;
147 }
148 return 0;
149}
150
151static enum power_supply_property ac_props[] = {
152 POWER_SUPPLY_PROP_ONLINE,
153};
154
149#ifdef CONFIG_ACPI_PROCFS_POWER 155#ifdef CONFIG_ACPI_PROCFS_POWER
150/* -------------------------------------------------------------------------- 156/* --------------------------------------------------------------------------
151 FS Interface (/proc) 157 FS Interface (/proc)
@@ -247,9 +253,7 @@ static void acpi_ac_notify(struct acpi_device *device, u32 event)
247 dev_name(&device->dev), event, 253 dev_name(&device->dev), event,
248 (u32) ac->state); 254 (u32) ac->state);
249 acpi_notifier_call_chain(device, event, (u32) ac->state); 255 acpi_notifier_call_chain(device, event, (u32) ac->state);
250#ifdef CONFIG_ACPI_SYSFS_POWER
251 kobject_uevent(&ac->charger.dev->kobj, KOBJ_CHANGE); 256 kobject_uevent(&ac->charger.dev->kobj, KOBJ_CHANGE);
252#endif
253 } 257 }
254 258
255 return; 259 return;
@@ -282,14 +286,12 @@ static int acpi_ac_add(struct acpi_device *device)
282#endif 286#endif
283 if (result) 287 if (result)
284 goto end; 288 goto end;
285#ifdef CONFIG_ACPI_SYSFS_POWER
286 ac->charger.name = acpi_device_bid(device); 289 ac->charger.name = acpi_device_bid(device);
287 ac->charger.type = POWER_SUPPLY_TYPE_MAINS; 290 ac->charger.type = POWER_SUPPLY_TYPE_MAINS;
288 ac->charger.properties = ac_props; 291 ac->charger.properties = ac_props;
289 ac->charger.num_properties = ARRAY_SIZE(ac_props); 292 ac->charger.num_properties = ARRAY_SIZE(ac_props);
290 ac->charger.get_property = get_ac_property; 293 ac->charger.get_property = get_ac_property;
291 power_supply_register(&ac->device->dev, &ac->charger); 294 power_supply_register(&ac->device->dev, &ac->charger);
292#endif
293 295
294 printk(KERN_INFO PREFIX "%s [%s] (%s)\n", 296 printk(KERN_INFO PREFIX "%s [%s] (%s)\n",
295 acpi_device_name(device), acpi_device_bid(device), 297 acpi_device_name(device), acpi_device_bid(device),
@@ -316,10 +318,8 @@ static int acpi_ac_resume(struct acpi_device *device)
316 old_state = ac->state; 318 old_state = ac->state;
317 if (acpi_ac_get_state(ac)) 319 if (acpi_ac_get_state(ac))
318 return 0; 320 return 0;
319#ifdef CONFIG_ACPI_SYSFS_POWER
320 if (old_state != ac->state) 321 if (old_state != ac->state)
321 kobject_uevent(&ac->charger.dev->kobj, KOBJ_CHANGE); 322 kobject_uevent(&ac->charger.dev->kobj, KOBJ_CHANGE);
322#endif
323 return 0; 323 return 0;
324} 324}
325 325
@@ -333,10 +333,8 @@ static int acpi_ac_remove(struct acpi_device *device, int type)
333 333
334 ac = acpi_driver_data(device); 334 ac = acpi_driver_data(device);
335 335
336#ifdef CONFIG_ACPI_SYSFS_POWER
337 if (ac->charger.dev) 336 if (ac->charger.dev)
338 power_supply_unregister(&ac->charger); 337 power_supply_unregister(&ac->charger);
339#endif
340#ifdef CONFIG_ACPI_PROCFS_POWER 338#ifdef CONFIG_ACPI_PROCFS_POWER
341 acpi_ac_remove_fs(device); 339 acpi_ac_remove_fs(device);
342#endif 340#endif