iio: accel: sca3000: Use sign_extend32() instead of opencoding sign extension.
authorJonathan Cameron <Jonathan.Cameron@huawei.com>
Sun, 17 Oct 2021 16:03:03 +0000 (17:03 +0100)
committerJonathan Cameron <Jonathan.Cameron@huawei.com>
Wed, 20 Oct 2021 13:43:53 +0000 (14:43 +0100)
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
drivers/iio/accel/sca3000.c

index cb753a4..c6b7530 100644 (file)
@@ -731,8 +731,7 @@ static int sca3000_read_raw(struct iio_dev *indio_dev,
                                return ret;
                        }
                        *val = (be16_to_cpup((__be16 *)st->rx) >> 3) & 0x1FFF;
-                       *val = ((*val) << (sizeof(*val) * 8 - 13)) >>
-                               (sizeof(*val) * 8 - 13);
+                       *val = sign_extend32(*val, 12);
                } else {
                        /* get the temperature when available */
                        ret = sca3000_read_data_short(st,