diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2011-10-26 15:39:02 +0200 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2011-10-26 15:39:02 +0200 |
commit | aa77677e0a288e08073620db5d2a31df83ca4788 (patch) | |
tree | 0d14b995a21c43f365d66b9ad101a334109fc4e4 /drivers/staging/iio/adc/ad7606_ring.c | |
parent | efb8d21b2c6db3497655cc6a033ae8a9883e4063 (diff) | |
parent | 43a3beb6da994549ec28a9f31727b997a025f958 (diff) | |
download | op-kernel-dev-aa77677e0a288e08073620db5d2a31df83ca4788.zip op-kernel-dev-aa77677e0a288e08073620db5d2a31df83ca4788.tar.gz |
Merge branch 'staging-next' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging
* 'staging-next' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging: (1519 commits)
staging: et131x: Remove redundant check and return statement
staging: et131x: Mainly whitespace changes to appease checkpatch
staging: et131x: Remove last of the forward declarations
staging: et131x: Remove even more forward declarations
staging: et131x: Remove yet more forward declarations
staging: et131x: Remove more forward declarations
staging: et131x: Remove forward declaration of et131x_adapter_setup
staging: et131x: Remove some forward declarations
staging: et131x: Remove unused rx_ring.recv_packet_pool
staging: et131x: Remove call to find pci pm capability
staging: et131x: Remove redundant et131x_reset_recv() call
staging: et131x: Remove unused rx_ring.recv_buffer_pool
Staging: bcm: Fix three initialization errors in InterfaceDld.c
Staging: bcm: Fix coding style issues in InterfaceDld.c
staging:iio:dac: Add AD5360 driver
staging:iio:trigger:bfin-timer: Fix compile error
Staging: vt6655: add some range checks before memcpy()
Staging: vt6655: whitespace fixes to iotcl.c
Staging: vt6656: add some range checks before memcpy()
Staging: vt6656: whitespace cleanups in ioctl.c
...
Fix up conflicts in:
- drivers/{Kconfig,Makefile}, drivers/staging/{Kconfig,Makefile}:
vg driver movement
- drivers/staging/brcm80211/brcmfmac/{dhd_linux.c,mac80211_if.c}:
driver removal vs now stale changes
- drivers/staging/rtl8192e/r8192E_core.c:
driver removal vs now stale changes
- drivers/staging/et131x/et131*:
driver consolidation into one file, tried to do fixups
Diffstat (limited to 'drivers/staging/iio/adc/ad7606_ring.c')
-rw-r--r-- | drivers/staging/iio/adc/ad7606_ring.c | 86 |
1 files changed, 25 insertions, 61 deletions
diff --git a/drivers/staging/iio/adc/ad7606_ring.c b/drivers/staging/iio/adc/ad7606_ring.c index a199bf4..20927fd 100644 --- a/drivers/staging/iio/adc/ad7606_ring.c +++ b/drivers/staging/iio/adc/ad7606_ring.c @@ -10,19 +10,17 @@ #include <linux/device.h> #include <linux/kernel.h> #include <linux/slab.h> -#include <linux/sysfs.h> #include "../iio.h" -#include "../ring_generic.h" +#include "../buffer_generic.h" #include "../ring_sw.h" -#include "../trigger.h" -#include "../sysfs.h" +#include "../trigger_consumer.h" #include "ad7606.h" int ad7606_scan_from_ring(struct iio_dev *indio_dev, unsigned ch) { - struct iio_ring_buffer *ring = indio_dev->ring; + struct iio_buffer *ring = indio_dev->buffer; int ret; u16 *ring_data; @@ -45,45 +43,13 @@ error_ret: } /** - * ad7606_ring_preenable() setup the parameters of the ring before enabling - * - * The complex nature of the setting of the nuber of bytes per datum is due - * to this driver currently ensuring that the timestamp is stored at an 8 - * byte boundary. - **/ -static int ad7606_ring_preenable(struct iio_dev *indio_dev) -{ - struct ad7606_state *st = iio_priv(indio_dev); - struct iio_ring_buffer *ring = indio_dev->ring; - size_t d_size; - - d_size = st->chip_info->num_channels * - st->chip_info->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 (ring->access->set_bytes_per_datum) - ring->access->set_bytes_per_datum(ring, d_size); - - st->d_size = d_size; - - return 0; -} - -/** * ad7606_trigger_handler_th() th/bh of trigger launched polling to ring buffer * **/ static irqreturn_t ad7606_trigger_handler_th_bh(int irq, void *p) { struct iio_poll_func *pf = p; - struct iio_dev *indio_dev = pf->private_data; - struct ad7606_state *st = iio_priv(indio_dev); + struct ad7606_state *st = iio_priv(pf->indio_dev); gpio_set_value(st->pdata->gpio_convst, 1); @@ -104,16 +70,17 @@ static void ad7606_poll_bh_to_ring(struct work_struct *work_s) struct ad7606_state *st = container_of(work_s, struct ad7606_state, poll_work); struct iio_dev *indio_dev = iio_priv_to_dev(st); - struct iio_ring_buffer *ring = indio_dev->ring; + struct iio_buffer *ring = indio_dev->buffer; s64 time_ns; __u8 *buf; int ret; - buf = kzalloc(st->d_size, GFP_KERNEL); + buf = kzalloc(ring->access->get_bytes_per_datum(ring), + GFP_KERNEL); if (buf == NULL) return; - if (st->have_frstdata) { + if (gpio_is_valid(st->pdata->gpio_frstdata)) { ret = st->bops->read_block(st->dev, 1, buf); if (ret) goto done; @@ -140,20 +107,20 @@ static void ad7606_poll_bh_to_ring(struct work_struct *work_s) time_ns = iio_get_time_ns(); if (ring->scan_timestamp) - memcpy(buf + st->d_size - sizeof(s64), - &time_ns, sizeof(time_ns)); + *((s64 *)(buf + ring->access->get_bytes_per_datum(ring) - + sizeof(s64))) = time_ns; - ring->access->store_to(indio_dev->ring, buf, time_ns); + ring->access->store_to(indio_dev->buffer, buf, time_ns); done: gpio_set_value(st->pdata->gpio_convst, 0); iio_trigger_notify_done(indio_dev->trig); kfree(buf); } -static const struct iio_ring_setup_ops ad7606_ring_setup_ops = { - .preenable = &ad7606_ring_preenable, - .postenable = &iio_triggered_ring_postenable, - .predisable = &iio_triggered_ring_predisable, +static const struct iio_buffer_setup_ops ad7606_ring_setup_ops = { + .preenable = &iio_sw_buffer_preenable, + .postenable = &iio_triggered_buffer_postenable, + .predisable = &iio_triggered_buffer_predisable, }; int ad7606_register_ring_funcs_and_init(struct iio_dev *indio_dev) @@ -161,14 +128,16 @@ int ad7606_register_ring_funcs_and_init(struct iio_dev *indio_dev) struct ad7606_state *st = iio_priv(indio_dev); int ret; - indio_dev->ring = iio_sw_rb_allocate(indio_dev); - if (!indio_dev->ring) { + indio_dev->buffer = iio_sw_rb_allocate(indio_dev); + if (!indio_dev->buffer) { ret = -ENOMEM; goto error_ret; } /* Effectively select the ring buffer implementation */ - indio_dev->ring->access = &ring_sw_access_funcs; + indio_dev->buffer->access = &ring_sw_access_funcs; + indio_dev->buffer->bpe = + st->chip_info->channels[0].scan_type.storagebits / 8; indio_dev->pollfunc = iio_alloc_pollfunc(&ad7606_trigger_handler_th_bh, &ad7606_trigger_handler_th_bh, 0, @@ -183,28 +152,23 @@ int ad7606_register_ring_funcs_and_init(struct iio_dev *indio_dev) /* Ring buffer functions - here trigger setup related */ - indio_dev->ring->setup_ops = &ad7606_ring_setup_ops; - indio_dev->ring->scan_timestamp = true ; + indio_dev->buffer->setup_ops = &ad7606_ring_setup_ops; + indio_dev->buffer->scan_timestamp = true ; INIT_WORK(&st->poll_work, &ad7606_poll_bh_to_ring); /* Flag that polled ring buffering is possible */ - indio_dev->modes |= INDIO_RING_TRIGGERED; + indio_dev->modes |= INDIO_BUFFER_TRIGGERED; return 0; error_deallocate_sw_rb: - iio_sw_rb_free(indio_dev->ring); + iio_sw_rb_free(indio_dev->buffer); error_ret: return ret; } void ad7606_ring_cleanup(struct iio_dev *indio_dev) { - if (indio_dev->trig) { - iio_put_trigger(indio_dev->trig); - iio_trigger_dettach_poll_func(indio_dev->trig, - indio_dev->pollfunc); - } iio_dealloc_pollfunc(indio_dev->pollfunc); - iio_sw_rb_free(indio_dev->ring); + iio_sw_rb_free(indio_dev->buffer); } |