• Home
  • Raw
  • Download

Lines Matching refs:sbs

57 	struct acpi_sbs *sbs;  member
135 struct acpi_sbs *sbs = to_acpi_sbs(psy); in sbs_get_ac_property() local
138 val->intval = sbs->charger_present; in sbs_get_ac_property()
327 static int acpi_manager_get_info(struct acpi_sbs *sbs) in acpi_manager_get_info() argument
332 result = acpi_smbus_read(sbs->hc, SMBUS_READ_WORD, ACPI_SBS_MANAGER, in acpi_manager_get_info()
335 sbs->batteries_supported = battery_system_info & 0x000f; in acpi_manager_get_info()
344 result = acpi_smbus_read(battery->sbs->hc, in acpi_battery_get_info()
365 result = acpi_smbus_read(battery->sbs->hc, in acpi_battery_get_state()
381 return acpi_smbus_read(battery->sbs->hc, SMBUS_READ_WORD, in acpi_battery_get_alarm()
388 struct acpi_sbs *sbs = battery->sbs; in acpi_battery_set_alarm() local
394 if (sbs->manager_present) { in acpi_battery_set_alarm()
395 ret = acpi_smbus_read(sbs->hc, SMBUS_READ_WORD, ACPI_SBS_MANAGER, in acpi_battery_set_alarm()
402 ret = acpi_smbus_write(sbs->hc, SMBUS_WRITE_WORD, in acpi_battery_set_alarm()
409 ret = acpi_smbus_write(sbs->hc, SMBUS_WRITE_WORD, ACPI_SBS_BATTERY, in acpi_battery_set_alarm()
415 static int acpi_ac_get_present(struct acpi_sbs *sbs) in acpi_ac_get_present() argument
420 result = acpi_smbus_read(sbs->hc, SMBUS_READ_WORD, ACPI_SBS_CHARGER, in acpi_ac_get_present()
437 sbs->charger_present = (status >> 15) & 0x1; in acpi_ac_get_present()
479 if (battery->sbs->manager_present) { in acpi_battery_read()
480 result = acpi_smbus_read(battery->sbs->hc, SMBUS_READ_WORD, in acpi_battery_read()
486 acpi_smbus_write(battery->sbs->hc, SMBUS_WRITE_WORD, in acpi_battery_read()
509 static int acpi_battery_add(struct acpi_sbs *sbs, int id) in acpi_battery_add() argument
511 struct acpi_battery *battery = &sbs->battery[id]; in acpi_battery_add()
516 battery->sbs = sbs; in acpi_battery_add()
534 battery->bat = power_supply_register(&sbs->device->dev, in acpi_battery_add()
548 ACPI_SBS_DEVICE_NAME, acpi_device_bid(sbs->device), in acpi_battery_add()
553 static void acpi_battery_remove(struct acpi_sbs *sbs, int id) in acpi_battery_remove() argument
555 struct acpi_battery *battery = &sbs->battery[id]; in acpi_battery_remove()
564 static int acpi_charger_add(struct acpi_sbs *sbs) in acpi_charger_add() argument
567 struct power_supply_config psy_cfg = { .drv_data = sbs, }; in acpi_charger_add()
569 result = acpi_ac_get_present(sbs); in acpi_charger_add()
573 sbs->charger_exists = 1; in acpi_charger_add()
574 sbs->charger = power_supply_register(&sbs->device->dev, in acpi_charger_add()
576 if (IS_ERR(sbs->charger)) { in acpi_charger_add()
577 result = PTR_ERR(sbs->charger); in acpi_charger_add()
578 sbs->charger = NULL; in acpi_charger_add()
581 ACPI_SBS_DEVICE_NAME, acpi_device_bid(sbs->device), in acpi_charger_add()
582 ACPI_AC_DIR_NAME, sbs->charger_present ? "on-line" : "off-line"); in acpi_charger_add()
587 static void acpi_charger_remove(struct acpi_sbs *sbs) in acpi_charger_remove() argument
589 if (sbs->charger) in acpi_charger_remove()
590 power_supply_unregister(sbs->charger); in acpi_charger_remove()
596 struct acpi_sbs *sbs = context; in acpi_sbs_callback() local
598 u8 saved_charger_state = sbs->charger_present; in acpi_sbs_callback()
601 if (sbs->charger_exists) { in acpi_sbs_callback()
602 acpi_ac_get_present(sbs); in acpi_sbs_callback()
603 if (sbs->charger_present != saved_charger_state) in acpi_sbs_callback()
604 kobject_uevent(&sbs->charger->dev.kobj, KOBJ_CHANGE); in acpi_sbs_callback()
607 if (sbs->manager_present) { in acpi_sbs_callback()
609 if (!(sbs->batteries_supported & (1 << id))) in acpi_sbs_callback()
611 bat = &sbs->battery[id]; in acpi_sbs_callback()
623 struct acpi_sbs *sbs; in acpi_sbs_add() local
627 sbs = kzalloc(sizeof(struct acpi_sbs), GFP_KERNEL); in acpi_sbs_add()
628 if (!sbs) { in acpi_sbs_add()
633 mutex_init(&sbs->lock); in acpi_sbs_add()
635 sbs->hc = acpi_driver_data(device->parent); in acpi_sbs_add()
636 sbs->device = device; in acpi_sbs_add()
639 device->driver_data = sbs; in acpi_sbs_add()
641 result = acpi_charger_add(sbs); in acpi_sbs_add()
648 result = acpi_manager_get_info(sbs); in acpi_sbs_add()
650 sbs->manager_present = 1; in acpi_sbs_add()
652 if ((sbs->batteries_supported & (1 << id))) in acpi_sbs_add()
653 acpi_battery_add(sbs, id); in acpi_sbs_add()
657 if (!sbs->manager_present) in acpi_sbs_add()
658 acpi_battery_add(sbs, 0); in acpi_sbs_add()
660 acpi_smbus_register_callback(sbs->hc, acpi_sbs_callback, sbs); in acpi_sbs_add()
669 struct acpi_sbs *sbs; in acpi_sbs_remove() local
674 sbs = acpi_driver_data(device); in acpi_sbs_remove()
675 if (!sbs) in acpi_sbs_remove()
677 mutex_lock(&sbs->lock); in acpi_sbs_remove()
678 acpi_smbus_unregister_callback(sbs->hc); in acpi_sbs_remove()
680 acpi_battery_remove(sbs, id); in acpi_sbs_remove()
681 acpi_charger_remove(sbs); in acpi_sbs_remove()
682 mutex_unlock(&sbs->lock); in acpi_sbs_remove()
683 mutex_destroy(&sbs->lock); in acpi_sbs_remove()
684 kfree(sbs); in acpi_sbs_remove()
691 struct acpi_sbs *sbs; in acpi_sbs_resume() local
694 sbs = to_acpi_device(dev)->driver_data; in acpi_sbs_resume()
695 acpi_sbs_callback(sbs); in acpi_sbs_resume()