Linux IIO development
 help / color / mirror / Atom feed
From: Jonathan Cameron <jic23@cam.ac.uk>
To: michael.hennerich@analog.com
Cc: linux-iio@vger.kernel.org, drivers@analog.com,
	device-drivers-devel@blackfin.uclinux.org
Subject: Re: [PATCH 1/6] IIO: GYRO: ADXRS450: Don't issue two messages, use two transfers
Date: Fri, 29 Apr 2011 13:05:10 +0100	[thread overview]
Message-ID: <4DBAA976.1050407@cam.ac.uk> (raw)
In-Reply-To: <1304074721-18159-1-git-send-email-michael.hennerich@analog.com>

On 04/29/11 11:58, michael.hennerich@analog.com wrote:
> From: Michael Hennerich <michael.hennerich@analog.com>
> 
> Don't issue the same message twice, use two transfers and group them together
> 
> Signed-off-by: Michael Hennerich <michael.hennerich@analog.com>
Acked-by: Jonathan Cameron <jic23@cam.ac.uk>
> ---
>  drivers/staging/iio/gyro/adxrs450_core.c |   58 ++++++++++++++---------------
>  1 files changed, 28 insertions(+), 30 deletions(-)
> 
> diff --git a/drivers/staging/iio/gyro/adxrs450_core.c b/drivers/staging/iio/gyro/adxrs450_core.c
> index dcd88ff..a1a71b7 100644
> --- a/drivers/staging/iio/gyro/adxrs450_core.c
> +++ b/drivers/staging/iio/gyro/adxrs450_core.c
> @@ -40,29 +40,28 @@ static int adxrs450_spi_read_reg_16(struct device *dev,
>  	struct iio_dev *indio_dev = dev_get_drvdata(dev);
>  	struct adxrs450_state *st = iio_dev_get_devdata(indio_dev);
>  	int ret;
> -	struct spi_transfer xfers = {
> -		.tx_buf = st->tx,
> -		.rx_buf = st->rx,
> -		.bits_per_word = 8,
> -		.len = 4,
> +	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,
> +		},
>  	};
> -	/* Needs to send the command twice to get the wanted value */
> +
>  	mutex_lock(&st->buf_lock);
> -	st->tx[0] = ADXRS450_READ_DATA | reg_address >> 7;
> +	st->tx[0] = ADXRS450_READ_DATA | (reg_address >> 7);
>  	st->tx[1] = reg_address << 1;
>  	st->tx[2] = 0;
>  	st->tx[3] = 0;
> -	spi_message_init(&msg);
> -	spi_message_add_tail(&xfers, &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);
> -		goto error_ret;
> -	}
> 
>  	spi_message_init(&msg);
> -	spi_message_add_tail(&xfers, &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",
> @@ -125,11 +124,17 @@ static int adxrs450_spi_sensor_data(struct device *dev, u16 *val)
>  	struct iio_dev *indio_dev = dev_get_drvdata(dev);
>  	struct adxrs450_state *st = iio_dev_get_devdata(indio_dev);
>  	int ret;
> -	struct spi_transfer xfers = {
> -		.tx_buf = st->tx,
> -		.rx_buf = st->rx,
> -		.bits_per_word = 8,
> -		.len = 4,
> +	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);
> @@ -139,15 +144,8 @@ static int adxrs450_spi_sensor_data(struct device *dev, u16 *val)
>  	st->tx[3] = 0;
> 
>  	spi_message_init(&msg);
> -	spi_message_add_tail(&xfers, &msg);
> -	ret = spi_sync(st->us, &msg);
> -	if (ret) {
> -		dev_err(&st->us->dev, "Problem while reading sensor data\n");
> -		goto error_ret;
> -	}
> -
> -	spi_message_init(&msg);
> -	spi_message_add_tail(&xfers, &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");
> --
> 1.6.0.2
> 
> 
> 


  parent reply	other threads:[~2011-04-29 12:02 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-04-29 10:58 [PATCH 1/6] IIO: GYRO: ADXRS450: Don't issue two messages, use two transfers michael.hennerich
2011-04-29 10:58 ` [PATCH 2/6] IIO: GYRO: ADXRS450: Cleanup result extraction and update license notice michael.hennerich
2011-04-29 12:08   ` Jonathan Cameron
2011-04-29 10:58 ` [PATCH 3/6] IIO: GYRO: ADXRS450: Add missing parity bit generation michael.hennerich
2011-04-29 12:09   ` Jonathan Cameron
2011-04-29 10:58 ` [PATCH 4/6] IIO: GYRO: ADXRS450: enforce sequential transfer delay of at least 0.1ms michael.hennerich
2011-04-29 12:12   ` Jonathan Cameron
2011-04-29 10:58 ` [PATCH 5/6] IIO: GYRO: ADXRS450: Fix sign issues, properly shift results and limit values michael.hennerich
2011-04-29 12:14   ` Jonathan Cameron
2011-04-29 10:58 ` [PATCH 6/6] IIO: GYRO: ADXRS450: Don't exit probe, in case the power on default is not met michael.hennerich
2011-04-29 12:15   ` Jonathan Cameron
2011-04-29 12:05 ` Jonathan Cameron [this message]
  -- strict thread matches above, loose matches on Subject: below --
2011-04-29 12:16 [PATCH 1/6] IIO: GYRO: ADXRS450: Don't issue two messages, use two transfers michael.hennerich

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=4DBAA976.1050407@cam.ac.uk \
    --to=jic23@cam.ac.uk \
    --cc=device-drivers-devel@blackfin.uclinux.org \
    --cc=drivers@analog.com \
    --cc=linux-iio@vger.kernel.org \
    --cc=michael.hennerich@analog.com \
    /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