Commit 630e7377 authored by Lars-Peter Clausen's avatar Lars-Peter Clausen Committed by Jonathan Cameron

staging:iio:ad9910: 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 9aa698a0
...@@ -119,7 +119,6 @@ static ssize_t ad9910_set_parameter(struct device *dev, ...@@ -119,7 +119,6 @@ static ssize_t ad9910_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 ad9910_config *config = (struct ad9910_config *)buf; struct ad9910_config *config = (struct ad9910_config *)buf;
...@@ -130,152 +129,118 @@ static ssize_t ad9910_set_parameter(struct device *dev, ...@@ -130,152 +129,118 @@ static ssize_t ad9910_set_parameter(struct device *dev,
xfer.tx_buf = &config->auxdac[0]; xfer.tx_buf = &config->auxdac[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 = 5; xfer.len = 5;
xfer.tx_buf = &config->ioupd[0]; xfer.tx_buf = &config->ioupd[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->ftw[0]; xfer.tx_buf = &config->ftw[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->pow[0]; xfer.tx_buf = &config->pow[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->asf[0]; xfer.tx_buf = &config->asf[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->multc[0]; xfer.tx_buf = &config->multc[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 = 9; xfer.len = 9;
xfer.tx_buf = &config->dig_rampl[0]; xfer.tx_buf = &config->dig_rampl[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 = 9; xfer.len = 9;
xfer.tx_buf = &config->dig_ramps[0]; xfer.tx_buf = &config->dig_ramps[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->dig_rampr[0]; xfer.tx_buf = &config->dig_rampr[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 = 9; xfer.len = 9;
xfer.tx_buf = &config->sin_tonep0[0]; xfer.tx_buf = &config->sin_tonep0[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 = 9; xfer.len = 9;
xfer.tx_buf = &config->sin_tonep1[0]; xfer.tx_buf = &config->sin_tonep1[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 = 9; xfer.len = 9;
xfer.tx_buf = &config->sin_tonep2[0]; xfer.tx_buf = &config->sin_tonep2[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 = 9; xfer.len = 9;
xfer.tx_buf = &config->sin_tonep3[0]; xfer.tx_buf = &config->sin_tonep3[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 = 9; xfer.len = 9;
xfer.tx_buf = &config->sin_tonep4[0]; xfer.tx_buf = &config->sin_tonep4[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 = 9; xfer.len = 9;
xfer.tx_buf = &config->sin_tonep5[0]; xfer.tx_buf = &config->sin_tonep5[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 = 9; xfer.len = 9;
xfer.tx_buf = &config->sin_tonep6[0]; xfer.tx_buf = &config->sin_tonep6[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 = 9; xfer.len = 9;
xfer.tx_buf = &config->sin_tonep7[0]; xfer.tx_buf = &config->sin_tonep7[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:
...@@ -288,7 +253,6 @@ static IIO_DEVICE_ATTR(dds, S_IWUSR, NULL, ad9910_set_parameter, 0); ...@@ -288,7 +253,6 @@ static IIO_DEVICE_ATTR(dds, S_IWUSR, NULL, ad9910_set_parameter, 0);
static void ad9910_init(struct ad9910_state *st) static void ad9910_init(struct ad9910_state *st)
{ {
struct spi_message msg;
struct spi_transfer xfer; struct spi_transfer xfer;
int ret; int ret;
u8 cfr[5]; u8 cfr[5];
...@@ -304,9 +268,7 @@ static void ad9910_init(struct ad9910_state *st) ...@@ -304,9 +268,7 @@ static void ad9910_init(struct ad9910_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;
...@@ -319,9 +281,7 @@ static void ad9910_init(struct ad9910_state *st) ...@@ -319,9 +281,7 @@ static void ad9910_init(struct ad9910_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;
...@@ -334,9 +294,7 @@ static void ad9910_init(struct ad9910_state *st) ...@@ -334,9 +294,7 @@ static void ad9910_init(struct ad9910_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;
......
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