diff options
-rw-r--r-- | drivers/acpi/Kconfig | 9 | ||||
-rw-r--r-- | drivers/acpi/ac.c | 16 | ||||
-rw-r--r-- | drivers/acpi/battery.c | 31 | ||||
-rw-r--r-- | drivers/acpi/sbs.c | 23 |
4 files changed, 67 insertions, 12 deletions
diff --git a/drivers/acpi/Kconfig b/drivers/acpi/Kconfig index b9f923ef173d..ccf6ea95f68c 100644 --- a/drivers/acpi/Kconfig +++ b/drivers/acpi/Kconfig | |||
@@ -82,6 +82,12 @@ config ACPI_PROCFS_POWER | |||
82 | and functions, which do not yet exist in /sys | 82 | and functions, which do not yet exist in /sys |
83 | 83 | ||
84 | Say N to delete power /proc/acpi/ folders that have moved to /sys/ | 84 | Say N to delete power /proc/acpi/ folders that have moved to /sys/ |
85 | config ACPI_SYSFS_POWER | ||
86 | bool "Future power /sys interface" | ||
87 | select POWER_SUPPLY | ||
88 | default y | ||
89 | ---help--- | ||
90 | Say N to disable power /sys interface | ||
85 | config ACPI_PROC_EVENT | 91 | config ACPI_PROC_EVENT |
86 | bool "Deprecated /proc/acpi/event support" | 92 | bool "Deprecated /proc/acpi/event support" |
87 | depends on PROC_FS | 93 | depends on PROC_FS |
@@ -103,7 +109,6 @@ config ACPI_PROC_EVENT | |||
103 | config ACPI_AC | 109 | config ACPI_AC |
104 | tristate "AC Adapter" | 110 | tristate "AC Adapter" |
105 | depends on X86 | 111 | depends on X86 |
106 | select POWER_SUPPLY | ||
107 | default y | 112 | default y |
108 | help | 113 | help |
109 | This driver adds support for the AC Adapter object, which indicates | 114 | This driver adds support for the AC Adapter object, which indicates |
@@ -113,7 +118,6 @@ config ACPI_AC | |||
113 | config ACPI_BATTERY | 118 | config ACPI_BATTERY |
114 | tristate "Battery" | 119 | tristate "Battery" |
115 | depends on X86 | 120 | depends on X86 |
116 | select POWER_SUPPLY | ||
117 | default y | 121 | default y |
118 | help | 122 | help |
119 | This driver adds support for battery information through | 123 | This driver adds support for battery information through |
@@ -368,7 +372,6 @@ config ACPI_HOTPLUG_MEMORY | |||
368 | config ACPI_SBS | 372 | config ACPI_SBS |
369 | tristate "Smart Battery System" | 373 | tristate "Smart Battery System" |
370 | depends on X86 | 374 | depends on X86 |
371 | select POWER_SUPPLY | ||
372 | help | 375 | help |
373 | This driver adds support for the Smart Battery System, another | 376 | This driver adds support for the Smart Battery System, another |
374 | type of access to battery information, found on some laptops. | 377 | type of access to battery information, found on some laptops. |
diff --git a/drivers/acpi/ac.c b/drivers/acpi/ac.c index 76ed4f52bebd..76b9bea98b6d 100644 --- a/drivers/acpi/ac.c +++ b/drivers/acpi/ac.c | |||
@@ -31,7 +31,9 @@ | |||
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 | ||
@@ -79,7 +81,9 @@ 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 | }; |
@@ -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 | -------------------------------------------------------------------------- */ |
@@ -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, |
@@ -280,12 +286,14 @@ static int acpi_ac_add(struct acpi_device *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); |
@@ -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,8 +347,10 @@ 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); |
353 | #endif | ||
342 | #ifdef CONFIG_ACPI_PROCFS_POWER | 354 | #ifdef CONFIG_ACPI_PROCFS_POWER |
343 | acpi_ac_remove_fs(device); | 355 | acpi_ac_remove_fs(device); |
344 | #endif | 356 | #endif |
diff --git a/drivers/acpi/battery.c b/drivers/acpi/battery.c index 8f7505d304b5..c4a769d1ba85 100644 --- a/drivers/acpi/battery.c +++ b/drivers/acpi/battery.c | |||
@@ -40,7 +40,9 @@ | |||
40 | #include <acpi/acpi_bus.h> | 40 | #include <acpi/acpi_bus.h> |
41 | #include <acpi/acpi_drivers.h> | 41 | #include <acpi/acpi_drivers.h> |
42 | 42 | ||
43 | #ifdef CONFIG_ACPI_SYSFS_POWER | ||
43 | #include <linux/power_supply.h> | 44 | #include <linux/power_supply.h> |
45 | #endif | ||
44 | 46 | ||
45 | #define ACPI_BATTERY_VALUE_UNKNOWN 0xFFFFFFFF | 47 | #define ACPI_BATTERY_VALUE_UNKNOWN 0xFFFFFFFF |
46 | 48 | ||
@@ -86,7 +88,9 @@ MODULE_DEVICE_TABLE(acpi, battery_device_ids); | |||
86 | 88 | ||
87 | struct acpi_battery { | 89 | struct acpi_battery { |
88 | struct mutex lock; | 90 | struct mutex lock; |
91 | #ifdef CONFIG_ACPI_SYSFS_POWER | ||
89 | struct power_supply bat; | 92 | struct power_supply bat; |
93 | #endif | ||
90 | struct acpi_device *device; | 94 | struct acpi_device *device; |
91 | unsigned long update_time; | 95 | unsigned long update_time; |
92 | int current_now; | 96 | int current_now; |
@@ -117,6 +121,7 @@ inline int acpi_battery_present(struct acpi_battery *battery) | |||
117 | return battery->device->status.battery_present; | 121 | return battery->device->status.battery_present; |
118 | } | 122 | } |
119 | 123 | ||
124 | #ifdef CONFIG_ACPI_SYSFS_POWER | ||
120 | static int acpi_battery_technology(struct acpi_battery *battery) | 125 | static int acpi_battery_technology(struct acpi_battery *battery) |
121 | { | 126 | { |
122 | if (!strcasecmp("NiCd", battery->type)) | 127 | if (!strcasecmp("NiCd", battery->type)) |
@@ -222,6 +227,7 @@ static enum power_supply_property energy_battery_props[] = { | |||
222 | POWER_SUPPLY_PROP_MODEL_NAME, | 227 | POWER_SUPPLY_PROP_MODEL_NAME, |
223 | POWER_SUPPLY_PROP_MANUFACTURER, | 228 | POWER_SUPPLY_PROP_MANUFACTURER, |
224 | }; | 229 | }; |
230 | #endif | ||
225 | 231 | ||
226 | #ifdef CONFIG_ACPI_PROCFS_POWER | 232 | #ifdef CONFIG_ACPI_PROCFS_POWER |
227 | inline char *acpi_battery_units(struct acpi_battery *battery) | 233 | inline char *acpi_battery_units(struct acpi_battery *battery) |
@@ -398,6 +404,7 @@ static int acpi_battery_init_alarm(struct acpi_battery *battery) | |||
398 | return acpi_battery_set_alarm(battery); | 404 | return acpi_battery_set_alarm(battery); |
399 | } | 405 | } |
400 | 406 | ||
407 | #ifdef CONFIG_ACPI_SYSFS_POWER | ||
401 | static ssize_t acpi_battery_alarm_show(struct device *dev, | 408 | static ssize_t acpi_battery_alarm_show(struct device *dev, |
402 | struct device_attribute *attr, | 409 | struct device_attribute *attr, |
403 | char *buf) | 410 | char *buf) |
@@ -429,11 +436,6 @@ static int sysfs_add_battery(struct acpi_battery *battery) | |||
429 | { | 436 | { |
430 | int result; | 437 | int result; |
431 | 438 | ||
432 | battery->update_time = 0; | ||
433 | result = acpi_battery_get_info(battery); | ||
434 | acpi_battery_init_alarm(battery); | ||
435 | if (result) | ||
436 | return result; | ||
437 | if (battery->power_unit) { | 439 | if (battery->power_unit) { |
438 | battery->bat.properties = charge_battery_props; | 440 | battery->bat.properties = charge_battery_props; |
439 | battery->bat.num_properties = | 441 | battery->bat.num_properties = |
@@ -462,18 +464,31 @@ static void sysfs_remove_battery(struct acpi_battery *battery) | |||
462 | power_supply_unregister(&battery->bat); | 464 | power_supply_unregister(&battery->bat); |
463 | battery->bat.dev = NULL; | 465 | battery->bat.dev = NULL; |
464 | } | 466 | } |
467 | #endif | ||
465 | 468 | ||
466 | static int acpi_battery_update(struct acpi_battery *battery) | 469 | static int acpi_battery_update(struct acpi_battery *battery) |
467 | { | 470 | { |
468 | int result = acpi_battery_get_status(battery); | 471 | int result; |
472 | result = acpi_battery_get_status(battery); | ||
469 | if (result) | 473 | if (result) |
470 | return result; | 474 | return result; |
475 | #ifdef CONFIG_ACPI_SYSFS_POWER | ||
471 | if (!acpi_battery_present(battery)) { | 476 | if (!acpi_battery_present(battery)) { |
472 | sysfs_remove_battery(battery); | 477 | sysfs_remove_battery(battery); |
478 | battery->update_time = 0; | ||
473 | return 0; | 479 | return 0; |
474 | } | 480 | } |
481 | #endif | ||
482 | if (!battery->update_time) { | ||
483 | result = acpi_battery_get_info(battery); | ||
484 | if (result) | ||
485 | return result; | ||
486 | acpi_battery_init_alarm(battery); | ||
487 | } | ||
488 | #ifdef CONFIG_ACPI_SYSFS_POWER | ||
475 | if (!battery->bat.dev) | 489 | if (!battery->bat.dev) |
476 | sysfs_add_battery(battery); | 490 | sysfs_add_battery(battery); |
491 | #endif | ||
477 | return acpi_battery_get_state(battery); | 492 | return acpi_battery_get_state(battery); |
478 | } | 493 | } |
479 | 494 | ||
@@ -767,9 +782,11 @@ static void acpi_battery_notify(acpi_handle handle, u32 event, void *data) | |||
767 | acpi_bus_generate_netlink_event(device->pnp.device_class, | 782 | acpi_bus_generate_netlink_event(device->pnp.device_class, |
768 | device->dev.bus_id, event, | 783 | device->dev.bus_id, event, |
769 | acpi_battery_present(battery)); | 784 | acpi_battery_present(battery)); |
785 | #ifdef CONFIG_ACPI_SYSFS_POWER | ||
770 | /* acpi_batter_update could remove power_supply object */ | 786 | /* acpi_batter_update could remove power_supply object */ |
771 | if (battery->bat.dev) | 787 | if (battery->bat.dev) |
772 | kobject_uevent(&battery->bat.dev->kobj, KOBJ_CHANGE); | 788 | kobject_uevent(&battery->bat.dev->kobj, KOBJ_CHANGE); |
789 | #endif | ||
773 | } | 790 | } |
774 | 791 | ||
775 | static int acpi_battery_add(struct acpi_device *device) | 792 | static int acpi_battery_add(struct acpi_device *device) |
@@ -828,7 +845,9 @@ static int acpi_battery_remove(struct acpi_device *device, int type) | |||
828 | #ifdef CONFIG_ACPI_PROCFS_POWER | 845 | #ifdef CONFIG_ACPI_PROCFS_POWER |
829 | acpi_battery_remove_fs(device); | 846 | acpi_battery_remove_fs(device); |
830 | #endif | 847 | #endif |
848 | #ifdef CONFIG_ACPI_SYSFS_POWER | ||
831 | sysfs_remove_battery(battery); | 849 | sysfs_remove_battery(battery); |
850 | #endif | ||
832 | mutex_destroy(&battery->lock); | 851 | mutex_destroy(&battery->lock); |
833 | kfree(battery); | 852 | kfree(battery); |
834 | return 0; | 853 | return 0; |
diff --git a/drivers/acpi/sbs.c b/drivers/acpi/sbs.c index 22cb95b349e4..f136c7d3b3c2 100644 --- a/drivers/acpi/sbs.c +++ b/drivers/acpi/sbs.c | |||
@@ -40,7 +40,9 @@ | |||
40 | #include <linux/jiffies.h> | 40 | #include <linux/jiffies.h> |
41 | #include <linux/delay.h> | 41 | #include <linux/delay.h> |
42 | 42 | ||
43 | #ifdef CONFIG_ACPI_SYSFS_POWER | ||
43 | #include <linux/power_supply.h> | 44 | #include <linux/power_supply.h> |
45 | #endif | ||
44 | 46 | ||
45 | #include "sbshc.h" | 47 | #include "sbshc.h" |
46 | 48 | ||
@@ -80,7 +82,9 @@ static const struct acpi_device_id sbs_device_ids[] = { | |||
80 | MODULE_DEVICE_TABLE(acpi, sbs_device_ids); | 82 | MODULE_DEVICE_TABLE(acpi, sbs_device_ids); |
81 | 83 | ||
82 | struct acpi_battery { | 84 | struct acpi_battery { |
85 | #ifdef CONFIG_ACPI_SYSFS_POWER | ||
83 | struct power_supply bat; | 86 | struct power_supply bat; |
87 | #endif | ||
84 | struct acpi_sbs *sbs; | 88 | struct acpi_sbs *sbs; |
85 | #ifdef CONFIG_ACPI_PROCFS_POWER | 89 | #ifdef CONFIG_ACPI_PROCFS_POWER |
86 | struct proc_dir_entry *proc_entry; | 90 | struct proc_dir_entry *proc_entry; |
@@ -113,7 +117,9 @@ struct acpi_battery { | |||
113 | #define to_acpi_battery(x) container_of(x, struct acpi_battery, bat); | 117 | #define to_acpi_battery(x) container_of(x, struct acpi_battery, bat); |
114 | 118 | ||
115 | struct acpi_sbs { | 119 | struct acpi_sbs { |
120 | #ifdef CONFIG_ACPI_SYSFS_POWER | ||
116 | struct power_supply charger; | 121 | struct power_supply charger; |
122 | #endif | ||
117 | struct acpi_device *device; | 123 | struct acpi_device *device; |
118 | struct acpi_smb_hc *hc; | 124 | struct acpi_smb_hc *hc; |
119 | struct mutex lock; | 125 | struct mutex lock; |
@@ -157,6 +163,7 @@ static inline int acpi_battery_scale(struct acpi_battery *battery) | |||
157 | acpi_battery_ipscale(battery); | 163 | acpi_battery_ipscale(battery); |
158 | } | 164 | } |
159 | 165 | ||
166 | #ifdef CONFIG_ACPI_SYSFS_POWER | ||
160 | static int sbs_get_ac_property(struct power_supply *psy, | 167 | static int sbs_get_ac_property(struct power_supply *psy, |
161 | enum power_supply_property psp, | 168 | enum power_supply_property psp, |
162 | union power_supply_propval *val) | 169 | union power_supply_propval *val) |
@@ -294,6 +301,7 @@ static enum power_supply_property sbs_energy_battery_props[] = { | |||
294 | POWER_SUPPLY_PROP_MODEL_NAME, | 301 | POWER_SUPPLY_PROP_MODEL_NAME, |
295 | POWER_SUPPLY_PROP_MANUFACTURER, | 302 | POWER_SUPPLY_PROP_MANUFACTURER, |
296 | }; | 303 | }; |
304 | #endif | ||
297 | 305 | ||
298 | /* -------------------------------------------------------------------------- | 306 | /* -------------------------------------------------------------------------- |
299 | Smart Battery System Management | 307 | Smart Battery System Management |
@@ -429,6 +437,7 @@ static int acpi_ac_get_present(struct acpi_sbs *sbs) | |||
429 | return result; | 437 | return result; |
430 | } | 438 | } |
431 | 439 | ||
440 | #ifdef CONFIG_ACPI_SYSFS_POWER | ||
432 | static ssize_t acpi_battery_alarm_show(struct device *dev, | 441 | static ssize_t acpi_battery_alarm_show(struct device *dev, |
433 | struct device_attribute *attr, | 442 | struct device_attribute *attr, |
434 | char *buf) | 443 | char *buf) |
@@ -458,6 +467,7 @@ static struct device_attribute alarm_attr = { | |||
458 | .show = acpi_battery_alarm_show, | 467 | .show = acpi_battery_alarm_show, |
459 | .store = acpi_battery_alarm_store, | 468 | .store = acpi_battery_alarm_store, |
460 | }; | 469 | }; |
470 | #endif | ||
461 | 471 | ||
462 | /* -------------------------------------------------------------------------- | 472 | /* -------------------------------------------------------------------------- |
463 | FS Interface (/proc/acpi) | 473 | FS Interface (/proc/acpi) |
@@ -793,6 +803,7 @@ static int acpi_battery_add(struct acpi_sbs *sbs, int id) | |||
793 | &acpi_battery_state_fops, &acpi_battery_alarm_fops, | 803 | &acpi_battery_state_fops, &acpi_battery_alarm_fops, |
794 | battery); | 804 | battery); |
795 | #endif | 805 | #endif |
806 | #ifdef CONFIG_ACPI_SYSFS_POWER | ||
796 | battery->bat.name = battery->name; | 807 | battery->bat.name = battery->name; |
797 | battery->bat.type = POWER_SUPPLY_TYPE_BATTERY; | 808 | battery->bat.type = POWER_SUPPLY_TYPE_BATTERY; |
798 | if (!acpi_battery_mode(battery)) { | 809 | if (!acpi_battery_mode(battery)) { |
@@ -813,6 +824,7 @@ static int acpi_battery_add(struct acpi_sbs *sbs, int id) | |||
813 | goto end; | 824 | goto end; |
814 | battery->have_sysfs_alarm = 1; | 825 | battery->have_sysfs_alarm = 1; |
815 | end: | 826 | end: |
827 | #endif | ||
816 | printk(KERN_INFO PREFIX "%s [%s]: Battery Slot [%s] (battery %s)\n", | 828 | printk(KERN_INFO PREFIX "%s [%s]: Battery Slot [%s] (battery %s)\n", |
817 | ACPI_SBS_DEVICE_NAME, acpi_device_bid(sbs->device), | 829 | ACPI_SBS_DEVICE_NAME, acpi_device_bid(sbs->device), |
818 | battery->name, sbs->battery->present ? "present" : "absent"); | 830 | battery->name, sbs->battery->present ? "present" : "absent"); |
@@ -822,12 +834,13 @@ static int acpi_battery_add(struct acpi_sbs *sbs, int id) | |||
822 | static void acpi_battery_remove(struct acpi_sbs *sbs, int id) | 834 | static void acpi_battery_remove(struct acpi_sbs *sbs, int id) |
823 | { | 835 | { |
824 | struct acpi_battery *battery = &sbs->battery[id]; | 836 | struct acpi_battery *battery = &sbs->battery[id]; |
825 | 837 | #ifdef CONFIG_ACPI_SYSFS_POWER | |
826 | if (battery->bat.dev) { | 838 | if (battery->bat.dev) { |
827 | if (battery->have_sysfs_alarm) | 839 | if (battery->have_sysfs_alarm) |
828 | device_remove_file(battery->bat.dev, &alarm_attr); | 840 | device_remove_file(battery->bat.dev, &alarm_attr); |
829 | power_supply_unregister(&battery->bat); | 841 | power_supply_unregister(&battery->bat); |
830 | } | 842 | } |
843 | #endif | ||
831 | #ifdef CONFIG_ACPI_PROCFS_POWER | 844 | #ifdef CONFIG_ACPI_PROCFS_POWER |
832 | if (battery->proc_entry) | 845 | if (battery->proc_entry) |
833 | acpi_sbs_remove_fs(&battery->proc_entry, acpi_battery_dir); | 846 | acpi_sbs_remove_fs(&battery->proc_entry, acpi_battery_dir); |
@@ -848,12 +861,14 @@ static int acpi_charger_add(struct acpi_sbs *sbs) | |||
848 | if (result) | 861 | if (result) |
849 | goto end; | 862 | goto end; |
850 | #endif | 863 | #endif |
864 | #ifdef CONFIG_ACPI_SYSFS_POWER | ||
851 | sbs->charger.name = "sbs-charger"; | 865 | sbs->charger.name = "sbs-charger"; |
852 | sbs->charger.type = POWER_SUPPLY_TYPE_MAINS; | 866 | sbs->charger.type = POWER_SUPPLY_TYPE_MAINS; |
853 | sbs->charger.properties = sbs_ac_props; | 867 | sbs->charger.properties = sbs_ac_props; |
854 | sbs->charger.num_properties = ARRAY_SIZE(sbs_ac_props); | 868 | sbs->charger.num_properties = ARRAY_SIZE(sbs_ac_props); |
855 | sbs->charger.get_property = sbs_get_ac_property; | 869 | sbs->charger.get_property = sbs_get_ac_property; |
856 | power_supply_register(&sbs->device->dev, &sbs->charger); | 870 | power_supply_register(&sbs->device->dev, &sbs->charger); |
871 | #endif | ||
857 | printk(KERN_INFO PREFIX "%s [%s]: AC Adapter [%s] (%s)\n", | 872 | printk(KERN_INFO PREFIX "%s [%s]: AC Adapter [%s] (%s)\n", |
858 | ACPI_SBS_DEVICE_NAME, acpi_device_bid(sbs->device), | 873 | ACPI_SBS_DEVICE_NAME, acpi_device_bid(sbs->device), |
859 | ACPI_AC_DIR_NAME, sbs->charger_present ? "on-line" : "off-line"); | 874 | ACPI_AC_DIR_NAME, sbs->charger_present ? "on-line" : "off-line"); |
@@ -863,8 +878,10 @@ static int acpi_charger_add(struct acpi_sbs *sbs) | |||
863 | 878 | ||
864 | static void acpi_charger_remove(struct acpi_sbs *sbs) | 879 | static void acpi_charger_remove(struct acpi_sbs *sbs) |
865 | { | 880 | { |
881 | #ifdef CONFIG_ACPI_SYSFS_POWER | ||
866 | if (sbs->charger.dev) | 882 | if (sbs->charger.dev) |
867 | power_supply_unregister(&sbs->charger); | 883 | power_supply_unregister(&sbs->charger); |
884 | #endif | ||
868 | #ifdef CONFIG_ACPI_PROCFS_POWER | 885 | #ifdef CONFIG_ACPI_PROCFS_POWER |
869 | if (sbs->charger_entry) | 886 | if (sbs->charger_entry) |
870 | acpi_sbs_remove_fs(&sbs->charger_entry, acpi_ac_dir); | 887 | acpi_sbs_remove_fs(&sbs->charger_entry, acpi_ac_dir); |
@@ -885,7 +902,9 @@ void acpi_sbs_callback(void *context) | |||
885 | ACPI_SBS_NOTIFY_STATUS, | 902 | ACPI_SBS_NOTIFY_STATUS, |
886 | sbs->charger_present); | 903 | sbs->charger_present); |
887 | #endif | 904 | #endif |
905 | #ifdef CONFIG_ACPI_SYSFS_POWER | ||
888 | kobject_uevent(&sbs->charger.dev->kobj, KOBJ_CHANGE); | 906 | kobject_uevent(&sbs->charger.dev->kobj, KOBJ_CHANGE); |
907 | #endif | ||
889 | } | 908 | } |
890 | if (sbs->manager_present) { | 909 | if (sbs->manager_present) { |
891 | for (id = 0; id < MAX_SBS_BAT; ++id) { | 910 | for (id = 0; id < MAX_SBS_BAT; ++id) { |
@@ -902,7 +921,9 @@ void acpi_sbs_callback(void *context) | |||
902 | ACPI_SBS_NOTIFY_STATUS, | 921 | ACPI_SBS_NOTIFY_STATUS, |
903 | bat->present); | 922 | bat->present); |
904 | #endif | 923 | #endif |
924 | #ifdef CONFIG_ACPI_SYSFS_POWER | ||
905 | kobject_uevent(&bat->bat.dev->kobj, KOBJ_CHANGE); | 925 | kobject_uevent(&bat->bat.dev->kobj, KOBJ_CHANGE); |
926 | #endif | ||
906 | } | 927 | } |
907 | } | 928 | } |
908 | } | 929 | } |