aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/iio/industrialio-buffer.c
AgeCommit message (Collapse)Author
2014-12-12iio: Move buffer registration to the coreLars-Peter Clausen
Originally device and buffer registration were kept as separate operations in IIO to allow to register two distinct sets of channels for buffered and non-buffered operations. This has since already been further restricted and the channel set registered for the buffer needs to be a subset of the channel set registered for the device. Additionally the possibility to not have a raw (or processed) attribute for a channel which was registered for the device was added a while ago. This means it is possible to not register any device level attributes for a channel even if it is registered for the device. Also if a channel's scan_index is set to -1 and the channel is registered for the buffer it is ignored. So in summary it means it is possible to register the same channel array for both the device and the buffer yet still end up with distinctive sets of channels for both of them. This makes the argument for having to have to manually register the channels for both the device and the buffer invalid. Considering that the vast majority of all drivers want to register the same set of channels for both the buffer and the device it makes sense to move the buffer registration into the core to avoid some boiler-plate code in the device driver setup path. Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2014-12-12iio: Unexport iio_scan_mask_set()Lars-Peter Clausen
Individual drivers should not be messing with the scan mask that contains the list of enabled channels. This is something that is supposed to be managed by the core. Now that the last few drivers that used it to configure a default scan mask have been updated to not do this anymore we can unexport the function. Note, this patch also requires moving a few functions around so they are all declared before the first internal user. Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Reviewed-by: Daniel Baluta <daniel.baluta@intel.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2014-08-25Merge tag 'iio-for-3.18a' of ↵Greg Kroah-Hartman
git://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio into work-next Jonathan writes: 1st round of new IIO drivers, functionality and cleanups for the 3.18 cycle. Maintainer Updates * Add 3 designated reviewers for IIO. Lars, Peter and Hartmut have been actively reviewing a lot of patches for a while now so this reflects the status quo. These three are probably the only reason I keep my head above the water! New drivers and device support * max5821 DAC * Rockchip SARADC * TI ADC128S052 ADC * BMC150 Accelerometer * exynos ADC driver gains support for s3c24xx and s3c64xx parts. * kxcjk-1013 gainst range control and runtime PM support to drive down it's power usage. Driver removals * Drop ad5930, ad99850, ad9852, ad9910 and ad9951 drivers on the simple basis that they drivers just provided a register write function with no compliant user space ABI whatsoever. Much better to drop them and start again for these in the fullness of time. Core Enhancements * Join together neighbouring elements in the demux units that feeds the binary interfaces. This cuts down on the number of individual copies needed when splitting out individual channels from the incoming channel scans. * Other demux related cleanups such as using roundup instead of a local implementation. Cleanups * Drop an unnecessary double setting of the owner field in xilinx adc. * Some more patches to use managed (devm) interfaces to cut down on complexity of removal code. * adis16060 coding style fixlets. * Fix some incorrect error returns in the Xilinx ADC driver. * Coding style fixlets for various accelerometer drivers. * Some sparse warning fixes to do with endianness and sign of variables. * Fix an incorrect and entirely pointless use of sizeof on a dynamic pointer in hid-sensor-magn-3d by dropping the relevant code.
2014-08-08iio:buffer: Wrong sized allocation of demux table elements.Jonathan Cameron
The size of the allocation is currently set to the size of the pointer rather than the structure we should actually be allocating. Signed-off-by: Jonathan Cameron <jic23@kernel.org> Reported-by: kbuild@01.org Reported-by: Dan Carpenter <dan.carpenter@oracle.com> Acked-by: Lars-Peter Clausen <lars@metafoo.de>
2014-08-04Merge tag 'staging-3.17-rc1' of ↵Linus Torvalds
git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging Pull staging driver updates from Greg KH: "Here's the big pull request for the staging driver tree for 3.17-rc1. Lots of things in here, over 2000 patches, but the best part is this: 1480 files changed, 39070 insertions(+), 254659 deletions(-) Thanks to the great work of Kristina Martšenko, 14 different staging drivers have been removed from the tree as they were obsolete and no one was willing to work on cleaning them up. Other than the driver removals, loads of cleanups are in here (comedi, lustre, etc.) as well as the usual IIO driver updates and additions. All of this has been in the linux-next tree for a while" * tag 'staging-3.17-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging: (2199 commits) staging: comedi: addi_apci_1564: remove diagnostic interrupt support code staging: comedi: addi_apci_1564: add subdevice to check diagnostic status staging: wlan-ng: coding style problem fix staging: wlan-ng: fixing coding style problems staging: comedi: ii_pci20kc: request and ioremap memory staging: lustre: bitwise vs logical typo staging: dgnc: Remove unneeded dgnc_trace.c and dgnc_trace.h staging: dgnc: rephrase comment staging: comedi: ni_tio: remove some dead code staging: rtl8723au: Fix static symbol sparse warning staging: rtl8723au: usb_dvobj_init(): Remove unused variable 'pdev_desc' staging: rtl8723au: Do not duplicate kernel provided USB macros staging: rtl8723au: Remove never set struct pwrctrl_priv.bHWPowerdown staging: rtl8723au: Remove two never set variables staging: rtl8723au: RSSI_test is never set staging:r8190: coding style: Fixed checkpatch reported Error staging:r8180: coding style: Fixed too long lines staging:r8180: coding style: Fixed commenting style staging: lustre: ptlrpc: lproc_ptlrpc.c - fix dereferenceing user space buffer staging: lustre: ldlm: ldlm_resource.c - fix dereferenceing user space buffer ...
2014-08-01iio: buffer: Coalesce adjacent demux table entriesLars-Peter Clausen
When copying multiple multiple samples that are adjacent in both the source as well as the destination buffer, instead of creating a new demux table entry for each sample just increase the length of the previous entry by the size of the new sample. This makes the demuxing process slightly more efficient. Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2014-07-27iio: buffer: Use roundup() instead of open-coding itLars-Peter Clausen
Makes the code slightly shorter and a bit easier to understand. Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2014-07-20iio: buffer: Fix demux table creationLars-Peter Clausen
When creating the demux table we need to iterate over the selected scan mask for the buffer to get the samples which should be copied to destination buffer. Right now the code uses the mask which contains all active channels, which means the demux table contains entries which causes it to copy all the samples from source to destination buffer one by one without doing any demuxing. Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Signed-off-by: Jonathan Cameron <jic23@kernel.org> Cc: Stable@vger.kernel.org
2014-06-29iio: staging: sca3000: hide stufftoread logicJosselin Costanzi
Change sca3000_ring implementation so that it exports a data_available function to iio. Signed-off-by: Josselin Costanzi <josselin.costanzi@mobile-devices.fr> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2014-04-29IIO: core: Modify scan element typeSrinivas Pandruvada
The current scan element type uses the following format: [be|le]:[s|u]bits/storagebits[>>shift]. To specify multiple elements in this type, added a repeat value. So new format is: [be|le]:[s|u]bits/storagebitsXr[>>shift]. Here r is specifying how may times, real/storage bits are repeating. When X is value is 0 or 1, then repeat value is not used in the format, and it will be same as existing format. Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2014-04-22Merge tag 'iio-fixes-for-3.15a' of ↵Greg Kroah-Hartman
git://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio into staging-linus Jonathan writes: First found of IIO fixes for the 3.15 cycle. * Fix the platform data support for the at91 adc driver. * A couple of related follow up patches get the support working again for at91sam9260 and at91sam9g45 as the earlier patch results in a device name change. * A default timer value in the at91 adc driver was bonkers. Make it sane. * Fix incorrect reporting of the integration time for the cm32181 light sensor * Fix a missing break in the ad2s1200 driver which would have give a false error return. * Make sure buffer scan mask queries from userspace return 0/1 rather than a fairly random value depending on their implementation of test_bit * Fix leak of the i2c client and a null pointer dereference in the cm36651 driver. * Fix a build warning on avr32 for the mxs-lradc (not exactly a critical combination - but the issue was real).
2014-03-22iio: querying buffer scan_mask should return 0/1Alec Berg
Ensure that querying the IIO buffer scan_mask returns a value of 0 or 1. Currently querying the scan mask has the value returned by test_bit(), which returns either true or false. For some architectures test_bit() may return -1 for true, which will appear to return an error when returning from iio_scan_mask_query(). Additionally, it's important for the sysfs interface to consistently return the same thing when querying the scan_mask. Signed-off-by: Alec Berg <alecaberg@chromium.org> Cc: stable@vger.kernel.org Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2014-02-18iio get rid of unneccessary error_retHartmut Knaack
Get rid of obsolete uses of goto error_ret and some empty lines. Signed-off-by: Hartmut Knaack <knaack.h@gmx.de> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2013-12-03iio: Add support for blocking IO on buffersLars-Peter Clausen
Currently the IIO buffer interface only allows non-blocking reads. This patch adds support for blocking IO. In blocking mode the thread will go to sleep if no data is available and will wait for the buffer implementation to signal that new data is available by waking up the buffers waitqueue. Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2013-12-03iio: Add data_available callback for buffersLars-Peter Clausen
This patch adds a new data_available() callback to the iio_buffer_access_funcs struct. The callback is used to indicate whether data is available in the buffer for reading. It is meant to replace the stufftoread flag from the iio_buffer struct. The reasoning for this is that the buffer implementation usually can determine whether data is available rather easily based on its state, on the other hand it can be rather tricky to update the stufftoread flag in a race free way. Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2013-10-19Merge 3.12-rc6 into staging-next.Greg Kroah-Hartman
We want these fixes in here as well. Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
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-16iio: Update buffer's bytes per datum after updating the scan maskLars-Peter Clausen
Currently a IIO device driver needs to make sure to update the buffer's bytes per datum after the scan mask has changed. This is usually done in the preenable callback by invoking iio_sw_buffer_preenable(). This is something that needs to be done and is done for virtually all devices which support buffers (we currently have only one exception). Also this a bit of a layering violation since we have to call the buffer setup ops from the device setup ops. This requires the device driver to know about the internal requirements of the buffer (e.g. whether we need to call the set_bytes_per_datum) callback. And especially with in-kernel buffer consumers, which allows to attach arbitrary buffers to a device, this is something that the driver can't know. Moving this to the core allows us to drop the individual calls to iio_sw_buffer_preenable() from drivers. Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Cc: Denis Ciocca <denis.ciocca@st.com> Cc: Marek Vasut <marex@denx.de> Cc: Zubair Lutfullah <zubair.lutfullah@gmail.com> Cc: Jacek Anaszewski <j.anaszewski@samsung.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2013-10-15iio:buffer: Free active scan mask in iio_disable_all_buffers()Lars-Peter Clausen
Usually the active scan mask is freed in __iio_update_buffers() when the buffer is disabled. But when the device is still sampling when it is removed we'll end up disabling the buffers in iio_disable_all_buffers(). So we also need to free the active scan mask here, otherwise it will be leaked. Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2013-10-12iio:buffer: Ignore noop requests for iio_update_buffers()Lars-Peter Clausen
Since the kernel now disables all buffers when a device is unregistered it might happen that a in-kernel consumer tries to disable that buffer again. So ignore requests where the buffer already is in the desired state. Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2013-10-12iio: Add a helper to free a list of IIO device attributesLars-Peter Clausen
We have the same code to free a IIO device attribute list in multiple place. This patch adds a new helper function to take care of this and replaces the custom instances with a call to the helper function. Note that we do not need to call list_del() for each of the list items since we will never look at any of the list items nor the list itself again. Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2013-10-12iio:buffer: Add proper locking for iio_update_buffers()Lars-Peter Clausen
We need to make sure that in-kernel users of iio_update_buffers() do not race against each other or against unregistration of the device. So we need to take both the mlock and the info_exist_lock when calling iio_update_buffers() from a in-kernel consumer. Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2013-10-12iio: Wakeup poll and blocking reads when the device is unregisteredLars-Peter Clausen
Once the device has been unregistered there won't be any new data no matter how long a userspace application waits, so we might as well wake them up and let them know. Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2013-10-12iio: Return -ENODEV for file operations if the device has been unregisteredLars-Peter Clausen
If the IIO device has been unregistered return -ENODEV for any further file operations like read() and ioctl(). This avoids userspace being able to grab new references to the device. 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-25Merge 3.12-rc2 into staging-next.Greg Kroah-Hartman
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>
2013-09-21iio: Pass scan mask as unsigned longPeter Meerwald
Signed-off-by: Peter Meerwald <pmeerw@pmeerw.net> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2013-09-21iio: Stop sampling when the device is removedLars-Peter Clausen
Make sure to stop sampling when the device is removed, otherwise it will continue to sample forever. Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2013-09-21iio: Fix crash when scan_bytes is computed with active_scan_mask == NULLPeter Meerwald
if device has available_scan_masks set and the buffer is enabled without any scan_elements enabled, in a NULL pointer is dereferenced in iio_compute_scan_bytes() [ 18.993713] Unable to handle kernel NULL pointer dereference at virtual address 00000000 [ 19.002593] pgd = debd4000 [ 19.005432] [00000000] *pgd=9ebc0831, *pte=00000000, *ppte=00000000 [ 19.012329] Internal error: Oops: 17 [#1] PREEMPT ARM [ 19.017639] Modules linked in: [ 19.020843] CPU: 0 Not tainted (3.9.11-00036-g75c888a-dirty #207) [ 19.027587] PC is at _find_first_bit_le+0xc/0x2c [ 19.032440] LR is at iio_compute_scan_bytes+0x2c/0xf4 [ 19.037719] pc : [<c021dc60>] lr : [<c03198d0>] psr: 200d0013 [ 19.037719] sp : debd9ed0 ip : 00000000 fp : 000802bc [ 19.049713] r10: 00000000 r9 : 00000000 r8 : deb67250 [ 19.055206] r7 : 00000000 r6 : 00000000 r5 : 00000000 r4 : deb67000 [ 19.062011] r3 : de96ec00 r2 : 00000000 r1 : 00000004 r0 : 00000000 [ 19.068847] Flags: nzCv IRQs on FIQs on Mode SVC_32 ISA ARM Segment user [ 19.076324] Control: 10c5387d Table: 9ebd4019 DAC: 00000015 problem is the rollback code in iio_update_buffers(), old_mask may be NULL (e.g. on first call) I'm not too confident about the fix; works for me... Signed-off-by: Peter Meerwald <pmeerw@pmeerw.net> Reviewed-by: Lars-Peter Clausen <lars@metafoo.de> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2013-09-18iio: Minor cleanups of industrialio-bufferPeter Meerwald
adding one return value check fix one kerneldoc Signed-off-by: Peter Meerwald <pmeerw@pmeerw.net> 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-09-15iio: refactor info mask and ext_info attribute creation.Jonathan Cameron
Introduce an enum to specify whether the attribute is separate or shared. Factor out the bitmap handling for loop into a separate function. Tidy up error handling and add a NULL assignment to squish a false positive warning from GCC. Change ext_info shared type from boolean to enum and update in all drivers. Signed-off-by: Jonathan Cameron <jic23@kernel.org> Reviewed-by: Lars-Peter Clausen <lars@metafoo.de>
2013-09-15iio:buffer: Simplify iio_buffer_is_active()Lars-Peter Clausen
We can skip having to loop through all the device's buffers to see if a certain buffer is active, if we let the buffer's list head point to itself when the buffer is inactive. Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2013-05-22iio: buffer: cleanup messages in iio_update_buffers()Michał Mirosław
1. make messages grepable (in one line) 2. include returned errno in them Signed-off-by: Michał Mirosław <mirq-linux@rere.qmqm.pl> 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-10-19iio: Use strict_strtouint instead of kstrtoulLars-Peter Clausen
strict_strto* has been deprecated in favor of kstrto*. Use strict_strtouint respective strict_strtoint, since that is what the functions we pass the converted values to expect. Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
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-09-03iio: whitespace cleanup and removal of semicolon after functionsPeter Meerwald
Signed-off-by: Peter Meerwald <pmeerw@pmeerw.net> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2012-07-12Merge tag 'togreg-3.6a' of ↵Greg Kroah-Hartman
git://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio into staging-next IIO: One new driver and a couple of nice cleanups.
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-09iio: Add callback to check whether a scan mask is validLars-Peter Clausen
This is useful for cases where the number of valid scan masks grows exponentially, but it is rather easy to check whether a mask is valid or not programmatically. An example of such a case is a device with multiple ADCs where each ADC has a upstream MUX, which allows to select from a number of physical channels. +-------+ +-------+ | | | | --- Channel 1 | ADC 1 |---| MUX 1 | --- ... | | | | --- Channel M +-------+ +-------+ . . . . . . . . . +-------+ +-------+ | | | | --- Channel M * N + 1 | ADC N |---| MUX N | --- ... | | | | --- Channel M * N + M +-------+ +-------+ The number of necessary scan masks for this case is (M+1)**N - 1, on the other hand it is easy to check whether subsets for each ADC of the scanmask have only one bit set. Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2012-07-08iio: iio_buffer_register: Use correct channel when calculating masklengthLars-Peter Clausen
The channel set assigned to the iio device is not necessarily the same has the channel set passed to iio_buffer_register. So to avoid possible complications always work with the channel set pass to iio_buffer_register and ignore the channel set assigned to the iio device. Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2012-06-18iio: iio_buffer_register: Skip channels with negative scan indexLars-Peter Clausen
It is not always the case that all channels can be used in buffered mode. This patch allows channels, which can not be used in buffered mode, to set their scan index to a negative number, which will cause iio_buffer_register to ignore the channel. Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Acked-by: Jonathan Cameron <jic23@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2012-06-15iio: buffer: Fix NULL pointer deref caused by empty scan maskLars-Peter Clausen
iio_scan_mask_match() returns NULL if the passed in scan mask is empty. This will happen if no channel has been selected and buffer is enabled. iio_sw_buffer_preenable() will assign NULL to indio_dev->active_scan_mask in this case. As a result iio_update_demux() will cause a NULL pointer deref, because it expects active_scan_mask to be non-NULL. Since it does not make much sense to start data capture if there is no data to capture this patch updates the code to fail gracefully in iio_scan_mask_match() instead of crashing the kernel. Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Acked-by: Jonathan Cameron <jic23@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2012-05-14iio: Use dev_to_iio_dev()Lars-Peter Clausen
Replace open-coded instances of getting a iio_dev struct from a device struct with dev_to_iio_dev(). Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Acked-by: Jonathan Cameron <jic23@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2012-04-25IIO: Move the core files to drivers/iioJonathan Cameron
Take the core support + the kfifo buffer implentation out of staging. Whilst we are far from done in improving this subsystem it is now at a stage where the userspae interfaces (provided by the core) can be considered stable. Drivers will follow over a longer time scale. Signed-off-by: Jonathan Cameron <jic23@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>