diff options
author | Michał Mirosław <mirq-linux@rere.qmqm.pl> | 2022-01-11 05:32:40 +0300 |
---|---|---|
committer | Sebastian Reichel <sre@kernel.org> | 2022-02-14 00:21:42 +0300 |
commit | cf215c37f581c4afd6a4880eeb9f4ac70d000c32 (patch) | |
tree | 9275ebf064e2ea00e8894ad4c208c3d9b4acf5c3 /drivers/power/supply/ltc2941-battery-gauge.c | |
parent | 8f5b373960f976cf80e54636a60637cbe9718f66 (diff) | |
download | linux-cf215c37f581c4afd6a4880eeb9f4ac70d000c32.tar.xz |
power: supply: ltc2941: simplify Qlsb calculation
Replace two divisions with a subtraction+shift for a small code size
improvement and less brackets.
Signed-off-by: Michał Mirosław <mirq-linux@rere.qmqm.pl>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
Diffstat (limited to 'drivers/power/supply/ltc2941-battery-gauge.c')
-rw-r--r-- | drivers/power/supply/ltc2941-battery-gauge.c | 8 |
1 files 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 */ |