diff options
Diffstat (limited to 'drivers/acpi/sbs.c')
-rw-r--r-- | drivers/acpi/sbs.c | 25 |
1 files changed, 17 insertions, 8 deletions
diff --git a/drivers/acpi/sbs.c b/drivers/acpi/sbs.c index 90fd09c65f95..73c1ba314299 100644 --- a/drivers/acpi/sbs.c +++ b/drivers/acpi/sbs.c | |||
@@ -113,6 +113,7 @@ struct acpi_battery { | |||
113 | u16 spec; | 113 | u16 spec; |
114 | u8 id; | 114 | u8 id; |
115 | u8 present:1; | 115 | u8 present:1; |
116 | u8 have_sysfs_alarm:1; | ||
116 | }; | 117 | }; |
117 | 118 | ||
118 | #define to_acpi_battery(x) container_of(x, struct acpi_battery, bat); | 119 | #define to_acpi_battery(x) container_of(x, struct acpi_battery, bat); |
@@ -808,7 +809,13 @@ static int acpi_battery_add(struct acpi_sbs *sbs, int id) | |||
808 | } | 809 | } |
809 | battery->bat.get_property = acpi_sbs_battery_get_property; | 810 | battery->bat.get_property = acpi_sbs_battery_get_property; |
810 | result = power_supply_register(&sbs->device->dev, &battery->bat); | 811 | result = power_supply_register(&sbs->device->dev, &battery->bat); |
811 | device_create_file(battery->bat.dev, &alarm_attr); | 812 | if (result) |
813 | goto end; | ||
814 | result = device_create_file(battery->bat.dev, &alarm_attr); | ||
815 | if (result) | ||
816 | goto end; | ||
817 | battery->have_sysfs_alarm = 1; | ||
818 | end: | ||
812 | printk(KERN_INFO PREFIX "%s [%s]: Battery Slot [%s] (battery %s)\n", | 819 | printk(KERN_INFO PREFIX "%s [%s]: Battery Slot [%s] (battery %s)\n", |
813 | ACPI_SBS_DEVICE_NAME, acpi_device_bid(sbs->device), | 820 | ACPI_SBS_DEVICE_NAME, acpi_device_bid(sbs->device), |
814 | battery->name, sbs->battery->present ? "present" : "absent"); | 821 | battery->name, sbs->battery->present ? "present" : "absent"); |
@@ -817,14 +824,16 @@ static int acpi_battery_add(struct acpi_sbs *sbs, int id) | |||
817 | 824 | ||
818 | static void acpi_battery_remove(struct acpi_sbs *sbs, int id) | 825 | static void acpi_battery_remove(struct acpi_sbs *sbs, int id) |
819 | { | 826 | { |
820 | if (sbs->battery[id].bat.dev) | 827 | struct acpi_battery *battery = &sbs->battery[id]; |
821 | device_remove_file(sbs->battery[id].bat.dev, &alarm_attr); | 828 | |
822 | power_supply_unregister(&sbs->battery[id].bat); | 829 | if (battery->bat.dev) { |
823 | #ifdef CONFIG_ACPI_PROCFS | 830 | if (battery->have_sysfs_alarm) |
824 | if (sbs->battery[id].proc_entry) { | 831 | device_remove_file(battery->bat.dev, &alarm_attr); |
825 | acpi_sbs_remove_fs(&(sbs->battery[id].proc_entry), | 832 | power_supply_unregister(&battery->bat); |
826 | acpi_battery_dir); | ||
827 | } | 833 | } |
834 | #ifdef CONFIG_ACPI_PROCFS | ||
835 | if (battery->proc_entry) | ||
836 | acpi_sbs_remove_fs(&battery->proc_entry, acpi_battery_dir); | ||
828 | #endif | 837 | #endif |
829 | } | 838 | } |
830 | 839 | ||