lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20230203123735.g727eokllnqxqxft@mercury.elektranox.org>
Date:   Fri, 3 Feb 2023 13:37:35 +0100
From:   Sebastian Reichel <sebastian.reichel@...labora.com>
To:     "Sicelo A. Mhlongo" <absicsz@...il.com>
Cc:     linux-pm@...r.kernel.org, pali@...nel.org, brauner@...nel.org,
        linux-kernel@...r.kernel.org
Subject: Re: [PATCH 1/1] power: supply: bq27xxx: fix reporting critical level

Hi,

On Mon, Jan 02, 2023 at 11:13:26AM +0200, Sicelo A. Mhlongo wrote:
> The EDV1/SOC1 flag is set when the battery voltage drops below the
> threshold set in EEPROM. From observing the capacity_level reported by
> the driver, and reading the datasheet, EDV1 remains set even when
> EDVF/SOCF gets set. Thus, bq27xxx_battery_capacity_level() never reaches
> the CAPACITY_LEVEL_CRITICAL code path, since CAPACITY_LEVEL_LOW takes
> precedence.
> 
> This commit fixes the issue by swapping the order in which the flags are
> tested. It was tested with bq27200 in the Nokia N900.
> 
> Signed-off-by: Sicelo A. Mhlongo <absicsz@...il.com>
> ---

Thanks, queued.

-- Sebastian

>  drivers/power/supply/bq27xxx_battery.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/power/supply/bq27xxx_battery.c b/drivers/power/supply/bq27xxx_battery.c
> index 8bf048fbd36a..5ff6f44fd47b 100644
> --- a/drivers/power/supply/bq27xxx_battery.c
> +++ b/drivers/power/supply/bq27xxx_battery.c
> @@ -1917,10 +1917,10 @@ static int bq27xxx_battery_capacity_level(struct bq27xxx_device_info *di,
>  	if (di->opts & BQ27XXX_O_ZERO) {
>  		if (di->cache.flags & BQ27000_FLAG_FC)
>  			level = POWER_SUPPLY_CAPACITY_LEVEL_FULL;
> -		else if (di->cache.flags & BQ27000_FLAG_EDV1)
> -			level = POWER_SUPPLY_CAPACITY_LEVEL_LOW;
>  		else if (di->cache.flags & BQ27000_FLAG_EDVF)
>  			level = POWER_SUPPLY_CAPACITY_LEVEL_CRITICAL;
> +		else if (di->cache.flags & BQ27000_FLAG_EDV1)
> +			level = POWER_SUPPLY_CAPACITY_LEVEL_LOW;
>  		else
>  			level = POWER_SUPPLY_CAPACITY_LEVEL_NORMAL;
>  	} else if (di->opts & BQ27Z561_O_BITS) {
> @@ -1933,10 +1933,10 @@ static int bq27xxx_battery_capacity_level(struct bq27xxx_device_info *di,
>  	} else {
>  		if (di->cache.flags & BQ27XXX_FLAG_FC)
>  			level = POWER_SUPPLY_CAPACITY_LEVEL_FULL;
> -		else if (di->cache.flags & BQ27XXX_FLAG_SOC1)
> -			level = POWER_SUPPLY_CAPACITY_LEVEL_LOW;
>  		else if (di->cache.flags & BQ27XXX_FLAG_SOCF)
>  			level = POWER_SUPPLY_CAPACITY_LEVEL_CRITICAL;
> +		else if (di->cache.flags & BQ27XXX_FLAG_SOC1)
> +			level = POWER_SUPPLY_CAPACITY_LEVEL_LOW;
>  		else
>  			level = POWER_SUPPLY_CAPACITY_LEVEL_NORMAL;
>  	}
> -- 
> 2.39.0
> 

Download attachment "signature.asc" of type "application/pgp-signature" (834 bytes)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ