Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

iio:ad7266: Mark transfer buffer as __be16

Fixes the following warnings from sparse:
drivers/iio/adc/ad7266.c:140:16: warning: cast to restricted __be16
drivers/iio/adc/ad7266.c:140:16: warning: cast to restricted __be16
drivers/iio/adc/ad7266.c:140:16: warning: cast to restricted __be16
drivers/iio/adc/ad7266.c:140:16: warning: cast to restricted __be16

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>

authored by

Lars-Peter Clausen and committed by
Jonathan Cameron
54e018da 791bb52a

+12 -9
+12 -9
drivers/iio/adc/ad7266.c
··· 43 43 * The buffer needs to be large enough to hold two samples (4 bytes) and 44 44 * the naturally aligned timestamp (8 bytes). 45 45 */ 46 - uint8_t data[ALIGN(4, sizeof(s64)) + sizeof(s64)] ____cacheline_aligned; 46 + struct { 47 + __be16 sample[2]; 48 + s64 timestamp; 49 + } data ____cacheline_aligned; 47 50 }; 48 51 49 52 static int ad7266_wakeup(struct ad7266_state *st) 50 53 { 51 54 /* Any read with >= 2 bytes will wake the device */ 52 - return spi_read(st->spi, st->data, 2); 55 + return spi_read(st->spi, &st->data.sample[0], 2); 53 56 } 54 57 55 58 static int ad7266_powerdown(struct ad7266_state *st) 56 59 { 57 60 /* Any read with < 2 bytes will powerdown the device */ 58 - return spi_read(st->spi, st->data, 1); 61 + return spi_read(st->spi, &st->data.sample[0], 1); 59 62 } 60 63 61 64 static int ad7266_preenable(struct iio_dev *indio_dev) ··· 87 84 struct ad7266_state *st = iio_priv(indio_dev); 88 85 int ret; 89 86 90 - ret = spi_read(st->spi, st->data, 4); 87 + ret = spi_read(st->spi, st->data.sample, 4); 91 88 if (ret == 0) { 92 - iio_push_to_buffers_with_timestamp(indio_dev, st->data, 89 + iio_push_to_buffers_with_timestamp(indio_dev, &st->data, 93 90 pf->timestamp); 94 91 } 95 92 ··· 140 137 ad7266_select_input(st, address); 141 138 142 139 ret = spi_sync(st->spi, &st->single_msg); 143 - *val = be16_to_cpu(st->data[address % 2]); 140 + *val = be16_to_cpu(st->data.sample[address % 2]); 144 141 145 142 return ret; 146 143 } ··· 445 442 ad7266_init_channels(indio_dev); 446 443 447 444 /* wakeup */ 448 - st->single_xfer[0].rx_buf = &st->data; 445 + st->single_xfer[0].rx_buf = &st->data.sample[0]; 449 446 st->single_xfer[0].len = 2; 450 447 st->single_xfer[0].cs_change = 1; 451 448 /* conversion */ 452 - st->single_xfer[1].rx_buf = &st->data; 449 + st->single_xfer[1].rx_buf = st->data.sample; 453 450 st->single_xfer[1].len = 4; 454 451 st->single_xfer[1].cs_change = 1; 455 452 /* powerdown */ 456 - st->single_xfer[2].tx_buf = &st->data; 453 + st->single_xfer[2].tx_buf = &st->data.sample[0]; 457 454 st->single_xfer[2].len = 1; 458 455 459 456 spi_message_init(&st->single_msg);