Lines Matching full:battery

3  *  battery.c - ACPI Battery Driver (Revision: 2.0)
11 #define pr_fmt(fmt) "ACPI: battery: " fmt
29 #include <acpi/battery.h>
35 #define ACPI_BATTERY_DEVICE_NAME "Battery"
37 /* Battery power unit: 0 means mW, 1 means mA */
49 MODULE_DESCRIPTION("ACPI Battery Driver");
76 * is running on battery or not. When mAh is the unit, most
132 static inline int acpi_battery_present(struct acpi_battery *battery) in acpi_battery_present() argument
134 return battery->device->status.battery_present; in acpi_battery_present()
137 static int acpi_battery_technology(struct acpi_battery *battery) in acpi_battery_technology() argument
139 if (!strcasecmp("NiCd", battery->type)) in acpi_battery_technology()
141 if (!strcasecmp("NiMH", battery->type)) in acpi_battery_technology()
143 if (!strcasecmp("LION", battery->type)) in acpi_battery_technology()
145 if (!strncasecmp("LI-ION", battery->type, 6)) in acpi_battery_technology()
147 if (!strcasecmp("LiP", battery->type)) in acpi_battery_technology()
152 static int acpi_battery_get_state(struct acpi_battery *battery);
154 static int acpi_battery_is_charged(struct acpi_battery *battery) in acpi_battery_is_charged() argument
157 if (battery->state != 0) in acpi_battery_is_charged()
160 /* battery not reporting charge */ in acpi_battery_is_charged()
161 if (battery->capacity_now == ACPI_BATTERY_VALUE_UNKNOWN || in acpi_battery_is_charged()
162 battery->capacity_now == 0) in acpi_battery_is_charged()
166 if (battery->full_charge_capacity == battery->capacity_now) in acpi_battery_is_charged()
170 if (battery->design_capacity <= battery->capacity_now) in acpi_battery_is_charged()
177 static bool acpi_battery_is_degraded(struct acpi_battery *battery) in acpi_battery_is_degraded() argument
179 return ACPI_BATTERY_CAPACITY_VALID(battery->full_charge_capacity) && in acpi_battery_is_degraded()
180 ACPI_BATTERY_CAPACITY_VALID(battery->design_capacity) && in acpi_battery_is_degraded()
181 battery->full_charge_capacity < battery->design_capacity; in acpi_battery_is_degraded()
184 static int acpi_battery_handle_discharging(struct acpi_battery *battery) in acpi_battery_handle_discharging() argument
187 * Some devices wrongly report discharging if the battery's charge level in acpi_battery_handle_discharging()
192 battery->rate_now == 0) in acpi_battery_handle_discharging()
203 struct acpi_battery *battery = to_acpi_battery(psy); in acpi_battery_get_property() local
205 if (acpi_battery_present(battery)) { in acpi_battery_get_property()
206 /* run battery update only if it is present */ in acpi_battery_get_property()
207 acpi_battery_get_state(battery); in acpi_battery_get_property()
212 if (battery->state & ACPI_BATTERY_STATE_DISCHARGING) in acpi_battery_get_property()
213 val->intval = acpi_battery_handle_discharging(battery); in acpi_battery_get_property()
214 else if (battery->state & ACPI_BATTERY_STATE_CHARGING) in acpi_battery_get_property()
216 else if (battery->state & ACPI_BATTERY_STATE_CHARGE_LIMITING) in acpi_battery_get_property()
218 else if (acpi_battery_is_charged(battery)) in acpi_battery_get_property()
224 val->intval = acpi_battery_present(battery); in acpi_battery_get_property()
227 val->intval = acpi_battery_technology(battery); in acpi_battery_get_property()
230 val->intval = battery->cycle_count; in acpi_battery_get_property()
233 if (battery->design_voltage == ACPI_BATTERY_VALUE_UNKNOWN) in acpi_battery_get_property()
236 val->intval = battery->design_voltage * 1000; in acpi_battery_get_property()
239 if (battery->voltage_now == ACPI_BATTERY_VALUE_UNKNOWN) in acpi_battery_get_property()
242 val->intval = battery->voltage_now * 1000; in acpi_battery_get_property()
246 if (battery->rate_now == ACPI_BATTERY_VALUE_UNKNOWN) in acpi_battery_get_property()
249 val->intval = battery->rate_now * 1000; in acpi_battery_get_property()
253 if (!ACPI_BATTERY_CAPACITY_VALID(battery->design_capacity)) in acpi_battery_get_property()
256 val->intval = battery->design_capacity * 1000; in acpi_battery_get_property()
260 if (!ACPI_BATTERY_CAPACITY_VALID(battery->full_charge_capacity)) in acpi_battery_get_property()
263 val->intval = battery->full_charge_capacity * 1000; in acpi_battery_get_property()
267 if (battery->capacity_now == ACPI_BATTERY_VALUE_UNKNOWN) in acpi_battery_get_property()
270 val->intval = battery->capacity_now * 1000; in acpi_battery_get_property()
273 if (ACPI_BATTERY_CAPACITY_VALID(battery->full_charge_capacity)) in acpi_battery_get_property()
274 full_capacity = battery->full_charge_capacity; in acpi_battery_get_property()
275 else if (ACPI_BATTERY_CAPACITY_VALID(battery->design_capacity)) in acpi_battery_get_property()
276 full_capacity = battery->design_capacity; in acpi_battery_get_property()
278 if (battery->capacity_now == ACPI_BATTERY_VALUE_UNKNOWN || in acpi_battery_get_property()
282 val->intval = battery->capacity_now * 100/ in acpi_battery_get_property()
286 if (battery->state & ACPI_BATTERY_STATE_CRITICAL) in acpi_battery_get_property()
288 else if (test_bit(ACPI_BATTERY_ALARM_PRESENT, &battery->flags) && in acpi_battery_get_property()
289 (battery->capacity_now <= battery->alarm)) in acpi_battery_get_property()
291 else if (acpi_battery_is_charged(battery)) in acpi_battery_get_property()
297 val->strval = battery->model_number; in acpi_battery_get_property()
300 val->strval = battery->oem_info; in acpi_battery_get_property()
303 val->strval = battery->serial_number; in acpi_battery_get_property()
375 /* Battery Management */
427 static int extract_package(struct acpi_battery *battery, in extract_package() argument
441 u8 *ptr = (u8 *)battery + offsets[i].offset; in extract_package()
462 int *x = (int *)((u8 *)battery + offsets[i].offset); in extract_package()
470 static int acpi_battery_get_status(struct acpi_battery *battery) in acpi_battery_get_status() argument
472 if (acpi_bus_get_status(battery->device)) { in acpi_battery_get_status()
473 acpi_handle_info(battery->device->handle, in acpi_battery_get_status()
482 struct acpi_battery *battery, in extract_battery_info() argument
488 result = extract_package(battery, buffer->pointer, in extract_battery_info()
492 result = extract_package(battery, buffer->pointer, in extract_battery_info()
496 result = extract_package(battery, buffer->pointer, in extract_battery_info()
498 if (test_bit(ACPI_BATTERY_QUIRK_PERCENTAGE_CAPACITY, &battery->flags)) in extract_battery_info()
499 battery->full_charge_capacity = battery->design_capacity; in extract_battery_info()
500 if (test_bit(ACPI_BATTERY_QUIRK_THINKPAD_MAH, &battery->flags) && in extract_battery_info()
501 battery->power_unit && battery->design_voltage) { in extract_battery_info()
502 battery->design_capacity = battery->design_capacity * in extract_battery_info()
503 10000 / battery->design_voltage; in extract_battery_info()
504 battery->full_charge_capacity = battery->full_charge_capacity * in extract_battery_info()
505 10000 / battery->design_voltage; in extract_battery_info()
506 battery->design_capacity_warning = in extract_battery_info()
507 battery->design_capacity_warning * in extract_battery_info()
508 10000 / battery->design_voltage; in extract_battery_info()
517 if (test_bit(ACPI_BATTERY_QUIRK_DEGRADED_FULL_CHARGE, &battery->flags) && in extract_battery_info()
518 battery->capacity_now > battery->full_charge_capacity) in extract_battery_info()
519 battery->capacity_now = battery->full_charge_capacity; in extract_battery_info()
524 static int acpi_battery_get_info(struct acpi_battery *battery) in acpi_battery_get_info() argument
526 const int xinfo = test_bit(ACPI_BATTERY_XINFO_PRESENT, &battery->flags); in acpi_battery_get_info()
530 if (!acpi_battery_present(battery)) in acpi_battery_get_info()
538 mutex_lock(&battery->lock); in acpi_battery_get_info()
539 status = acpi_evaluate_object(battery->device->handle, in acpi_battery_get_info()
542 mutex_unlock(&battery->lock); in acpi_battery_get_info()
545 acpi_handle_info(battery->device->handle, in acpi_battery_get_info()
551 battery, in acpi_battery_get_info()
565 static int acpi_battery_get_state(struct acpi_battery *battery) in acpi_battery_get_state() argument
571 if (!acpi_battery_present(battery)) in acpi_battery_get_state()
574 if (battery->update_time && in acpi_battery_get_state()
575 time_before(jiffies, battery->update_time + in acpi_battery_get_state()
579 mutex_lock(&battery->lock); in acpi_battery_get_state()
580 status = acpi_evaluate_object(battery->device->handle, "_BST", in acpi_battery_get_state()
582 mutex_unlock(&battery->lock); in acpi_battery_get_state()
585 acpi_handle_info(battery->device->handle, in acpi_battery_get_state()
591 result = extract_package(battery, buffer.pointer, in acpi_battery_get_state()
593 battery->update_time = jiffies; in acpi_battery_get_state()
600 if (battery->power_unit == ACPI_BATTERY_POWER_UNIT_MA && in acpi_battery_get_state()
601 battery->rate_now != ACPI_BATTERY_VALUE_UNKNOWN && in acpi_battery_get_state()
602 (s16)(battery->rate_now) < 0) { in acpi_battery_get_state()
603 battery->rate_now = abs((s16)battery->rate_now); in acpi_battery_get_state()
607 if (test_bit(ACPI_BATTERY_QUIRK_PERCENTAGE_CAPACITY, &battery->flags) in acpi_battery_get_state()
608 && battery->capacity_now >= 0 && battery->capacity_now <= 100) in acpi_battery_get_state()
609 battery->capacity_now = (battery->capacity_now * in acpi_battery_get_state()
610 battery->full_charge_capacity) / 100; in acpi_battery_get_state()
611 if (test_bit(ACPI_BATTERY_QUIRK_THINKPAD_MAH, &battery->flags) && in acpi_battery_get_state()
612 battery->power_unit && battery->design_voltage) { in acpi_battery_get_state()
613 battery->capacity_now = battery->capacity_now * in acpi_battery_get_state()
614 10000 / battery->design_voltage; in acpi_battery_get_state()
616 if (test_bit(ACPI_BATTERY_QUIRK_DEGRADED_FULL_CHARGE, &battery->flags) && in acpi_battery_get_state()
617 battery->capacity_now > battery->full_charge_capacity) in acpi_battery_get_state()
618 battery->capacity_now = battery->full_charge_capacity; in acpi_battery_get_state()
623 static int acpi_battery_set_alarm(struct acpi_battery *battery) in acpi_battery_set_alarm() argument
627 if (!acpi_battery_present(battery) || in acpi_battery_set_alarm()
628 !test_bit(ACPI_BATTERY_ALARM_PRESENT, &battery->flags)) in acpi_battery_set_alarm()
631 mutex_lock(&battery->lock); in acpi_battery_set_alarm()
632 status = acpi_execute_simple_method(battery->device->handle, "_BTP", in acpi_battery_set_alarm()
633 battery->alarm); in acpi_battery_set_alarm()
634 mutex_unlock(&battery->lock); in acpi_battery_set_alarm()
639 acpi_handle_debug(battery->device->handle, "Alarm set to %d\n", in acpi_battery_set_alarm()
640 battery->alarm); in acpi_battery_set_alarm()
645 static int acpi_battery_init_alarm(struct acpi_battery *battery) in acpi_battery_init_alarm() argument
648 if (!acpi_has_method(battery->device->handle, "_BTP")) { in acpi_battery_init_alarm()
649 clear_bit(ACPI_BATTERY_ALARM_PRESENT, &battery->flags); in acpi_battery_init_alarm()
652 set_bit(ACPI_BATTERY_ALARM_PRESENT, &battery->flags); in acpi_battery_init_alarm()
653 if (!battery->alarm) in acpi_battery_init_alarm()
654 battery->alarm = battery->design_capacity_warning; in acpi_battery_init_alarm()
655 return acpi_battery_set_alarm(battery); in acpi_battery_init_alarm()
662 struct acpi_battery *battery = to_acpi_battery(dev_get_drvdata(dev)); in acpi_battery_alarm_show() local
664 return sysfs_emit(buf, "%d\n", battery->alarm * 1000); in acpi_battery_alarm_show()
672 struct acpi_battery *battery = to_acpi_battery(dev_get_drvdata(dev)); in acpi_battery_alarm_store() local
675 battery->alarm = x/1000; in acpi_battery_alarm_store()
676 if (acpi_battery_present(battery)) in acpi_battery_alarm_store()
677 acpi_battery_set_alarm(battery); in acpi_battery_alarm_store()
694 * The Battery Hooking API
708 struct acpi_battery *battery; in battery_hook_unregister_unlocked() local
714 list_for_each_entry(battery, &acpi_battery_list, list) { in battery_hook_unregister_unlocked()
715 if (!hook->remove_battery(battery->bat, hook)) in battery_hook_unregister_unlocked()
716 power_supply_changed(battery->bat); in battery_hook_unregister_unlocked()
727 * Ignore already unregistered battery hooks. This might happen in battery_hook_unregister()
728 * if a battery hook was previously unloaded due to an error when in battery_hook_unregister()
729 * adding a new battery. in battery_hook_unregister()
740 struct acpi_battery *battery; in battery_hook_register() local
746 * to notify the hook that a battery is available in battery_hook_register()
747 * for each battery, so that the driver may add in battery_hook_register()
750 list_for_each_entry(battery, &acpi_battery_list, list) { in battery_hook_register()
751 if (hook->add_battery(battery->bat, hook)) { in battery_hook_register()
753 * If a add-battery returns non-zero, in battery_hook_register()
763 power_supply_changed(battery->bat); in battery_hook_register()
787 * This function gets called right after the battery sysfs
791 static void battery_hook_add_battery(struct acpi_battery *battery) in battery_hook_add_battery() argument
796 INIT_LIST_HEAD(&battery->list); in battery_hook_add_battery()
797 list_add(&battery->list, &acpi_battery_list); in battery_hook_add_battery()
799 * Since we added a new battery to the list, we need to in battery_hook_add_battery()
802 * when a battery gets hotplugged or initialized in battery_hook_add_battery()
803 * during the battery module initialization. in battery_hook_add_battery()
806 if (hook_node->add_battery(battery->bat, hook_node)) { in battery_hook_add_battery()
819 static void battery_hook_remove_battery(struct acpi_battery *battery) in battery_hook_remove_battery() argument
826 * custom attributes from the battery. in battery_hook_remove_battery()
829 hook->remove_battery(battery->bat, hook); in battery_hook_remove_battery()
831 /* Then, just remove the battery from the list */ in battery_hook_remove_battery()
832 list_del(&battery->list); in battery_hook_remove_battery()
851 static int sysfs_add_battery(struct acpi_battery *battery) in sysfs_add_battery() argument
854 .drv_data = battery, in sysfs_add_battery()
859 if (!ACPI_BATTERY_CAPACITY_VALID(battery->full_charge_capacity) && in sysfs_add_battery()
860 !ACPI_BATTERY_CAPACITY_VALID(battery->design_capacity)) in sysfs_add_battery()
863 if (battery->power_unit == ACPI_BATTERY_POWER_UNIT_MA) { in sysfs_add_battery()
865 battery->bat_desc.properties = in sysfs_add_battery()
867 battery->bat_desc.num_properties = in sysfs_add_battery()
870 battery->bat_desc.properties = charge_battery_props; in sysfs_add_battery()
871 battery->bat_desc.num_properties = in sysfs_add_battery()
876 battery->bat_desc.properties = in sysfs_add_battery()
878 battery->bat_desc.num_properties = in sysfs_add_battery()
881 battery->bat_desc.properties = energy_battery_props; in sysfs_add_battery()
882 battery->bat_desc.num_properties = in sysfs_add_battery()
887 battery->bat_desc.name = acpi_device_bid(battery->device); in sysfs_add_battery()
888 battery->bat_desc.type = POWER_SUPPLY_TYPE_BATTERY; in sysfs_add_battery()
889 battery->bat_desc.get_property = acpi_battery_get_property; in sysfs_add_battery()
891 battery->bat = power_supply_register_no_ws(&battery->device->dev, in sysfs_add_battery()
892 &battery->bat_desc, &psy_cfg); in sysfs_add_battery()
894 if (IS_ERR(battery->bat)) { in sysfs_add_battery()
895 int result = PTR_ERR(battery->bat); in sysfs_add_battery()
897 battery->bat = NULL; in sysfs_add_battery()
900 battery_hook_add_battery(battery); in sysfs_add_battery()
904 static void sysfs_remove_battery(struct acpi_battery *battery) in sysfs_remove_battery() argument
906 mutex_lock(&battery->sysfs_lock); in sysfs_remove_battery()
907 if (!battery->bat) { in sysfs_remove_battery()
908 mutex_unlock(&battery->sysfs_lock); in sysfs_remove_battery()
911 battery_hook_remove_battery(battery); in sysfs_remove_battery()
912 power_supply_unregister(battery->bat); in sysfs_remove_battery()
913 battery->bat = NULL; in sysfs_remove_battery()
914 mutex_unlock(&battery->sysfs_lock); in sysfs_remove_battery()
919 struct acpi_battery *battery = (struct acpi_battery *)private; in find_battery() local
929 if (battery->design_capacity * battery->design_voltage / 1000 in find_battery()
931 battery->design_capacity * 10 == dmi_capacity) in find_battery()
933 &battery->flags); in find_battery()
939 * report percentage battery remaining capacity directly to OS.
943 * Now we found some battery reports percentage remaining capacity
949 static void acpi_battery_quirks(struct acpi_battery *battery) in acpi_battery_quirks() argument
951 if (test_bit(ACPI_BATTERY_QUIRK_PERCENTAGE_CAPACITY, &battery->flags)) in acpi_battery_quirks()
954 if (battery->full_charge_capacity == 100 && in acpi_battery_quirks()
955 battery->rate_now == ACPI_BATTERY_VALUE_UNKNOWN && in acpi_battery_quirks()
956 battery->capacity_now >= 0 && battery->capacity_now <= 100) { in acpi_battery_quirks()
957 set_bit(ACPI_BATTERY_QUIRK_PERCENTAGE_CAPACITY, &battery->flags); in acpi_battery_quirks()
958 battery->full_charge_capacity = battery->design_capacity; in acpi_battery_quirks()
959 battery->capacity_now = (battery->capacity_now * in acpi_battery_quirks()
960 battery->full_charge_capacity) / 100; in acpi_battery_quirks()
963 if (test_bit(ACPI_BATTERY_QUIRK_THINKPAD_MAH, &battery->flags)) in acpi_battery_quirks()
966 if (battery->power_unit && dmi_name_in_vendors("LENOVO")) { in acpi_battery_quirks()
971 dmi_walk(find_battery, battery); in acpi_battery_quirks()
973 &battery->flags) && in acpi_battery_quirks()
974 battery->design_voltage) { in acpi_battery_quirks()
975 battery->design_capacity = in acpi_battery_quirks()
976 battery->design_capacity * in acpi_battery_quirks()
977 10000 / battery->design_voltage; in acpi_battery_quirks()
978 battery->full_charge_capacity = in acpi_battery_quirks()
979 battery->full_charge_capacity * in acpi_battery_quirks()
980 10000 / battery->design_voltage; in acpi_battery_quirks()
981 battery->design_capacity_warning = in acpi_battery_quirks()
982 battery->design_capacity_warning * in acpi_battery_quirks()
983 10000 / battery->design_voltage; in acpi_battery_quirks()
984 battery->capacity_now = battery->capacity_now * in acpi_battery_quirks()
985 10000 / battery->design_voltage; in acpi_battery_quirks()
990 if (test_bit(ACPI_BATTERY_QUIRK_DEGRADED_FULL_CHARGE, &battery->flags)) in acpi_battery_quirks()
993 if (acpi_battery_is_degraded(battery) && in acpi_battery_quirks()
994 battery->capacity_now > battery->full_charge_capacity) { in acpi_battery_quirks()
995 set_bit(ACPI_BATTERY_QUIRK_DEGRADED_FULL_CHARGE, &battery->flags); in acpi_battery_quirks()
996 battery->capacity_now = battery->full_charge_capacity; in acpi_battery_quirks()
1000 static int acpi_battery_update(struct acpi_battery *battery, bool resume) in acpi_battery_update() argument
1002 int result = acpi_battery_get_status(battery); in acpi_battery_update()
1007 if (!acpi_battery_present(battery)) { in acpi_battery_update()
1008 sysfs_remove_battery(battery); in acpi_battery_update()
1009 battery->update_time = 0; in acpi_battery_update()
1016 if (!battery->update_time) { in acpi_battery_update()
1017 result = acpi_battery_get_info(battery); in acpi_battery_update()
1020 acpi_battery_init_alarm(battery); in acpi_battery_update()
1023 result = acpi_battery_get_state(battery); in acpi_battery_update()
1026 acpi_battery_quirks(battery); in acpi_battery_update()
1028 if (!battery->bat) { in acpi_battery_update()
1029 result = sysfs_add_battery(battery); in acpi_battery_update()
1035 * Wakeup the system if battery is critical low in acpi_battery_update()
1038 if ((battery->state & ACPI_BATTERY_STATE_CRITICAL) || in acpi_battery_update()
1039 (test_bit(ACPI_BATTERY_ALARM_PRESENT, &battery->flags) && in acpi_battery_update()
1040 (battery->capacity_now <= battery->alarm))) in acpi_battery_update()
1041 acpi_pm_wakeup_event(&battery->device->dev); in acpi_battery_update()
1046 static void acpi_battery_refresh(struct acpi_battery *battery) in acpi_battery_refresh() argument
1050 if (!battery->bat) in acpi_battery_refresh()
1053 power_unit = battery->power_unit; in acpi_battery_refresh()
1055 acpi_battery_get_info(battery); in acpi_battery_refresh()
1057 if (power_unit == battery->power_unit) in acpi_battery_refresh()
1060 /* The battery has changed its reporting units. */ in acpi_battery_refresh()
1061 sysfs_remove_battery(battery); in acpi_battery_refresh()
1062 sysfs_add_battery(battery); in acpi_battery_refresh()
1069 struct acpi_battery *battery = acpi_driver_data(device); in acpi_battery_notify() local
1072 if (!battery) in acpi_battery_notify()
1074 old = battery->bat; in acpi_battery_notify()
1078 * triggered, battery state is still reported as "Full", and changes to in acpi_battery_notify()
1084 acpi_battery_refresh(battery); in acpi_battery_notify()
1085 acpi_battery_update(battery, false); in acpi_battery_notify()
1088 acpi_battery_present(battery)); in acpi_battery_notify()
1089 acpi_notifier_call_chain(device, event, acpi_battery_present(battery)); in acpi_battery_notify()
1091 if (old && battery->bat) in acpi_battery_notify()
1092 power_supply_changed(battery->bat); in acpi_battery_notify()
1098 struct acpi_battery *battery = container_of(nb, struct acpi_battery, in battery_notify() local
1105 if (!acpi_battery_present(battery)) in battery_notify()
1108 if (battery->bat) { in battery_notify()
1109 acpi_battery_refresh(battery); in battery_notify()
1111 result = acpi_battery_get_info(battery); in battery_notify()
1115 result = sysfs_add_battery(battery); in battery_notify()
1120 acpi_battery_init_alarm(battery); in battery_notify()
1121 acpi_battery_get_state(battery); in battery_notify()
1190 * during boot up and this causes battery driver fails to be
1191 * probed due to failure of getting battery information
1196 static int acpi_battery_update_retry(struct acpi_battery *battery) in acpi_battery_update_retry() argument
1201 ret = acpi_battery_update(battery, false); in acpi_battery_update_retry()
1213 struct acpi_battery *battery; in acpi_battery_add() local
1221 battery = kzalloc(sizeof(struct acpi_battery), GFP_KERNEL); in acpi_battery_add()
1222 if (!battery) in acpi_battery_add()
1224 battery->device = device; in acpi_battery_add()
1227 device->driver_data = battery; in acpi_battery_add()
1228 mutex_init(&battery->lock); in acpi_battery_add()
1229 mutex_init(&battery->sysfs_lock); in acpi_battery_add()
1230 if (acpi_has_method(battery->device->handle, "_BIX")) in acpi_battery_add()
1231 set_bit(ACPI_BATTERY_XINFO_PRESENT, &battery->flags); in acpi_battery_add()
1233 result = acpi_battery_update_retry(battery); in acpi_battery_add()
1237 pr_info("Slot [%s] (battery %s)\n", acpi_device_bid(device), in acpi_battery_add()
1240 battery->pm_nb.notifier_call = battery_notify; in acpi_battery_add()
1241 register_pm_notifier(&battery->pm_nb); in acpi_battery_add()
1254 unregister_pm_notifier(&battery->pm_nb); in acpi_battery_add()
1256 sysfs_remove_battery(battery); in acpi_battery_add()
1257 mutex_destroy(&battery->lock); in acpi_battery_add()
1258 mutex_destroy(&battery->sysfs_lock); in acpi_battery_add()
1259 kfree(battery); in acpi_battery_add()
1266 struct acpi_battery *battery; in acpi_battery_remove() local
1271 battery = acpi_driver_data(device); in acpi_battery_remove()
1277 unregister_pm_notifier(&battery->pm_nb); in acpi_battery_remove()
1278 sysfs_remove_battery(battery); in acpi_battery_remove()
1280 mutex_destroy(&battery->lock); in acpi_battery_remove()
1281 mutex_destroy(&battery->sysfs_lock); in acpi_battery_remove()
1282 kfree(battery); in acpi_battery_remove()
1289 struct acpi_battery *battery; in acpi_battery_resume() local
1294 battery = acpi_driver_data(to_acpi_device(dev)); in acpi_battery_resume()
1295 if (!battery) in acpi_battery_resume()
1298 battery->update_time = 0; in acpi_battery_resume()
1299 acpi_battery_update(battery, true); in acpi_battery_resume()
1309 .name = "battery",