diff options
-rw-r--r-- | drivers/staging/iio/adc/ad7280a.c | 29 |
1 files changed, 15 insertions, 14 deletions
diff --git a/drivers/staging/iio/adc/ad7280a.c b/drivers/staging/iio/adc/ad7280a.c index 89ee65bdc279..1ac11f64827c 100644 --- a/drivers/staging/iio/adc/ad7280a.c +++ b/drivers/staging/iio/adc/ad7280a.c | |||
@@ -134,6 +134,8 @@ struct ad7280_state { | |||
134 | unsigned char aux_threshhigh; | 134 | unsigned char aux_threshhigh; |
135 | unsigned char aux_threshlow; | 135 | unsigned char aux_threshlow; |
136 | unsigned char cb_mask[AD7280A_MAX_CHAIN]; | 136 | unsigned char cb_mask[AD7280A_MAX_CHAIN]; |
137 | |||
138 | __be32 buf[2] ____cacheline_aligned; | ||
137 | }; | 139 | }; |
138 | 140 | ||
139 | static void ad7280_crc8_build_table(unsigned char *crc_tab) | 141 | static void ad7280_crc8_build_table(unsigned char *crc_tab) |
@@ -189,22 +191,22 @@ static void ad7280_delay(struct ad7280_state *st) | |||
189 | msleep(1); | 191 | msleep(1); |
190 | } | 192 | } |
191 | 193 | ||
192 | static int __ad7280_read32(struct spi_device *spi, unsigned *val) | 194 | static int __ad7280_read32(struct ad7280_state *st, unsigned *val) |
193 | { | 195 | { |
194 | __be32 rx_buf, tx_buf = cpu_to_be32(AD7280A_READ_TXVAL); | ||
195 | int ret; | 196 | int ret; |
196 | |||
197 | struct spi_transfer t = { | 197 | struct spi_transfer t = { |
198 | .tx_buf = &tx_buf, | 198 | .tx_buf = &st->buf[0], |
199 | .rx_buf = &rx_buf, | 199 | .rx_buf = &st->buf[1], |
200 | .len = 4, | 200 | .len = 4, |
201 | }; | 201 | }; |
202 | 202 | ||
203 | ret = spi_sync_transfer(spi, &t, 1); | 203 | st->buf[0] = cpu_to_be32(AD7280A_READ_TXVAL); |
204 | |||
205 | ret = spi_sync_transfer(st->spi, &t, 1); | ||
204 | if (ret) | 206 | if (ret) |
205 | return ret; | 207 | return ret; |
206 | 208 | ||
207 | *val = be32_to_cpu(rx_buf); | 209 | *val = be32_to_cpu(st->buf[1]); |
208 | 210 | ||
209 | return 0; | 211 | return 0; |
210 | } | 212 | } |
@@ -214,12 +216,11 @@ static int ad7280_write(struct ad7280_state *st, unsigned devaddr, | |||
214 | { | 216 | { |
215 | unsigned reg = (devaddr << 27 | addr << 21 | | 217 | unsigned reg = (devaddr << 27 | addr << 21 | |
216 | (val & 0xFF) << 13 | all << 12); | 218 | (val & 0xFF) << 13 | all << 12); |
217 | __be32 tx_buf; | ||
218 | 219 | ||
219 | reg |= ad7280_calc_crc8(st->crc_tab, reg >> 11) << 3 | 0x2; | 220 | reg |= ad7280_calc_crc8(st->crc_tab, reg >> 11) << 3 | 0x2; |
220 | tx_buf = cpu_to_be32(reg); | 221 | st->buf[0] = cpu_to_be32(reg); |
221 | 222 | ||
222 | return spi_write(st->spi, &tx_buf, 4); | 223 | return spi_write(st->spi, &st->buf[0], 4); |
223 | } | 224 | } |
224 | 225 | ||
225 | static int ad7280_read(struct ad7280_state *st, unsigned devaddr, | 226 | static int ad7280_read(struct ad7280_state *st, unsigned devaddr, |
@@ -249,7 +250,7 @@ static int ad7280_read(struct ad7280_state *st, unsigned devaddr, | |||
249 | if (ret) | 250 | if (ret) |
250 | return ret; | 251 | return ret; |
251 | 252 | ||
252 | __ad7280_read32(st->spi, &tmp); | 253 | __ad7280_read32(st, &tmp); |
253 | 254 | ||
254 | if (ad7280_check_crc(st, tmp)) | 255 | if (ad7280_check_crc(st, tmp)) |
255 | return -EIO; | 256 | return -EIO; |
@@ -287,7 +288,7 @@ static int ad7280_read_channel(struct ad7280_state *st, unsigned devaddr, | |||
287 | 288 | ||
288 | ad7280_delay(st); | 289 | ad7280_delay(st); |
289 | 290 | ||
290 | __ad7280_read32(st->spi, &tmp); | 291 | __ad7280_read32(st, &tmp); |
291 | 292 | ||
292 | if (ad7280_check_crc(st, tmp)) | 293 | if (ad7280_check_crc(st, tmp)) |
293 | return -EIO; | 294 | return -EIO; |
@@ -320,7 +321,7 @@ static int ad7280_read_all_channels(struct ad7280_state *st, unsigned cnt, | |||
320 | ad7280_delay(st); | 321 | ad7280_delay(st); |
321 | 322 | ||
322 | for (i = 0; i < cnt; i++) { | 323 | for (i = 0; i < cnt; i++) { |
323 | __ad7280_read32(st->spi, &tmp); | 324 | __ad7280_read32(st, &tmp); |
324 | 325 | ||
325 | if (ad7280_check_crc(st, tmp)) | 326 | if (ad7280_check_crc(st, tmp)) |
326 | return -EIO; | 327 | return -EIO; |
@@ -363,7 +364,7 @@ static int ad7280_chain_setup(struct ad7280_state *st) | |||
363 | return ret; | 364 | return ret; |
364 | 365 | ||
365 | for (n = 0; n <= AD7280A_MAX_CHAIN; n++) { | 366 | for (n = 0; n <= AD7280A_MAX_CHAIN; n++) { |
366 | __ad7280_read32(st->spi, &val); | 367 | __ad7280_read32(st, &val); |
367 | if (val == 0) | 368 | if (val == 0) |
368 | return n - 1; | 369 | return n - 1; |
369 | 370 | ||