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

iio:adc:ti-adc084s021 Tidy up endian types

By adding a few local variables and avoiding a void * for
a parameter we can easily make all the endian types explicit and
get rid of the warnings from sparse:

CHECK drivers/iio/adc/ti-adc084s021.c
drivers/iio/adc/ti-adc084s021.c:84:26: warning: incorrect type in assignment (different base types)
drivers/iio/adc/ti-adc084s021.c:84:26: expected unsigned short [usertype]
drivers/iio/adc/ti-adc084s021.c:84:26: got restricted __be16
drivers/iio/adc/ti-adc084s021.c:115:24: warning: cast to restricted __be16
drivers/iio/adc/ti-adc084s021.c:115:24: warning: cast to restricted __be16
drivers/iio/adc/ti-adc084s021.c:115:24: warning: cast to restricted __be16
drivers/iio/adc/ti-adc084s021.c:115:24: warning: cast to restricted __be16

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Link: https://lore.kernel.org/r/20200722155103.979802-23-jic23@kernel.org

+5 -5
+5 -5
drivers/iio/adc/ti-adc084s021.c
··· 70 70 * @adc: The ADC SPI data. 71 71 * @data: Buffer for converted data. 72 72 */ 73 - static int adc084s021_adc_conversion(struct adc084s021 *adc, void *data) 73 + static int adc084s021_adc_conversion(struct adc084s021 *adc, __be16 *data) 74 74 { 75 75 int n_words = (adc->spi_trans.len >> 1) - 1; /* Discard first word */ 76 76 int ret, i = 0; 77 - u16 *p = data; 78 77 79 78 /* Do the transfer */ 80 79 ret = spi_sync(adc->spi, &adc->message); ··· 81 82 return ret; 82 83 83 84 for (; i < n_words; i++) 84 - *(p + i) = adc->rx_buf[i + 1]; 85 + *(data + i) = adc->rx_buf[i + 1]; 85 86 86 87 return ret; 87 88 } ··· 92 93 { 93 94 struct adc084s021 *adc = iio_priv(indio_dev); 94 95 int ret; 96 + __be16 be_val; 95 97 96 98 switch (mask) { 97 99 case IIO_CHAN_INFO_RAW: ··· 107 107 } 108 108 109 109 adc->tx_buf[0] = channel->channel << 3; 110 - ret = adc084s021_adc_conversion(adc, val); 110 + ret = adc084s021_adc_conversion(adc, &be_val); 111 111 iio_device_release_direct_mode(indio_dev); 112 112 regulator_disable(adc->reg); 113 113 if (ret < 0) 114 114 return ret; 115 115 116 - *val = be16_to_cpu(*val); 116 + *val = be16_to_cpu(be_val); 117 117 *val = (*val >> channel->scan_type.shift) & 0xff; 118 118 119 119 return IIO_VAL_INT;