mirror of
https://github.com/raspberrypi/linux.git
synced 2025-12-06 18:09:56 +00:00
iio: Fix endianness issue in ak8975_read_axis()
commit 8ba42fb7b1 upstream.
i2c_smbus_read_word_data() does host endian conversion already,
no need for le16_to_cpu()
Signed-off-by: Peter Meerwald <pmeerw@pmeerw.net>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
3fd2391b28
commit
9ab8ee47dd
@@ -352,8 +352,6 @@ static int ak8975_read_axis(struct iio_dev *indio_dev, int index, int *val)
|
|||||||
{
|
{
|
||||||
struct ak8975_data *data = iio_priv(indio_dev);
|
struct ak8975_data *data = iio_priv(indio_dev);
|
||||||
struct i2c_client *client = data->client;
|
struct i2c_client *client = data->client;
|
||||||
u16 meas_reg;
|
|
||||||
s16 raw;
|
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
mutex_lock(&data->lock);
|
mutex_lock(&data->lock);
|
||||||
@@ -401,16 +399,11 @@ static int ak8975_read_axis(struct iio_dev *indio_dev, int index, int *val)
|
|||||||
dev_err(&client->dev, "Read axis data fails\n");
|
dev_err(&client->dev, "Read axis data fails\n");
|
||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
meas_reg = ret;
|
|
||||||
|
|
||||||
mutex_unlock(&data->lock);
|
mutex_unlock(&data->lock);
|
||||||
|
|
||||||
/* Endian conversion of the measured values. */
|
|
||||||
raw = (s16) (le16_to_cpu(meas_reg));
|
|
||||||
|
|
||||||
/* Clamp to valid range. */
|
/* Clamp to valid range. */
|
||||||
raw = clamp_t(s16, raw, -4096, 4095);
|
*val = clamp_t(s16, ret, -4096, 4095);
|
||||||
*val = raw;
|
|
||||||
return IIO_VAL_INT;
|
return IIO_VAL_INT;
|
||||||
|
|
||||||
exit:
|
exit:
|
||||||
|
|||||||
Reference in New Issue
Block a user