Commit cf215c37 authored by Michał Mirosław's avatar Michał Mirosław Committed by Sebastian Reichel

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: default avatarMichał Mirosław <mirq-linux@rere.qmqm.pl>
Signed-off-by: default avatarSebastian Reichel <sebastian.reichel@collabora.com>
parent 8f5b3739
......@@ -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 */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment