From: Martin Kepplinger Date: Thu, 16 Apr 2015 19:45:09 +0000 (-0700) Subject: drivers/rtc/rtc-x1205.c: use sign_extend32() for sign extension X-Git-Tag: v4.1-rc1~102^2~95 X-Git-Url: https://asedeno.scripts.mit.edu/gitweb/?a=commitdiff_plain;h=86e66604fca053e5ecb2427538aa233637119409;p=linux.git drivers/rtc/rtc-x1205.c: use sign_extend32() for sign extension Despite its name, sign_extend32() is safe to use for 8 bit types too. (See https://lkml.org/lkml/2015/1/18/289). Signed-off-by: Martin Kepplinger Cc: Alessandro Zummo Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- diff --git a/drivers/rtc/rtc-x1205.c b/drivers/rtc/rtc-x1205.c index b1de58e0b3d0..5638b7ba8b06 100644 --- a/drivers/rtc/rtc-x1205.c +++ b/drivers/rtc/rtc-x1205.c @@ -22,6 +22,7 @@ #include #include #include +#include #define DRV_VERSION "1.0.8" @@ -366,8 +367,7 @@ static int x1205_get_atrim(struct i2c_client *client, int *trim) * perform sign extension. The formula is * Catr = (atr * 0.25pF) + 11.00pF. */ - if (atr & 0x20) - atr |= 0xC0; + atr = sign_extend32(atr, 5); dev_dbg(&client->dev, "%s: raw atr=%x (%d)\n", __func__, atr, atr);