mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-10-07 00:59:06 +00:00
drivers: iio: adc: ltc2497: fix LSB shift
commit6327a930ab
upstream. Correct the "sub_lsb" shift for the ltc2497 and drop the sub_lsb element which is now constant. An earlier version of the code shifted by 14 but this was a consequence of reading three bytes into a __be32 buffer and using be32_to_cpu(), so eight extra bits needed to be skipped. Now we use get_unaligned_be24() and thus the additional skip is wrong. Fixes:2187cfeb36
("drivers: iio: adc: ltc2497: LTC2499 support") Signed-off-by: Ian Ray <ian.ray@ge.com> Link: https://lore.kernel.org/r/20230127125714.44608-1-ian.ray@ge.com Cc: <Stable@vger.kernel.org> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
54231e3022
commit
7d797975cf
1 changed files with 2 additions and 4 deletions
|
@ -28,7 +28,6 @@ struct ltc2497_driverdata {
|
||||||
struct ltc2497core_driverdata common_ddata;
|
struct ltc2497core_driverdata common_ddata;
|
||||||
struct i2c_client *client;
|
struct i2c_client *client;
|
||||||
u32 recv_size;
|
u32 recv_size;
|
||||||
u32 sub_lsb;
|
|
||||||
/*
|
/*
|
||||||
* DMA (thus cache coherency maintenance) may require the
|
* DMA (thus cache coherency maintenance) may require the
|
||||||
* transfer buffers to live in their own cache lines.
|
* transfer buffers to live in their own cache lines.
|
||||||
|
@ -65,10 +64,10 @@ static int ltc2497_result_and_measure(struct ltc2497core_driverdata *ddata,
|
||||||
* equivalent to a sign extension.
|
* equivalent to a sign extension.
|
||||||
*/
|
*/
|
||||||
if (st->recv_size == 3) {
|
if (st->recv_size == 3) {
|
||||||
*val = (get_unaligned_be24(st->data.d8) >> st->sub_lsb)
|
*val = (get_unaligned_be24(st->data.d8) >> 6)
|
||||||
- BIT(ddata->chip_info->resolution + 1);
|
- BIT(ddata->chip_info->resolution + 1);
|
||||||
} else {
|
} else {
|
||||||
*val = (be32_to_cpu(st->data.d32) >> st->sub_lsb)
|
*val = (be32_to_cpu(st->data.d32) >> 6)
|
||||||
- BIT(ddata->chip_info->resolution + 1);
|
- BIT(ddata->chip_info->resolution + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -122,7 +121,6 @@ static int ltc2497_probe(struct i2c_client *client)
|
||||||
st->common_ddata.chip_info = chip_info;
|
st->common_ddata.chip_info = chip_info;
|
||||||
|
|
||||||
resolution = chip_info->resolution;
|
resolution = chip_info->resolution;
|
||||||
st->sub_lsb = 31 - (resolution + 1);
|
|
||||||
st->recv_size = BITS_TO_BYTES(resolution) + 1;
|
st->recv_size = BITS_TO_BYTES(resolution) + 1;
|
||||||
|
|
||||||
return ltc2497core_probe(dev, indio_dev);
|
return ltc2497core_probe(dev, indio_dev);
|
||||||
|
|
Loading…
Reference in a new issue