Commit 82df3e04 authored by Martin Kepplinger's avatar Martin Kepplinger Committed by Alexandre Belloni

rtc: pcf2123: use sign_extend32() for sign extension

Use sign_extend32() instead of open coding sign extension.
Signed-off-by: default avatarMartin Kepplinger <martink@posteo.de>
Signed-off-by: default avatarAlexandre Belloni <alexandre.belloni@free-electrons.com>
parent c5776dec
...@@ -96,7 +96,7 @@ ...@@ -96,7 +96,7 @@
#define CD_TMR_TE BIT(3) /* Countdown timer enable */ #define CD_TMR_TE BIT(3) /* Countdown timer enable */
/* PCF2123_REG_OFFSET BITS */ /* PCF2123_REG_OFFSET BITS */
#define OFFSET_SIGN_BIT BIT(6) /* 2's complement sign bit */ #define OFFSET_SIGN_BIT 6 /* 2's complement sign bit */
#define OFFSET_COARSE BIT(7) /* Coarse mode offset */ #define OFFSET_COARSE BIT(7) /* Coarse mode offset */
#define OFFSET_STEP (2170) /* Offset step in parts per billion */ #define OFFSET_STEP (2170) /* Offset step in parts per billion */
...@@ -217,7 +217,7 @@ static int pcf2123_read_offset(struct device *dev, long *offset) ...@@ -217,7 +217,7 @@ static int pcf2123_read_offset(struct device *dev, long *offset)
if (reg & OFFSET_COARSE) if (reg & OFFSET_COARSE)
reg <<= 1; /* multiply by 2 and sign extend */ reg <<= 1; /* multiply by 2 and sign extend */
else else
reg |= (reg & OFFSET_SIGN_BIT) << 1; /* sign extend only */ reg = sign_extend32(reg, OFFSET_SIGN_BIT);
*offset = ((long)reg) * OFFSET_STEP; *offset = ((long)reg) * OFFSET_STEP;
......
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