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

iio: accel: sca3000: Use sign_extend32() instead of opencoding sign extension.

Whilst nice to get rid of this non obvious code, this also clears a
static checker warning:

drivers/iio/accel/sca3000.c:734 sca3000_read_raw()
warn: no-op. '((*val) << 19) >> 19'

Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Reviewed-by: Lars-Peter Clausen <lars@metafoo.de>
Link: https://lore.kernel.org/r/20211017160303.72441-1-jic23@kernel.org

+1 -2
+1 -2
drivers/iio/accel/sca3000.c
··· 731 731 return ret; 732 732 } 733 733 *val = (be16_to_cpup((__be16 *)st->rx) >> 3) & 0x1FFF; 734 - *val = ((*val) << (sizeof(*val) * 8 - 13)) >> 735 - (sizeof(*val) * 8 - 13); 734 + *val = sign_extend32(*val, 12); 736 735 } else { 737 736 /* get the temperature when available */ 738 737 ret = sca3000_read_data_short(st,