staging: iio: cdc: ad7746: Use local buffer for multi byte reads.
authorJonathan Cameron <Jonathan.Cameron@huawei.com>
Sun, 26 Jun 2022 12:29:26 +0000 (13:29 +0100)
committerJonathan Cameron <Jonathan.Cameron@huawei.com>
Mon, 15 Aug 2022 21:30:00 +0000 (22:30 +0100)
I2C does not require DMA safe buffers so there is no need to ensure
the buffers are in their own cacheline. Hence simplify things by
using a local variable instead of embedding the buffer in the chip
info structure.

Includes a trivial whitespace cleanup to drop a line between function
and error handling.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Link: https://lore.kernel.org/r/20220626122938.582107-6-jic23@kernel.org
drivers/staging/iio/cdc/ad7746.c

index 0b5cb788abee76eca48d8c9a4dfeef7e6dccdff2..496e90f559c7d964049eeae64e22270c122830a2 100644 (file)
@@ -96,8 +96,6 @@ struct ad7746_chip_info {
        u8      vt_setup;
        u8      capdac[2][2];
        s8      capdac_set;
-
-       u8 data[3] ____cacheline_aligned;
 };
 
 enum ad7746_chan {
@@ -522,6 +520,7 @@ static int ad7746_read_raw(struct iio_dev *indio_dev,
        struct ad7746_chip_info *chip = iio_priv(indio_dev);
        int ret, delay, idx;
        u8 regval, reg;
+       u8 data[3];
 
        mutex_lock(&chip->lock);
 
@@ -544,13 +543,11 @@ static int ad7746_read_raw(struct iio_dev *indio_dev,
 
                ret = i2c_smbus_read_i2c_block_data(chip->client,
                                                    chan->address >> 8,
-                                                   sizeof(chip->data),
-                                                   chip->data);
-
+                                                   sizeof(data), data);
                if (ret < 0)
                        goto out;
 
-               *val = get_unaligned_be24(chip->data) - 0x800000;
+               *val = get_unaligned_be24(data) - 0x800000;
 
                switch (chan->type) {
                case IIO_TEMP: