Lines Matching full:ac
3 * acpi_ac.c - ACPI AC Adapter Driver (Revision: 27)
9 #define pr_fmt(fmt) "ACPI: AC: " fmt
24 #define ACPI_AC_DEVICE_NAME "AC Adapter"
32 MODULE_DESCRIPTION("ACPI AC Adapter Driver");
54 .name = "ac",
74 /* AC Adapter Management */
75 static int acpi_ac_get_state(struct acpi_ac *ac) in acpi_ac_get_state() argument
79 if (!ac) in acpi_ac_get_state()
83 ac->state = 1; in acpi_ac_get_state()
87 status = acpi_evaluate_integer(ac->device->handle, "_PSR", NULL, in acpi_ac_get_state()
88 &ac->state); in acpi_ac_get_state()
90 acpi_handle_info(ac->device->handle, in acpi_ac_get_state()
91 "Error reading AC Adapter state: %s\n", in acpi_ac_get_state()
93 ac->state = ACPI_AC_STATUS_UNKNOWN; in acpi_ac_get_state()
105 struct acpi_ac *ac = to_acpi_ac(psy); in get_ac_property() local
107 if (!ac) in get_ac_property()
110 if (acpi_ac_get_state(ac)) in get_ac_property()
115 val->intval = ac->state; in get_ac_property()
132 struct acpi_ac *ac = acpi_driver_data(device); in acpi_ac_notify() local
134 if (!ac) in acpi_ac_notify()
146 * A buggy BIOS may notify AC first and then sleep for in acpi_ac_notify()
148 * EC event handler (_Qxx). This will cause the AC state in acpi_ac_notify()
155 acpi_ac_get_state(ac); in acpi_ac_notify()
158 (u32) ac->state); in acpi_ac_notify()
159 acpi_notifier_call_chain(device, event, (u32) ac->state); in acpi_ac_notify()
160 kobject_uevent(&ac->charger->dev.kobj, KOBJ_CHANGE); in acpi_ac_notify()
167 struct acpi_ac *ac = container_of(nb, struct acpi_ac, battery_nb); in acpi_ac_battery_notify() local
171 * On HP Pavilion dv6-6179er AC status notifications aren't triggered in acpi_ac_battery_notify()
174 * discharging. Re-reading AC status triggers lost AC notifications, in acpi_ac_battery_notify()
175 * if AC status has changed. in acpi_ac_battery_notify()
179 acpi_ac_get_state(ac); in acpi_ac_battery_notify()
220 struct acpi_ac *ac = NULL; in acpi_ac_add() local
226 ac = kzalloc(sizeof(struct acpi_ac), GFP_KERNEL); in acpi_ac_add()
227 if (!ac) in acpi_ac_add()
230 ac->device = device; in acpi_ac_add()
233 device->driver_data = ac; in acpi_ac_add()
235 result = acpi_ac_get_state(ac); in acpi_ac_add()
239 psy_cfg.drv_data = ac; in acpi_ac_add()
241 ac->charger_desc.name = acpi_device_bid(device); in acpi_ac_add()
242 ac->charger_desc.type = POWER_SUPPLY_TYPE_MAINS; in acpi_ac_add()
243 ac->charger_desc.properties = ac_props; in acpi_ac_add()
244 ac->charger_desc.num_properties = ARRAY_SIZE(ac_props); in acpi_ac_add()
245 ac->charger_desc.get_property = get_ac_property; in acpi_ac_add()
246 ac->charger = power_supply_register(&ac->device->dev, in acpi_ac_add()
247 &ac->charger_desc, &psy_cfg); in acpi_ac_add()
248 if (IS_ERR(ac->charger)) { in acpi_ac_add()
249 result = PTR_ERR(ac->charger); in acpi_ac_add()
254 acpi_device_bid(device), ac->state ? "on-line" : "off-line"); in acpi_ac_add()
256 ac->battery_nb.notifier_call = acpi_ac_battery_notify; in acpi_ac_add()
257 register_acpi_notifier(&ac->battery_nb); in acpi_ac_add()
267 power_supply_unregister(ac->charger); in acpi_ac_add()
268 unregister_acpi_notifier(&ac->battery_nb); in acpi_ac_add()
270 kfree(ac); in acpi_ac_add()
278 struct acpi_ac *ac; in acpi_ac_resume() local
284 ac = acpi_driver_data(to_acpi_device(dev)); in acpi_ac_resume()
285 if (!ac) in acpi_ac_resume()
288 old_state = ac->state; in acpi_ac_resume()
289 if (acpi_ac_get_state(ac)) in acpi_ac_resume()
291 if (old_state != ac->state) in acpi_ac_resume()
292 kobject_uevent(&ac->charger->dev.kobj, KOBJ_CHANGE); in acpi_ac_resume()
302 struct acpi_ac *ac = NULL; in acpi_ac_remove() local
307 ac = acpi_driver_data(device); in acpi_ac_remove()
311 power_supply_unregister(ac->charger); in acpi_ac_remove()
312 unregister_acpi_notifier(&ac->battery_nb); in acpi_ac_remove()
314 kfree(ac); in acpi_ac_remove()