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: Jonathan Cameron <jic23@cam.ac.uk>,
	linux-iio@vger.kernel.org, drivers@analog.com
Subject: Re: [PATCH 1/7] staging:iio:ad7887: Preallocate sample buffer
Date: Sat, 10 Nov 2012 10:07:05 +0000	[thread overview]
Message-ID: <509E2749.2000709@kernel.org> (raw)
In-Reply-To: <1352109406-7206-1-git-send-email-lars@metafoo.de>

On 11/05/2012 09:56 AM, Lars-Peter Clausen wrote:
> We know that the sample buffer will at most need to hold two 16 bit samples and
> the 64 bit aligned 64 bit timestamp. Preallocate a buffer large enough to hold
> this instead of allocating and freeing it each time a sample is read.
> 
> Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
All 7 applied to togreg branch.

A nice series and good to get this one out of staging as it's
been pretty much clean for an awful long time!

Jonathan

p.s. I thought I had sent this the other day but it appears not!
> ---
>  drivers/staging/iio/adc/ad7887.h      |  6 ++++--
>  drivers/staging/iio/adc/ad7887_ring.c | 15 ++-------------
>  2 files changed, 6 insertions(+), 15 deletions(-)
> 
> diff --git a/drivers/staging/iio/adc/ad7887.h b/drivers/staging/iio/adc/ad7887.h
> index 2e09e54..71e5092 100644
> --- a/drivers/staging/iio/adc/ad7887.h
> +++ b/drivers/staging/iio/adc/ad7887.h
> @@ -72,9 +72,11 @@ struct ad7887_state {
>  	/*
>  	 * DMA (thus cache coherency maintenance) requires the
>  	 * transfer buffers to live in their own cache lines.
> +	 * Buffer needs to be large enough to hold two 16 bit samples and a
> +	 * 64 bit aligned 64 bit timestamp.
>  	 */
> -
> -	unsigned char			data[4] ____cacheline_aligned;
> +	unsigned char data[ALIGN(4, sizeof(s64)) + sizeof(s64)]
> +		____cacheline_aligned;
>  };
>  
>  enum ad7887_supported_device_ids {
> diff --git a/drivers/staging/iio/adc/ad7887_ring.c b/drivers/staging/iio/adc/ad7887_ring.c
> index b39923b..f11925e 100644
> --- a/drivers/staging/iio/adc/ad7887_ring.c
> +++ b/drivers/staging/iio/adc/ad7887_ring.c
> @@ -73,31 +73,20 @@ static irqreturn_t ad7887_trigger_handler(int irq, void *p)
>  	struct iio_dev *indio_dev = pf->indio_dev;
>  	struct ad7887_state *st = iio_priv(indio_dev);
>  	s64 time_ns;
> -	__u8 *buf;
>  	int b_sent;
>  
> -	unsigned int bytes = bitmap_weight(indio_dev->active_scan_mask,
> -					   indio_dev->masklength) *
> -		st->chip_info->channel[0].scan_type.storagebits / 8;
> -
> -	buf = kzalloc(indio_dev->scan_bytes, GFP_KERNEL);
> -	if (buf == NULL)
> -		goto done;
> -
>  	b_sent = spi_sync(st->spi, st->ring_msg);
>  	if (b_sent)
>  		goto done;
>  
>  	time_ns = iio_get_time_ns();
>  
> -	memcpy(buf, st->data, bytes);
>  	if (indio_dev->scan_timestamp)
> -		memcpy(buf + indio_dev->scan_bytes - sizeof(s64),
> +		memcpy(st->data + indio_dev->scan_bytes - sizeof(s64),
>  		       &time_ns, sizeof(time_ns));
>  
> -	iio_push_to_buffer(indio_dev->buffer, buf);
> +	iio_push_to_buffer(indio_dev->buffer, st->data);
>  done:
> -	kfree(buf);
>  	iio_trigger_notify_done(indio_dev->trig);
>  
>  	return IRQ_HANDLED;
> 

      parent reply	other threads:[~2012-11-10 10:07 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-11-05  9:56 [PATCH 1/7] staging:iio:ad7887: Preallocate sample buffer Lars-Peter Clausen
2012-11-05  9:56 ` [PATCH 2/7] staging:iio:ad7887: Rework regulator handling Lars-Peter Clausen
2012-11-05  9:56 ` [PATCH 3/7] staging:iio:ad7887: Squash everything into one file Lars-Peter Clausen
2012-11-05  9:56 ` [PATCH 4/7] staging:iio:ad7887: Use proper kernel doc Lars-Peter Clausen
2012-11-05  9:56 ` [PATCH 5/7] staging:iio:ad7887: Allow to use internal ref in two channel mode Lars-Peter Clausen
2012-11-05  9:56 ` [PATCH 6/7] staging:iio:ad7887: Use passed in chan spec in ad7887_read_raw Lars-Peter Clausen
2012-11-05  9:56 ` [PATCH 7/7] staging:iio: Move the ad7887 driver out of staging Lars-Peter Clausen
2012-11-10 10:07 ` 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=509E2749.2000709@kernel.org \
    --to=jic23@kernel.org \
    --cc=drivers@analog.com \
    --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;
as well as URLs for NNTP newsgroup(s).