Commit 3658a71b authored by Lars-Peter Clausen's avatar Lars-Peter Clausen Committed by Jonathan Cameron

staging:iio:ad9951: Use spi_sync_transfer()

Use the spi_sync_transfer() helper function instead of open-coding it. Makes the
code a bit shorter.
Signed-off-by: default avatarLars-Peter Clausen <lars@metafoo.de>
Signed-off-by: default avatarJonathan Cameron <jic23@kernel.org>
parent 630e7377
...@@ -60,7 +60,6 @@ static ssize_t ad9951_set_parameter(struct device *dev, ...@@ -60,7 +60,6 @@ static ssize_t ad9951_set_parameter(struct device *dev,
const char *buf, const char *buf,
size_t len) size_t len)
{ {
struct spi_message msg;
struct spi_transfer xfer; struct spi_transfer xfer;
int ret; int ret;
struct ad9951_config *config = (struct ad9951_config *)buf; struct ad9951_config *config = (struct ad9951_config *)buf;
...@@ -71,36 +70,28 @@ static ssize_t ad9951_set_parameter(struct device *dev, ...@@ -71,36 +70,28 @@ static ssize_t ad9951_set_parameter(struct device *dev,
xfer.tx_buf = &config->asf[0]; xfer.tx_buf = &config->asf[0];
mutex_lock(&st->lock); mutex_lock(&st->lock);
spi_message_init(&msg); ret = spi_sync_transfer(st->sdev, &xfer, 1);
spi_message_add_tail(&xfer, &msg);
ret = spi_sync(st->sdev, &msg);
if (ret) if (ret)
goto error_ret; goto error_ret;
xfer.len = 2; xfer.len = 2;
xfer.tx_buf = &config->arr[0]; xfer.tx_buf = &config->arr[0];
spi_message_init(&msg); ret = spi_sync_transfer(st->sdev, &xfer, 1);
spi_message_add_tail(&xfer, &msg);
ret = spi_sync(st->sdev, &msg);
if (ret) if (ret)
goto error_ret; goto error_ret;
xfer.len = 5; xfer.len = 5;
xfer.tx_buf = &config->ftw0[0]; xfer.tx_buf = &config->ftw0[0];
spi_message_init(&msg); ret = spi_sync_transfer(st->sdev, &xfer, 1);
spi_message_add_tail(&xfer, &msg);
ret = spi_sync(st->sdev, &msg);
if (ret) if (ret)
goto error_ret; goto error_ret;
xfer.len = 3; xfer.len = 3;
xfer.tx_buf = &config->ftw1[0]; xfer.tx_buf = &config->ftw1[0];
spi_message_init(&msg); ret = spi_sync_transfer(st->sdev, &xfer, 1);
spi_message_add_tail(&xfer, &msg);
ret = spi_sync(st->sdev, &msg);
if (ret) if (ret)
goto error_ret; goto error_ret;
error_ret: error_ret:
...@@ -113,7 +104,6 @@ static IIO_DEVICE_ATTR(dds, S_IWUSR, NULL, ad9951_set_parameter, 0); ...@@ -113,7 +104,6 @@ static IIO_DEVICE_ATTR(dds, S_IWUSR, NULL, ad9951_set_parameter, 0);
static void ad9951_init(struct ad9951_state *st) static void ad9951_init(struct ad9951_state *st)
{ {
struct spi_message msg;
struct spi_transfer xfer; struct spi_transfer xfer;
int ret; int ret;
u8 cfr[5]; u8 cfr[5];
...@@ -129,9 +119,7 @@ static void ad9951_init(struct ad9951_state *st) ...@@ -129,9 +119,7 @@ static void ad9951_init(struct ad9951_state *st)
xfer.len = 5; xfer.len = 5;
xfer.tx_buf = &cfr; xfer.tx_buf = &cfr;
spi_message_init(&msg); ret = spi_sync_transfer(st->sdev, &xfer, 1);
spi_message_add_tail(&xfer, &msg);
ret = spi_sync(st->sdev, &msg);
if (ret) if (ret)
goto error_ret; goto error_ret;
...@@ -143,9 +131,7 @@ static void ad9951_init(struct ad9951_state *st) ...@@ -143,9 +131,7 @@ static void ad9951_init(struct ad9951_state *st)
xfer.len = 4; xfer.len = 4;
xfer.tx_buf = &cfr; xfer.tx_buf = &cfr;
spi_message_init(&msg); ret = spi_sync_transfer(st->sdev, &xfer, 1);
spi_message_add_tail(&xfer, &msg);
ret = spi_sync(st->sdev, &msg);
if (ret) if (ret)
goto error_ret; goto error_ret;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment