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: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20200827215839.5pjkgyjhgs3joz6g@earth.universe>
Date:   Thu, 27 Aug 2020 23:58:39 +0200
From:   Sebastian Reichel <sre@...nel.org>
To:     Ikjoon Jang <ikjn@...omium.org>
Cc:     linux-pm@...r.kernel.org, linux-kernel@...r.kernel.org,
        drinkcat@...omium.org
Subject: Re: [PATCH v3 1/2] power: supply: sbs-battery: combine
 get_presence_and_health

Hi,

On Thu, Aug 13, 2020 at 01:10:07PM +0800, Ikjoon Jang wrote:
> This patch enables calling sbs_get_battery_presence_and_health()
> without checking its chip type. No functional changes.
> 
> Signed-off-by: Ikjoon Jang <ikjn@...omium.org>
> ---

Thanks, queued.

-- Sebastian

>  drivers/power/supply/sbs-battery.c | 73 +++++++++++++++---------------
>  1 file changed, 36 insertions(+), 37 deletions(-)
> 
> diff --git a/drivers/power/supply/sbs-battery.c b/drivers/power/supply/sbs-battery.c
> index 83b9924033bd..6acb4ea25d2a 100644
> --- a/drivers/power/supply/sbs-battery.c
> +++ b/drivers/power/supply/sbs-battery.c
> @@ -389,37 +389,6 @@ static bool sbs_bat_needs_calibration(struct i2c_client *client)
>  	return !!(ret & BIT(7));
>  }
>  
> -static int sbs_get_battery_presence_and_health(
> -	struct i2c_client *client, enum power_supply_property psp,
> -	union power_supply_propval *val)
> -{
> -	int ret;
> -
> -	/* Dummy command; if it succeeds, battery is present. */
> -	ret = sbs_read_word_data(client, sbs_data[REG_STATUS].addr);
> -
> -	if (ret < 0) { /* battery not present*/
> -		if (psp == POWER_SUPPLY_PROP_PRESENT) {
> -			val->intval = 0;
> -			return 0;
> -		}
> -		return ret;
> -	}
> -
> -	if (psp == POWER_SUPPLY_PROP_PRESENT)
> -		val->intval = 1; /* battery present */
> -	else { /* POWER_SUPPLY_PROP_HEALTH */
> -		if (sbs_bat_needs_calibration(client)) {
> -			val->intval = POWER_SUPPLY_HEALTH_CALIBRATION_REQUIRED;
> -		} else {
> -			/* SBS spec doesn't have a general health command. */
> -			val->intval = POWER_SUPPLY_HEALTH_UNKNOWN;
> -		}
> -	}
> -
> -	return 0;
> -}
> -
>  static int sbs_get_ti_battery_presence_and_health(
>  	struct i2c_client *client, enum power_supply_property psp,
>  	union power_supply_propval *val)
> @@ -478,6 +447,41 @@ static int sbs_get_ti_battery_presence_and_health(
>  	return 0;
>  }
>  
> +static int sbs_get_battery_presence_and_health(
> +	struct i2c_client *client, enum power_supply_property psp,
> +	union power_supply_propval *val)
> +{
> +	struct sbs_info *chip = i2c_get_clientdata(client);
> +	int ret;
> +
> +	if (chip->flags & SBS_FLAGS_TI_BQ20ZX5)
> +		return sbs_get_ti_battery_presence_and_health(client, psp, val);
> +
> +	/* Dummy command; if it succeeds, battery is present. */
> +	ret = sbs_read_word_data(client, sbs_data[REG_STATUS].addr);
> +
> +	if (ret < 0) { /* battery not present*/
> +		if (psp == POWER_SUPPLY_PROP_PRESENT) {
> +			val->intval = 0;
> +			return 0;
> +		}
> +		return ret;
> +	}
> +
> +	if (psp == POWER_SUPPLY_PROP_PRESENT)
> +		val->intval = 1; /* battery present */
> +	else { /* POWER_SUPPLY_PROP_HEALTH */
> +		if (sbs_bat_needs_calibration(client)) {
> +			val->intval = POWER_SUPPLY_HEALTH_CALIBRATION_REQUIRED;
> +		} else {
> +			/* SBS spec doesn't have a general health command. */
> +			val->intval = POWER_SUPPLY_HEALTH_UNKNOWN;
> +		}
> +	}
> +
> +	return 0;
> +}
> +
>  static int sbs_get_battery_property(struct i2c_client *client,
>  	int reg_offset, enum power_supply_property psp,
>  	union power_supply_propval *val)
> @@ -780,12 +784,7 @@ static int sbs_get_property(struct power_supply *psy,
>  	switch (psp) {
>  	case POWER_SUPPLY_PROP_PRESENT:
>  	case POWER_SUPPLY_PROP_HEALTH:
> -		if (chip->flags & SBS_FLAGS_TI_BQ20ZX5)
> -			ret = sbs_get_ti_battery_presence_and_health(client,
> -								     psp, val);
> -		else
> -			ret = sbs_get_battery_presence_and_health(client, psp,
> -								  val);
> +		ret = sbs_get_battery_presence_and_health(client, psp, val);
>  
>  		/* this can only be true if no gpio is used */
>  		if (psp == POWER_SUPPLY_PROP_PRESENT)
> -- 
> 2.28.0.236.gb10cc79966-goog
> 

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