Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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 <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>

authored by

Martin Kepplinger and committed by
Linus Torvalds
86e66604 e706974d

+2 -2
+2 -2
drivers/rtc/rtc-x1205.c
··· 22 22 #include <linux/rtc.h> 23 23 #include <linux/delay.h> 24 24 #include <linux/module.h> 25 + #include <linux/bitops.h> 25 26 26 27 #define DRV_VERSION "1.0.8" 27 28 ··· 367 366 * perform sign extension. The formula is 368 367 * Catr = (atr * 0.25pF) + 11.00pF. 369 368 */ 370 - if (atr & 0x20) 371 - atr |= 0xC0; 369 + atr = sign_extend32(atr, 5); 372 370 373 371 dev_dbg(&client->dev, "%s: raw atr=%x (%d)\n", __func__, atr, atr); 374 372