Skip to content

Commit

Permalink
hwmon: (jc42) Use sign_extend32 for sign extension
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Guenter Roeck committed Jan 26, 2015
1 parent add513b commit bca6a1a
Showing 1 changed file with 1 addition and 5 deletions.
6 changes: 1 addition & 5 deletions drivers/hwmon/jc42.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit bca6a1a

Please sign in to comment.