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: <20220211201844.5g4x7tjpuw64hhwt@mercury.elektranox.org>
Date:   Fri, 11 Feb 2022 21:18:44 +0100
From:   Sebastian Reichel <sebastian.reichel@...labora.com>
To:     Michał Mirosław <mirq-linux@...e.qmqm.pl>
Cc:     linux-pm@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH 1/2] power: supply: ltc2941: simplify Qlsb calculation

Hi,

On Tue, Jan 11, 2022 at 03:32:40AM +0100, Michał Mirosław wrote:
> Replace two divisions with a subtraction+shift for a small code size
> improvement and less brackets.
> 
> Signed-off-by: Michał Mirosław <mirq-linux@...e.qmqm.pl>
> ---

Thanks, queued.

-- Sebastian

>  drivers/power/supply/ltc2941-battery-gauge.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/power/supply/ltc2941-battery-gauge.c b/drivers/power/supply/ltc2941-battery-gauge.c
> index 09f3e78af4e0..c0cbf4cd59ee 100644
> --- a/drivers/power/supply/ltc2941-battery-gauge.c
> +++ b/drivers/power/supply/ltc2941-battery-gauge.c
> @@ -490,13 +490,13 @@ static int ltc294x_i2c_probe(struct i2c_client *client,
>  	if (info->id == LTC2943_ID) {
>  		if (prescaler_exp > LTC2943_MAX_PRESCALER_EXP)
>  			prescaler_exp = LTC2943_MAX_PRESCALER_EXP;
> -		info->Qlsb = ((340 * 50000) / r_sense) /
> -				(4096 / (1 << (2*prescaler_exp)));
> +		info->Qlsb = ((340 * 50000) / r_sense) >>
> +			     (12 - 2*prescaler_exp);
>  	} else {
>  		if (prescaler_exp > LTC2941_MAX_PRESCALER_EXP)
>  			prescaler_exp = LTC2941_MAX_PRESCALER_EXP;
> -		info->Qlsb = ((85 * 50000) / r_sense) /
> -				(128 / (1 << prescaler_exp));
> +		info->Qlsb = ((85 * 50000) / r_sense) >>
> +			     (7 - prescaler_exp);
>  	}
>  
>  	/* Read status register to check for LTC2942 */
> -- 
> 2.30.2
> 

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