Skip to content

Commit

Permalink
iio: Fix endianness issue in ak8975_read_axis()
Browse files Browse the repository at this point in the history
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>
Cc: Stable@vger.kernel.org
  • Loading branch information
Peter Meerwald authored and Jonathan Cameron committed Jun 7, 2014
1 parent 6d4eed9 commit 8ba42fb
Showing 1 changed file with 1 addition and 8 deletions.
9 changes: 1 addition & 8 deletions drivers/iio/magnetometer/ak8975.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 i2c_client *client = data->client;
u16 meas_reg;
s16 raw;
int ret;

mutex_lock(&data->lock);
Expand Down Expand Up @@ -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");
goto exit;
}
meas_reg = ret;

mutex_unlock(&data->lock);

/* Endian conversion of the measured values. */
raw = (s16) (le16_to_cpu(meas_reg));

/* Clamp to valid range. */
raw = clamp_t(s16, raw, -4096, 4095);
*val = raw;
*val = clamp_t(s16, ret, -4096, 4095);
return IIO_VAL_INT;

exit:
Expand Down

0 comments on commit 8ba42fb

Please sign in to comment.