From: Jonathan Cameron <jic23@kernel.org>
To: linux-iio@vger.kernel.org
Cc: lars@metafoo.de, Jonathan Cameron <jic23@kernel.org>
Subject: [PATCH 06/14] staging:iio:adc:ad7298 use iio_sw_buffer_preenable to avoid code repitition.
Date: Wed, 18 Apr 2012 14:13:46 +0100 [thread overview]
Message-ID: <1334754834-13622-7-git-send-email-jic23@kernel.org> (raw)
In-Reply-To: <1334754834-13622-1-git-send-email-jic23@kernel.org>
Here some addition elements are needed, but this generic function cuts
down on the amount of code.
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
---
drivers/staging/iio/adc/ad7298.h | 1 -
drivers/staging/iio/adc/ad7298_ring.c | 24 ++++++++----------------
2 files changed, 8 insertions(+), 17 deletions(-)
diff --git a/drivers/staging/iio/adc/ad7298.h b/drivers/staging/iio/adc/ad7298.h
index a0e5dea..5051a7e 100644
--- a/drivers/staging/iio/adc/ad7298.h
+++ b/drivers/staging/iio/adc/ad7298.h
@@ -38,7 +38,6 @@ struct ad7298_platform_data {
struct ad7298_state {
struct spi_device *spi;
struct regulator *reg;
- size_t d_size;
u16 int_vref_mv;
unsigned ext_ref;
struct spi_transfer ring_xfer[10];
diff --git a/drivers/staging/iio/adc/ad7298_ring.c b/drivers/staging/iio/adc/ad7298_ring.c
index feeb0ee..5c13690 100644
--- a/drivers/staging/iio/adc/ad7298_ring.c
+++ b/drivers/staging/iio/adc/ad7298_ring.c
@@ -28,25 +28,17 @@
static int ad7298_ring_preenable(struct iio_dev *indio_dev)
{
struct ad7298_state *st = iio_priv(indio_dev);
- struct iio_buffer *ring = indio_dev->buffer;
- size_t d_size;
int i, m;
unsigned short command;
- int scan_count = bitmap_weight(indio_dev->active_scan_mask,
- indio_dev->masklength);
- d_size = scan_count * (AD7298_STORAGE_BITS / 8);
-
- if (ring->scan_timestamp) {
- d_size += sizeof(s64);
-
- if (d_size % sizeof(s64))
- d_size += sizeof(s64) - (d_size % sizeof(s64));
- }
+ int scan_count, ret;
- if (ring->access->set_bytes_per_datum)
- ring->access->set_bytes_per_datum(ring, d_size);
+ ret = iio_sw_buffer_preenable(indio_dev);
+ if (ret < 0)
+ return ret;
- st->d_size = d_size;
+ /* Now compute overall size */
+ scan_count = bitmap_weight(indio_dev->active_scan_mask,
+ indio_dev->masklength);
command = AD7298_WRITE | st->ext_ref;
@@ -102,7 +94,7 @@ static irqreturn_t ad7298_trigger_handler(int irq, void *p)
if (ring->scan_timestamp) {
time_ns = iio_get_time_ns();
- memcpy((u8 *)buf + st->d_size - sizeof(s64),
+ memcpy((u8 *)buf + indio_dev->scan_bytes - sizeof(s64),
&time_ns, sizeof(time_ns));
}
--
1.7.0.4
next prev parent reply other threads:[~2012-04-18 13:14 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-04-18 13:13 [PATCH 00/14] Staging:iio: Cleanup and refactor pre multibuffer Jonathan Cameron
2012-04-18 13:13 ` [PATCH 01/14] staging:iio:buffer trivial use of strtobool to remove dodgy equivalent Jonathan Cameron
2012-04-18 13:13 ` [PATCH 02/14] staging:iio:buffer: pull computation of scan length into a utility function Jonathan Cameron
2012-04-18 13:13 ` [PATCH 03/14] staging:iio: scan_index_timestamp move to iio_dev from buffer Jonathan Cameron
2012-04-18 13:13 ` [PATCH 04/14] staging:iio: add caching of the number of bytes in a scan Jonathan Cameron
[not found] ` <4F91944F.3070701@metafoo.de>
2012-04-20 17:02 ` Jonathan Cameron
2012-04-18 13:13 ` [PATCH 05/14] staging:iio:adc:ad7192 make use of iio_sw_buffer_preenable Jonathan Cameron
2012-04-18 13:13 ` Jonathan Cameron [this message]
2012-04-18 13:13 ` [PATCH 07/14] staging:iio:adc:ad7476 use iio_sw_buffer_preenable instead of local version Jonathan Cameron
2012-04-18 13:13 ` [PATCH 08/14] staging:iio:adc:ad7793 use iio_sw_buffer_preenable to avoid repitition Jonathan Cameron
2012-04-18 13:13 ` [PATCH 09/14] staging:iio:adc:ad7887 make use of iio_sw_buffer_preenable Jonathan Cameron
2012-04-18 13:13 ` [PATCH 10/14] staging:iio:adc:ad799x use iio_sw_buffer_preenable to avoid code repitiion Jonathan Cameron
2012-04-18 13:13 ` [PATCH 11/14] staging:iio:meter:ad7758 use iio_sw_buffer_preenable to avoid code repition Jonathan Cameron
2012-04-18 13:13 ` [PATCH 12/14] staging:iio:impedance-analyser make use of iio_sw_buffer_preenable Jonathan Cameron
2012-04-18 13:13 ` [PATCH 13/14] staging:iio: Add caching of scan_timestamp to the core as well as buffers Jonathan Cameron
2012-04-18 13:13 ` [PATCH 14/14] staging:iio: pull out demux cleanup for a particular buffer Jonathan Cameron
[not found] ` <4F919648.2070503@metafoo.de>
2012-04-21 9:10 ` [PATCH 00/14] Staging:iio: Cleanup and refactor pre multibuffer 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=1334754834-13622-7-git-send-email-jic23@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).