Skip to content

Commit

Permalink
drivers/rtc/rtc-x1205.c: use sign_extend32() for sign extension
Browse files Browse the repository at this point in the history
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 <martink@posteo.de>
Cc: Alessandro Zummo <a.zummo@towertech.it>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
  • Loading branch information
Martin Kepplinger authored and Linus Torvalds committed Apr 17, 2015
1 parent e706974 commit 86e6660
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions drivers/rtc/rtc-x1205.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include <linux/rtc.h>
#include <linux/delay.h>
#include <linux/module.h>
#include <linux/bitops.h>

#define DRV_VERSION "1.0.8"

Expand Down Expand Up @@ -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);

Expand Down

0 comments on commit 86e6660

Please sign in to comment.