summaryrefslogtreecommitdiffstats
path: root/drivers/iio/buffer_cb.c
Commit message (Collapse)AuthorAgeFilesLines
* iio: Add reference counting for buffersLars-Peter Clausen2013-10-121-6/+15
| | | | | | | | | | | | | | | | | | | | | 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>
* Merge 3.12-rc2 into staging-next.Greg Kroah-Hartman2013-09-251-0/+2
|\ | | | | | | | | | | | | | | This resolves the merge problem with two iio drivers that Stephen Rothwell pointed out. Reported-by: Stephen Rothwell <sfr@canb.auug.org.au> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
| * iio:buffer_cb: Add missing iio_buffer_init()Lars-Peter Clausen2013-09-211-0/+2
| | | | | | | | | | | | | | Make sure to properly initialize the IIO buffer data structure. Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
* | iio: iio_push_to_buffers(): Change type of 'data' to const void *Lars-Peter Clausen2013-09-151-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* | iio:buffer_cb: Constify iio_cb_accessLars-Peter Clausen2013-09-151-1/+1
|/ | | | | | | The iio_cb_access struct is never modified so we can mark it as const. Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
* iio:callback buffer: free the scan_maskJonathan Cameron2013-06-041-1/+4
| | | | | Reported-by: Michał Mirosław <mirq-linux@rere.qmqm.pl> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
* iio: Update iio_channel_get_all and iio_channel_get_all_cb APIGuenter Roeck2013-02-021-2/+2
| | | | | | | | | Pass device pointer instead of device name as parameter to iio_channel_get_all and iio_channel_get_all_cb. This will enable us to use OF information to retrieve consumer channel information. Signed-off-by: Guenter Roeck <linux@roeck-us.net> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
* staging:iio: add a callback buffer for in kernel push interfaceJonathan Cameron2012-11-101-0/+113
This callback buffer is meant to be opaque to users, but basically adds a very simple pass through buffer to which data may be pushed when it is inserted into the buffer list. Signed-off-by: Jonathan Cameron <jic23@kernel.org>