From patchwork Wed Jan 9 17:31:10 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lars-Peter Clausen X-Patchwork-Id: 1953741 Return-Path: X-Original-To: patchwork-spi-devel-general@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from lists.sourceforge.net (lists.sourceforge.net [216.34.181.88]) by patchwork1.kernel.org (Postfix) with ESMTP id 140B03FD40 for ; Wed, 9 Jan 2013 17:30:43 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=sfs-ml-4.v29.ch3.sourceforge.com) by sfs-ml-4.v29.ch3.sourceforge.com with esmtp (Exim 4.76) (envelope-from ) id 1TszUA-00079f-15; Wed, 09 Jan 2013 17:30:42 +0000 Received: from sog-mx-3.v43.ch3.sourceforge.com ([172.29.43.193] helo=mx.sourceforge.net) by sfs-ml-4.v29.ch3.sourceforge.com with esmtp (Exim 4.76) (envelope-from ) id 1TszU7-00079M-UX for spi-devel-general@lists.sourceforge.net; Wed, 09 Jan 2013 17:30:39 +0000 X-ACL-Warn: Received: from smtp-out-052.synserver.de ([212.40.185.52]) by sog-mx-3.v43.ch3.sourceforge.com with esmtp (Exim 4.76) id 1TszU5-0006t4-Ga for spi-devel-general@lists.sourceforge.net; Wed, 09 Jan 2013 17:30:39 +0000 Received: (qmail 5546 invoked by uid 0); 9 Jan 2013 17:30:31 -0000 X-SynServer-TrustedSrc: 1 X-SynServer-AuthUser: lars@metafoo.de X-SynServer-PPID: 5469 Received: from eisbaer.ursus-maritimus.org (HELO lars-adi-laptop.analog.com) [78.47.220.141] by 217.119.54.87 with SMTP; 9 Jan 2013 17:30:30 -0000 From: Lars-Peter Clausen To: Grant Likely Subject: [PATCH 2/3] iio: Use spi_sync_transfer() Date: Wed, 9 Jan 2013 18:31:10 +0100 Message-Id: <1357752671-30222-2-git-send-email-lars@metafoo.de> X-Mailer: git-send-email 1.8.0 In-Reply-To: <1357752671-30222-1-git-send-email-lars@metafoo.de> References: <1357752671-30222-1-git-send-email-lars@metafoo.de> X-Spam-Score: 0.0 (/) X-Spam-Report: Spam Filtering performed by mx.sourceforge.net. See http://spamassassin.org/tag/ for more details. -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/, no trust [212.40.185.52 listed in list.dnswl.org] X-Headers-End: 1TszU5-0006t4-Ga Cc: Lars-Peter Clausen , linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, Julia Lawall , Jonathan Cameron , spi-devel-general@lists.sourceforge.net X-BeenThere: spi-devel-general@lists.sourceforge.net X-Mailman-Version: 2.1.9 Precedence: list List-Id: Linux SPI core/device drivers discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: spi-devel-general-bounces@lists.sourceforge.net Use the new spi_sync_transfer() helper function instead of open-coding it. Signed-off-by: Lars-Peter Clausen --- drivers/iio/dac/ad5360.c | 7 +------ drivers/iio/dac/ad5421.c | 7 +------ drivers/iio/dac/ad5504.c | 6 +----- drivers/iio/dac/ad5686.c | 7 +------ drivers/iio/dac/ad5755.c | 7 +------ drivers/iio/dac/ad5764.c | 7 +------ drivers/iio/dac/ad5791.c | 6 +----- drivers/iio/frequency/ad9523.c | 14 ++------------ 8 files changed, 9 insertions(+), 52 deletions(-) diff --git a/drivers/iio/dac/ad5360.c b/drivers/iio/dac/ad5360.c index 8fce84f..8ae07a5 100644 --- a/drivers/iio/dac/ad5360.c +++ b/drivers/iio/dac/ad5360.c @@ -213,7 +213,6 @@ static int ad5360_read(struct iio_dev *indio_dev, unsigned int type, unsigned int addr) { struct ad5360_state *st = iio_priv(indio_dev); - struct spi_message m; int ret; struct spi_transfer t[] = { { @@ -226,10 +225,6 @@ static int ad5360_read(struct iio_dev *indio_dev, unsigned int type, }, }; - spi_message_init(&m); - spi_message_add_tail(&t[0], &m); - spi_message_add_tail(&t[1], &m); - mutex_lock(&indio_dev->mlock); st->data[0].d32 = cpu_to_be32(AD5360_CMD(AD5360_CMD_SPECIAL_FUNCTION) | @@ -237,7 +232,7 @@ static int ad5360_read(struct iio_dev *indio_dev, unsigned int type, AD5360_READBACK_TYPE(type) | AD5360_READBACK_ADDR(addr)); - ret = spi_sync(st->spi, &m); + ret = spi_sync_transfer(st->spi, t, ARRAY_SIZE(t)); if (ret >= 0) ret = be32_to_cpu(st->data[1].d32) & 0xffff; diff --git a/drivers/iio/dac/ad5421.c b/drivers/iio/dac/ad5421.c index cdbc5bf..e8f752f 100644 --- a/drivers/iio/dac/ad5421.c +++ b/drivers/iio/dac/ad5421.c @@ -127,7 +127,6 @@ static int ad5421_write(struct iio_dev *indio_dev, unsigned int reg, static int ad5421_read(struct iio_dev *indio_dev, unsigned int reg) { struct ad5421_state *st = iio_priv(indio_dev); - struct spi_message m; int ret; struct spi_transfer t[] = { { @@ -140,15 +139,11 @@ static int ad5421_read(struct iio_dev *indio_dev, unsigned int reg) }, }; - spi_message_init(&m); - spi_message_add_tail(&t[0], &m); - spi_message_add_tail(&t[1], &m); - mutex_lock(&indio_dev->mlock); st->data[0].d32 = cpu_to_be32((1 << 23) | (reg << 16)); - ret = spi_sync(st->spi, &m); + ret = spi_sync_transfer(st->spi, t, ARRAY_SIZE(t)); if (ret >= 0) ret = be32_to_cpu(st->data[1].d32) & 0xffff; diff --git a/drivers/iio/dac/ad5504.c b/drivers/iio/dac/ad5504.c index 242bdc7..428a549 100644 --- a/drivers/iio/dac/ad5504.c +++ b/drivers/iio/dac/ad5504.c @@ -85,11 +85,7 @@ static int ad5504_spi_read(struct spi_device *spi, u8 addr) .rx_buf = &val, .len = 2, }; - struct spi_message m; - - spi_message_init(&m); - spi_message_add_tail(&t, &m); - ret = spi_sync(spi, &m); + ret = spi_sync_transfer(spi, &t, 1); if (ret < 0) return ret; diff --git a/drivers/iio/dac/ad5686.c b/drivers/iio/dac/ad5686.c index 6948d75..1bf32d8 100644 --- a/drivers/iio/dac/ad5686.c +++ b/drivers/iio/dac/ad5686.c @@ -117,18 +117,13 @@ static int ad5686_spi_read(struct ad5686_state *st, u8 addr) .len = 3, }, }; - struct spi_message m; int ret; - spi_message_init(&m); - spi_message_add_tail(&t[0], &m); - spi_message_add_tail(&t[1], &m); - st->data[0].d32 = cpu_to_be32(AD5686_CMD(AD5686_CMD_READBACK_ENABLE) | AD5686_ADDR(addr)); st->data[1].d32 = cpu_to_be32(AD5686_CMD(AD5686_CMD_NOOP)); - ret = spi_sync(st->spi, &m); + ret = spi_sync_transfer(st->spi, t, ARRAY_SIZE(t)); if (ret < 0) return ret; diff --git a/drivers/iio/dac/ad5755.c b/drivers/iio/dac/ad5755.c index 5db3506..906b022 100644 --- a/drivers/iio/dac/ad5755.c +++ b/drivers/iio/dac/ad5755.c @@ -153,7 +153,6 @@ static int ad5755_write_ctrl(struct iio_dev *indio_dev, unsigned int channel, static int ad5755_read(struct iio_dev *indio_dev, unsigned int addr) { struct ad5755_state *st = iio_priv(indio_dev); - struct spi_message m; int ret; struct spi_transfer t[] = { { @@ -167,16 +166,12 @@ static int ad5755_read(struct iio_dev *indio_dev, unsigned int addr) }, }; - spi_message_init(&m); - spi_message_add_tail(&t[0], &m); - spi_message_add_tail(&t[1], &m); - mutex_lock(&indio_dev->mlock); st->data[0].d32 = cpu_to_be32(AD5755_READ_FLAG | (addr << 16)); st->data[1].d32 = cpu_to_be32(AD5755_NOOP); - ret = spi_sync(st->spi, &m); + ret = spi_sync_transfer(st->spi, t, ARRAY_SIZE(t)); if (ret >= 0) ret = be32_to_cpu(st->data[1].d32) & 0xffff; diff --git a/drivers/iio/dac/ad5764.c b/drivers/iio/dac/ad5764.c index ffce304..d3d334b 100644 --- a/drivers/iio/dac/ad5764.c +++ b/drivers/iio/dac/ad5764.c @@ -135,7 +135,6 @@ static int ad5764_read(struct iio_dev *indio_dev, unsigned int reg, unsigned int *val) { struct ad5764_state *st = iio_priv(indio_dev); - struct spi_message m; int ret; struct spi_transfer t[] = { { @@ -148,15 +147,11 @@ static int ad5764_read(struct iio_dev *indio_dev, unsigned int reg, }, }; - spi_message_init(&m); - spi_message_add_tail(&t[0], &m); - spi_message_add_tail(&t[1], &m); - mutex_lock(&indio_dev->mlock); st->data[0].d32 = cpu_to_be32((1 << 23) | (reg << 16)); - ret = spi_sync(st->spi, &m); + ret = spi_sync_transfer(st->spi, t, ARRAY_SIZE(t)); if (ret >= 0) *val = be32_to_cpu(st->data[1].d32) & 0xffff; diff --git a/drivers/iio/dac/ad5791.c b/drivers/iio/dac/ad5791.c index 2bd2e37..2cc0a8e 100644 --- a/drivers/iio/dac/ad5791.c +++ b/drivers/iio/dac/ad5791.c @@ -125,7 +125,6 @@ static int ad5791_spi_read(struct spi_device *spi, u8 addr, u32 *val) u8 d8[4]; } data[3]; int ret; - struct spi_message msg; struct spi_transfer xfers[] = { { .tx_buf = &data[0].d8[1], @@ -144,10 +143,7 @@ static int ad5791_spi_read(struct spi_device *spi, u8 addr, u32 *val) AD5791_ADDR(addr)); data[1].d32 = cpu_to_be32(AD5791_ADDR(AD5791_ADDR_NOOP)); - spi_message_init(&msg); - spi_message_add_tail(&xfers[0], &msg); - spi_message_add_tail(&xfers[1], &msg); - ret = spi_sync(spi, &msg); + ret = spi_sync_transfer(spi, xfers, ARRAY_SIZE(xfers)); *val = be32_to_cpu(data[2].d32); diff --git a/drivers/iio/frequency/ad9523.c b/drivers/iio/frequency/ad9523.c index b737c64..2a18405 100644 --- a/drivers/iio/frequency/ad9523.c +++ b/drivers/iio/frequency/ad9523.c @@ -287,7 +287,6 @@ struct ad9523_state { static int ad9523_read(struct iio_dev *indio_dev, unsigned addr) { struct ad9523_state *st = iio_priv(indio_dev); - struct spi_message m; int ret; /* 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) }, }; - spi_message_init(&m); - spi_message_add_tail(&t[0], &m); - spi_message_add_tail(&t[1], &m); - st->data[0].d32 = cpu_to_be32(AD9523_READ | AD9523_CNT(AD9523_TRANSF_LEN(addr)) | AD9523_ADDR(addr)); - ret = spi_sync(st->spi, &m); + ret = spi_sync_transfer(st->spi, t, ARRAY_SIZE(t)); if (ret < 0) dev_err(&indio_dev->dev, "read failed (%d)", ret); else @@ -326,7 +321,6 @@ static int ad9523_read(struct iio_dev *indio_dev, unsigned addr) static int ad9523_write(struct iio_dev *indio_dev, unsigned addr, unsigned val) { struct ad9523_state *st = iio_priv(indio_dev); - struct spi_message m; int ret; struct spi_transfer t[] = { { @@ -338,16 +332,12 @@ static int ad9523_write(struct iio_dev *indio_dev, unsigned addr, unsigned val) }, }; - spi_message_init(&m); - spi_message_add_tail(&t[0], &m); - spi_message_add_tail(&t[1], &m); - st->data[0].d32 = cpu_to_be32(AD9523_WRITE | AD9523_CNT(AD9523_TRANSF_LEN(addr)) | AD9523_ADDR(addr)); st->data[1].d32 = cpu_to_be32(val); - ret = spi_sync(st->spi, &m); + ret = spi_sync_transfer(st->spi, t, ARRAY_SIZE(t)); if (ret < 0) dev_err(&indio_dev->dev, "write failed (%d)", ret);