* [PATCH 1/5] staging:iio:kfifo remove entirely pointless code.
2011-10-20 16:29 [PATCH 0/5] staging:iio: add demux support Jonathan Cameron
@ 2011-10-20 16:29 ` Jonathan Cameron
2011-10-20 16:29 ` [PATCH 2/5] staging:iio:fine iio channel from scan index util function Jonathan Cameron
` (3 subsequent siblings)
4 siblings, 0 replies; 7+ messages in thread
From: Jonathan Cameron @ 2011-10-20 16:29 UTC (permalink / raw)
To: linux-iio; +Cc: Jonathan Cameron
I really don't want to think about how this bit got
in there. It allocates some storage - copies something
into it then frees it without making use of it.
Oops.
Signed-off-by: Jonathan Cameron <jic23@cam.ac.uk>
---
drivers/staging/iio/kfifo_buf.c | 9 +--------
1 files changed, 1 insertions(+), 8 deletions(-)
diff --git a/drivers/staging/iio/kfifo_buf.c b/drivers/staging/iio/kfifo_buf.c
index e8c234b..fd98a0e 100644
--- a/drivers/staging/iio/kfifo_buf.c
+++ b/drivers/staging/iio/kfifo_buf.c
@@ -150,16 +150,9 @@ static int iio_store_to_kfifo(struct iio_buffer *r,
{
int ret;
struct iio_kfifo *kf = iio_to_kfifo(r);
- u8 *datal = kmalloc(r->bytes_per_datum, GFP_KERNEL);
- memcpy(datal, data, r->bytes_per_datum - sizeof(timestamp));
- memcpy(datal + r->bytes_per_datum - sizeof(timestamp),
- ×tamp, sizeof(timestamp));
ret = kfifo_in(&kf->kf, data, r->bytes_per_datum);
- if (ret != r->bytes_per_datum) {
- kfree(datal);
+ if (ret != r->bytes_per_datum)
return -EBUSY;
- }
- kfree(datal);
return 0;
}
--
1.7.7
^ permalink raw reply related [flat|nested] 7+ messages in thread* [PATCH 2/5] staging:iio:fine iio channel from scan index util function
2011-10-20 16:29 [PATCH 0/5] staging:iio: add demux support Jonathan Cameron
2011-10-20 16:29 ` [PATCH 1/5] staging:iio:kfifo remove entirely pointless code Jonathan Cameron
@ 2011-10-20 16:29 ` Jonathan Cameron
2011-10-20 16:29 ` [PATCH 3/5] staging:iio: trigger fixes for repeat request of same trigger and allocation failure Jonathan Cameron
` (2 subsequent siblings)
4 siblings, 0 replies; 7+ messages in thread
From: Jonathan Cameron @ 2011-10-20 16:29 UTC (permalink / raw)
To: linux-iio; +Cc: Jonathan Cameron
Useful for getting to the channel based on scan mask alone.
Signed-off-by: Jonathan Cameron <jic23@cam.ac.uk>
---
drivers/staging/iio/iio.h | 8 ++++++++
drivers/staging/iio/industrialio-core.c | 11 +++++++++++
2 files changed, 19 insertions(+), 0 deletions(-)
diff --git a/drivers/staging/iio/iio.h b/drivers/staging/iio/iio.h
index f3d88cd..429589f 100644
--- a/drivers/staging/iio/iio.h
+++ b/drivers/staging/iio/iio.h
@@ -322,6 +322,14 @@ struct iio_dev {
};
/**
+ * iio_find_channel_from_si() - get channel from its scan index
+ * @indio_dev: device
+ * @si: scan index to match
+ */
+const struct iio_chan_spec
+*iio_find_channel_from_si(struct iio_dev *indio_dev, int si);
+
+/**
* iio_device_register() - register a device with the IIO subsystem
* @indio_dev: Device structure filled by the device driver
**/
diff --git a/drivers/staging/iio/industrialio-core.c b/drivers/staging/iio/industrialio-core.c
index 326e967..00ef005 100644
--- a/drivers/staging/iio/industrialio-core.c
+++ b/drivers/staging/iio/industrialio-core.c
@@ -88,6 +88,17 @@ static const char * const iio_chan_info_postfix[] = {
[IIO_CHAN_INFO_AVERAGE_RAW_SHARED/2] = "mean_raw",
};
+const struct iio_chan_spec
+*iio_find_channel_from_si(struct iio_dev *indio_dev, int si)
+{
+ int i;
+
+ for (i = 0; i < indio_dev->num_channels; i++)
+ if (indio_dev->channels[i].scan_index == si)
+ return &indio_dev->channels[i];
+ return NULL;
+}
+
/**
* struct iio_detected_event_list - list element for events that have occurred
* @list: linked list header
--
1.7.7
^ permalink raw reply related [flat|nested] 7+ messages in thread* [PATCH 3/5] staging:iio: trigger fixes for repeat request of same trigger and allocation failure
2011-10-20 16:29 [PATCH 0/5] staging:iio: add demux support Jonathan Cameron
2011-10-20 16:29 ` [PATCH 1/5] staging:iio:kfifo remove entirely pointless code Jonathan Cameron
2011-10-20 16:29 ` [PATCH 2/5] staging:iio:fine iio channel from scan index util function Jonathan Cameron
@ 2011-10-20 16:29 ` Jonathan Cameron
2011-10-20 16:29 ` [PATCH 4/5] staging:iio: add demux optionally to path from device to buffer Jonathan Cameron
2011-10-20 16:29 ` [PATCH 5/5] staging:iio:adc:max1363 use new demuxing support Jonathan Cameron
4 siblings, 0 replies; 7+ messages in thread
From: Jonathan Cameron @ 2011-10-20 16:29 UTC (permalink / raw)
To: linux-iio; +Cc: Jonathan Cameron
Both of these are decidedly silly bugs show up whilst testing
completely different code paths.
Signed-off-by: Jonathan Cameron <jic23@cam.ac.uk>
---
drivers/staging/iio/industrialio-trigger.c | 12 +++++++++++-
1 files changed, 11 insertions(+), 1 deletions(-)
diff --git a/drivers/staging/iio/industrialio-trigger.c b/drivers/staging/iio/industrialio-trigger.c
index 2c626e0..57c8d83 100644
--- a/drivers/staging/iio/industrialio-trigger.c
+++ b/drivers/staging/iio/industrialio-trigger.c
@@ -222,8 +222,16 @@ static int iio_trigger_attach_poll_func(struct iio_trigger *trig,
ret = request_threaded_irq(pf->irq, pf->h, pf->thread,
pf->type, pf->name,
pf);
- if (trig->ops && trig->ops->set_trigger_state && notinuse)
+ if (ret < 0) {
+ module_put(pf->indio_dev->info->driver_module);
+ return ret;
+ }
+
+ if (trig->ops && trig->ops->set_trigger_state && notinuse) {
ret = trig->ops->set_trigger_state(trig, true);
+ if (ret < 0)
+ module_put(pf->indio_dev->info->driver_module);
+ }
return ret;
}
@@ -336,6 +344,8 @@ static ssize_t iio_trigger_write_current(struct device *dev,
mutex_unlock(&indio_dev->mlock);
trig = iio_trigger_find_by_name(buf, len);
+ if (oldtrig == trig)
+ return len;
if (trig && indio_dev->info->validate_trigger) {
ret = indio_dev->info->validate_trigger(indio_dev, trig);
--
1.7.7
^ permalink raw reply related [flat|nested] 7+ messages in thread* [PATCH 4/5] staging:iio: add demux optionally to path from device to buffer
2011-10-20 16:29 [PATCH 0/5] staging:iio: add demux support Jonathan Cameron
` (2 preceding siblings ...)
2011-10-20 16:29 ` [PATCH 3/5] staging:iio: trigger fixes for repeat request of same trigger and allocation failure Jonathan Cameron
@ 2011-10-20 16:29 ` Jonathan Cameron
2011-10-20 16:29 ` [PATCH 5/5] staging:iio:adc:max1363 use new demuxing support Jonathan Cameron
4 siblings, 0 replies; 7+ messages in thread
From: Jonathan Cameron @ 2011-10-20 16:29 UTC (permalink / raw)
To: linux-iio; +Cc: Jonathan Cameron
This gives you only what you ask for which is handy
for some devices with weird scan combinations.
Routes all data flow through a core utility function.
That and this demuxing support will be needed to do
demuxing to multiple destinations in kernel.
Signed-off-by: Jonathan Cameron <jic23@cam.ac.uk>
---
drivers/staging/iio/buffer_generic.h | 15 ++++
drivers/staging/iio/industrialio-buffer.c | 120 ++++++++++++++++++++++++++++-
2 files changed, 131 insertions(+), 4 deletions(-)
diff --git a/drivers/staging/iio/buffer_generic.h b/drivers/staging/iio/buffer_generic.h
index 9e8f010..1b0e781 100644
--- a/drivers/staging/iio/buffer_generic.h
+++ b/drivers/staging/iio/buffer_generic.h
@@ -96,6 +96,8 @@ struct iio_buffer_setup_ops {
* @access: [DRIVER] buffer access functions associated with the
* implementation.
* @flags: [INTERN] file ops related flags including busy flag.
+ * @demux_list: [INTERN] list of operations required to demux the scan.
+ * @demux_bounce: [INTERN] buffer for doing gather from incoming scan.
**/
struct iio_buffer {
struct iio_dev *indio_dev;
@@ -115,6 +117,8 @@ struct iio_buffer {
bool stufftoread;
unsigned long flags;
const struct attribute_group *attrs;
+ struct list_head demux_list;
+ unsigned char *demux_bounce;
};
/**
@@ -153,6 +157,17 @@ int iio_scan_mask_set(struct iio_buffer *buffer, int bit);
container_of(d, struct iio_buffer, dev)
/**
+ * iio_push_to_buffer() - push to a registered buffer.
+ * @buffer: IIO buffer structure for device
+ * @scan: Full scan.
+ * @timestamp:
+ */
+int iio_push_to_buffer(struct iio_buffer *buffer, unsigned char *data,
+ s64 timestamp);
+
+int iio_update_demux(struct iio_dev *indio_dev);
+
+/**
* iio_buffer_register() - register the buffer with IIO core
* @indio_dev: device with the buffer to be registered
**/
diff --git a/drivers/staging/iio/industrialio-buffer.c b/drivers/staging/iio/industrialio-buffer.c
index 6dd5d7d..bac672d 100644
--- a/drivers/staging/iio/industrialio-buffer.c
+++ b/drivers/staging/iio/industrialio-buffer.c
@@ -125,10 +125,9 @@ static ssize_t iio_scan_el_show(struct device *dev,
int ret;
struct iio_dev *indio_dev = dev_get_drvdata(dev);
- ret = iio_scan_mask_query(indio_dev->buffer,
- to_iio_dev_attr(attr)->address);
- if (ret < 0)
- return ret;
+ ret = test_bit(to_iio_dev_attr(attr)->address,
+ indio_dev->buffer->scan_mask);
+
return sprintf(buf, "%d\n", ret);
}
@@ -295,6 +294,7 @@ int iio_buffer_register(struct iio_dev *indio_dev,
attrcount_orig++;
}
attrcount = attrcount_orig;
+ INIT_LIST_HEAD(&buffer->demux_list);
INIT_LIST_HEAD(&buffer->scan_el_dev_attr_list);
if (channels) {
/* new magic */
@@ -633,3 +633,115 @@ int iio_scan_mask_query(struct iio_buffer *buffer, int bit)
return test_bit(bit, mask);
};
EXPORT_SYMBOL_GPL(iio_scan_mask_query);
+
+/**
+ * struct iio_demux_table() - table describing demux memcpy ops
+ * @from: index to copy from
+ * @to: index to copy to
+ * @length: how many bytes to copy
+ * @l: list head used for management
+ */
+struct iio_demux_table {
+ unsigned from;
+ unsigned to;
+ unsigned length;
+ struct list_head l;
+};
+
+static unsigned char * iio_demux(struct iio_buffer *buffer,
+ unsigned char *datain)
+{
+ struct iio_demux_table *t;
+
+ if (list_empty(&buffer->demux_list))
+ return datain;
+ list_for_each_entry(t, &buffer->demux_list, l)
+ memcpy(buffer->demux_bounce + t->to,
+ datain + t->from, t->length);
+
+ return buffer->demux_bounce;
+}
+
+int iio_push_to_buffer(struct iio_buffer *buffer, unsigned char *data,
+ s64 timestamp)
+{
+ unsigned char *dataout = iio_demux(buffer, data);
+
+ return buffer->access->store_to(buffer, dataout, timestamp);
+}
+EXPORT_SYMBOL_GPL(iio_push_to_buffer);
+
+int iio_update_demux(struct iio_dev *indio_dev)
+{
+ const struct iio_chan_spec *ch;
+ struct iio_buffer *buffer = indio_dev->buffer;
+ long *in_mask;
+ int ret, in_ind = -1, out_ind, length;
+ unsigned in_loc = 0, out_loc = 0;
+ struct iio_demux_table *p, *q;
+
+ /* Clear out any old demux */
+ list_for_each_entry_safe(p, q, &buffer->demux_list, l) {
+ list_del(&p->l);
+ kfree(p);
+ }
+ kfree(buffer->demux_bounce);
+
+ /* First work out which scan mode we will actually have */
+ in_mask = iio_scan_mask_match(indio_dev->available_scan_masks,
+ indio_dev->masklength,
+ buffer->scan_mask);
+
+ out_ind = find_first_bit(buffer->scan_mask, indio_dev->masklength);
+ /* Now we have the two masks, work from least sig and build up sizes */
+ while (out_ind != indio_dev->masklength) {
+ in_ind = find_next_bit(in_mask,
+ indio_dev->masklength,
+ in_ind + 1);
+ while (in_ind != out_ind) {
+ in_ind = find_next_bit(in_mask,
+ indio_dev->masklength,
+ in_ind + 1);
+ ch = iio_find_channel_from_si(indio_dev, in_ind);
+ length = ch->scan_type.storagebits/8;
+ /* Make sure we are aligned */
+ in_loc += length;
+ if (in_loc % length)
+ in_loc += length - in_loc % length;
+ }
+ p = kmalloc(sizeof(*p), GFP_KERNEL);
+ if (p == NULL) {
+ ret = -ENOMEM;
+ goto error_clear_mux_table;
+ }
+ ch = iio_find_channel_from_si(indio_dev, in_ind);
+ length = ch->scan_type.storagebits/8;
+ if (out_loc % length)
+ out_loc += length - out_loc % length;
+ if (in_loc % length)
+ in_loc += length - in_loc % length;
+ p->from = in_loc;
+ p->to = out_loc;
+ p->length = length;
+ list_add_tail(&p->l, &buffer->demux_list);
+ out_loc += length;
+ in_loc += length;
+ out_ind = find_next_bit(buffer->scan_mask,
+ indio_dev->masklength,
+ out_ind + 1);
+ }
+ buffer->demux_bounce = kzalloc(out_loc, GFP_KERNEL);
+ if (buffer->demux_bounce == NULL) {
+ ret = -ENOMEM;
+ goto error_clear_mux_table;
+ }
+ return 0;
+
+error_clear_mux_table:
+ list_for_each_entry_safe(p, q, &buffer->demux_list, l) {
+ list_del(&p->l);
+ kfree(p);
+ }
+ return ret;
+}
+EXPORT_SYMBOL_GPL(iio_update_demux);
--
1.7.7
^ permalink raw reply related [flat|nested] 7+ messages in thread* [PATCH 5/5] staging:iio:adc:max1363 use new demuxing support.
2011-10-20 16:29 [PATCH 0/5] staging:iio: add demux support Jonathan Cameron
` (3 preceding siblings ...)
2011-10-20 16:29 ` [PATCH 4/5] staging:iio: add demux optionally to path from device to buffer Jonathan Cameron
@ 2011-10-20 16:29 ` Jonathan Cameron
2011-10-24 13:45 ` Jonathan Cameron
4 siblings, 1 reply; 7+ messages in thread
From: Jonathan Cameron @ 2011-10-20 16:29 UTC (permalink / raw)
To: linux-iio; +Cc: Jonathan Cameron
Note that time stamps are not currently supported
hence for now I've cheekly removed them from this
driver. Also hence no sign off.
---
drivers/staging/iio/adc/max1363_core.c | 4 ----
drivers/staging/iio/adc/max1363_ring.c | 27 ++++++---------------------
2 files changed, 6 insertions(+), 25 deletions(-)
diff --git a/drivers/staging/iio/adc/max1363_core.c b/drivers/staging/iio/adc/max1363_core.c
index eb699ad..8f19d2d 100644
--- a/drivers/staging/iio/adc/max1363_core.c
+++ b/drivers/staging/iio/adc/max1363_core.c
@@ -325,7 +325,6 @@ static const enum max1363_modes max1363_mode_list[] = {
MAX1363_CHAN_B(2, 3, d2m3, 5, bits, em), \
MAX1363_CHAN_B(1, 0, d1m0, 6, bits, em), \
MAX1363_CHAN_B(3, 2, d3m2, 7, bits, em), \
- IIO_CHAN_SOFT_TIMESTAMP(8) \
}
static struct iio_chan_spec max1036_channels[] = MAX1363_4X_CHANS(8, 0);
@@ -383,7 +382,6 @@ static const enum max1363_modes max1238_mode_list[] = {
MAX1363_CHAN_B(7, 6, d7m6, 21, bits, 0), \
MAX1363_CHAN_B(9, 8, d9m8, 22, bits, 0), \
MAX1363_CHAN_B(11, 10, d11m10, 23, bits, 0), \
- IIO_CHAN_SOFT_TIMESTAMP(24) \
}
static struct iio_chan_spec max1038_channels[] = MAX1363_12X_CHANS(8);
static struct iio_chan_spec max1138_channels[] = MAX1363_12X_CHANS(10);
@@ -424,7 +422,6 @@ static const enum max1363_modes max11608_mode_list[] = {
MAX1363_CHAN_B(3, 2, d3m2, 13, bits, 0), \
MAX1363_CHAN_B(5, 4, d5m4, 14, bits, 0), \
MAX1363_CHAN_B(7, 6, d7m6, 15, bits, 0), \
- IIO_CHAN_SOFT_TIMESTAMP(16) \
}
static struct iio_chan_spec max11602_channels[] = MAX1363_8X_CHANS(8);
static struct iio_chan_spec max11608_channels[] = MAX1363_8X_CHANS(10);
@@ -439,7 +436,6 @@ static const enum max1363_modes max11644_mode_list[] = {
MAX1363_CHAN_U(1, _s1, 1, bits, 0), \
MAX1363_CHAN_B(0, 1, d0m1, 2, bits, 0), \
MAX1363_CHAN_B(1, 0, d1m0, 3, bits, 0), \
- IIO_CHAN_SOFT_TIMESTAMP(4) \
}
static struct iio_chan_spec max11646_channels[] = MAX1363_2X_CHANS(10);
diff --git a/drivers/staging/iio/adc/max1363_ring.c b/drivers/staging/iio/adc/max1363_ring.c
index df6893e..294dec9 100644
--- a/drivers/staging/iio/adc/max1363_ring.c
+++ b/drivers/staging/iio/adc/max1363_ring.c
@@ -68,36 +68,21 @@ error_ret:
static int max1363_ring_preenable(struct iio_dev *indio_dev)
{
struct max1363_state *st = iio_priv(indio_dev);
- struct iio_buffer *ring = indio_dev->buffer;
- size_t d_size = 0;
- unsigned long numvals;
/*
* Need to figure out the current mode based upon the requested
* scan mask in iio_dev
*/
- st->current_mode = max1363_match_mode(ring->scan_mask,
- st->chip_info);
+ st->current_mode = max1363_match_mode(indio_dev->buffer->scan_mask,
+ st->chip_info);
if (!st->current_mode)
return -EINVAL;
-
max1363_set_scan_mode(st);
- numvals = bitmap_weight(st->current_mode->modemask,
- indio_dev->masklength);
- if (ring->access->set_bytes_per_datum) {
- if (ring->scan_timestamp)
- d_size += sizeof(s64);
- if (st->chip_info->bits != 8)
- d_size += numvals*2;
- else
- d_size += numvals;
- if (ring->scan_timestamp && (d_size % 8))
- d_size += 8 - (d_size % 8);
- ring->access->set_bytes_per_datum(ring, d_size);
- }
+ /* work out how to pull out the channels we actually want */
+ iio_update_demux(indio_dev);
- return 0;
+ return iio_sw_buffer_preenable(indio_dev);
}
static irqreturn_t max1363_trigger_handler(int irq, void *p)
@@ -141,7 +126,7 @@ static irqreturn_t max1363_trigger_handler(int irq, void *p)
memcpy(rxbuf + d_size - sizeof(s64), &time_ns, sizeof(time_ns));
- indio_dev->buffer->access->store_to(indio_dev->buffer, rxbuf, time_ns);
+ iio_push_to_buffer(indio_dev->buffer, rxbuf, time_ns);
done:
iio_trigger_notify_done(indio_dev->trig);
kfree(rxbuf);
--
1.7.7
^ permalink raw reply related [flat|nested] 7+ messages in thread* Re: [PATCH 5/5] staging:iio:adc:max1363 use new demuxing support.
2011-10-20 16:29 ` [PATCH 5/5] staging:iio:adc:max1363 use new demuxing support Jonathan Cameron
@ 2011-10-24 13:45 ` Jonathan Cameron
0 siblings, 0 replies; 7+ messages in thread
From: Jonathan Cameron @ 2011-10-24 13:45 UTC (permalink / raw)
To: Jonathan Cameron; +Cc: linux-iio
On 10/20/11 17:29, Jonathan Cameron wrote:
> Note that time stamps are not currently supported
> hence for now I've cheekly removed them from this
> driver. Also hence no sign off.
Also in a last minute 'cleanup' I removed the bit that set
buffer->bpe appropriately. Bad idea as now it is used
(before it wasn't).
oops.
> ---
> drivers/staging/iio/adc/max1363_core.c | 4 ----
> drivers/staging/iio/adc/max1363_ring.c | 27 ++++++---------------------
> 2 files changed, 6 insertions(+), 25 deletions(-)
>
> diff --git a/drivers/staging/iio/adc/max1363_core.c b/drivers/staging/iio/adc/max1363_core.c
> index eb699ad..8f19d2d 100644
> --- a/drivers/staging/iio/adc/max1363_core.c
> +++ b/drivers/staging/iio/adc/max1363_core.c
> @@ -325,7 +325,6 @@ static const enum max1363_modes max1363_mode_list[] = {
> MAX1363_CHAN_B(2, 3, d2m3, 5, bits, em), \
> MAX1363_CHAN_B(1, 0, d1m0, 6, bits, em), \
> MAX1363_CHAN_B(3, 2, d3m2, 7, bits, em), \
> - IIO_CHAN_SOFT_TIMESTAMP(8) \
> }
>
> static struct iio_chan_spec max1036_channels[] = MAX1363_4X_CHANS(8, 0);
> @@ -383,7 +382,6 @@ static const enum max1363_modes max1238_mode_list[] = {
> MAX1363_CHAN_B(7, 6, d7m6, 21, bits, 0), \
> MAX1363_CHAN_B(9, 8, d9m8, 22, bits, 0), \
> MAX1363_CHAN_B(11, 10, d11m10, 23, bits, 0), \
> - IIO_CHAN_SOFT_TIMESTAMP(24) \
> }
> static struct iio_chan_spec max1038_channels[] = MAX1363_12X_CHANS(8);
> static struct iio_chan_spec max1138_channels[] = MAX1363_12X_CHANS(10);
> @@ -424,7 +422,6 @@ static const enum max1363_modes max11608_mode_list[] = {
> MAX1363_CHAN_B(3, 2, d3m2, 13, bits, 0), \
> MAX1363_CHAN_B(5, 4, d5m4, 14, bits, 0), \
> MAX1363_CHAN_B(7, 6, d7m6, 15, bits, 0), \
> - IIO_CHAN_SOFT_TIMESTAMP(16) \
> }
> static struct iio_chan_spec max11602_channels[] = MAX1363_8X_CHANS(8);
> static struct iio_chan_spec max11608_channels[] = MAX1363_8X_CHANS(10);
> @@ -439,7 +436,6 @@ static const enum max1363_modes max11644_mode_list[] = {
> MAX1363_CHAN_U(1, _s1, 1, bits, 0), \
> MAX1363_CHAN_B(0, 1, d0m1, 2, bits, 0), \
> MAX1363_CHAN_B(1, 0, d1m0, 3, bits, 0), \
> - IIO_CHAN_SOFT_TIMESTAMP(4) \
> }
>
> static struct iio_chan_spec max11646_channels[] = MAX1363_2X_CHANS(10);
> diff --git a/drivers/staging/iio/adc/max1363_ring.c b/drivers/staging/iio/adc/max1363_ring.c
> index df6893e..294dec9 100644
> --- a/drivers/staging/iio/adc/max1363_ring.c
> +++ b/drivers/staging/iio/adc/max1363_ring.c
> @@ -68,36 +68,21 @@ error_ret:
> static int max1363_ring_preenable(struct iio_dev *indio_dev)
> {
> struct max1363_state *st = iio_priv(indio_dev);
> - struct iio_buffer *ring = indio_dev->buffer;
> - size_t d_size = 0;
> - unsigned long numvals;
>
> /*
> * Need to figure out the current mode based upon the requested
> * scan mask in iio_dev
> */
> - st->current_mode = max1363_match_mode(ring->scan_mask,
> - st->chip_info);
> + st->current_mode = max1363_match_mode(indio_dev->buffer->scan_mask,
> + st->chip_info);
> if (!st->current_mode)
> return -EINVAL;
> -
> max1363_set_scan_mode(st);
>
> - numvals = bitmap_weight(st->current_mode->modemask,
> - indio_dev->masklength);
> - if (ring->access->set_bytes_per_datum) {
> - if (ring->scan_timestamp)
> - d_size += sizeof(s64);
> - if (st->chip_info->bits != 8)
> - d_size += numvals*2;
> - else
> - d_size += numvals;
> - if (ring->scan_timestamp && (d_size % 8))
> - d_size += 8 - (d_size % 8);
> - ring->access->set_bytes_per_datum(ring, d_size);
> - }
> + /* work out how to pull out the channels we actually want */
> + iio_update_demux(indio_dev);
>
> - return 0;
> + return iio_sw_buffer_preenable(indio_dev);
> }
>
> static irqreturn_t max1363_trigger_handler(int irq, void *p)
> @@ -141,7 +126,7 @@ static irqreturn_t max1363_trigger_handler(int irq, void *p)
>
> memcpy(rxbuf + d_size - sizeof(s64), &time_ns, sizeof(time_ns));
>
> - indio_dev->buffer->access->store_to(indio_dev->buffer, rxbuf, time_ns);
> + iio_push_to_buffer(indio_dev->buffer, rxbuf, time_ns);
> done:
> iio_trigger_notify_done(indio_dev->trig);
> kfree(rxbuf);
^ permalink raw reply [flat|nested] 7+ messages in thread