Messages in this thread Patch in this message | | | From | Martin Kepplinger <> | Subject | [PATCH 4/4] hwmon: jc42: use bitops' sign_extend16 | Date | Wed, 14 Jan 2015 17:56:41 +0100 |
| |
Signed-off-by: Martin Kepplinger <martink@posteo.de> Reviewed-by: Guenter Roeck <linux@roeck-us.net> --- drivers/hwmon/jc42.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-)
diff --git a/drivers/hwmon/jc42.c b/drivers/hwmon/jc42.c index 388f8bc..d0582a3 100644 --- a/drivers/hwmon/jc42.c +++ b/drivers/hwmon/jc42.c @@ -31,6 +31,7 @@ #include <linux/hwmon-sysfs.h> #include <linux/err.h> #include <linux/mutex.h> +#include <linux/bitops.h> /* Addresses to scan */ static const unsigned short normal_i2c[] = { @@ -213,11 +214,7 @@ static u16 jc42_temp_to_reg(int temp, bool extended) static int jc42_temp_from_reg(s16 reg) { - reg &= 0x1fff; - - /* sign extend register */ - if (reg & 0x1000) - reg |= 0xf000; + reg = sign_extend16(reg, 12); /* convert from 0.0625 to 0.001 resolution */ return reg * 125 / 2; -- 2.1.4
| |