• Home
  • Raw
  • Download

Lines Matching full:battery

3  *  battery.c - ACPI Battery Driver (Revision: 2.0)
30 #include <acpi/battery.h>
38 #define ACPI_BATTERY_DEVICE_NAME "Battery"
40 /* Battery power unit: 0 means mW, 1 means mA */
49 ACPI_MODULE_NAME("battery");
53 MODULE_DESCRIPTION("ACPI Battery Driver");
74 /* Lists of PMIC ACPI HIDs with an (often better) native battery driver */
85 is running on battery or not. When mAh is the unit, most
140 static inline int acpi_battery_present(struct acpi_battery *battery) in acpi_battery_present() argument
142 return battery->device->status.battery_present; in acpi_battery_present()
145 static int acpi_battery_technology(struct acpi_battery *battery) in acpi_battery_technology() argument
147 if (!strcasecmp("NiCd", battery->type)) in acpi_battery_technology()
149 if (!strcasecmp("NiMH", battery->type)) in acpi_battery_technology()
151 if (!strcasecmp("LION", battery->type)) in acpi_battery_technology()
153 if (!strncasecmp("LI-ION", battery->type, 6)) in acpi_battery_technology()
155 if (!strcasecmp("LiP", battery->type)) in acpi_battery_technology()
160 static int acpi_battery_get_state(struct acpi_battery *battery);
162 static int acpi_battery_is_charged(struct acpi_battery *battery) in acpi_battery_is_charged() argument
165 if (battery->state != 0) in acpi_battery_is_charged()
168 /* battery not reporting charge */ in acpi_battery_is_charged()
169 if (battery->capacity_now == ACPI_BATTERY_VALUE_UNKNOWN || in acpi_battery_is_charged()
170 battery->capacity_now == 0) in acpi_battery_is_charged()
174 if (battery->full_charge_capacity == battery->capacity_now) in acpi_battery_is_charged()
178 if (battery->design_capacity <= battery->capacity_now) in acpi_battery_is_charged()
185 static bool acpi_battery_is_degraded(struct acpi_battery *battery) in acpi_battery_is_degraded() argument
187 return ACPI_BATTERY_CAPACITY_VALID(battery->full_charge_capacity) && in acpi_battery_is_degraded()
188 ACPI_BATTERY_CAPACITY_VALID(battery->design_capacity) && in acpi_battery_is_degraded()
189 battery->full_charge_capacity < battery->design_capacity; in acpi_battery_is_degraded()
192 static int acpi_battery_handle_discharging(struct acpi_battery *battery) in acpi_battery_handle_discharging() argument
195 * Some devices wrongly report discharging if the battery's charge level in acpi_battery_handle_discharging()
200 battery->rate_now == 0) in acpi_battery_handle_discharging()
211 struct acpi_battery *battery = to_acpi_battery(psy); in acpi_battery_get_property() local
213 if (acpi_battery_present(battery)) { in acpi_battery_get_property()
214 /* run battery update only if it is present */ in acpi_battery_get_property()
215 acpi_battery_get_state(battery); in acpi_battery_get_property()
220 if (battery->state & ACPI_BATTERY_STATE_DISCHARGING) in acpi_battery_get_property()
221 val->intval = acpi_battery_handle_discharging(battery); in acpi_battery_get_property()
222 else if (battery->state & ACPI_BATTERY_STATE_CHARGING) in acpi_battery_get_property()
224 else if (acpi_battery_is_charged(battery)) in acpi_battery_get_property()
232 val->intval = acpi_battery_present(battery); in acpi_battery_get_property()
235 val->intval = acpi_battery_technology(battery); in acpi_battery_get_property()
238 val->intval = battery->cycle_count; in acpi_battery_get_property()
241 if (battery->design_voltage == ACPI_BATTERY_VALUE_UNKNOWN) in acpi_battery_get_property()
244 val->intval = battery->design_voltage * 1000; in acpi_battery_get_property()
247 if (battery->voltage_now == ACPI_BATTERY_VALUE_UNKNOWN) in acpi_battery_get_property()
250 val->intval = battery->voltage_now * 1000; in acpi_battery_get_property()
254 if (battery->rate_now == ACPI_BATTERY_VALUE_UNKNOWN) in acpi_battery_get_property()
257 val->intval = battery->rate_now * 1000; in acpi_battery_get_property()
261 if (!ACPI_BATTERY_CAPACITY_VALID(battery->design_capacity)) in acpi_battery_get_property()
264 val->intval = battery->design_capacity * 1000; in acpi_battery_get_property()
268 if (!ACPI_BATTERY_CAPACITY_VALID(battery->full_charge_capacity)) in acpi_battery_get_property()
271 val->intval = battery->full_charge_capacity * 1000; in acpi_battery_get_property()
275 if (battery->capacity_now == ACPI_BATTERY_VALUE_UNKNOWN) in acpi_battery_get_property()
278 val->intval = battery->capacity_now * 1000; in acpi_battery_get_property()
281 if (ACPI_BATTERY_CAPACITY_VALID(battery->full_charge_capacity)) in acpi_battery_get_property()
282 full_capacity = battery->full_charge_capacity; in acpi_battery_get_property()
283 else if (ACPI_BATTERY_CAPACITY_VALID(battery->design_capacity)) in acpi_battery_get_property()
284 full_capacity = battery->design_capacity; in acpi_battery_get_property()
286 if (battery->capacity_now == ACPI_BATTERY_VALUE_UNKNOWN || in acpi_battery_get_property()
290 val->intval = battery->capacity_now * 100/ in acpi_battery_get_property()
294 if (battery->state & ACPI_BATTERY_STATE_CRITICAL) in acpi_battery_get_property()
296 else if (test_bit(ACPI_BATTERY_ALARM_PRESENT, &battery->flags) && in acpi_battery_get_property()
297 (battery->capacity_now <= battery->alarm)) in acpi_battery_get_property()
299 else if (acpi_battery_is_charged(battery)) in acpi_battery_get_property()
305 val->strval = battery->model_number; in acpi_battery_get_property()
308 val->strval = battery->oem_info; in acpi_battery_get_property()
311 val->strval = battery->serial_number; in acpi_battery_get_property()
384 Battery Management
437 static int extract_package(struct acpi_battery *battery, in extract_package() argument
450 u8 *ptr = (u8 *)battery + offsets[i].offset; in extract_package()
461 int *x = (int *)((u8 *)battery + offsets[i].offset); in extract_package()
469 static int acpi_battery_get_status(struct acpi_battery *battery) in acpi_battery_get_status() argument
471 if (acpi_bus_get_status(battery->device)) { in acpi_battery_get_status()
480 struct acpi_battery *battery, in extract_battery_info() argument
486 result = extract_package(battery, buffer->pointer, in extract_battery_info()
490 result = extract_package(battery, buffer->pointer, in extract_battery_info()
494 result = extract_package(battery, buffer->pointer, in extract_battery_info()
496 if (test_bit(ACPI_BATTERY_QUIRK_PERCENTAGE_CAPACITY, &battery->flags)) in extract_battery_info()
497 battery->full_charge_capacity = battery->design_capacity; in extract_battery_info()
498 if (test_bit(ACPI_BATTERY_QUIRK_THINKPAD_MAH, &battery->flags) && in extract_battery_info()
499 battery->power_unit && battery->design_voltage) { in extract_battery_info()
500 battery->design_capacity = battery->design_capacity * in extract_battery_info()
501 10000 / battery->design_voltage; in extract_battery_info()
502 battery->full_charge_capacity = battery->full_charge_capacity * in extract_battery_info()
503 10000 / battery->design_voltage; in extract_battery_info()
504 battery->design_capacity_warning = in extract_battery_info()
505 battery->design_capacity_warning * in extract_battery_info()
506 10000 / battery->design_voltage; in extract_battery_info()
513 if (test_bit(ACPI_BATTERY_QUIRK_DEGRADED_FULL_CHARGE, &battery->flags) && in extract_battery_info()
514 battery->capacity_now > battery->full_charge_capacity) in extract_battery_info()
515 battery->capacity_now = battery->full_charge_capacity; in extract_battery_info()
520 static int acpi_battery_get_info(struct acpi_battery *battery) in acpi_battery_get_info() argument
522 const int xinfo = test_bit(ACPI_BATTERY_XINFO_PRESENT, &battery->flags); in acpi_battery_get_info()
526 if (!acpi_battery_present(battery)) in acpi_battery_get_info()
534 mutex_lock(&battery->lock); in acpi_battery_get_info()
535 status = acpi_evaluate_object(battery->device->handle, in acpi_battery_get_info()
538 mutex_unlock(&battery->lock); in acpi_battery_get_info()
545 battery, in acpi_battery_get_info()
559 static int acpi_battery_get_state(struct acpi_battery *battery) in acpi_battery_get_state() argument
565 if (!acpi_battery_present(battery)) in acpi_battery_get_state()
568 if (battery->update_time && in acpi_battery_get_state()
569 time_before(jiffies, battery->update_time + in acpi_battery_get_state()
573 mutex_lock(&battery->lock); in acpi_battery_get_state()
574 status = acpi_evaluate_object(battery->device->handle, "_BST", in acpi_battery_get_state()
576 mutex_unlock(&battery->lock); in acpi_battery_get_state()
583 result = extract_package(battery, buffer.pointer, in acpi_battery_get_state()
585 battery->update_time = jiffies; in acpi_battery_get_state()
592 if (battery->power_unit == ACPI_BATTERY_POWER_UNIT_MA && in acpi_battery_get_state()
593 battery->rate_now != ACPI_BATTERY_VALUE_UNKNOWN && in acpi_battery_get_state()
594 (s16)(battery->rate_now) < 0) { in acpi_battery_get_state()
595 battery->rate_now = abs((s16)battery->rate_now); in acpi_battery_get_state()
596 pr_warn_once(FW_BUG "battery: (dis)charge rate invalid.\n"); in acpi_battery_get_state()
599 if (test_bit(ACPI_BATTERY_QUIRK_PERCENTAGE_CAPACITY, &battery->flags) in acpi_battery_get_state()
600 && battery->capacity_now >= 0 && battery->capacity_now <= 100) in acpi_battery_get_state()
601 battery->capacity_now = (battery->capacity_now * in acpi_battery_get_state()
602 battery->full_charge_capacity) / 100; in acpi_battery_get_state()
603 if (test_bit(ACPI_BATTERY_QUIRK_THINKPAD_MAH, &battery->flags) && in acpi_battery_get_state()
604 battery->power_unit && battery->design_voltage) { in acpi_battery_get_state()
605 battery->capacity_now = battery->capacity_now * in acpi_battery_get_state()
606 10000 / battery->design_voltage; in acpi_battery_get_state()
608 if (test_bit(ACPI_BATTERY_QUIRK_DEGRADED_FULL_CHARGE, &battery->flags) && in acpi_battery_get_state()
609 battery->capacity_now > battery->full_charge_capacity) in acpi_battery_get_state()
610 battery->capacity_now = battery->full_charge_capacity; in acpi_battery_get_state()
615 static int acpi_battery_set_alarm(struct acpi_battery *battery) in acpi_battery_set_alarm() argument
619 if (!acpi_battery_present(battery) || in acpi_battery_set_alarm()
620 !test_bit(ACPI_BATTERY_ALARM_PRESENT, &battery->flags)) in acpi_battery_set_alarm()
623 mutex_lock(&battery->lock); in acpi_battery_set_alarm()
624 status = acpi_execute_simple_method(battery->device->handle, "_BTP", in acpi_battery_set_alarm()
625 battery->alarm); in acpi_battery_set_alarm()
626 mutex_unlock(&battery->lock); in acpi_battery_set_alarm()
631 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Alarm set to %d\n", battery->alarm)); in acpi_battery_set_alarm()
635 static int acpi_battery_init_alarm(struct acpi_battery *battery) in acpi_battery_init_alarm() argument
638 if (!acpi_has_method(battery->device->handle, "_BTP")) { in acpi_battery_init_alarm()
639 clear_bit(ACPI_BATTERY_ALARM_PRESENT, &battery->flags); in acpi_battery_init_alarm()
642 set_bit(ACPI_BATTERY_ALARM_PRESENT, &battery->flags); in acpi_battery_init_alarm()
643 if (!battery->alarm) in acpi_battery_init_alarm()
644 battery->alarm = battery->design_capacity_warning; in acpi_battery_init_alarm()
645 return acpi_battery_set_alarm(battery); in acpi_battery_init_alarm()
652 struct acpi_battery *battery = to_acpi_battery(dev_get_drvdata(dev)); in acpi_battery_alarm_show() local
653 return sprintf(buf, "%d\n", battery->alarm * 1000); in acpi_battery_alarm_show()
661 struct acpi_battery *battery = to_acpi_battery(dev_get_drvdata(dev)); in acpi_battery_alarm_store() local
663 battery->alarm = x/1000; in acpi_battery_alarm_store()
664 if (acpi_battery_present(battery)) in acpi_battery_alarm_store()
665 acpi_battery_set_alarm(battery); in acpi_battery_alarm_store()
676 * The Battery Hooking API
690 struct acpi_battery *battery; in __battery_hook_unregister() local
697 list_for_each_entry(battery, &acpi_battery_list, list) { in __battery_hook_unregister()
698 hook->remove_battery(battery->bat); in __battery_hook_unregister()
714 struct acpi_battery *battery; in battery_hook_register() local
721 * to notify the hook that a battery is available in battery_hook_register()
722 * for each battery, so that the driver may add in battery_hook_register()
725 list_for_each_entry(battery, &acpi_battery_list, list) { in battery_hook_register()
726 if (hook->add_battery(battery->bat)) { in battery_hook_register()
728 * If a add-battery returns non-zero, in battery_hook_register()
745 * This function gets called right after the battery sysfs
749 static void battery_hook_add_battery(struct acpi_battery *battery) in battery_hook_add_battery() argument
754 INIT_LIST_HEAD(&battery->list); in battery_hook_add_battery()
755 list_add(&battery->list, &acpi_battery_list); in battery_hook_add_battery()
757 * Since we added a new battery to the list, we need to in battery_hook_add_battery()
760 * when a battery gets hotplugged or initialized in battery_hook_add_battery()
761 * during the battery module initialization. in battery_hook_add_battery()
764 if (hook_node->add_battery(battery->bat)) { in battery_hook_add_battery()
777 static void battery_hook_remove_battery(struct acpi_battery *battery) in battery_hook_remove_battery() argument
784 * custom attributes from the battery. in battery_hook_remove_battery()
787 hook->remove_battery(battery->bat); in battery_hook_remove_battery()
789 /* Then, just remove the battery from the list */ in battery_hook_remove_battery()
790 list_del(&battery->list); in battery_hook_remove_battery()
809 static int sysfs_add_battery(struct acpi_battery *battery) in sysfs_add_battery() argument
811 struct power_supply_config psy_cfg = { .drv_data = battery, }; in sysfs_add_battery()
814 if (!ACPI_BATTERY_CAPACITY_VALID(battery->full_charge_capacity) && in sysfs_add_battery()
815 !ACPI_BATTERY_CAPACITY_VALID(battery->design_capacity)) in sysfs_add_battery()
818 if (battery->power_unit == ACPI_BATTERY_POWER_UNIT_MA) { in sysfs_add_battery()
820 battery->bat_desc.properties = in sysfs_add_battery()
822 battery->bat_desc.num_properties = in sysfs_add_battery()
825 battery->bat_desc.properties = charge_battery_props; in sysfs_add_battery()
826 battery->bat_desc.num_properties = in sysfs_add_battery()
831 battery->bat_desc.properties = in sysfs_add_battery()
833 battery->bat_desc.num_properties = in sysfs_add_battery()
836 battery->bat_desc.properties = energy_battery_props; in sysfs_add_battery()
837 battery->bat_desc.num_properties = in sysfs_add_battery()
842 battery->bat_desc.name = acpi_device_bid(battery->device); in sysfs_add_battery()
843 battery->bat_desc.type = POWER_SUPPLY_TYPE_BATTERY; in sysfs_add_battery()
844 battery->bat_desc.get_property = acpi_battery_get_property; in sysfs_add_battery()
846 battery->bat = power_supply_register_no_ws(&battery->device->dev, in sysfs_add_battery()
847 &battery->bat_desc, &psy_cfg); in sysfs_add_battery()
849 if (IS_ERR(battery->bat)) { in sysfs_add_battery()
850 int result = PTR_ERR(battery->bat); in sysfs_add_battery()
852 battery->bat = NULL; in sysfs_add_battery()
855 battery_hook_add_battery(battery); in sysfs_add_battery()
856 return device_create_file(&battery->bat->dev, &alarm_attr); in sysfs_add_battery()
859 static void sysfs_remove_battery(struct acpi_battery *battery) in sysfs_remove_battery() argument
861 mutex_lock(&battery->sysfs_lock); in sysfs_remove_battery()
862 if (!battery->bat) { in sysfs_remove_battery()
863 mutex_unlock(&battery->sysfs_lock); in sysfs_remove_battery()
866 battery_hook_remove_battery(battery); in sysfs_remove_battery()
867 device_remove_file(&battery->bat->dev, &alarm_attr); in sysfs_remove_battery()
868 power_supply_unregister(battery->bat); in sysfs_remove_battery()
869 battery->bat = NULL; in sysfs_remove_battery()
870 mutex_unlock(&battery->sysfs_lock); in sysfs_remove_battery()
875 struct acpi_battery *battery = (struct acpi_battery *)private; in find_battery() local
883 if (battery->design_capacity * battery->design_voltage / 1000 in find_battery()
885 battery->design_capacity * 10 == dmi_capacity) in find_battery()
887 &battery->flags); in find_battery()
893 * report percentage battery remaining capacity directly to OS.
897 * Now we found some battery reports percentage remaining capacity
903 static void acpi_battery_quirks(struct acpi_battery *battery) in acpi_battery_quirks() argument
905 if (test_bit(ACPI_BATTERY_QUIRK_PERCENTAGE_CAPACITY, &battery->flags)) in acpi_battery_quirks()
908 if (battery->full_charge_capacity == 100 && in acpi_battery_quirks()
909 battery->rate_now == ACPI_BATTERY_VALUE_UNKNOWN && in acpi_battery_quirks()
910 battery->capacity_now >= 0 && battery->capacity_now <= 100) { in acpi_battery_quirks()
911 set_bit(ACPI_BATTERY_QUIRK_PERCENTAGE_CAPACITY, &battery->flags); in acpi_battery_quirks()
912 battery->full_charge_capacity = battery->design_capacity; in acpi_battery_quirks()
913 battery->capacity_now = (battery->capacity_now * in acpi_battery_quirks()
914 battery->full_charge_capacity) / 100; in acpi_battery_quirks()
917 if (test_bit(ACPI_BATTERY_QUIRK_THINKPAD_MAH, &battery->flags)) in acpi_battery_quirks()
920 if (battery->power_unit && dmi_name_in_vendors("LENOVO")) { in acpi_battery_quirks()
924 dmi_walk(find_battery, battery); in acpi_battery_quirks()
926 &battery->flags) && in acpi_battery_quirks()
927 battery->design_voltage) { in acpi_battery_quirks()
928 battery->design_capacity = in acpi_battery_quirks()
929 battery->design_capacity * in acpi_battery_quirks()
930 10000 / battery->design_voltage; in acpi_battery_quirks()
931 battery->full_charge_capacity = in acpi_battery_quirks()
932 battery->full_charge_capacity * in acpi_battery_quirks()
933 10000 / battery->design_voltage; in acpi_battery_quirks()
934 battery->design_capacity_warning = in acpi_battery_quirks()
935 battery->design_capacity_warning * in acpi_battery_quirks()
936 10000 / battery->design_voltage; in acpi_battery_quirks()
937 battery->capacity_now = battery->capacity_now * in acpi_battery_quirks()
938 10000 / battery->design_voltage; in acpi_battery_quirks()
943 if (test_bit(ACPI_BATTERY_QUIRK_DEGRADED_FULL_CHARGE, &battery->flags)) in acpi_battery_quirks()
946 if (acpi_battery_is_degraded(battery) && in acpi_battery_quirks()
947 battery->capacity_now > battery->full_charge_capacity) { in acpi_battery_quirks()
948 set_bit(ACPI_BATTERY_QUIRK_DEGRADED_FULL_CHARGE, &battery->flags); in acpi_battery_quirks()
949 battery->capacity_now = battery->full_charge_capacity; in acpi_battery_quirks()
953 static int acpi_battery_update(struct acpi_battery *battery, bool resume) in acpi_battery_update() argument
955 int result = acpi_battery_get_status(battery); in acpi_battery_update()
960 if (!acpi_battery_present(battery)) { in acpi_battery_update()
961 sysfs_remove_battery(battery); in acpi_battery_update()
962 battery->update_time = 0; in acpi_battery_update()
969 if (!battery->update_time) { in acpi_battery_update()
970 result = acpi_battery_get_info(battery); in acpi_battery_update()
973 acpi_battery_init_alarm(battery); in acpi_battery_update()
976 result = acpi_battery_get_state(battery); in acpi_battery_update()
979 acpi_battery_quirks(battery); in acpi_battery_update()
981 if (!battery->bat) { in acpi_battery_update()
982 result = sysfs_add_battery(battery); in acpi_battery_update()
988 * Wakeup the system if battery is critical low in acpi_battery_update()
991 if ((battery->state & ACPI_BATTERY_STATE_CRITICAL) || in acpi_battery_update()
992 (test_bit(ACPI_BATTERY_ALARM_PRESENT, &battery->flags) && in acpi_battery_update()
993 (battery->capacity_now <= battery->alarm))) in acpi_battery_update()
994 acpi_pm_wakeup_event(&battery->device->dev); in acpi_battery_update()
999 static void acpi_battery_refresh(struct acpi_battery *battery) in acpi_battery_refresh() argument
1003 if (!battery->bat) in acpi_battery_refresh()
1006 power_unit = battery->power_unit; in acpi_battery_refresh()
1008 acpi_battery_get_info(battery); in acpi_battery_refresh()
1010 if (power_unit == battery->power_unit) in acpi_battery_refresh()
1013 /* The battery has changed its reporting units. */ in acpi_battery_refresh()
1014 sysfs_remove_battery(battery); in acpi_battery_refresh()
1015 sysfs_add_battery(battery); in acpi_battery_refresh()
1024 struct acpi_battery *battery = acpi_driver_data(device); in acpi_battery_notify() local
1027 if (!battery) in acpi_battery_notify()
1029 old = battery->bat; in acpi_battery_notify()
1033 * triggered, battery state is still reported as "Full", and changes to in acpi_battery_notify()
1039 acpi_battery_refresh(battery); in acpi_battery_notify()
1040 acpi_battery_update(battery, false); in acpi_battery_notify()
1043 acpi_battery_present(battery)); in acpi_battery_notify()
1044 acpi_notifier_call_chain(device, event, acpi_battery_present(battery)); in acpi_battery_notify()
1046 if (old && battery->bat) in acpi_battery_notify()
1047 power_supply_changed(battery->bat); in acpi_battery_notify()
1053 struct acpi_battery *battery = container_of(nb, struct acpi_battery, in battery_notify() local
1060 if (!acpi_battery_present(battery)) in battery_notify()
1063 if (battery->bat) { in battery_notify()
1064 acpi_battery_refresh(battery); in battery_notify()
1066 result = acpi_battery_get_info(battery); in battery_notify()
1070 result = sysfs_add_battery(battery); in battery_notify()
1075 acpi_battery_init_alarm(battery); in battery_notify()
1076 acpi_battery_get_state(battery); in battery_notify()
1179 * during boot up and this causes battery driver fails to be
1180 * probed due to failure of getting battery information
1185 static int acpi_battery_update_retry(struct acpi_battery *battery) in acpi_battery_update_retry() argument
1190 ret = acpi_battery_update(battery, false); in acpi_battery_update_retry()
1202 struct acpi_battery *battery = NULL; in acpi_battery_add() local
1210 battery = kzalloc(sizeof(struct acpi_battery), GFP_KERNEL); in acpi_battery_add()
1211 if (!battery) in acpi_battery_add()
1213 battery->device = device; in acpi_battery_add()
1216 device->driver_data = battery; in acpi_battery_add()
1217 mutex_init(&battery->lock); in acpi_battery_add()
1218 mutex_init(&battery->sysfs_lock); in acpi_battery_add()
1219 if (acpi_has_method(battery->device->handle, "_BIX")) in acpi_battery_add()
1220 set_bit(ACPI_BATTERY_XINFO_PRESENT, &battery->flags); in acpi_battery_add()
1222 result = acpi_battery_update_retry(battery); in acpi_battery_add()
1226 pr_info(PREFIX "%s Slot [%s] (battery %s)\n", in acpi_battery_add()
1230 battery->pm_nb.notifier_call = battery_notify; in acpi_battery_add()
1231 register_pm_notifier(&battery->pm_nb); in acpi_battery_add()
1238 sysfs_remove_battery(battery); in acpi_battery_add()
1239 mutex_destroy(&battery->lock); in acpi_battery_add()
1240 mutex_destroy(&battery->sysfs_lock); in acpi_battery_add()
1241 kfree(battery); in acpi_battery_add()
1247 struct acpi_battery *battery = NULL; in acpi_battery_remove() local
1252 battery = acpi_driver_data(device); in acpi_battery_remove()
1253 unregister_pm_notifier(&battery->pm_nb); in acpi_battery_remove()
1254 sysfs_remove_battery(battery); in acpi_battery_remove()
1255 mutex_destroy(&battery->lock); in acpi_battery_remove()
1256 mutex_destroy(&battery->sysfs_lock); in acpi_battery_remove()
1257 kfree(battery); in acpi_battery_remove()
1265 struct acpi_battery *battery; in acpi_battery_resume() local
1270 battery = acpi_driver_data(to_acpi_device(dev)); in acpi_battery_resume()
1271 if (!battery) in acpi_battery_resume()
1274 battery->update_time = 0; in acpi_battery_resume()
1275 acpi_battery_update(battery, true); in acpi_battery_resume()
1285 .name = "battery",