Using realbits as i2c/spi read len, when that value is not byte aligned (e.g 12 bits), lead to skip msb part of out data registers. Fix this using storagebits as read length Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@xxxxxx> --- drivers/iio/common/st_sensors/st_sensors_buffer.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/iio/common/st_sensors/st_sensors_buffer.c b/drivers/iio/common/st_sensors/st_sensors_buffer.c index fe7775b..d01aa34 100644 --- a/drivers/iio/common/st_sensors/st_sensors_buffer.c +++ b/drivers/iio/common/st_sensors/st_sensors_buffer.c @@ -30,16 +30,15 @@ static int st_sensors_get_buffer_element(struct iio_dev *indio_dev, u8 *buf) for_each_set_bit(i, indio_dev->active_scan_mask, num_data_channels) { const struct iio_chan_spec *channel = &indio_dev->channels[i]; - unsigned int bytes_to_read = channel->scan_type.realbits >> 3; unsigned int storage_bytes = channel->scan_type.storagebits >> 3; buf = PTR_ALIGN(buf, storage_bytes); if (sdata->tf->read_multiple_byte(&sdata->tb, sdata->dev, channel->address, - bytes_to_read, buf, + storage_bytes, buf, sdata->multiread_bit) < - bytes_to_read) + storage_bytes) return -EIO; /* Advance the buffer pointer */ -- 2.7.4 -- To unsubscribe from this list: send the line "unsubscribe linux-iio" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html