diff options
author | Lars-Peter Clausen <lars@metafoo.de> | 2013-06-14 16:58:00 +0100 |
---|---|---|
committer | Jonathan Cameron <jic23@kernel.org> | 2013-06-14 21:54:09 +0100 |
commit | 88198d2b4238b8f711918abe5e2b9bd7efc7c775 (patch) | |
tree | 76855324db2dcc0649d3f612d8c1d79b66dcfe05 | |
parent | 7bd49fe120622b130ca0c4675a17a53e12aba99c (diff) |
staging:iio:ad7291: Use sign_extend32 instead of open-coding it
This makes it a bit more obvious what is going on than open-coding it.
Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
-rw-r--r-- | drivers/staging/iio/adc/ad7291.c | 11 |
1 files changed, 3 insertions, 8 deletions
diff --git a/drivers/staging/iio/adc/ad7291.c b/drivers/staging/iio/adc/ad7291.c index 2a7e6a77a46b..c2709d68af69 100644 --- a/drivers/staging/iio/adc/ad7291.c +++ b/drivers/staging/iio/adc/ad7291.c @@ -275,7 +275,6 @@ static int ad7291_read_event_value(struct iio_dev *indio_dev, struct ad7291_chip_info *chip = iio_priv(indio_dev); int ret; u16 uval; - s16 signval; ret = ad7291_i2c_read(chip, ad7291_threshold_reg(event_code), &uval); if (ret < 0) @@ -286,8 +285,7 @@ static int ad7291_read_event_value(struct iio_dev *indio_dev, *val = uval & AD7291_VALUE_MASK; return 0; case IIO_TEMP: - signval = (s16)((uval & AD7291_VALUE_MASK) << 4) >> 4; - *val = signval; + *val = sign_extend32(uval, 11); return 0; default: return -EINVAL; @@ -397,7 +395,6 @@ static int ad7291_read_raw(struct iio_dev *indio_dev, int ret; struct ad7291_chip_info *chip = iio_priv(indio_dev); u16 regval; - s16 signval; switch (mask) { case IIO_CHAN_INFO_RAW: @@ -433,8 +430,7 @@ static int ad7291_read_raw(struct iio_dev *indio_dev, AD7291_T_SENSE); if (ret < 0) return ret; - signval = (s16)((ret & AD7291_VALUE_MASK) << 4) >> 4; - *val = signval; + *val = sign_extend32(ret, 11); return IIO_VAL_INT; default: return -EINVAL; @@ -444,8 +440,7 @@ static int ad7291_read_raw(struct iio_dev *indio_dev, AD7291_T_AVERAGE); if (ret < 0) return ret; - signval = (s16)((ret & AD7291_VALUE_MASK) << 4) >> 4; - *val = signval; + *val = sign_extend32(ret, 11); return IIO_VAL_INT; case IIO_CHAN_INFO_SCALE: switch (chan->type) { |