Skip to content

Commit c68f067

Browse files
khfengrafaeljw
authored andcommitted
ACPI / battery: Add quirk for Asus GL502VSK and UX305LA
On Asus GL502VSK and UX305LA, ACPI incorrectly reports discharging when battery is full and AC is plugged. However rate_now is correct under this circumstance, hence we can use "rate_now == 0" as a predicate to report battery full status correctly. Link: https://bugs.launchpad.net/bugs/1482390 Signed-off-by: Kai-Heng Feng <[email protected]> Signed-off-by: Rafael J. Wysocki <[email protected]>
1 parent 6993ce4 commit c68f067

File tree

1 file changed

+29
-3
lines changed

1 file changed

+29
-3
lines changed

drivers/acpi/battery.c

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ static async_cookie_t async_cookie;
7070
static bool battery_driver_registered;
7171
static int battery_bix_broken_package;
7272
static int battery_notification_delay_ms;
73+
static int battery_full_discharging;
7374
static unsigned int cache_time = 1000;
7475
module_param(cache_time, uint, 0644);
7576
MODULE_PARM_DESC(cache_time, "cache time in milliseconds");
@@ -214,9 +215,12 @@ static int acpi_battery_get_property(struct power_supply *psy,
214215
return -ENODEV;
215216
switch (psp) {
216217
case POWER_SUPPLY_PROP_STATUS:
217-
if (battery->state & ACPI_BATTERY_STATE_DISCHARGING)
218-
val->intval = POWER_SUPPLY_STATUS_DISCHARGING;
219-
else if (battery->state & ACPI_BATTERY_STATE_CHARGING)
218+
if (battery->state & ACPI_BATTERY_STATE_DISCHARGING) {
219+
if (battery_full_discharging && battery->rate_now == 0)
220+
val->intval = POWER_SUPPLY_STATUS_FULL;
221+
else
222+
val->intval = POWER_SUPPLY_STATUS_DISCHARGING;
223+
} else if (battery->state & ACPI_BATTERY_STATE_CHARGING)
220224
val->intval = POWER_SUPPLY_STATUS_CHARGING;
221225
else if (acpi_battery_is_charged(battery))
222226
val->intval = POWER_SUPPLY_STATUS_FULL;
@@ -1166,6 +1170,12 @@ battery_notification_delay_quirk(const struct dmi_system_id *d)
11661170
return 0;
11671171
}
11681172

1173+
static int __init battery_full_discharging_quirk(const struct dmi_system_id *d)
1174+
{
1175+
battery_full_discharging = 1;
1176+
return 0;
1177+
}
1178+
11691179
static const struct dmi_system_id bat_dmi_table[] __initconst = {
11701180
{
11711181
.callback = battery_bix_broken_package_quirk,
@@ -1183,6 +1193,22 @@ static const struct dmi_system_id bat_dmi_table[] __initconst = {
11831193
DMI_MATCH(DMI_PRODUCT_NAME, "Aspire V5-573G"),
11841194
},
11851195
},
1196+
{
1197+
.callback = battery_full_discharging_quirk,
1198+
.ident = "ASUS GL502VSK",
1199+
.matches = {
1200+
DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."),
1201+
DMI_MATCH(DMI_PRODUCT_NAME, "GL502VSK"),
1202+
},
1203+
},
1204+
{
1205+
.callback = battery_full_discharging_quirk,
1206+
.ident = "ASUS UX305LA",
1207+
.matches = {
1208+
DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."),
1209+
DMI_MATCH(DMI_PRODUCT_NAME, "UX305LA"),
1210+
},
1211+
},
11861212
{},
11871213
};
11881214

0 commit comments

Comments
 (0)