diff options
author | Alexey Starikovskiy <astarikovskiy@suse.de> | 2008-01-01 14:27:24 -0500 |
---|---|---|
committer | Len Brown <len.brown@intel.com> | 2008-01-01 14:27:24 -0500 |
commit | 97749cd9adbb2985e4b2aee1a59d6b970fe9c3a7 (patch) | |
tree | 22e32a16eb78178e4f50963e4f61320b8bf935ab /drivers/acpi/sbs.c | |
parent | e697789d64f8748cb219d7f5c413c512953802cc (diff) |
ACPI: Make sysfs interface in ACPI power optional.
Reference: http://bugzilla.kernel.org/show_bug.cgi?id=9494
Signed-off-by: Alexey Starikovskiy <astarikovskiy@suse.de>
Signed-off-by: Len Brown <len.brown@intel.com>
Diffstat (limited to 'drivers/acpi/sbs.c')
-rw-r--r-- | drivers/acpi/sbs.c | 23 |
1 files changed, 22 insertions, 1 deletions
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 | } |