summaryrefslogtreecommitdiff
path: root/include/linux/iio/buffer.h
AgeCommit message (Collapse)Author
2013-10-16iio: Remove unused iio_sw_buffer_preenable()Lars-Peter Clausen
The functionality implemented by iio_sw_buffer_preenable() is now done directly in the IIO core and previous users of iio_sw_buffer_preenable() have all been updated to not use it anymore. It is unused now and can be remove. Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2013-10-12iio: Add reference counting for buffersLars-Peter Clausen
Since the buffer is accessed by userspace we can not just free the buffers memory once we are done with it in kernel space. There might still be open file descriptors and userspace still might be accessing the buffer. This patch adds support for reference counting to the IIO buffers. When a buffer is created and initialized its initial reference count is set to 1. Instead of freeing the memory of the buffer the buffer's _free() function will drop that reference again. But only after the last reference to the buffer has been dropped the buffer the buffer's memory will be freed. The IIO device will take a reference to its primary buffer. The patch adds a small helper function for this called iio_device_attach_buffer() which will get a reference to the buffer and assign the buffer to the IIO device. This function must be used instead of assigning the buffer to the device by hand. The reference is only dropped once the IIO device is freed and we can be sure that there are no more open file handles. A reference to a buffer will also be taken whenever the buffer is active to avoid the buffer being freed while data is still being send to it. Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2013-09-21iio: Add iio_push_buffers_with_timestamp() helperLars-Peter Clausen
Drivers using software buffers often store the timestamp in their data buffer before calling iio_push_to_buffers() with that data buffer. Storing the timestamp in the buffer usually involves some ugly pointer arithmetic. This patch adds a new helper function called iio_push_buffers_with_timestamp() which is similar to iio_push_to_buffers but takes an additional timestamp parameter. The function will help to hide to uglyness in one central place instead of exposing it in every driver. If timestamps are enabled for the IIO device iio_push_buffers_with_timestamp() will store the timestamp as the last element in buffer, before passing the buffer on to iio_push_buffers(). The buffer needs large enough to hold the timestamp in this case. If timestamps are disabled iio_push_buffers_with_timestamp() will behave just like iio_push_buffers(). Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Cc: Oleksandr Kravchenko <o.v.kravchenko@globallogic.com> Cc: Josh Wu <josh.wu@atmel.com> Cc: Denis Ciocca <denis.ciocca@gmail.com> Cc: Manuel Stahl <manuel.stahl@iis.fraunhofer.de> Cc: Ge Gao <ggao@invensense.com> Cc: Peter Meerwald <pmeerw@pmeerw.net> Cc: Jacek Anaszewski <j.anaszewski@samsung.com> Cc: Fabio Estevam <fabio.estevam@freescale.com> Cc: Marek Vasut <marex@denx.de> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2013-09-15iio: iio_push_to_buffers(): Change type of 'data' to const void *Lars-Peter Clausen
Change the type of the 'data' parameter for iio_push_to_buffers() from 'u8 *' to 'const void *'. Drivers typically use the correct type (e.g. __be16 *) for their data buffer. When passing the buffer to iio_push_to_buffers() it needs to be cast to 'u8 *' for the compiler to not complain (and also having to add __force if we want to keep sparse happy as well). Since the buffer implementation should not care about the data layout (except the size of one sample) using a void pointer is the correct thing to do. Also make it const as the buffer implementations are not supposed to modify it. Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2013-01-31staging:iio: Remove noop call to __iio_update_bufferLars-Peter Clausen
__iio_update_buffer updates the buffer's bytes_per_datum and length fields. But the only user of this function just passes in these exact fields, so the call basically looks like this: buffer->bytes_per_datum = buffer->bytes_per_datum; buffer->length = buffer->length; Which means it is a noop and can be removed. Also remove the function itself, since it is now unused. Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2012-11-19iio: Fix iio_buffer_register stub signatureLars-Peter Clausen
Match the iio_buffer_register stub signature up to the real function and make the second parameter const. This fixes a the following warnings if CONFIG_IIO_BUFFER is disabled: drivers/staging/iio/accel/adis16201_core.c: In function ‘adis16201_probe’: drivers/staging/iio/accel/adis16201_core.c:536: warning: passing argument 2 of ‘iio_buffer_register’ discards qualifiers from pointer target type drivers/staging/iio/accel/adis16203_core.c: In function ‘adis16203_probe’: drivers/staging/iio/accel/adis16203_core.c:468: warning: passing argument 2 of ‘iio_buffer_register’ discards qualifiers from pointer target type drivers/staging/iio/accel/adis16204_core.c: In function ‘adis16204_probe’: drivers/staging/iio/accel/adis16204_core.c:527: warning: passing argument 2 of ‘iio_buffer_register’ discards qualifiers from pointer target type drivers/staging/iio/accel/adis16209_core.c: In function ‘adis16209_probe’: drivers/staging/iio/accel/adis16209_core.c:542: warning: passing argument 2 of ‘iio_buffer_register’ discards qualifiers from pointer target type drivers/staging/iio/accel/adis16240_core.c: In function ‘adis16240_probe’: drivers/staging/iio/accel/adis16240_core.c:588: warning: passing argument 2 of ‘iio_buffer_register’ discards qualifiers from pointer target type Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2012-11-10staging:iio: Add support for multiple buffersJonathan Cameron
Route all buffer writes through the demux. Addition or removal of a buffer results in tear down and setup of all the buffers for a given device. Signed-off-by: Jonathan Cameron <jic23@kernel.org> Tested-by: srinivas pandruvada <srinivas.pandruvada@intel.com>
2012-09-08iio: Drop timestamp parameter from buffer store_to callbackLars-Peter Clausen
Drop timestamp parameter from buffer store_to callback and subsequently from iio_push_to_buffer. The timestamp parameter is unused and it seems likely that it will stay unused in the future, so it should be safe to remove it. Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2012-07-09iio: Introduce iio_validate_scan_mask_onehotLars-Peter Clausen
Add a helper function for validating a scan mask for devices where exactly one channel must be selected during sampling. This is a common case among devices which have scan mask restrictions so it makes sense to provide this function in the core. Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2012-07-07iio: cleanup buffer.h commentsPeter Meerwald
Signed-off-by: Peter Meerwald <pmeerw@pmeerw.net> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2012-06-18iio: remove extra ; after function definitionPeter Meerwald
Signed-off-by: Peter Meerwald <pmeerw@pmeerw.net> Acked-by: Jonathan Cameron <jic23@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2012-04-25IIO: Move core headers to include/linux/iioJonathan Cameron
Step 1 in moving the IIO core out of staging. Signed-off-by: Jonathan Cameron <jic23@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>