forked from Minki/linux
hwmon: (jc42) Use sign_extend32 for sign extension
Despite the name, sign_extend32 works just fine for 16 bit variables, so it is safe to use. Cc: Martin Kepplinger <martink@posteo.de> Reviewed-by: Jean Delvare <jdelvare@suse.de> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
This commit is contained in:
parent
add513be1c
commit
bca6a1ada0
@ -213,11 +213,7 @@ static u16 jc42_temp_to_reg(int temp, bool extended)
|
|||||||
|
|
||||||
static int jc42_temp_from_reg(s16 reg)
|
static int jc42_temp_from_reg(s16 reg)
|
||||||
{
|
{
|
||||||
reg &= 0x1fff;
|
reg = sign_extend32(reg, 12);
|
||||||
|
|
||||||
/* sign extend register */
|
|
||||||
if (reg & 0x1000)
|
|
||||||
reg |= 0xf000;
|
|
||||||
|
|
||||||
/* convert from 0.0625 to 0.001 resolution */
|
/* convert from 0.0625 to 0.001 resolution */
|
||||||
return reg * 125 / 2;
|
return reg * 125 / 2;
|
||||||
|
Loading…
Reference in New Issue
Block a user