2021-10-08 03:06:54

by André Almeida

[permalink] [raw]
Subject: [PATCH 1/1] acpi: battery: Accept charges over the design capacity as full

Some buggy firmware and/or brand new batteries can support a charge that's
slightly over the reported design capacity. In such cases, the kernel will
report to userspace that the charging state of the battery is "Unknown",
when in reality the battery charge is "Full", at least from the design
capacity point of view. Make the fallback condition accepts capacities
over the designed capacity so userspace knows that is full.

Signed-off-by: André Almeida <[email protected]>
---
drivers/acpi/battery.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/acpi/battery.c b/drivers/acpi/battery.c
index dae91f906cea..8afa85d6eb6a 100644
--- a/drivers/acpi/battery.c
+++ b/drivers/acpi/battery.c
@@ -169,7 +169,7 @@ static int acpi_battery_is_charged(struct acpi_battery *battery)
return 1;

/* fallback to using design values for broken batteries */
- if (battery->design_capacity == battery->capacity_now)
+ if (battery->design_capacity <= battery->capacity_now)
return 1;

/* we don't do any sort of metric based on percentages */
--
2.33.0


2021-10-08 07:00:31

by Hans de Goede

[permalink] [raw]
Subject: Re: [PATCH 1/1] acpi: battery: Accept charges over the design capacity as full

Hi,

On 10/8/21 5:05 AM, André Almeida wrote:
> Some buggy firmware and/or brand new batteries can support a charge that's
> slightly over the reported design capacity. In such cases, the kernel will
> report to userspace that the charging state of the battery is "Unknown",
> when in reality the battery charge is "Full", at least from the design
> capacity point of view. Make the fallback condition accepts capacities
> over the designed capacity so userspace knows that is full.
>
> Signed-off-by: André Almeida <[email protected]>

Thanks, patch looks good to me:

Reviewed-by: Hans de Goede <[email protected]>

Regards,

Hans


> ---
> drivers/acpi/battery.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/acpi/battery.c b/drivers/acpi/battery.c
> index dae91f906cea..8afa85d6eb6a 100644
> --- a/drivers/acpi/battery.c
> +++ b/drivers/acpi/battery.c
> @@ -169,7 +169,7 @@ static int acpi_battery_is_charged(struct acpi_battery *battery)
> return 1;
>
> /* fallback to using design values for broken batteries */
> - if (battery->design_capacity == battery->capacity_now)
> + if (battery->design_capacity <= battery->capacity_now)
> return 1;
>
> /* we don't do any sort of metric based on percentages */
>

2021-10-13 11:35:59

by Sebastian Reichel

[permalink] [raw]
Subject: Re: [PATCH 1/1] acpi: battery: Accept charges over the design capacity as full

Hi,

On Fri, Oct 08, 2021 at 12:05:29AM -0300, Andr? Almeida wrote:
> Some buggy firmware and/or brand new batteries can support a charge that's
> slightly over the reported design capacity. In such cases, the kernel will
> report to userspace that the charging state of the battery is "Unknown",
> when in reality the battery charge is "Full", at least from the design
> capacity point of view. Make the fallback condition accepts capacities
> over the designed capacity so userspace knows that is full.
>
> Signed-off-by: Andr? Almeida <[email protected]>
> ---
> drivers/acpi/battery.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/acpi/battery.c b/drivers/acpi/battery.c
> index dae91f906cea..8afa85d6eb6a 100644
> --- a/drivers/acpi/battery.c
> +++ b/drivers/acpi/battery.c
> @@ -169,7 +169,7 @@ static int acpi_battery_is_charged(struct acpi_battery *battery)
> return 1;
>
> /* fallback to using design values for broken batteries */
> - if (battery->design_capacity == battery->capacity_now)
> + if (battery->design_capacity <= battery->capacity_now)
> return 1;
>
> /* we don't do any sort of metric based on percentages */

Reviewed-by: Sebastian Reichel <[email protected]>

-- Sebastian


Attachments:
(No filename) (1.27 kB)
signature.asc (849.00 B)
Download all attachments

2021-10-13 17:56:47

by Rafael J. Wysocki

[permalink] [raw]
Subject: Re: [PATCH 1/1] acpi: battery: Accept charges over the design capacity as full

On Wed, Oct 13, 2021 at 1:34 PM Sebastian Reichel
<[email protected]> wrote:
>
> Hi,
>
> On Fri, Oct 08, 2021 at 12:05:29AM -0300, André Almeida wrote:
> > Some buggy firmware and/or brand new batteries can support a charge that's
> > slightly over the reported design capacity. In such cases, the kernel will
> > report to userspace that the charging state of the battery is "Unknown",
> > when in reality the battery charge is "Full", at least from the design
> > capacity point of view. Make the fallback condition accepts capacities
> > over the designed capacity so userspace knows that is full.
> >
> > Signed-off-by: André Almeida <[email protected]>
> > ---
> > drivers/acpi/battery.c | 2 +-
> > 1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/drivers/acpi/battery.c b/drivers/acpi/battery.c
> > index dae91f906cea..8afa85d6eb6a 100644
> > --- a/drivers/acpi/battery.c
> > +++ b/drivers/acpi/battery.c
> > @@ -169,7 +169,7 @@ static int acpi_battery_is_charged(struct acpi_battery *battery)
> > return 1;
> >
> > /* fallback to using design values for broken batteries */
> > - if (battery->design_capacity == battery->capacity_now)
> > + if (battery->design_capacity <= battery->capacity_now)
> > return 1;
> >
> > /* we don't do any sort of metric based on percentages */
>
> Reviewed-by: Sebastian Reichel <[email protected]>

Applied as 5.16 material, thanks!