diff options
author | Lars-Peter Clausen <lars@metafoo.de> | 2013-01-09 12:31:00 -0500 |
---|---|---|
committer | Jonathan Cameron <jic23@kernel.org> | 2013-02-09 06:08:42 -0500 |
commit | 14543a00fc3ce6dac9f297535c502a0085a50467 (patch) | |
tree | 1c244bcc56bd4a48ee2c305856457d102d6eccbe /drivers/iio/frequency | |
parent | 6d9eecd418afb2c12e5db5be3d72f0f1df43bdd9 (diff) |
iio: Use spi_sync_transfer()
Use the new spi_sync_transfer() helper function instead of open-coding it.
Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Diffstat (limited to 'drivers/iio/frequency')
-rw-r--r-- | drivers/iio/frequency/ad9523.c | 14 |
1 files changed, 2 insertions, 12 deletions
diff --git a/drivers/iio/frequency/ad9523.c b/drivers/iio/frequency/ad9523.c index 80307473e3a9..1ea132e239ea 100644 --- a/drivers/iio/frequency/ad9523.c +++ b/drivers/iio/frequency/ad9523.c | |||
@@ -287,7 +287,6 @@ struct ad9523_state { | |||
287 | static int ad9523_read(struct iio_dev *indio_dev, unsigned addr) | 287 | static int ad9523_read(struct iio_dev *indio_dev, unsigned addr) |
288 | { | 288 | { |
289 | struct ad9523_state *st = iio_priv(indio_dev); | 289 | struct ad9523_state *st = iio_priv(indio_dev); |
290 | struct spi_message m; | ||
291 | int ret; | 290 | int ret; |
292 | 291 | ||
293 | /* We encode the register size 1..3 bytes into the register address. | 292 | /* We encode the register size 1..3 bytes into the register address. |
@@ -305,15 +304,11 @@ static int ad9523_read(struct iio_dev *indio_dev, unsigned addr) | |||
305 | }, | 304 | }, |
306 | }; | 305 | }; |
307 | 306 | ||
308 | spi_message_init(&m); | ||
309 | spi_message_add_tail(&t[0], &m); | ||
310 | spi_message_add_tail(&t[1], &m); | ||
311 | |||
312 | st->data[0].d32 = cpu_to_be32(AD9523_READ | | 307 | st->data[0].d32 = cpu_to_be32(AD9523_READ | |
313 | AD9523_CNT(AD9523_TRANSF_LEN(addr)) | | 308 | AD9523_CNT(AD9523_TRANSF_LEN(addr)) | |
314 | AD9523_ADDR(addr)); | 309 | AD9523_ADDR(addr)); |
315 | 310 | ||
316 | ret = spi_sync(st->spi, &m); | 311 | ret = spi_sync_transfer(st->spi, t, ARRAY_SIZE(t)); |
317 | if (ret < 0) | 312 | if (ret < 0) |
318 | dev_err(&indio_dev->dev, "read failed (%d)", ret); | 313 | dev_err(&indio_dev->dev, "read failed (%d)", ret); |
319 | else | 314 | else |
@@ -326,7 +321,6 @@ static int ad9523_read(struct iio_dev *indio_dev, unsigned addr) | |||
326 | static int ad9523_write(struct iio_dev *indio_dev, unsigned addr, unsigned val) | 321 | static int ad9523_write(struct iio_dev *indio_dev, unsigned addr, unsigned val) |
327 | { | 322 | { |
328 | struct ad9523_state *st = iio_priv(indio_dev); | 323 | struct ad9523_state *st = iio_priv(indio_dev); |
329 | struct spi_message m; | ||
330 | int ret; | 324 | int ret; |
331 | struct spi_transfer t[] = { | 325 | struct spi_transfer t[] = { |
332 | { | 326 | { |
@@ -338,16 +332,12 @@ static int ad9523_write(struct iio_dev *indio_dev, unsigned addr, unsigned val) | |||
338 | }, | 332 | }, |
339 | }; | 333 | }; |
340 | 334 | ||
341 | spi_message_init(&m); | ||
342 | spi_message_add_tail(&t[0], &m); | ||
343 | spi_message_add_tail(&t[1], &m); | ||
344 | |||
345 | st->data[0].d32 = cpu_to_be32(AD9523_WRITE | | 335 | st->data[0].d32 = cpu_to_be32(AD9523_WRITE | |
346 | AD9523_CNT(AD9523_TRANSF_LEN(addr)) | | 336 | AD9523_CNT(AD9523_TRANSF_LEN(addr)) | |
347 | AD9523_ADDR(addr)); | 337 | AD9523_ADDR(addr)); |
348 | st->data[1].d32 = cpu_to_be32(val); | 338 | st->data[1].d32 = cpu_to_be32(val); |
349 | 339 | ||
350 | ret = spi_sync(st->spi, &m); | 340 | ret = spi_sync_transfer(st->spi, t, ARRAY_SIZE(t)); |
351 | 341 | ||
352 | if (ret < 0) | 342 | if (ret < 0) |
353 | dev_err(&indio_dev->dev, "write failed (%d)", ret); | 343 | dev_err(&indio_dev->dev, "write failed (%d)", ret); |