* [PATCH] ACPI / battery: add quirk for Asus GL502VSK and UX305LA
@ 2017-09-22 8:27 Kai-Heng Feng
2017-10-12 5:16 ` Kai-Heng Feng
2017-11-21 1:14 ` Rafael J. Wysocki
0 siblings, 2 replies; 5+ messages in thread
From: Kai-Heng Feng @ 2017-09-22 8:27 UTC (permalink / raw)
To: rjw, lenb; +Cc: linux-acpi, linux-kernel, Kai-Heng Feng
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.
BugLink: https://bugs.launchpad.net/bugs/1482390
Signed-off-by: Kai-Heng Feng <kai.heng.feng@canonical.com>
---
drivers/acpi/battery.c | 29 ++++++++++++++++++++++++++++-
1 file changed, 28 insertions(+), 1 deletion(-)
diff --git a/drivers/acpi/battery.c b/drivers/acpi/battery.c
index 13e7b56e33ae..f9f008cf3da7 100644
--- a/drivers/acpi/battery.c
+++ b/drivers/acpi/battery.c
@@ -70,6 +70,7 @@ static async_cookie_t async_cookie;
static bool battery_driver_registered;
static int battery_bix_broken_package;
static int battery_notification_delay_ms;
+static int battery_full_discharging;
static unsigned int cache_time = 1000;
module_param(cache_time, uint, 0644);
MODULE_PARM_DESC(cache_time, "cache time in milliseconds");
@@ -214,7 +215,10 @@ static int acpi_battery_get_property(struct power_supply *psy,
return -ENODEV;
switch (psp) {
case POWER_SUPPLY_PROP_STATUS:
- if (battery->state & ACPI_BATTERY_STATE_DISCHARGING)
+ if (battery_full_discharging && battery->rate_now == 0 &&
+ battery->state & ACPI_BATTERY_STATE_DISCHARGING)
+ val->intval = POWER_SUPPLY_STATUS_FULL;
+ else if (battery->state & ACPI_BATTERY_STATE_DISCHARGING)
val->intval = POWER_SUPPLY_STATUS_DISCHARGING;
else if (battery->state & ACPI_BATTERY_STATE_CHARGING)
val->intval = POWER_SUPPLY_STATUS_CHARGING;
@@ -1166,6 +1170,13 @@ battery_notification_delay_quirk(const struct dmi_system_id *d)
return 0;
}
+static int __init
+battery_full_discharging_quirk(const struct dmi_system_id *d)
+{
+ battery_full_discharging = 1;
+ return 0;
+}
+
static const struct dmi_system_id bat_dmi_table[] __initconst = {
{
.callback = battery_bix_broken_package_quirk,
@@ -1183,6 +1194,22 @@ static const struct dmi_system_id bat_dmi_table[] __initconst = {
DMI_MATCH(DMI_PRODUCT_NAME, "Aspire V5-573G"),
},
},
+ {
+ .callback = battery_full_discharging_quirk,
+ .ident = "ASUS GL502VSK",
+ .matches = {
+ DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."),
+ DMI_MATCH(DMI_PRODUCT_NAME, "GL502VSK"),
+ },
+ },
+ {
+ .callback = battery_full_discharging_quirk,
+ .ident = "ASUS UX305LA",
+ .matches = {
+ DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."),
+ DMI_MATCH(DMI_PRODUCT_NAME, "UX305LA"),
+ },
+ },
{},
};
--
2.14.1
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] ACPI / battery: add quirk for Asus GL502VSK and UX305LA
2017-09-22 8:27 [PATCH] ACPI / battery: add quirk for Asus GL502VSK and UX305LA Kai-Heng Feng
@ 2017-10-12 5:16 ` Kai-Heng Feng
2017-11-20 8:24 ` Kai Heng Feng
2017-11-21 1:14 ` Rafael J. Wysocki
1 sibling, 1 reply; 5+ messages in thread
From: Kai-Heng Feng @ 2017-10-12 5:16 UTC (permalink / raw)
To: Rafael J. Wysocki, lenb; +Cc: linux-acpi, LKML, Kai-Heng Feng
On Fri, Sep 22, 2017 at 4:27 PM, Kai-Heng Feng
<kai.heng.feng@canonical.com> wrote:
> 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.
>
> BugLink: https://bugs.launchpad.net/bugs/1482390
> Signed-off-by: Kai-Heng Feng <kai.heng.feng@canonical.com>
> ---
> drivers/acpi/battery.c | 29 ++++++++++++++++++++++++++++-
> 1 file changed, 28 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/acpi/battery.c b/drivers/acpi/battery.c
> index 13e7b56e33ae..f9f008cf3da7 100644
> --- a/drivers/acpi/battery.c
> +++ b/drivers/acpi/battery.c
> @@ -70,6 +70,7 @@ static async_cookie_t async_cookie;
> static bool battery_driver_registered;
> static int battery_bix_broken_package;
> static int battery_notification_delay_ms;
> +static int battery_full_discharging;
> static unsigned int cache_time = 1000;
> module_param(cache_time, uint, 0644);
> MODULE_PARM_DESC(cache_time, "cache time in milliseconds");
> @@ -214,7 +215,10 @@ static int acpi_battery_get_property(struct power_supply *psy,
> return -ENODEV;
> switch (psp) {
> case POWER_SUPPLY_PROP_STATUS:
> - if (battery->state & ACPI_BATTERY_STATE_DISCHARGING)
> + if (battery_full_discharging && battery->rate_now == 0 &&
> + battery->state & ACPI_BATTERY_STATE_DISCHARGING)
> + val->intval = POWER_SUPPLY_STATUS_FULL;
> + else if (battery->state & ACPI_BATTERY_STATE_DISCHARGING)
> val->intval = POWER_SUPPLY_STATUS_DISCHARGING;
> else if (battery->state & ACPI_BATTERY_STATE_CHARGING)
> val->intval = POWER_SUPPLY_STATUS_CHARGING;
> @@ -1166,6 +1170,13 @@ battery_notification_delay_quirk(const struct dmi_system_id *d)
> return 0;
> }
>
> +static int __init
> +battery_full_discharging_quirk(const struct dmi_system_id *d)
> +{
> + battery_full_discharging = 1;
> + return 0;
> +}
> +
> static const struct dmi_system_id bat_dmi_table[] __initconst = {
> {
> .callback = battery_bix_broken_package_quirk,
> @@ -1183,6 +1194,22 @@ static const struct dmi_system_id bat_dmi_table[] __initconst = {
> DMI_MATCH(DMI_PRODUCT_NAME, "Aspire V5-573G"),
> },
> },
> + {
> + .callback = battery_full_discharging_quirk,
> + .ident = "ASUS GL502VSK",
> + .matches = {
> + DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."),
> + DMI_MATCH(DMI_PRODUCT_NAME, "GL502VSK"),
> + },
> + },
> + {
> + .callback = battery_full_discharging_quirk,
> + .ident = "ASUS UX305LA",
> + .matches = {
> + DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."),
> + DMI_MATCH(DMI_PRODUCT_NAME, "UX305LA"),
> + },
> + },
> {},
> };
>
Hi,
Is there any improvement I can make for this patch?
> --
> 2.14.1
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] ACPI / battery: add quirk for Asus GL502VSK and UX305LA
2017-10-12 5:16 ` Kai-Heng Feng
@ 2017-11-20 8:24 ` Kai Heng Feng
2017-11-20 14:18 ` Rafael J. Wysocki
0 siblings, 1 reply; 5+ messages in thread
From: Kai Heng Feng @ 2017-11-20 8:24 UTC (permalink / raw)
To: Rafael J. Wysocki, lenb; +Cc: linux-acpi, LKML
> On 12 Oct 2017, at 1:16 PM, Kai-Heng Feng <kai.heng.feng@canonical.com> wrote:
>
> On Fri, Sep 22, 2017 at 4:27 PM, Kai-Heng Feng
> <kai.heng.feng@canonical.com> wrote:
>> 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.
>>
>> BugLink: https://bugs.launchpad.net/bugs/1482390
>> Signed-off-by: Kai-Heng Feng <kai.heng.feng@canonical.com>
>> ---
>> drivers/acpi/battery.c | 29 ++++++++++++++++++++++++++++-
>> 1 file changed, 28 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/acpi/battery.c b/drivers/acpi/battery.c
>> index 13e7b56e33ae..f9f008cf3da7 100644
>> --- a/drivers/acpi/battery.c
>> +++ b/drivers/acpi/battery.c
>> @@ -70,6 +70,7 @@ static async_cookie_t async_cookie;
>> static bool battery_driver_registered;
>> static int battery_bix_broken_package;
>> static int battery_notification_delay_ms;
>> +static int battery_full_discharging;
>> static unsigned int cache_time = 1000;
>> module_param(cache_time, uint, 0644);
>> MODULE_PARM_DESC(cache_time, "cache time in milliseconds");
>> @@ -214,7 +215,10 @@ static int acpi_battery_get_property(struct power_supply *psy,
>> return -ENODEV;
>> switch (psp) {
>> case POWER_SUPPLY_PROP_STATUS:
>> - if (battery->state & ACPI_BATTERY_STATE_DISCHARGING)
>> + if (battery_full_discharging && battery->rate_now == 0 &&
>> + battery->state & ACPI_BATTERY_STATE_DISCHARGING)
>> + val->intval = POWER_SUPPLY_STATUS_FULL;
>> + else if (battery->state & ACPI_BATTERY_STATE_DISCHARGING)
>> val->intval = POWER_SUPPLY_STATUS_DISCHARGING;
>> else if (battery->state & ACPI_BATTERY_STATE_CHARGING)
>> val->intval = POWER_SUPPLY_STATUS_CHARGING;
>> @@ -1166,6 +1170,13 @@ battery_notification_delay_quirk(const struct dmi_system_id *d)
>> return 0;
>> }
>>
>> +static int __init
>> +battery_full_discharging_quirk(const struct dmi_system_id *d)
>> +{
>> + battery_full_discharging = 1;
>> + return 0;
>> +}
>> +
>> static const struct dmi_system_id bat_dmi_table[] __initconst = {
>> {
>> .callback = battery_bix_broken_package_quirk,
>> @@ -1183,6 +1194,22 @@ static const struct dmi_system_id bat_dmi_table[] __initconst = {
>> DMI_MATCH(DMI_PRODUCT_NAME, "Aspire V5-573G"),
>> },
>> },
>> + {
>> + .callback = battery_full_discharging_quirk,
>> + .ident = "ASUS GL502VSK",
>> + .matches = {
>> + DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."),
>> + DMI_MATCH(DMI_PRODUCT_NAME, "GL502VSK"),
>> + },
>> + },
>> + {
>> + .callback = battery_full_discharging_quirk,
>> + .ident = "ASUS UX305LA",
>> + .matches = {
>> + DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."),
>> + DMI_MATCH(DMI_PRODUCT_NAME, "UX305LA"),
>> + },
>> + },
>> {},
>> };
>>
>
> Hi,
>
> Is there any improvement I can make for this patch?
Another gentle ping…
>
>> --
>> 2.14.1
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] ACPI / battery: add quirk for Asus GL502VSK and UX305LA
2017-11-20 8:24 ` Kai Heng Feng
@ 2017-11-20 14:18 ` Rafael J. Wysocki
0 siblings, 0 replies; 5+ messages in thread
From: Rafael J. Wysocki @ 2017-11-20 14:18 UTC (permalink / raw)
To: Kai Heng Feng; +Cc: lenb, linux-acpi, LKML
On Monday, November 20, 2017 9:24:32 AM CET Kai Heng Feng wrote:
>
> > On 12 Oct 2017, at 1:16 PM, Kai-Heng Feng <kai.heng.feng@canonical.com> wrote:
> >
> > On Fri, Sep 22, 2017 at 4:27 PM, Kai-Heng Feng
> > <kai.heng.feng@canonical.com> wrote:
> >> 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.
> >>
> >> BugLink: https://bugs.launchpad.net/bugs/1482390
> >> Signed-off-by: Kai-Heng Feng <kai.heng.feng@canonical.com>
> >> ---
> >> drivers/acpi/battery.c | 29 ++++++++++++++++++++++++++++-
> >> 1 file changed, 28 insertions(+), 1 deletion(-)
> >>
> >> diff --git a/drivers/acpi/battery.c b/drivers/acpi/battery.c
> >> index 13e7b56e33ae..f9f008cf3da7 100644
> >> --- a/drivers/acpi/battery.c
> >> +++ b/drivers/acpi/battery.c
> >> @@ -70,6 +70,7 @@ static async_cookie_t async_cookie;
> >> static bool battery_driver_registered;
> >> static int battery_bix_broken_package;
> >> static int battery_notification_delay_ms;
> >> +static int battery_full_discharging;
> >> static unsigned int cache_time = 1000;
> >> module_param(cache_time, uint, 0644);
> >> MODULE_PARM_DESC(cache_time, "cache time in milliseconds");
> >> @@ -214,7 +215,10 @@ static int acpi_battery_get_property(struct power_supply *psy,
> >> return -ENODEV;
> >> switch (psp) {
> >> case POWER_SUPPLY_PROP_STATUS:
> >> - if (battery->state & ACPI_BATTERY_STATE_DISCHARGING)
> >> + if (battery_full_discharging && battery->rate_now == 0 &&
> >> + battery->state & ACPI_BATTERY_STATE_DISCHARGING)
> >> + val->intval = POWER_SUPPLY_STATUS_FULL;
> >> + else if (battery->state & ACPI_BATTERY_STATE_DISCHARGING)
> >> val->intval = POWER_SUPPLY_STATUS_DISCHARGING;
> >> else if (battery->state & ACPI_BATTERY_STATE_CHARGING)
> >> val->intval = POWER_SUPPLY_STATUS_CHARGING;
> >> @@ -1166,6 +1170,13 @@ battery_notification_delay_quirk(const struct dmi_system_id *d)
> >> return 0;
> >> }
> >>
> >> +static int __init
> >> +battery_full_discharging_quirk(const struct dmi_system_id *d)
> >> +{
> >> + battery_full_discharging = 1;
> >> + return 0;
> >> +}
> >> +
> >> static const struct dmi_system_id bat_dmi_table[] __initconst = {
> >> {
> >> .callback = battery_bix_broken_package_quirk,
> >> @@ -1183,6 +1194,22 @@ static const struct dmi_system_id bat_dmi_table[] __initconst = {
> >> DMI_MATCH(DMI_PRODUCT_NAME, "Aspire V5-573G"),
> >> },
> >> },
> >> + {
> >> + .callback = battery_full_discharging_quirk,
> >> + .ident = "ASUS GL502VSK",
> >> + .matches = {
> >> + DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."),
> >> + DMI_MATCH(DMI_PRODUCT_NAME, "GL502VSK"),
> >> + },
> >> + },
> >> + {
> >> + .callback = battery_full_discharging_quirk,
> >> + .ident = "ASUS UX305LA",
> >> + .matches = {
> >> + DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."),
> >> + DMI_MATCH(DMI_PRODUCT_NAME, "UX305LA"),
> >> + },
> >> + },
> >> {},
> >> };
> >>
> >
> > Hi,
> >
> > Is there any improvement I can make for this patch?
>
> Another gentle ping…
Sorry for the delay.
I've a couple of comments, I'll respond to the original patch later today.
Thanks,
Rafael
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] ACPI / battery: add quirk for Asus GL502VSK and UX305LA
2017-09-22 8:27 [PATCH] ACPI / battery: add quirk for Asus GL502VSK and UX305LA Kai-Heng Feng
2017-10-12 5:16 ` Kai-Heng Feng
@ 2017-11-21 1:14 ` Rafael J. Wysocki
1 sibling, 0 replies; 5+ messages in thread
From: Rafael J. Wysocki @ 2017-11-21 1:14 UTC (permalink / raw)
To: Kai-Heng Feng; +Cc: lenb, linux-acpi, linux-kernel
On Friday, September 22, 2017 10:27:44 AM CET Kai-Heng Feng wrote:
> 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.
>
> BugLink: https://bugs.launchpad.net/bugs/1482390
> Signed-off-by: Kai-Heng Feng <kai.heng.feng@canonical.com>
> ---
> drivers/acpi/battery.c | 29 ++++++++++++++++++++++++++++-
> 1 file changed, 28 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/acpi/battery.c b/drivers/acpi/battery.c
> index 13e7b56e33ae..f9f008cf3da7 100644
> --- a/drivers/acpi/battery.c
> +++ b/drivers/acpi/battery.c
> @@ -70,6 +70,7 @@ static async_cookie_t async_cookie;
> static bool battery_driver_registered;
> static int battery_bix_broken_package;
> static int battery_notification_delay_ms;
> +static int battery_full_discharging;
> static unsigned int cache_time = 1000;
> module_param(cache_time, uint, 0644);
> MODULE_PARM_DESC(cache_time, "cache time in milliseconds");
> @@ -214,7 +215,10 @@ static int acpi_battery_get_property(struct power_supply *psy,
> return -ENODEV;
> switch (psp) {
> case POWER_SUPPLY_PROP_STATUS:
> - if (battery->state & ACPI_BATTERY_STATE_DISCHARGING)
> + if (battery_full_discharging && battery->rate_now == 0 &&
> + battery->state & ACPI_BATTERY_STATE_DISCHARGING)
> + val->intval = POWER_SUPPLY_STATUS_FULL;
> + else if (battery->state & ACPI_BATTERY_STATE_DISCHARGING)
You are adding a special sub-case to the
(battery->state & ACPI_BATTERY_STATE_DISCHARGING) case, so it would be cleaner
to do that in the following way:
if (battery->state & ACPI_BATTERY_STATE_DISCHARGING) {
if (battery_full_discharging && battery->rate_now == 0)
val->intval = POWER_SUPPLY_STATUS_FULL;
else
val->intval = POWER_SUPPLY_STATUS_DISCHARGING;
} else if (battery->state & ACPI_BATTERY_STATE_CHARGING) {
val->intval = POWER_SUPPLY_STATUS_CHARGING;
}
> val->intval = POWER_SUPPLY_STATUS_DISCHARGING;
> else if (battery->state & ACPI_BATTERY_STATE_CHARGING)
> val->intval = POWER_SUPPLY_STATUS_CHARGING;
> @@ -1166,6 +1170,13 @@ battery_notification_delay_quirk(const struct dmi_system_id *d)
> return 0;
> }
>
> +static int __init
> +battery_full_discharging_quirk(const struct dmi_system_id *d)
> +{
> + battery_full_discharging = 1;
> + return 0;
> +}
> +
> static const struct dmi_system_id bat_dmi_table[] __initconst = {
> {
> .callback = battery_bix_broken_package_quirk,
> @@ -1183,6 +1194,22 @@ static const struct dmi_system_id bat_dmi_table[] __initconst = {
> DMI_MATCH(DMI_PRODUCT_NAME, "Aspire V5-573G"),
> },
> },
> + {
> + .callback = battery_full_discharging_quirk,
> + .ident = "ASUS GL502VSK",
> + .matches = {
> + DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."),
> + DMI_MATCH(DMI_PRODUCT_NAME, "GL502VSK"),
> + },
> + },
> + {
> + .callback = battery_full_discharging_quirk,
> + .ident = "ASUS UX305LA",
> + .matches = {
> + DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."),
> + DMI_MATCH(DMI_PRODUCT_NAME, "UX305LA"),
> + },
> + },
> {},
> };
>
>
Thanks,
Rafael
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2017-11-21 1:15 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-09-22 8:27 [PATCH] ACPI / battery: add quirk for Asus GL502VSK and UX305LA Kai-Heng Feng
2017-10-12 5:16 ` Kai-Heng Feng
2017-11-20 8:24 ` Kai Heng Feng
2017-11-20 14:18 ` Rafael J. Wysocki
2017-11-21 1:14 ` Rafael J. Wysocki
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®