From: Jonathan Cameron <jic23@kernel.org>
To: Lars-Peter Clausen <lars@metafoo.de>
Cc: Jonathan Cameron <jic23@cam.ac.uk>, linux-iio@vger.kernel.org
Subject: Re: [PATCH 01/11] Partially revert "staging:iio:gyro:adxrs450 make more use of spi_read and spi_write."
Date: Sat, 02 Feb 2013 09:29:14 +0000 [thread overview]
Message-ID: <510CDC6A.7000002@kernel.org> (raw)
In-Reply-To: <1359642478-9622-1-git-send-email-lars@metafoo.de>
On 01/31/2013 02:27 PM, Lars-Peter Clausen wrote:
> This partially reverts commit cb4496876f03631eff913b3c608c964d48d61eb9. There is
> no apparent reason why we should split a transaction which consists out of
> multiple transfers into multiple transactions each having one transfer. While
> this works it introduces a bunch of unnecessary context switch and additional
> setup costs.
>
> Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Whole series applied to togreg branch of iio.git.
Thanks,
> ---
> drivers/staging/iio/gyro/adxrs450_core.c | 48 ++++++++++++++++++++++----------
> 1 file changed, 34 insertions(+), 14 deletions(-)
>
> diff --git a/drivers/staging/iio/gyro/adxrs450_core.c b/drivers/staging/iio/gyro/adxrs450_core.c
> index f0ce81d..318e8c9 100644
> --- a/drivers/staging/iio/gyro/adxrs450_core.c
> +++ b/drivers/staging/iio/gyro/adxrs450_core.c
> @@ -34,8 +34,21 @@ static int adxrs450_spi_read_reg_16(struct iio_dev *indio_dev,
> u8 reg_address,
> u16 *val)
> {
> + struct spi_message msg;
> struct adxrs450_state *st = iio_priv(indio_dev);
> int ret;
> + struct spi_transfer xfers[] = {
> + {
> + .tx_buf = st->tx,
> + .bits_per_word = 8,
> + .len = 4,
> + .cs_change = 1,
> + }, {
> + .rx_buf = st->rx,
> + .bits_per_word = 8,
> + .len = 4,
> + },
> + };
>
> mutex_lock(&st->buf_lock);
> st->tx[0] = ADXRS450_READ_DATA | (reg_address >> 7);
> @@ -46,13 +59,10 @@ static int adxrs450_spi_read_reg_16(struct iio_dev *indio_dev,
> if (!(hweight32(be32_to_cpu(*(u32 *)st->tx)) & 1))
> st->tx[3] |= ADXRS450_P;
>
> - ret = spi_write(st->us, st->tx, 4);
> - if (ret) {
> - dev_err(&st->us->dev, "problem while reading 16 bit register 0x%02x\n",
> - reg_address);
> - goto error_ret;
> - }
> - ret = spi_read(st->us, st->rx, 4);
> + spi_message_init(&msg);
> + spi_message_add_tail(&xfers[0], &msg);
> + spi_message_add_tail(&xfers[1], &msg);
> + ret = spi_sync(st->us, &msg);
> if (ret) {
> dev_err(&st->us->dev, "problem while reading 16 bit register 0x%02x\n",
> reg_address);
> @@ -105,8 +115,21 @@ static int adxrs450_spi_write_reg_16(struct iio_dev *indio_dev,
> **/
> static int adxrs450_spi_sensor_data(struct iio_dev *indio_dev, s16 *val)
> {
> + struct spi_message msg;
> struct adxrs450_state *st = iio_priv(indio_dev);
> int ret;
> + struct spi_transfer xfers[] = {
> + {
> + .tx_buf = st->tx,
> + .bits_per_word = 8,
> + .len = 4,
> + .cs_change = 1,
> + }, {
> + .rx_buf = st->rx,
> + .bits_per_word = 8,
> + .len = 4,
> + },
> + };
>
> mutex_lock(&st->buf_lock);
> st->tx[0] = ADXRS450_SENSOR_DATA;
> @@ -114,13 +137,10 @@ static int adxrs450_spi_sensor_data(struct iio_dev *indio_dev, s16 *val)
> st->tx[2] = 0;
> st->tx[3] = 0;
>
> - ret = spi_write(st->us, st->tx, 4);
> - if (ret) {
> - dev_err(&st->us->dev, "Problem while reading sensor data\n");
> - goto error_ret;
> - }
> -
> - ret = spi_read(st->us, st->rx, 4);
> + spi_message_init(&msg);
> + spi_message_add_tail(&xfers[0], &msg);
> + spi_message_add_tail(&xfers[1], &msg);
> + ret = spi_sync(st->us, &msg);
> if (ret) {
> dev_err(&st->us->dev, "Problem while reading sensor data\n");
> goto error_ret;
>
prev parent reply other threads:[~2013-02-02 9:29 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-01-31 14:27 [PATCH 01/11] Partially revert "staging:iio:gyro:adxrs450 make more use of spi_read and spi_write." Lars-Peter Clausen
2013-01-31 14:27 ` [PATCH 02/11] staging:iio:adxrs450: Make transfer buffers __be32 Lars-Peter Clausen
2013-01-31 14:27 ` [PATCH 03/11] staging:iio:adxrs450: Perform sign extension for the calibbias register Lars-Peter Clausen
2013-01-31 14:27 ` [PATCH 04/11] staging:iio:adxrs450: Reject out of range calibscale values Lars-Peter Clausen
2013-01-31 14:27 ` [PATCH 05/11] staging:iio:adxrs450: Don't spam the bootlog Lars-Peter Clausen
2013-01-31 14:27 ` [PATCH 06/11] staging:iio:adxrs450: Reflow overlong lines Lars-Peter Clausen
2013-01-31 14:27 ` [PATCH 07/11] staging:iio:adxrs450: Don't split string across multiple lines Lars-Peter Clausen
2013-01-31 14:27 ` [PATCH 08/11] staging:iio:adxrs450: Use usleep_range for the sequential transfer dealy Lars-Peter Clausen
2013-01-31 14:27 ` [PATCH 09/11] staging:iio:adxrs450: Fixup kernel doc comments Lars-Peter Clausen
2013-01-31 14:27 ` [PATCH 10/11] staging:iio:adxrs450: Move header file contents to main file Lars-Peter Clausen
2013-01-31 14:27 ` [PATCH 11/11] staging:iio: Move adxrs450 driver out of staging Lars-Peter Clausen
2013-02-02 9:29 ` Jonathan Cameron [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=510CDC6A.7000002@kernel.org \
--to=jic23@kernel.org \
--cc=jic23@cam.ac.uk \
--cc=lars@metafoo.de \
--cc=linux-iio@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox