diff options
author | Kai-Heng Feng <kai.heng.feng@canonical.com> | 2017-11-21 03:33:06 -0500 |
---|---|---|
committer | Rafael J. Wysocki <rafael.j.wysocki@intel.com> | 2017-12-18 06:25:51 -0500 |
commit | c68f0676ef7df08d52a65031db3e0ba017dbfd89 (patch) | |
tree | 03f3087ebc63271a03e409e0427563ebcd6f3b4f | |
parent | 6993ce46c910ec83b4a7f064bbf76f254217019c (diff) |
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 <kai.heng.feng@canonical.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
-rw-r--r-- | drivers/acpi/battery.c | 32 |
1 files changed, 29 insertions, 3 deletions
diff --git a/drivers/acpi/battery.c b/drivers/acpi/battery.c index f2eb6c37ea0a..19bc440820e6 100644 --- a/drivers/acpi/battery.c +++ b/drivers/acpi/battery.c | |||
@@ -70,6 +70,7 @@ static async_cookie_t async_cookie; | |||
70 | static bool battery_driver_registered; | 70 | static bool battery_driver_registered; |
71 | static int battery_bix_broken_package; | 71 | static int battery_bix_broken_package; |
72 | static int battery_notification_delay_ms; | 72 | static int battery_notification_delay_ms; |
73 | static int battery_full_discharging; | ||
73 | static unsigned int cache_time = 1000; | 74 | static unsigned int cache_time = 1000; |
74 | module_param(cache_time, uint, 0644); | 75 | module_param(cache_time, uint, 0644); |
75 | MODULE_PARM_DESC(cache_time, "cache time in milliseconds"); | 76 | MODULE_PARM_DESC(cache_time, "cache time in milliseconds"); |
@@ -214,9 +215,12 @@ static int acpi_battery_get_property(struct power_supply *psy, | |||
214 | return -ENODEV; | 215 | return -ENODEV; |
215 | switch (psp) { | 216 | switch (psp) { |
216 | case POWER_SUPPLY_PROP_STATUS: | 217 | case POWER_SUPPLY_PROP_STATUS: |
217 | if (battery->state & ACPI_BATTERY_STATE_DISCHARGING) | 218 | if (battery->state & ACPI_BATTERY_STATE_DISCHARGING) { |
218 | val->intval = POWER_SUPPLY_STATUS_DISCHARGING; | 219 | if (battery_full_discharging && battery->rate_now == 0) |
219 | else if (battery->state & ACPI_BATTERY_STATE_CHARGING) | 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) | ||
220 | val->intval = POWER_SUPPLY_STATUS_CHARGING; | 224 | val->intval = POWER_SUPPLY_STATUS_CHARGING; |
221 | else if (acpi_battery_is_charged(battery)) | 225 | else if (acpi_battery_is_charged(battery)) |
222 | val->intval = POWER_SUPPLY_STATUS_FULL; | 226 | val->intval = POWER_SUPPLY_STATUS_FULL; |
@@ -1166,6 +1170,12 @@ battery_notification_delay_quirk(const struct dmi_system_id *d) | |||
1166 | return 0; | 1170 | return 0; |
1167 | } | 1171 | } |
1168 | 1172 | ||
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 | |||
1169 | static const struct dmi_system_id bat_dmi_table[] __initconst = { | 1179 | static const struct dmi_system_id bat_dmi_table[] __initconst = { |
1170 | { | 1180 | { |
1171 | .callback = battery_bix_broken_package_quirk, | 1181 | .callback = battery_bix_broken_package_quirk, |
@@ -1183,6 +1193,22 @@ static const struct dmi_system_id bat_dmi_table[] __initconst = { | |||
1183 | DMI_MATCH(DMI_PRODUCT_NAME, "Aspire V5-573G"), | 1193 | DMI_MATCH(DMI_PRODUCT_NAME, "Aspire V5-573G"), |
1184 | }, | 1194 | }, |
1185 | }, | 1195 | }, |
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 | }, | ||
1186 | {}, | 1212 | {}, |
1187 | }; | 1213 | }; |
1188 | 1214 | ||