When battery state changes (i. e. it starts to charge/discharge), it could indicate that AC adapter has been plugged or unplugged. When POWER_SUPPLY_PROP_ONLINE is read, AC driver should check actual adapter state, and emit notification if the state has changed (my previous patch). This patch finally solves the problem with AC notifications on my HP Pavilion dv6-6179er. Signed-off-by: Alexander Mezin <mezin.alexander@xxxxxxxxx> --- drivers/acpi/battery.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/drivers/acpi/battery.c b/drivers/acpi/battery.c index 470e754..68b263c 100644 --- a/drivers/acpi/battery.c +++ b/drivers/acpi/battery.c @@ -671,9 +671,22 @@ static void acpi_battery_quirks(struct acpi_battery *battery) } } +static int acpi_battery_check_ac_state(struct device *dev, void *unused) +{ + struct power_supply *ps = dev_get_drvdata(dev); + union power_supply_propval temp; + + if (ps->type != POWER_SUPPLY_TYPE_MAINS) + return 0; + + ps->get_property(ps, POWER_SUPPLY_PROP_ONLINE, &temp); + return 0; +} + static int acpi_battery_update(struct acpi_battery *battery) { int result, old_present = acpi_battery_present(battery); + int old_state = battery->state; result = acpi_battery_get_status(battery); if (result) return result; @@ -696,6 +709,15 @@ static int acpi_battery_update(struct acpi_battery *battery) } result = acpi_battery_get_state(battery); acpi_battery_quirks(battery); + if (old_state != battery->state) + /* + * Some BIOSes don't send notifications when ac adapter + * is plugged or unplugged. + * If battery changes its state, this could indicate that + * AC adapter's state has changed too. + */ + class_for_each_device(power_supply_class, NULL, NULL, + &acpi_battery_check_ac_state); return result; } -- 1.8.5.4 -- To unsubscribe from this list: send the line "unsubscribe linux-acpi" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html