hwmon: (jc42) Use sign_extend32 for sign extension
Guenter Roeck
maintainerPATCH 1/2 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 <[email protected]>
Signed-off-by Guenter Roeck <[email protected]>
--- drivers/hwmon/jc42.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-)
drivers/hwmon/jc42.c +1 -5
@@ -213,11 +213,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_extend32 (reg,12 );/* convert from 0.0625 to 0.001 resolution */ return reg *125 /2 ;
Signature · 7 lines
2.1.0 _______________________________________________ lm-sensors mailing list [email protected] http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
Hi Guenter,
Quoted 16 lines · Guenter Roeck
Despite the name,
sign_extend32works just fine for 16 bit variables, so it is safe to use.Cc Martin Kepplinger <[email protected]>Signed-off-by Guenter Roeck <[email protected]>--- drivers/hwmon/jc42.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-)drivers/hwmon/jc42.c +0
-0@@ -213,11 +213,7 @@ static u16 jc42_temp_to_reg(int temp, bool extended)static int jc42_temp_from_reg (s16 reg)
drivers/hwmon/jc42.c static u16 jc42_temp_to_reg(int temp, bool extended) · line 219
Quoted 10 lines
drivers/hwmon/jc42.c +1
-5{ - reg &=0x1fff ; - -/* sign extend register */ -if (reg &0x1000 ) - reg |=0xf000 ; + reg =sign_extend32 (reg,12 );/* convert from 0.0625 to 0.001 resolution */ return reg *125 /2 ;
Good idea, tested OK.
Reviewed-by Jean Delvare <[email protected]>
Signature · 7 lines
Jean Delvare SUSE L3 Support _______________________________________________ lm-sensors mailing list [email protected] http://lists.lm-sensors.org/mailman/listinfo/lm-sensors