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] [thread-next>] [day] [month] [year] [list]
Message-ID: <b5mhivpuhyfj3knw3w5wmi2kxyyej7cdnh3kd6wyenumfy7qpr@vnfvfj5gsmtx>
Date: Wed, 11 Dec 2024 02:38:03 +0100
From: Sebastian Reichel <sebastian.reichel@...labora.com>
To: Kim Seer Paller <kimseer.paller@...log.com>
Cc: Rob Herring <robh@...nel.org>, 
	Krzysztof Kozlowski <krzk+dt@...nel.org>, Conor Dooley <conor+dt@...nel.org>, 
	Mike Looijmans <mike.looijmans@...ic.nl>, linux-pm@...r.kernel.org, devicetree@...r.kernel.org, 
	linux-kernel@...r.kernel.org
Subject: Re: [PATCH v5 2/2] power/supply: Add support for ltc4162-f/s and
 ltc4015

Hi,

On Tue, Dec 10, 2024 at 02:05:06PM +0800, Kim Seer Paller wrote:
>  static int ltc4162l_get_ibat(struct ltc4162l_info *info,
>  			     union power_supply_propval *val)
>  {
> +	const struct ltc4162l_chip_info *chip_info = info->chip_info;
>  	unsigned int regval;
>  	int ret;
>  
> @@ -249,9 +356,8 @@ static int ltc4162l_get_ibat(struct ltc4162l_info *info,
>  	if (ret)
>  		return ret;
>  
> -	/* Signed 16-bit number, 1.466μV / RSNSB amperes/LSB. */
>  	ret = (s16)(regval & 0xFFFF);
> -	val->intval = 100 * mult_frac(ret, 14660, (int)info->rsnsb);
> +	val->intval = mult_frac(ret, chip_info->ibat_resolution_uv, info->rsnsb);

ibat_resolution_uv is in picovolt as far as I can see:

1.466 uV / RSNSB = 1466 nV / RSNSB = 1466000 pV / RSNSB

RSNSB is provided in microOhm and picoVolt / microOhm equals
microAmp, which is the unit expected by the power-supply
subsystem.

>  	return 0;
>  }
> @@ -260,6 +366,7 @@ static int ltc4162l_get_ibat(struct ltc4162l_info *info,
>  static int ltc4162l_get_input_voltage(struct ltc4162l_info *info,
>  				      union power_supply_propval *val)
>  {
> +	const struct ltc4162l_chip_info *chip_info = info->chip_info;
>  	unsigned int regval;
>  	int ret;
>  
> @@ -267,8 +374,7 @@ static int ltc4162l_get_input_voltage(struct ltc4162l_info *info,
>  	if (ret)
>  		return ret;
>  
> -	/* 1.649mV/LSB */
> -	val->intval =  regval * 1694;
> +	val->intval =  regval * chip_info->vin_resolution_mv;

I believe it should be vin_resolution_uv. Microvolt is what the
power-supply subsystem wants and 1.649 mV (from the comment above) is
1649 uV (from the chip_info->vin_resolution_mv value) :)

>  
>  	return 0;
>  }

Otherwise LGTM.

-- Sebastian

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