Re: [PATCH] olpc_battery: Fix endian neutral breakage for s16values

From: Anton Vorontsov
Date: Fri Sep 24 2010 - 15:38:02 EST


On Fri, Sep 24, 2010 at 08:31:33PM +0100, Daniel Drake wrote:
> From: Richard A. Smith <richard@xxxxxxxxxx>
>
> When the driver was updated to be endian neutral (8e9c7716c)
> the signed part of the s16 values was lost. This is because be16_to_cpu()
> returns a signed value. This patch casts the values back to a s16 number
> prior to the the cast up to an int.
>
> Signed-off-by: Richard A. Smith <richard@xxxxxxxxxx>
> Signed-off-by: Daniel Drake <dsd@xxxxxxxxxx>

Good catch.

[...]
> - val->intval = (int)be16_to_cpu(ec_word) * 9760L / 32;
> + val->intval = (int)((s16)be16_to_cpu(ec_word)) * 9760L / 32;

Do we really need "(int)" then?

Thanks,

--
Anton Vorontsov
email: cbouatmailru@xxxxxxxxx
irc://irc.freenode.net/bd2
--
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/