linux-iio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jonathan Cameron <jic23@kernel.org>
To: Lars-Peter Clausen <lars@metafoo.de>
Cc: linux-iio@vger.kernel.org
Subject: Re: [PATCH 11/15] staging:iio:ad7280a: Do not store transfer buffer on the stack
Date: Sat, 30 Nov 2013 11:12:51 +0000	[thread overview]
Message-ID: <5299C833.2020805@kernel.org> (raw)
In-Reply-To: <1385383327-28181-11-git-send-email-lars@metafoo.de>

On 11/25/13 12:42, Lars-Peter Clausen wrote:
> Some I2C controllers may not be able to handle transfer buffers that are placed
> on the stack.
> 
> Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Applied to the togreg branch of iio.git
> ---
>  drivers/staging/iio/adc/ad7280a.c | 29 +++++++++++++++--------------
>  1 file changed, 15 insertions(+), 14 deletions(-)
> 
> diff --git a/drivers/staging/iio/adc/ad7280a.c b/drivers/staging/iio/adc/ad7280a.c
> index 89ee65b..1ac11f6 100644
> --- a/drivers/staging/iio/adc/ad7280a.c
> +++ b/drivers/staging/iio/adc/ad7280a.c
> @@ -134,6 +134,8 @@ struct ad7280_state {
>  	unsigned char			aux_threshhigh;
>  	unsigned char			aux_threshlow;
>  	unsigned char			cb_mask[AD7280A_MAX_CHAIN];
> +
> +	__be32				buf[2] ____cacheline_aligned;
>  };
>  
>  static void ad7280_crc8_build_table(unsigned char *crc_tab)
> @@ -189,22 +191,22 @@ static void ad7280_delay(struct ad7280_state *st)
>  		msleep(1);
>  }
>  
> -static int __ad7280_read32(struct spi_device *spi, unsigned *val)
> +static int __ad7280_read32(struct ad7280_state *st, unsigned *val)
>  {
> -	__be32 rx_buf, tx_buf = cpu_to_be32(AD7280A_READ_TXVAL);
>  	int ret;
> -
>  	struct spi_transfer t = {
> -		.tx_buf	= &tx_buf,
> -		.rx_buf = &rx_buf,
> +		.tx_buf	= &st->buf[0],
> +		.rx_buf = &st->buf[1],
>  		.len = 4,
>  	};
>  
> -	ret = spi_sync_transfer(spi, &t, 1);
> +	st->buf[0] = cpu_to_be32(AD7280A_READ_TXVAL);
> +
> +	ret = spi_sync_transfer(st->spi, &t, 1);
>  	if (ret)
>  		return ret;
>  
> -	*val = be32_to_cpu(rx_buf);
> +	*val = be32_to_cpu(st->buf[1]);
>  
>  	return 0;
>  }
> @@ -214,12 +216,11 @@ static int ad7280_write(struct ad7280_state *st, unsigned devaddr,
>  {
>  	unsigned reg = (devaddr << 27 | addr << 21 |
>  			(val & 0xFF) << 13 | all << 12);
> -	__be32 tx_buf;
>  
>  	reg |= ad7280_calc_crc8(st->crc_tab, reg >> 11) << 3 | 0x2;
> -	tx_buf = cpu_to_be32(reg);
> +	st->buf[0] = cpu_to_be32(reg);
>  
> -	return spi_write(st->spi, &tx_buf, 4);
> +	return spi_write(st->spi, &st->buf[0], 4);
>  }
>  
>  static int ad7280_read(struct ad7280_state *st, unsigned devaddr,
> @@ -249,7 +250,7 @@ static int ad7280_read(struct ad7280_state *st, unsigned devaddr,
>  	if (ret)
>  		return ret;
>  
> -	__ad7280_read32(st->spi, &tmp);
> +	__ad7280_read32(st, &tmp);
>  
>  	if (ad7280_check_crc(st, tmp))
>  		return -EIO;
> @@ -287,7 +288,7 @@ static int ad7280_read_channel(struct ad7280_state *st, unsigned devaddr,
>  
>  	ad7280_delay(st);
>  
> -	__ad7280_read32(st->spi, &tmp);
> +	__ad7280_read32(st, &tmp);
>  
>  	if (ad7280_check_crc(st, tmp))
>  		return -EIO;
> @@ -320,7 +321,7 @@ static int ad7280_read_all_channels(struct ad7280_state *st, unsigned cnt,
>  	ad7280_delay(st);
>  
>  	for (i = 0; i < cnt; i++) {
> -		__ad7280_read32(st->spi, &tmp);
> +		__ad7280_read32(st, &tmp);
>  
>  		if (ad7280_check_crc(st, tmp))
>  			return -EIO;
> @@ -363,7 +364,7 @@ static int ad7280_chain_setup(struct ad7280_state *st)
>  		return ret;
>  
>  	for (n = 0; n <= AD7280A_MAX_CHAIN; n++) {
> -		__ad7280_read32(st->spi, &val);
> +		__ad7280_read32(st, &val);
>  		if (val == 0)
>  			return n - 1;
>  
> 

  reply	other threads:[~2013-11-30 11:12 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-11-25 12:41 [PATCH 01/15] iio:ad5504: Mark transfer buffers as __be16 Lars-Peter Clausen
2013-11-25 12:41 ` [PATCH 02/15] iio:ad5504: Do not store transfer buffers on the stack Lars-Peter Clausen
2013-11-30 11:07   ` Jonathan Cameron
2013-11-25 12:41 ` [PATCH 03/15] iio:ad5421: Mark transfer buffer as __be32 Lars-Peter Clausen
2013-11-30 11:07   ` Jonathan Cameron
2013-11-25 12:41 ` [PATCH 04/15] iio:ad5686: " Lars-Peter Clausen
2013-11-30 11:07   ` Jonathan Cameron
2013-11-25 12:41 ` [PATCH 05/15] iio:ad5755: " Lars-Peter Clausen
2013-11-30 11:08   ` Jonathan Cameron
2013-11-25 12:41 ` [PATCH 06/15] iio:ad5791: Mark transfer buffers " Lars-Peter Clausen
2013-11-30 11:08   ` Jonathan Cameron
2013-11-25 12:41 ` [PATCH 07/15] iio:ad5791: Do not store transfer buffers on the stack Lars-Peter Clausen
2013-11-30 11:09   ` Jonathan Cameron
2013-12-22 17:36     ` Jonathan Cameron
2013-12-22 17:40       ` Lars-Peter Clausen
2013-12-22 17:43         ` Jonathan Cameron
2013-11-25 12:42 ` [PATCH 08/15] iio:ad7266: Mark transfer buffer as __be16 Lars-Peter Clausen
2013-11-30 11:10   ` Jonathan Cameron
2013-11-25 12:42 ` [PATCH 09/15] iio:vcnl4000: " Lars-Peter Clausen
2013-11-30 11:11   ` Jonathan Cameron
2013-11-25 12:42 ` [PATCH 10/15] staging:iio:ad7280a: Mark transfer buffer as __be32 Lars-Peter Clausen
2013-11-30 11:12   ` Jonathan Cameron
2013-11-25 12:42 ` [PATCH 11/15] staging:iio:ad7280a: Do not store transfer buffer on the stack Lars-Peter Clausen
2013-11-30 11:12   ` Jonathan Cameron [this message]
2013-11-25 12:42 ` [PATCH 12/15] staging:iio:ad7746: Mark transfer buffer as __be32 Lars-Peter Clausen
2013-11-30 11:13   ` Jonathan Cameron
2013-11-25 12:42 ` [PATCH 13/15] staging:iio:ad7746: Do not store the transfer buffer on the stack Lars-Peter Clausen
2013-11-30 11:13   ` Jonathan Cameron
2013-12-22 17:22     ` Jonathan Cameron
2013-11-25 12:42 ` [PATCH 14/15] staging:iio:ad9832: Mark transfer buffers as __be16 Lars-Peter Clausen
2013-11-30 11:14   ` Jonathan Cameron
2013-12-03 10:27     ` Lars-Peter Clausen
2013-12-03 14:56       ` Jonathan Cameron
2013-12-03 20:09         ` Jonathan Cameron
2013-12-03 20:11           ` Lars-Peter Clausen
2013-11-25 12:42 ` [PATCH 15/15] staging:iio:ad9834: Mark transfer buffers as __b16 Lars-Peter Clausen
2013-11-30 11:14   ` Jonathan Cameron
2013-11-30 11:03 ` [PATCH 01/15] iio:ad5504: Mark transfer buffers as __be16 Jonathan Cameron

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=5299C833.2020805@kernel.org \
    --to=jic23@kernel.org \
    --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;
as well as URLs for NNTP newsgroup(s).