Re: [PATCH] power_supply: add CHARGE_COUNTER property and olpc_batterysupport for it

From: Richard A. Smith
Date: Tue May 13 2008 - 10:20:35 EST


Andres Salomon wrote:

+ ec_word = be16_to_cpu(ec_word);
+ val->intval = ec_word * 4167 / 10;

Whats wrong with:

> + val->intval = ((int)ec_word) * 6250 / 15;

Which does not have overflow problems and keeps more precision.

--
Richard Smith <richard@xxxxxxxxxx>
One Laptop Per Child
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/