Staging:iio: Cleanup and refactor pre multibuffer.
Subsystems (4)
Jonathan Cameron
maintainercover Staging:iio: Cleanup and refactor pre multibuffer.
Sits on top of the series
[PATCH 00/16 V3] IIO: Make the value attribute optional for channels
This series consists of the first chunk of what was
[PATCH 1/4] staging:iio: make all buffer access pass through the buffer_list As Lars-Peter rightly pointed out that patch was a whole mess of different elements all bunged in together.
I believe this lot are all fairly uncontroversial unless I have trashed a driver by accident. (which is entirely plausible).
There are a few temporary frigs in here to ensure some of the cached values are correct before we put the real change in place. For example the scan_timestamp gets cached both in the core and in the buffers. For this change it would have made sense to drop it from the buffers but then we'd just end up putting it back again a few patches later.
Anyhow, please do take a look at what we have here. Some are trivial, but there are a good few driver reworks that could do with testing (as I'll almost guarantee I've messed something up ripping the original large patch apart!)
Thanks,
Jonathan Cameron
Jonathan Cameron (14):
staging:iio:buffer trivial use of strtobool to remove dodgy
equivalent.
staging:iio:buffer: pull computation of scan length into a utility
function.
staging:iio: scan_index_timestamp move to iio_dev from buffer staging:iio: add caching of the number of bytes in a scan. staging:iio:adc:ad7192 make use of iio_sw_buffer_preenable. staging:iio:adc:ad7298 use iio_sw_buffer_preenable to avoid code
repitition.
staging:iio:adc:ad7476 use iio_sw_buffer_preenable instead of local
version.
staging:iio:adc:ad7793 use iio_sw_buffer_preenable to avoid
repitition.
staging:iio:adc:ad7887 make use of iio_sw_buffer_preenable. staging:iio:adc:ad799x use iio_sw_buffer_preenable to avoid code
repitiion
staging:iio:meter:ad7758 use iio_sw_buffer_preenable to avoid code
repition
staging:iio:impedance-analyser make use of iio_sw_buffer_preenable staging:iio: Add caching of scan_timestamp to the core as well as
buffers.
staging:iio: pull out demux cleanup for a particular buffer.
drivers/staging/iio/accel/adis16201_ring.c | 5 +- drivers/staging/iio/accel/adis16203_ring.c | 5 +- drivers/staging/iio/accel/adis16204_ring.c | 5 +- drivers/staging/iio/accel/adis16209_ring.c | 6 +- drivers/staging/iio/accel/adis16240_ring.c | 5 +- drivers/staging/iio/accel/lis3l02dq_ring.c | 6 +- drivers/staging/iio/adc/ad7192.c | 24 ++------ drivers/staging/iio/adc/ad7298.h | 1 - drivers/staging/iio/adc/ad7298_ring.c | 26 +++------ drivers/staging/iio/adc/ad7476.h | 1 - drivers/staging/iio/adc/ad7476_ring.c | 38 +----------- drivers/staging/iio/adc/ad7606_ring.c | 8 +-- drivers/staging/iio/adc/ad7793.c | 23 ++------ drivers/staging/iio/adc/ad7887.h | 1 - drivers/staging/iio/adc/ad7887_ring.c | 25 ++------ drivers/staging/iio/adc/ad799x.h | 1 - drivers/staging/iio/adc/ad799x_ring.c | 24 +------- drivers/staging/iio/adc/max1363_ring.c | 4 +- drivers/staging/iio/buffer.h | 2 - drivers/staging/iio/gyro/adis16260_ring.c | 5 +- drivers/staging/iio/iio.h | 6 ++ drivers/staging/iio/iio_simple_dummy_buffer.c | 11 +-- drivers/staging/iio/impedance-analyzer/ad5933.c | 11 +--- drivers/staging/iio/imu/adis16400_ring.c | 4 +- drivers/staging/iio/industrialio-buffer.c | 69 +++++++++++++++-------- drivers/staging/iio/meter/ade7758_ring.c | 22 ++----- 26 files changed, 121 insertions(+), 217 deletions(-)
Jonathan Cameron
maintainerPATCH 1/14 staging:iio:buffer trivial use of strtobool to remove dodgy equivalent.
--- drivers/staging/iio/industrialio-buffer.c | 13 +++++++++---- 1 files changed, 9 insertions(+), 4 deletions(-)
drivers/staging/iio/industrialio-buffer.c +9 -4
@@ -124,13 +124,15 @@ static ssize_t iio_scan_el_store(struct device *dev,const char *buf, size_t len) { - int ret = 0; + int ret;bool state;struct iio_dev *indio_dev =dev_get_drvdata (dev);struct iio_buffer *buffer = indio_dev->buffer;struct iio_dev_attr *this_attr =to_iio_dev_attr (attr); - state = !(buf[0 ] =='0' ); + ret =strtobool (buf, &state); +if (ret <0 ) +return ret;mutex_lock (&indio_dev->mlock);if (iio_buffer_enabled (indio_dev)) { ret = -EBUSY ;
@@ -169,11 +171,14 @@ static ssize_t iio_scan_el_ts_store(struct device *dev,const char *buf, size_t len) { - int ret = 0; + int ret;struct iio_dev *indio_dev =dev_get_drvdata (dev);bool state; - state = !(buf[0 ] =='0' ); + ret =strtobool (buf, &state); +if (ret <0 ) +return ret; +mutex_lock (&indio_dev->mlock);if (iio_buffer_enabled (indio_dev)) { ret = -EBUSY ;
Signature · 1 line
1.7.0.4
Jonathan Cameron
maintainerPATCH 2/14 staging:iio:buffer: pull computation of scan length into a utility function.
In reply to Jonathan CameronPrincipal reason is to make later patches more coherent and easier to review but this set in itself separates a logical entity out nicely wihin the code.
--- drivers/staging/iio/industrialio-buffer.c | 28 ++++++++++++++++++++-------- 1 files changed, 20 insertions(+), 8 deletions(-)
drivers/staging/iio/industrialio-buffer.c +20 -8
@@ -508,30 +508,41 @@ static const unsigned long *iio_scan_mask_match(const unsigned long *av_masks,return NULL ; } -int iio_sw_buffer_preenable (struct iio_dev *indio_dev) +static int iio_compute_scan_bytes (struct iio_dev *indio_dev,const long *mask, +bool timestamp) { -struct iio_buffer *buffer = indio_dev->buffer;const struct iio_chan_spec *ch;unsigned bytes =0 ;int length, i; -dev_dbg (&indio_dev->dev,"%s\n" , __func__);/* How much space will the demuxed element take? */ -for_each_set_bit (i, buffer->scan_mask, +for_each_set_bit (i, mask, indio_dev->masklength) { ch =iio_find_channel_from_si (indio_dev, i); - length = ch->scan_type.storagebits/8 ; + length = ch->scan_type.storagebits /8 ; bytes =ALIGN (bytes, length); bytes += length; } -if (buffer->scan_timestamp) { +if (timestamp) { ch =iio_find_channel_from_si (indio_dev, - buffer->scan_index_timestamp); - length = ch->scan_type.storagebits/8 ; + indio_dev + ->buffer->scan_index_timestamp); + length = ch->scan_type.storagebits /8 ; bytes =ALIGN (bytes, length); bytes += length; } +return bytes; +} + +int iio_sw_buffer_preenable (struct iio_dev *indio_dev) +{ +struct iio_buffer *buffer = indio_dev->buffer; +unsigned bytes; +dev_dbg (&indio_dev->dev,"%s\n" , __func__); + +/* How much space will the demuxed element take? */ + bytes =iio_compute_scan_bytes (indio_dev, buffer->scan_mask, + buffer->scan_timestamp); buffer->access->set_bytes_per_datum (buffer, bytes);/* What scan mask do we actually have ?*/
Signature · 1 line
1.7.0.4
Jonathan Cameron
maintainerPATCH 3/14 staging:iio: scan_index_timestamp move to iio_dev from buffer
In reply to Jonathan CameronThis is just a locally cached value that is device specific (rather than buffer specific.) Hence it wants to come out of the buffer before we add multiple buffer support.
--- drivers/staging/iio/buffer.h | 2 -- drivers/staging/iio/iio.h | 2 ++ drivers/staging/iio/industrialio-buffer.c | 7 +++---- 3 files changed, 5 insertions(+), 6 deletions(-)
drivers/staging/iio/buffer.h +0 -2
@@ -56,7 +56,6 @@ struct iio_buffer_access_funcs {* @scan_el_attrs: [DRIVER] control of scan elements if that scan mode * control method is used * @scan_mask: [INTERN] bitmask used in masking scan mode elements -* @scan_index_timestamp:[INTERN] cache of the index to the timestamp * @scan_timestamp: [INTERN] does the scan mode include a timestamp * @access: [DRIVER] buffer access functions associated with the * implementation.
@@ -74,7 +73,6 @@ struct iio_buffer {struct attribute_group *scan_el_attrs;long *scan_mask;bool scan_timestamp; -unsigned scan_index_timestamp;const struct iio_buffer_access_funcs *access;struct list_head scan_el_dev_attr_list;struct attribute_group scan_el_group;
drivers/staging/iio/iio.h +2 -0
@@ -305,6 +305,7 @@ struct iio_buffer_setup_ops {* @masklength: [INTERN] the length of the mask established from * channels * @active_scan_mask: [INTERN] union of all scan masks requested by buffers +* @scan_index_timestamp:[INTERN] cache of the index to the timestamp * @trig: [INTERN] current device trigger (buffer modes) * @pollfunc: [DRIVER] function run on trigger being received * @channels: [DRIVER] channel specification structure table
@@ -339,6 +340,7 @@ struct iio_dev {const unsigned long *available_scan_masks;unsigned masklength;const unsigned long *active_scan_mask; +unsigned scan_index_timestamp;struct iio_trigger *trig;struct iio_poll_func *pollfunc;
drivers/staging/iio/industrialio-buffer.c +3 -4
@@ -296,7 +296,7 @@ int iio_buffer_register(struct iio_dev *indio_dev, goto error_cleanup_dynamic; attrcount += ret;if (channels[i].type ==IIO_TIMESTAMP ) - buffer->scan_index_timestamp = + indio_dev->scan_index_timestamp = channels[i].scan_index; }if (indio_dev->masklength && buffer->scan_mask ==NULL ) {
@@ -525,8 +525,7 @@ static int iio_compute_scan_bytes(struct iio_dev *indio_dev, const long *mask, }if (timestamp) { ch =iio_find_channel_from_si (indio_dev, - indio_dev - ->buffer->scan_index_timestamp); + indio_dev->scan_index_timestamp); length = ch->scan_type.storagebits /8 ; bytes =ALIGN (bytes, length); bytes += length;
@@ -721,7 +720,7 @@ int iio_update_demux(struct iio_dev *indio_dev) goto error_clear_mux_table; } ch =iio_find_channel_from_si (indio_dev, - buffer->scan_index_timestamp); + indio_dev->scan_index_timestamp); length = ch->scan_type.storagebits/8 ;if (out_loc % length) out_loc += length - out_loc % length;
Signature · 1 line
1.7.0.4
Jonathan Cameron
maintainerPATCH 4/14 staging:iio: add caching of the number of bytes in a scan.
In reply to Jonathan Cameron--- drivers/staging/iio/accel/adis16201_ring.c | 3 +-- drivers/staging/iio/accel/adis16203_ring.c | 3 +-- drivers/staging/iio/accel/adis16204_ring.c | 3 +-- drivers/staging/iio/accel/adis16209_ring.c | 4 +--- drivers/staging/iio/accel/adis16240_ring.c | 3 +-- drivers/staging/iio/accel/lis3l02dq_ring.c | 4 ++-- drivers/staging/iio/adc/ad7606_ring.c | 3 +-- drivers/staging/iio/gyro/adis16260_ring.c | 3 +-- drivers/staging/iio/iio.h | 2 ++ drivers/staging/iio/iio_simple_dummy_buffer.c | 9 +++------ drivers/staging/iio/imu/adis16400_ring.c | 4 ++-- drivers/staging/iio/industrialio-buffer.c | 6 +++--- 12 files changed, 19 insertions(+), 28 deletions(-)
drivers/staging/iio/accel/adis16201_ring.c +1 -2
@@ -66,9 +66,8 @@ static irqreturn_t adis16201_trigger_handler(int irq, void *p)int i =0 ;s16 *data; -size_t datasize = ring->access->get_bytes_per_datum (ring); - data =kmalloc (datasize,GFP_KERNEL ); + data =kmalloc (indio_dev->scan_bytes,GFP_KERNEL );if (data ==NULL ) {dev_err (&st->us->dev,"memory alloc failed in ring bh" );return -ENOMEM ;
drivers/staging/iio/accel/adis16203_ring.c +1 -2
@@ -66,9 +66,8 @@ static irqreturn_t adis16203_trigger_handler(int irq, void *p)int i =0 ;s16 *data; -size_t datasize = ring->access->get_bytes_per_datum (ring); - data =kmalloc (datasize,GFP_KERNEL ); + data =kmalloc (indio_dev->scan_bytes,GFP_KERNEL );if (data ==NULL ) {dev_err (&st->us->dev,"memory alloc failed in ring bh" );return -ENOMEM ;
drivers/staging/iio/accel/adis16204_ring.c +1 -2
@@ -63,9 +63,8 @@ static irqreturn_t adis16204_trigger_handler(int irq, void *p)struct iio_buffer *ring = indio_dev->buffer;int i =0 ;s16 *data; -size_t datasize = ring->access->get_bytes_per_datum (ring); - data =kmalloc (datasize,GFP_KERNEL ); + data =kmalloc (indio_dev->scan_bytes,GFP_KERNEL );if (data ==NULL ) {dev_err (&st->us->dev,"memory alloc failed in ring bh" );return -ENOMEM ;
drivers/staging/iio/accel/adis16209_ring.c +1 -3
@@ -61,12 +61,10 @@ static irqreturn_t adis16209_trigger_handler(int irq, void *p)struct iio_dev *indio_dev = pf->indio_dev;struct adis16209_state *st =iio_priv (indio_dev);struct iio_buffer *ring = indio_dev->buffer; -int i =0 ;s16 *data; -size_t datasize = ring->access->get_bytes_per_datum (ring); - data =kmalloc (datasize ,GFP_KERNEL ); + data =kmalloc (indio_dev->scan_bytes,GFP_KERNEL );if (data ==NULL ) {dev_err (&st->us->dev,"memory alloc failed in ring bh" );return -ENOMEM ;
drivers/staging/iio/accel/adis16240_ring.c +1 -2
@@ -61,9 +61,8 @@ static irqreturn_t adis16240_trigger_handler(int irq, void *p)int i =0 ;s16 *data; -size_t datasize = ring->access->get_bytes_per_datum (ring); - data =kmalloc (datasize,GFP_KERNEL ); + data =kmalloc (indio_dev->scan_bytes,GFP_KERNEL );if (data ==NULL ) {dev_err (&st->us->dev,"memory alloc failed in ring bh" );return -ENOMEM ;
drivers/staging/iio/accel/lis3l02dq_ring.c +2 -2
@@ -137,9 +137,9 @@ static irqreturn_t lis3l02dq_trigger_handler(int irq, void *p)struct iio_dev *indio_dev = pf->indio_dev;struct iio_buffer *buffer = indio_dev->buffer;int len =0 ; -size_t datasize = buffer->access->get_bytes_per_datum (buffer); -char *data =kmalloc (datasize,GFP_KERNEL ); +char *data; + data =kmalloc (indio_dev->scan_bytes,GFP_KERNEL );if (data ==NULL ) {dev_err (indio_dev->dev.parent,"memory alloc failed in buffer bh" );
drivers/staging/iio/adc/ad7606_ring.c +1 -2
@@ -51,8 +51,7 @@ static void ad7606_poll_bh_to_ring(struct work_struct *work_s)__u8 *buf;int ret; - buf =kzalloc (ring->access->get_bytes_per_datum (ring), -GFP_KERNEL ); + buf =kzalloc (indio_dev->scan_bytes,GFP_KERNEL );if (buf ==NULL )return ;
drivers/staging/iio/gyro/adis16260_ring.c +1 -2
@@ -66,9 +66,8 @@ static irqreturn_t adis16260_trigger_handler(int irq, void *p)struct iio_buffer *ring = indio_dev->buffer;int i =0 ;s16 *data; -size_t datasize = ring->access->get_bytes_per_datum (ring); - data =kmalloc (datasize ,GFP_KERNEL ); + data =kmalloc (indio_dev->scan_bytes,GFP_KERNEL );if (data ==NULL ) {dev_err (&st->us->dev,"memory alloc failed in ring bh" );return -ENOMEM ;
drivers/staging/iio/iio.h +2 -0
@@ -299,6 +299,7 @@ struct iio_buffer_setup_ops {* and owner * @event_interface: [INTERN] event chrdevs associated with interrupt lines * @buffer: [DRIVER] any buffer present +* @scan_bytes: [INTERN] num bytes captured to be fed to buffer demux * @mlock: [INTERN] lock used to prevent simultaneous device state * changes * @available_scan_masks: [DRIVER] optional array of allowed bitmasks
@@ -335,6 +336,7 @@ struct iio_dev {struct iio_event_interface *event_interface;struct iio_buffer *buffer; +int scan_bytes;struct mutex mlock;const unsigned long *available_scan_masks;
drivers/staging/iio/iio_simple_dummy_buffer.c +3 -6
@@ -48,12 +48,9 @@ static irqreturn_t iio_simple_dummy_trigger_h(int irq, void *p)struct iio_dev *indio_dev = pf->indio_dev;struct iio_buffer *buffer = indio_dev->buffer;int len =0 ; -/* -* The datasize is obtained from the buffer. It was stored when -* the preenable setup function was called. -*/ -size_t datasize = buffer->access->get_bytes_per_datum (buffer); -u16 *data =kmalloc (datasize,GFP_KERNEL ); +u16 *data; + + data =kmalloc (indio_dev->scan_bytes,GFP_KERNEL );if (data ==NULL )return -ENOMEM ;
drivers/staging/iio/imu/adis16400_ring.c +2 -2
@@ -119,12 +119,12 @@ static irqreturn_t adis16400_trigger_handler(int irq, void *p)struct iio_buffer *ring = indio_dev->buffer;int i =0 , j, ret =0 ;s16 *data; -size_t datasize = ring->access->get_bytes_per_datum (ring); +/* Asumption that long is enough for maximum channels */ unsigned long mask = *indio_dev->active_scan_mask;int scan_count =bitmap_weight (indio_dev->active_scan_mask, indio_dev->masklength); - data =kmalloc (datasize ,GFP_KERNEL ); + data =kmalloc (indio_dev->scan_bytes,GFP_KERNEL );if (data ==NULL ) {dev_err (&st->us->dev,"memory alloc failed in ring bh" );return -ENOMEM ;
drivers/staging/iio/industrialio-buffer.c +3 -3
@@ -536,13 +536,13 @@ static int iio_compute_scan_bytes(struct iio_dev *indio_dev, const long *mask,int iio_sw_buffer_preenable (struct iio_dev *indio_dev) {struct iio_buffer *buffer = indio_dev->buffer; -unsigned bytes =0 ;dev_dbg (&indio_dev->dev,"%s\n" , __func__);/* How much space will the demuxed element take? */ - bytes =iio_compute_scan_bytes (indio_dev, buffer->scan_mask, + indio_dev->scan_bytes = +iio_compute_scan_bytes (indio_dev, buffer->scan_mask, buffer->scan_timestamp); - buffer->access->set_bytes_per_datum (buffer, bytes); + buffer->access->set_bytes_per_datum (buffer, indio_dev->scan_bytes);/* What scan mask do we actually have ?*/ if (indio_dev->available_scan_masks)
Signature · 1 line
1.7.0.4
A message that is not in the archive (sent off-list or not yet received): [email protected]
Re: [PATCH 04/14] staging:iio: add caching of the number of bytes in a scan.
Odd will chase that down. Probably wasn't on a clean tree. Thanks!
--
Sent from my Android phone with K-9 Mail. Please excuse my brevity.
Lars-Peter Clausen <[email protected]> wrote:
drivers/staging/iio/industrialio-buffer.c static int iio_compute_scan_bytes(struct iio_dev *indio_dev, const long *mask, · line 539
Quoted 12 lines · Jonathan Cameron
Signed-off-by Jonathan Cameron <[email protected]>---
[...]drivers/staging/iio/industrialio-buffer.c +0
-1@@ -536,13 +536,13 @@ static int iio_compute_scan_bytes(struct iio_dev *indio_dev, const long *mask,int iio_sw_buffer_preenable (struct iio_dev *indio_dev) {struct iio_buffer *buffer = indio_dev->buffer; -unsigned bytes =0 ;
This line didn't apply.
Jonathan Cameron
maintainerPATCH 5/14 staging:iio:adc:ad7192 make use of iio_sw_buffer_preenable.
In reply to Jonathan CameronThis is not a fast path, so although the original code was more consise use the generic case to cut down on code repitition.
--- drivers/staging/iio/adc/ad7192.c | 22 +++++----------------- 1 files changed, 5 insertions(+), 17 deletions(-)
drivers/staging/iio/adc/ad7192.c +5 -17
@@ -456,31 +456,19 @@ out:static int ad7192_ring_preenable (struct iio_dev *indio_dev) {struct ad7192_state *st =iio_priv (indio_dev); -struct iio_buffer *ring = indio_dev->buffer; -size_t d_size;unsigned channel; +int ret;if (bitmap_empty (indio_dev->active_scan_mask, indio_dev->masklength))return -EINVAL ; + ret =iio_sw_buffer_preenable (indio_dev); +if (ret <0 ) +return ret; + channel =find_first_bit (indio_dev->active_scan_mask, indio_dev->masklength); - d_size =bitmap_weight (indio_dev->active_scan_mask, - indio_dev->masklength) * - indio_dev->channels[0 ].scan_type.storagebits /8 ; - -if (ring->scan_timestamp) { - d_size +=sizeof (s64); - -if (d_size %sizeof (s64)) - d_size +=sizeof (s64) - (d_size %sizeof (s64)); - } - -if (indio_dev->buffer->access->set_bytes_per_datum) - indio_dev->buffer->access-> -set_bytes_per_datum (indio_dev->buffer, d_size); - st->mode = (st->mode & ~AD7192_MODE_SEL (-1 )) |AD7192_MODE_SEL (AD7192_MODE_CONT ); st->conf = (st->conf & ~AD7192_CONF_CHAN(-1)) |
Signature · 1 line
1.7.0.4
Jonathan Cameron
maintainerPATCH 6/14 staging:iio:adc:ad7298 use iio_sw_buffer_preenable to avoid code repitition.
In reply to Jonathan CameronHere some addition elements are needed, but this generic function cuts down on the amount of code.
--- drivers/staging/iio/adc/ad7298.h | 1 - drivers/staging/iio/adc/ad7298_ring.c | 24 ++++++++---------------- 2 files changed, 8 insertions(+), 17 deletions(-)
drivers/staging/iio/adc/ad7298.h +0 -1
@@ -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 ];
drivers/staging/iio/adc/ad7298_ring.c +8 -16
@@ -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)); }
Signature · 1 line
1.7.0.4
Jonathan Cameron
maintainerPATCH 7/14 staging:iio:adc:ad7476 use iio_sw_buffer_preenable instead of local version.
In reply to Jonathan CameronNow the generic version caches the scan size the version in this driver is redundant.
--- drivers/staging/iio/adc/ad7476.h | 1 - drivers/staging/iio/adc/ad7476_ring.c | 36 ++------------------------------ 2 files changed, 3 insertions(+), 34 deletions(-)
drivers/staging/iio/adc/ad7476.h +0 -1
@@ -27,7 +27,6 @@ struct ad7476_state {struct spi_device *spi;const struct ad7476_chip_info *chip_info;struct regulator *reg; -size_t d_size;u16 int_vref_mv;struct spi_transfer xfer;struct spi_message msg;
drivers/staging/iio/adc/ad7476_ring.c +3 -33
@@ -20,36 +20,6 @@#include "ad7476.h" -/** -* ad7476_ring_preenable() setup the parameters of the ring before enabling -* -* The complex nature of the setting of the number of bytes per datum is due -* to this driver currently ensuring that the timestamp is stored at an 8 -* byte boundary. -**/ -static int ad7476_ring_preenable (struct iio_dev *indio_dev) -{ -struct ad7476_state *st =iio_priv (indio_dev); -struct iio_buffer *ring = indio_dev->buffer; - - st->d_size =bitmap_weight (indio_dev->active_scan_mask, - indio_dev->masklength) * - st->chip_info->channel[0 ].scan_type.storagebits /8 ; - -if (ring->scan_timestamp) { - st->d_size +=sizeof (s64); - -if (st->d_size %sizeof (s64)) - st->d_size +=sizeof (s64) - (st->d_size %sizeof (s64)); - } - -if (indio_dev->buffer->access->set_bytes_per_datum) - indio_dev->buffer->access-> -set_bytes_per_datum (indio_dev->buffer, st->d_size); - -return 0 ; -} -static irqreturn_t ad7476_trigger_handler (int irq,void *p) {struct iio_poll_func *pf = p;
@@ -59,7 +29,7 @@ static irqreturn_t ad7476_trigger_handler(int irq, void *p)__u8 *rxbuf;int b_sent; - rxbuf =kzalloc (st->d_size,GFP_KERNEL ); + rxbuf =kzalloc (indio_dev->scan_bytes,GFP_KERNEL );if (rxbuf ==NULL )return -ENOMEM ;
@@ -71,7 +41,7 @@ static irqreturn_t ad7476_trigger_handler(int irq, void *p) time_ns =iio_get_time_ns ();if (indio_dev->buffer->scan_timestamp) -memcpy (rxbuf + st->d_size -sizeof (s64), +memcpy (rxbuf + indio_dev->scan_bytes -sizeof (s64), &time_ns,sizeof (time_ns)); indio_dev->buffer->access->store_to (indio_dev->buffer, rxbuf, time_ns);
@@ -83,7 +53,7 @@ done: }static const struct iio_buffer_setup_ops ad7476_ring_setup_ops = { - .preenable = &ad7476_ring_preenable, + .preenable = &iio_sw_buffer_preenable, .postenable = &iio_triggered_buffer_postenable, .predisable = &iio_triggered_buffer_predisable, };
Signature · 1 line
1.7.0.4
Jonathan Cameron
maintainerPATCH 8/14 staging:iio:adc:ad7793 use iio_sw_buffer_preenable to avoid repitition.
In reply to Jonathan CameronNow the generic function caches the scan size a lot of what was here was redundant and is removed.
--- drivers/staging/iio/adc/ad7793.c | 21 ++++----------------- 1 files changed, 4 insertions(+), 17 deletions(-)
drivers/staging/iio/adc/ad7793.c +4 -17
@@ -319,31 +319,18 @@ out:static int ad7793_ring_preenable (struct iio_dev *indio_dev) {struct ad7793_state *st =iio_priv (indio_dev); -struct iio_buffer *ring = indio_dev->buffer; -size_t d_size;unsigned channel; +int ret;if (bitmap_empty (indio_dev->active_scan_mask, indio_dev->masklength))return -EINVAL ; + ret =iio_sw_buffer_preenable (indio_dev); +if (ret <0 ) +return ret; channel =find_first_bit (indio_dev->active_scan_mask, indio_dev->masklength); - d_size =bitmap_weight (indio_dev->active_scan_mask, - indio_dev->masklength) * - indio_dev->channels[0 ].scan_type.storagebits /8 ; - -if (ring->scan_timestamp) { - d_size +=sizeof (s64); - -if (d_size %sizeof (s64)) - d_size +=sizeof (s64) - (d_size %sizeof (s64)); - } - -if (indio_dev->buffer->access->set_bytes_per_datum) - indio_dev->buffer->access-> -set_bytes_per_datum (indio_dev->buffer, d_size); - st->mode = (st->mode & ~AD7793_MODE_SEL (-1 )) |AD7793_MODE_SEL (AD7793_MODE_CONT ); st->conf = (st->conf & ~AD7793_CONF_CHAN(-1)) |
Signature · 1 line
1.7.0.4
Jonathan Cameron
maintainerPATCH 9/14 staging:iio:adc:ad7887 make use of iio_sw_buffer_preenable.
In reply to Jonathan CameronUsing this generic function cuts down on repeated code at the cost of some computation in a slow path.
--- drivers/staging/iio/adc/ad7887.h | 1 - drivers/staging/iio/adc/ad7887_ring.c | 23 ++++++----------------- 2 files changed, 6 insertions(+), 18 deletions(-)
drivers/staging/iio/adc/ad7887.h +0 -1
@@ -63,7 +63,6 @@ struct ad7887_state {struct spi_device *spi;const struct ad7887_chip_info *chip_info;struct regulator *reg; -size_t d_size;u16 int_vref_mv;struct spi_transfer xfer[4 ];struct spi_message msg[3 ];
drivers/staging/iio/adc/ad7887_ring.c +6 -17
@@ -29,22 +29,11 @@static int ad7887_ring_preenable (struct iio_dev *indio_dev) {struct ad7887_state *st =iio_priv (indio_dev); -struct iio_buffer *ring = indio_dev->buffer; - - st->d_size =bitmap_weight (indio_dev->active_scan_mask, - indio_dev->masklength) * - st->chip_info->channel[0 ].scan_type.storagebits /8 ; - -if (ring->scan_timestamp) { - st->d_size +=sizeof (s64); - -if (st->d_size %sizeof (s64)) - st->d_size +=sizeof (s64) - (st->d_size %sizeof (s64)); - } +int ret; -if (indio_dev->buffer->access->set_bytes_per_datum) - indio_dev->buffer->access-> -set_bytes_per_datum (indio_dev->buffer, st->d_size); + ret =iio_sw_buffer_preenable (indio_dev); +if (ret <0 ) +return ret;/* We know this is a single long so can 'cheat' */ switch (*indio_dev->active_scan_mask) {
@@ -92,7 +81,7 @@ static irqreturn_t ad7887_trigger_handler(int irq, void *p) indio_dev->masklength) * st->chip_info->channel[0 ].scan_type.storagebits /8 ; - buf =kzalloc (st->d_size,GFP_KERNEL ); + buf =kzalloc (indio_dev->scan_bytes,GFP_KERNEL );if (buf ==NULL )return -ENOMEM ;
@@ -104,7 +93,7 @@ static irqreturn_t ad7887_trigger_handler(int irq, void *p)memcpy (buf, st->data, bytes);if (ring->scan_timestamp) -memcpy (buf + st->d_size -sizeof (s64), +memcpy (buf + indio_dev->scan_bytes -sizeof (s64), &time_ns,sizeof (time_ns)); indio_dev->buffer->access->store_to (indio_dev->buffer, buf, time_ns);
Signature · 1 line
1.7.0.4
Jonathan Cameron
maintainerPATCH 10/14 staging:iio:adc:ad799x use iio_sw_buffer_preenable to avoid code repitiion
In reply to Jonathan CameronUsing this generic function cuts down on repeated code at the cost of a little overhead in a slow path.
--- drivers/staging/iio/adc/ad799x.h | 1 - drivers/staging/iio/adc/ad799x_ring.c | 22 +++------------------- 2 files changed, 3 insertions(+), 20 deletions(-)
drivers/staging/iio/adc/ad799x.h +0 -1
@@ -104,7 +104,6 @@ struct ad799x_chip_info {struct ad799x_state {struct i2c_client *client;const struct ad799x_chip_info *chip_info; -size_t d_size;struct iio_trigger *trig;struct regulator *reg;u16 int_vref_mv;
drivers/staging/iio/adc/ad799x_ring.c +3 -19
@@ -32,9 +32,7 @@**/ static int ad799x_ring_preenable (struct iio_dev *indio_dev) { -struct iio_buffer *ring = indio_dev->buffer;struct ad799x_state *st =iio_priv (indio_dev); -/* * Need to figure out the current mode based upon the requested * scan mask in iio_dev
@@ -43,21 +41,7 @@ static int ad799x_ring_preenable(struct iio_dev *indio_dev)if (st->id == ad7997 || st->id == ad7998)ad7997_8_set_scan_mode (st, *indio_dev->active_scan_mask); - st->d_size =bitmap_weight (indio_dev->active_scan_mask, - indio_dev->masklength) *2 ; - -if (ring->scan_timestamp) { - st->d_size +=sizeof (s64); - -if (st->d_size %sizeof (s64)) - st->d_size +=sizeof (s64) - (st->d_size %sizeof (s64)); - } - -if (indio_dev->buffer->access->set_bytes_per_datum) - indio_dev->buffer->access-> -set_bytes_per_datum (indio_dev->buffer, st->d_size); - -return 0 ; +return iio_sw_buffer_preenable (indio_dev); }/**
@@ -78,7 +62,7 @@ static irqreturn_t ad799x_trigger_handler(int irq, void *p)int b_sent;u8 cmd; - rxbuf =kmalloc (st->d_size,GFP_KERNEL ); + rxbuf =kmalloc (indio_dev->scan_bytes,GFP_KERNEL );if (rxbuf ==NULL ) goto out;
@@ -112,7 +96,7 @@ static irqreturn_t ad799x_trigger_handler(int irq, void *p) time_ns =iio_get_time_ns ();if (ring->scan_timestamp) -memcpy (rxbuf + st->d_size -sizeof (s64), +memcpy (rxbuf + indio_dev->scan_bytes -sizeof (s64), &time_ns,sizeof (time_ns)); ring->access->store_to (indio_dev->buffer, rxbuf, time_ns);
Signature · 1 line
1.7.0.4
Jonathan Cameron
maintainerPATCH 11/14 staging:iio:meter:ad7758 use iio_sw_buffer_preenable to avoid code repition
In reply to Jonathan CameronUsing this generic function adds a little overhead to a slow path but reduces the amount of code repitition in exchange.
--- drivers/staging/iio/meter/ade7758_ring.c | 20 +++++--------------- 1 files changed, 5 insertions(+), 15 deletions(-)
drivers/staging/iio/meter/ade7758_ring.c +5 -15
@@ -92,29 +92,19 @@ static irqreturn_t ade7758_trigger_handler(int irq, void *p)static int ade7758_ring_preenable (struct iio_dev *indio_dev) {struct ade7758_state *st =iio_priv (indio_dev); -struct iio_buffer *ring = indio_dev->buffer; -size_t d_size;unsigned channel; +int ret;if (!bitmap_empty (indio_dev->active_scan_mask, indio_dev->masklength))return -EINVAL ; + ret =iio_sw_buffer_preenable (indio_dev); +if (ret <0 ) +return ret; + channel =find_first_bit (indio_dev->active_scan_mask, indio_dev->masklength); - d_size = st->ade7758_ring_channels[channel].scan_type.storagebits /8 ; - -if (ring->scan_timestamp) { - d_size +=sizeof (s64); - -if (d_size %sizeof (s64)) - d_size +=sizeof (s64) - (d_size %sizeof (s64)); - } - -if (indio_dev->buffer->access->set_bytes_per_datum) - indio_dev->buffer->access-> -set_bytes_per_datum (indio_dev->buffer, d_size); -ade7758_write_waveform_type (&indio_dev->dev, st->ade7758_ring_channels[channel].address);
Signature · 1 line
1.7.0.4
Jonathan Cameron
maintainerPATCH 12/14 staging:iio:impedance-analyser make use of iio_sw_buffer_preenable
In reply to Jonathan CameronThis avoids some code duplication by using the generic form in a non performance critical place.
--- drivers/staging/iio/impedance-analyzer/ad5933.c | 11 +++-------- 1 files changed, 3 insertions(+), 8 deletions(-)
drivers/staging/iio/impedance-analyzer/ad5933.c +3 -8
@@ -569,19 +569,14 @@ static const struct iio_info ad5933_info = {static int ad5933_ring_preenable (struct iio_dev *indio_dev) {struct ad5933_state *st =iio_priv (indio_dev); -size_t d_size;int ret;if (bitmap_empty (indio_dev->active_scan_mask, indio_dev->masklength))return -EINVAL ; - d_size =bitmap_weight (indio_dev->active_scan_mask, - indio_dev->masklength) * - ad5933_channels[1 ].scan_type.storagebits /8 ; - -if (indio_dev->buffer->access->set_bytes_per_datum) - indio_dev->buffer->access-> -set_bytes_per_datum (indio_dev->buffer, d_size); + ret =iio_sw_buffer_preenable (indio_dev); +if (ret <0 ) +return ret; ret =ad5933_reset (st);if (ret <0 )
Signature · 1 line
1.7.0.4
Jonathan Cameron
maintainerPATCH 13/14 staging:iio: Add caching of scan_timestamp to the core as well as buffers.
In reply to Jonathan CameronThis will be needed when multiple buffer support is added.
--- drivers/staging/iio/accel/adis16201_ring.c | 2 +- drivers/staging/iio/accel/adis16203_ring.c | 2 +- drivers/staging/iio/accel/adis16204_ring.c | 2 +- drivers/staging/iio/accel/adis16209_ring.c | 2 +- drivers/staging/iio/accel/adis16240_ring.c | 2 +- drivers/staging/iio/accel/lis3l02dq_ring.c | 2 +- drivers/staging/iio/adc/ad7192.c | 2 +- drivers/staging/iio/adc/ad7298_ring.c | 2 +- drivers/staging/iio/adc/ad7476_ring.c | 2 +- drivers/staging/iio/adc/ad7606_ring.c | 5 ++--- drivers/staging/iio/adc/ad7793.c | 2 +- drivers/staging/iio/adc/ad7887_ring.c | 2 +- drivers/staging/iio/adc/ad799x_ring.c | 2 +- drivers/staging/iio/adc/max1363_ring.c | 4 ++-- drivers/staging/iio/gyro/adis16260_ring.c | 2 +- drivers/staging/iio/iio.h | 2 ++ drivers/staging/iio/iio_simple_dummy_buffer.c | 2 +- drivers/staging/iio/industrialio-buffer.c | 1 + drivers/staging/iio/meter/ade7758_ring.c | 2 +- 19 files changed, 22 insertions(+), 20 deletions(-)
drivers/staging/iio/accel/adis16201_ring.c +1 -1
@@ -80,7 +80,7 @@ static irqreturn_t adis16201_trigger_handler(int irq, void *p) data[i] =be16_to_cpup ((__be16 *)&(st->rx[i*2 ]));/* Guaranteed to be aligned with 8 byte boundary */ -if (ring->scan_timestamp) +if (indio_dev->scan_timestamp) *((s64 *)(data + ((i +3 )/4 )*4 )) = pf->timestamp; ring->access->store_to (ring, (u8 *)data, pf->timestamp);
drivers/staging/iio/accel/adis16203_ring.c +1 -1
@@ -80,7 +80,7 @@ static irqreturn_t adis16203_trigger_handler(int irq, void *p) data[i] =be16_to_cpup ((__be16 *)&(st->rx[i*2 ]));/* Guaranteed to be aligned with 8 byte boundary */ -if (ring->scan_timestamp) +if (indio_dev->scan_timestamp) *((s64 *)(data + ((i +3 )/4 )*4 )) = pf->timestamp; ring->access->store_to(ring,
drivers/staging/iio/accel/adis16204_ring.c +1 -1
@@ -77,7 +77,7 @@ static irqreturn_t adis16204_trigger_handler(int irq, void *p) data[i] =be16_to_cpup ((__be16 *)&(st->rx[i*2 ]));/* Guaranteed to be aligned with 8 byte boundary */ -if (ring->scan_timestamp) +if (indio_dev->scan_timestamp) *((s64 *)(data + ((i +3 )/4 )*4 )) = pf->timestamp; ring->access->store_to (ring, (u8 *)data, pf->timestamp);
drivers/staging/iio/accel/adis16209_ring.c +1 -1
@@ -77,7 +77,7 @@ static irqreturn_t adis16209_trigger_handler(int irq, void *p) data[i] =be16_to_cpup ((__be16 *)&(st->rx[i*2 ]));/* Guaranteed to be aligned with 8 byte boundary */ -if (ring->scan_timestamp) +if (indio_dev->scan_timestamp) *((s64 *)(data + ((i +3 )/4 )*4 )) = pf->timestamp; ring->access->store_to (ring, (u8 *)data, pf->timestamp);
drivers/staging/iio/accel/adis16240_ring.c +1 -1
@@ -75,7 +75,7 @@ static irqreturn_t adis16240_trigger_handler(int irq, void *p) data[i] =be16_to_cpup ((__be16 *)&(st->rx[i*2 ]));/* Guaranteed to be aligned with 8 byte boundary */ -if (ring->scan_timestamp) +if (indio_dev->scan_timestamp) *((s64 *)(data + ((i +3 )/4 )*4 )) = pf->timestamp; ring->access->store_to (ring, (u8 *)data, pf->timestamp);
drivers/staging/iio/accel/lis3l02dq_ring.c +1 -1
@@ -150,7 +150,7 @@ static irqreturn_t lis3l02dq_trigger_handler(int irq, void *p) len =lis3l02dq_get_buffer_element (indio_dev, data);/* Guaranteed to be aligned with 8 byte boundary */ -if (buffer->scan_timestamp) +if (indio_dev->scan_timestamp) *(s64 *)(((phys_addr_t )data + len +sizeof (s64) -1 ) & ~(sizeof (s64) -1 )) = pf->timestamp;
drivers/staging/iio/adc/ad7192.c +1 -1
@@ -521,7 +521,7 @@ static irqreturn_t ad7192_trigger_handler(int irq, void *p) indio_dev->channels[0].scan_type.realbits/8);/* Guaranteed to be aligned with 8 byte boundary */ -if (ring->scan_timestamp) +if (indio_dev->scan_timestamp) dat64[1 ] = pf->timestamp; ring->access->store_to (ring, (u8 *)dat64, pf->timestamp);
drivers/staging/iio/adc/ad7298_ring.c +1 -1
@@ -92,7 +92,7 @@ static irqreturn_t ad7298_trigger_handler(int irq, void *p)if (b_sent)return b_sent; -if (ring->scan_timestamp) { +if (indio_dev->scan_timestamp) { time_ns =iio_get_time_ns ();memcpy ((u8 *)buf + indio_dev->scan_bytes -sizeof (s64), &time_ns,sizeof (time_ns));
drivers/staging/iio/adc/ad7476_ring.c +1 -1
@@ -40,7 +40,7 @@ static irqreturn_t ad7476_trigger_handler(int irq, void *p) time_ns =iio_get_time_ns (); -if (indio_dev->buffer->scan_timestamp) +if (indio_dev->scan_timestamp)memcpy (rxbuf + indio_dev->scan_bytes -sizeof (s64), &time_ns,sizeof (time_ns));
drivers/staging/iio/adc/ad7606_ring.c +2 -3
@@ -81,9 +81,8 @@ static void ad7606_poll_bh_to_ring(struct work_struct *work_s) time_ns =iio_get_time_ns (); -if (ring->scan_timestamp) - *((s64 *)(buf + ring->access->get_bytes_per_datum (ring) - -sizeof (s64))) = time_ns; +if (indio_dev->scan_timestamp) + *((s64 *)(buf + indio_dev->scan_bytes -sizeof (s64))) = time_ns; ring->access->store_to (indio_dev->buffer, buf, time_ns); done:
drivers/staging/iio/adc/ad7793.c +1 -1
@@ -386,7 +386,7 @@ static irqreturn_t ad7793_trigger_handler(int irq, void *p) indio_dev->channels[0].scan_type.realbits/8);/* Guaranteed to be aligned with 8 byte boundary */ -if (ring->scan_timestamp) +if (indio_dev->scan_timestamp) dat64[1 ] = pf->timestamp; ring->access->store_to (ring, (u8 *)dat64, pf->timestamp);
drivers/staging/iio/adc/ad7887_ring.c +1 -1
@@ -92,7 +92,7 @@ static irqreturn_t ad7887_trigger_handler(int irq, void *p) time_ns =iio_get_time_ns ();memcpy (buf, st->data, bytes); -if (ring->scan_timestamp) +if (indio_dev->scan_timestamp)memcpy (buf + indio_dev->scan_bytes -sizeof (s64), &time_ns,sizeof (time_ns));
drivers/staging/iio/adc/ad799x_ring.c +1 -1
@@ -95,7 +95,7 @@ static irqreturn_t ad799x_trigger_handler(int irq, void *p) time_ns =iio_get_time_ns (); -if (ring->scan_timestamp) +if (indio_dev->scan_timestamp)memcpy (rxbuf + indio_dev->scan_bytes -sizeof (s64), &time_ns,sizeof (time_ns));
drivers/staging/iio/adc/max1363_ring.c +2 -2
@@ -54,7 +54,7 @@ static irqreturn_t max1363_trigger_handler(int irq, void *p) d_size = numvals*2 ; else d_size = numvals; -if (indio_dev->buffer->scan_timestamp) { +if (indio_dev->scan_timestamp) { d_size +=sizeof (s64);if (d_size %sizeof (s64)) d_size +=sizeof (s64) - (d_size %sizeof (s64));
@@ -78,7 +78,7 @@ static irqreturn_t max1363_trigger_handler(int irq, void *p) time_ns =iio_get_time_ns (); -if (indio_dev->buffer->scan_timestamp) +if (indio_dev->scan_timestamp)memcpy (rxbuf + d_size -sizeof (s64), &time_ns,sizeof (time_ns));iio_push_to_buffer (indio_dev->buffer, rxbuf, time_ns);
drivers/staging/iio/gyro/adis16260_ring.c +1 -1
@@ -80,7 +80,7 @@ static irqreturn_t adis16260_trigger_handler(int irq, void *p) data[i] =be16_to_cpup ((__be16 *)&(st->rx[i*2 ]));/* Guaranteed to be aligned with 8 byte boundary */ -if (ring->scan_timestamp) +if (indio_dev->scan_timestamp) *((s64 *)(data + ((i +3 )/4 )*4 )) = pf->timestamp; ring->access->store_to (ring, (u8 *)data, pf->timestamp);
drivers/staging/iio/iio.h +2 -0
@@ -306,6 +306,7 @@ struct iio_buffer_setup_ops {* @masklength: [INTERN] the length of the mask established from * channels * @active_scan_mask: [INTERN] union of all scan masks requested by buffers +* @scan_timestamp: [INTERN] set if any buffers have requested timestamp * @scan_index_timestamp:[INTERN] cache of the index to the timestamp * @trig: [INTERN] current device trigger (buffer modes) * @pollfunc: [DRIVER] function run on trigger being received
@@ -342,6 +343,7 @@ struct iio_dev {const unsigned long *available_scan_masks;unsigned masklength;const unsigned long *active_scan_mask; +bool scan_timestamp;unsigned scan_index_timestamp;struct iio_trigger *trig;struct iio_poll_func *pollfunc;
drivers/staging/iio/iio_simple_dummy_buffer.c +1 -1
@@ -84,7 +84,7 @@ static irqreturn_t iio_simple_dummy_trigger_h(int irq, void *p) } }/* Store a timestampe at an 8 byte boundary */ -if (buffer->scan_timestamp) +if (indio_dev->scan_timestamp) *(s64 *)(((phys_addr_t )data + len +sizeof (s64) -1 ) & ~(sizeof (s64) -1 )) =iio_get_time_ns ();
drivers/staging/iio/industrialio-buffer.c +1 -0
@@ -185,6 +185,7 @@ static ssize_t iio_scan_el_ts_store(struct device *dev, goto error_ret; } indio_dev->buffer->scan_timestamp = state; + indio_dev->scan_timestamp = state; error_ret:mutex_unlock (&indio_dev->mlock);
drivers/staging/iio/meter/ade7758_ring.c +1 -1
@@ -72,7 +72,7 @@ static irqreturn_t ade7758_trigger_handler(int irq, void *p) *dat32 =get_unaligned_be32 (&st->rx_buf[5 ]) &0xFFFFFF ;/* Guaranteed to be aligned with 8 byte boundary */ -if (ring->scan_timestamp) +if (indio_dev->scan_timestamp) dat64[1 ] = pf->timestamp; ring->access->store_to (ring, (u8 *)dat64, pf->timestamp);
Signature · 1 line
1.7.0.4
Jonathan Cameron
maintainerPATCH 14/14 staging:iio: pull out demux cleanup for a particular buffer.
In reply to Jonathan CameronThis will come in handy again when we move to multiple buffers so lets pull it out into a little utility function now.
--- drivers/staging/iio/industrialio-buffer.c | 22 +++++++++++++--------- 1 files changed, 13 insertions(+), 9 deletions(-)
drivers/staging/iio/industrialio-buffer.c +13 -9
@@ -655,19 +655,25 @@ int iio_push_to_buffer(struct iio_buffer *buffer, unsigned char *data, }EXPORT_SYMBOL_GPL (iio_push_to_buffer); +static void iio_buffer_demux_free (struct iio_buffer *buffer) +{ +struct iio_demux_table *p, *q; +list_for_each_entry_safe (p, q, &buffer->demux_list, l) { +list_del (&p->l); +kfree (p); + } +} +int iio_update_demux (struct iio_dev *indio_dev) {const struct iio_chan_spec *ch;struct iio_buffer *buffer = indio_dev->buffer;int ret, in_ind =-1 , out_ind, length;unsigned in_loc =0 , out_loc =0 ; -struct iio_demux_table *p, *q; +struct iio_demux_table *p;/* Clear out any old demux */ -list_for_each_entry_safe (p, q, &buffer->demux_list, l) { -list_del (&p->l); -kfree (p); - } +iio_buffer_demux_free (buffer);kfree (buffer->demux_bounce); buffer->demux_bounce =NULL ;
@@ -742,10 +748,8 @@ int iio_update_demux(struct iio_dev *indio_dev)return 0 ; error_clear_mux_table: -list_for_each_entry_safe (p, q, &buffer->demux_list, l) { -list_del (&p->l); -kfree (p); - } +iio_buffer_demux_free (buffer); +return ret; }EXPORT_SYMBOL_GPL (iio_update_demux);
Signature · 1 line
1.7.0.4
A message that is not in the archive (sent off-list or not yet received): [email protected]
Jonathan Cameron
maintainerQuoted 10 lines · Lars-Peter Clausen
Quoted 9 lines · Jonathan Cameron
Sits on top of the series
[PATCH 00/16 V3] IIO: Make the value attribute optional for channels
This series consists of the first chunk of what was
[PATCH 1/4] staging:iio: make all buffer access pass through thebuffer_listAs Lars-Peter rightly pointed out that patch was a whole mess of different elements all bunged in together.
Quoted 5 lines
Quoted 2 lines
I believe this lot are all fairly uncontroversial unless I have trashed a driver by accident. (which is entirely plausible).
Yep, looks all pretty straight forward. With the compiler warning fixed:
Fixed up and sent on to Greg.
Quoted 75 lines
Quoted 61 lines
There are a few temporary frigs in here to ensure some of the cached values are correct before we put the real change in place. For example the
scan_timestampgets cached both in the core and in the buffers. For this change it would have made sense to drop it from the buffers but then we'd just end up putting it back again a few patches later.Anyhow, please do take a look at what we have here. Some are trivial, but there are a good few driver reworks that could do with testing (as I'll almost guarantee I've messed something up ripping the original large patch apart!)
Thanks,
Jonathan Cameron
Jonathan Cameron (14):
staging:iio:buffer trivial use of strtobool to remove dodgy
equivalent.
staging:iio:buffer: pull computation of scan length into a utility
function.
staging:iio:scan_index_timestampmove toiio_devfrom buffer staging:iio: add caching of the number of bytes in a scan. staging:iio:adc:ad7192 make use ofiio_sw_buffer_preenable. staging:iio:adc:ad7298 useiio_sw_buffer_preenableto avoid code
repitition.
staging:iio:adc:ad7476 useiio_sw_buffer_preenableinstead of local
version.
staging:iio:adc:ad7793 useiio_sw_buffer_preenableto avoid
repitition.
staging:iio:adc:ad7887 make use ofiio_sw_buffer_preenable. staging:iio:adc:ad799x useiio_sw_buffer_preenableto avoid code
repitiion
staging:iio:meter:ad7758 useiio_sw_buffer_preenableto avoid code
repition
staging:iio:impedance-analyser make use ofiio_sw_buffer_preenablestaging:iio: Add caching ofscan_timestampto the core as well as
buffers.
staging:iio: pull out demux cleanup for a particular buffer.drivers/staging/iio/accel/adis16201_ring.c | 5 +- drivers/staging/iio/accel/adis16203_ring.c | 5 +- drivers/staging/iio/accel/adis16204_ring.c | 5 +- drivers/staging/iio/accel/adis16209_ring.c | 6 +- drivers/staging/iio/accel/adis16240_ring.c | 5 +- drivers/staging/iio/accel/lis3l02dq_ring.c | 6 +- drivers/staging/iio/adc/ad7192.c | 24 ++------ drivers/staging/iio/adc/ad7298.h | 1 - drivers/staging/iio/adc/ad7298_ring.c | 26 +++------ drivers/staging/iio/adc/ad7476.h | 1 - drivers/staging/iio/adc/ad7476_ring.c | 38 +----------- drivers/staging/iio/adc/ad7606_ring.c | 8 +-- drivers/staging/iio/adc/ad7793.c | 23 ++------ drivers/staging/iio/adc/ad7887.h | 1 - drivers/staging/iio/adc/ad7887_ring.c | 25 ++------ drivers/staging/iio/adc/ad799x.h | 1 - drivers/staging/iio/adc/ad799x_ring.c | 24 +------- drivers/staging/iio/adc/max1363_ring.c | 4 +- drivers/staging/iio/buffer.h | 2 -Quoted 9 lines
drivers/staging/iio/gyro/adis16260_ring.c | 5 +- drivers/staging/iio/iio.h | 6 ++ drivers/staging/iio/iio_simple_dummy_buffer.c | 11 +-- drivers/staging/iio/impedance-analyzer/ad5933.c | 11 +--- drivers/staging/iio/imu/adis16400_ring.c | 4 +- drivers/staging/iio/industrialio-buffer.c | 69 +++++++++++++++-------- drivers/staging/iio/meter/ade7758_ring.c | 22 ++----- 26 files changed, 121 insertions(+), 217 deletions(-)--
To unsubscribe from this list: send the line "unsubscribe linux-iio" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html