summaryrefslogtreecommitdiff
path: root/drivers/staging/iio/accel/sca3000_ring.c
AgeCommit message (Collapse)Author
2016-02-20staging: iio: accel: Remove unnecessary else after goto in if blockJanani Ravichandran
This patch removes the unnecessary else following an if block with a goto statement. Signed-off-by: Janani Ravichandran <janani.rvchndrn@gmail.com> Acked-by: Daniel Baluta <daniel.baluta@intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2015-12-19Staging: iio: accel: sca3000: Fixed NULL comparison styleBhaktipriya Shridhar
The variable u8 **rx_p, is a pointer-to-pointer and hence the check should be "if (!*rx_p)" and not "if (!rx_p)". In the earlier version, checkpatch.pl gave the following check, which was incorrect: CHECK: Comparison to NULL could be written "!rx_p" + if (*rx_p == NULL) { Signed-off-by: Bhaktipriya Shridhar <bhaktipriya96@gmail.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2015-10-29staging: iio: accel: add blank lines after function definitionsIoana Ciornei
This patch add blank lines after functions definitions in order to follow the linux coding style. Signed-off-by: Ioana Ciornei <ciorneiioana@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2015-10-29staging: iio: accel: change uint8_t to u8Ioana Ciornei
This patch changes uint8_t type to preferred kernel type u8 in order to follow the linux coding style conventions. Signed-off-by: Ioana Ciornei <ciorneiioana@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2015-10-29staging: iio: accel: properly align function argumentsIoana Ciornei
This patch properly aligns the function arguments or its parameters in order to match the open bracket. Signed-off-by: Ioana Ciornei <ciorneiioana@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2015-10-29staging: iio: accel: add spaces aroung binary operatorsIoana Ciornei
This patch adds spaces around binary operators such as '*', '/', '+' in order to improve readability. Signed-off-by: Ioana Ciornei <ciorneiioana@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2015-10-27Merge 4.3-rc7 into staging-nextGreg Kroah-Hartman
We want the other staging patches in this branch as well. Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2015-10-24staging: iio: accel: Remove explicit comparisonsCristina Moraru
Remove comparisons to 0 or NULL Signed-off-by: Cristina Moraru <cristina.moraru09@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2015-10-03iio: accel: sca3000: memory corruption in sca3000_read_first_n_hw_rb()Dan Carpenter
"num_read" is in byte units but we are write u16s so we end up write twice as much as intended. Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com> Cc: <Stable@vger.kernel.org> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2015-06-01iio: Specify supported modes for buffersLars-Peter Clausen
For each buffer type specify the supported device modes for this buffer. This allows us for devices which support multiple different operating modes to pick the correct operating mode based on the modes supported by the attached buffers. It also prevents that buffers with conflicting modes are attached to a device at the same time or that a buffer with a non-supported mode is attached to a device (e.g. in-kernel callback buffer to a device only supporting hardware mode). Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2015-03-29iio: add watermark logic to iio read and pollJosselin Costanzi
Currently the IIO buffer blocking read only wait until at least one data element is available. This patch makes the reader sleep until enough data is collected before returning to userspace. This should limit the read() calls count when trying to get data in batches. Co-author: Yannick Bedhomme <yannick.bedhomme@mobile-devices.fr> Signed-off-by: Josselin Costanzi <josselin.costanzi@mobile-devices.fr> [rebased and remove buffer timeout] Signed-off-by: Octavian Purdila <octavian.purdila@intel.com> Reviewed-by: Lars-Peter Clausen <lars@metafoo.de> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2014-12-12iio: buffer: Drop get_length callbackLars-Peter Clausen
We already do have the length field in the struct iio_buffer which is expected to be in sync with the current size of the buffer. And currently all implementations of the get_length callback either return this field or a constant number. This patch removes the get_length callback and replaces all occurrences in the IIO core with directly accessing the length field of the buffer. Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2014-12-12iio: buffer: Allocate standard attributes in the coreLars-Peter Clausen
All buffers want at least the length and the enable attribute. Move the creation of those attributes to the core instead of having to do this in each individual buffer implementation. This allows us to get rid of some boiler-plate code. Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2014-12-12iio: Remove get_bytes_per_datum() from iio_buffer_access_funcsLars-Peter Clausen
There haven't been any users of the get_bytes_per_datum() callback for a while. The core assumes that the number of bytes per datum can be calculated based on the enabled channels and the storage size of the channel and iio_compute_scan_bytes() is used to compute this number. So remove the callback. Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2014-09-28staging: iio: accel: Use __be16 instead of u16Aybuke Ozdemir
This patch fixes these warning messages found by sparse: drivers/staging/iio/accel/sca3000_ring.c:120:61: warning: incorrect type in argument 1 (different base types) drivers/staging/iio/accel/sca3000_ring.c:120:61: expected restricted __be16 const [usertype] *p drivers/staging/iio/accel/sca3000_ring.c:120:61: got unsigned short [usertype] * Signed-off-by: Aybuke Ozdemir <aybuke.147@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-06-29iio: staging: sca3000: hide stufftoread logiciio-for-3.17bJosselin 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-03-07Staging: iio/accel: Fix Prefer netdev_warn(netdev, ...then dev_warn(dev, ... ↵Monam Agarwal
then pr_warn(... to printk(KERN_INFO ... in sca3000_ring.c This patch fixes the following checkpatch.pl warning in sca3000_ring.c WARNING: Prefer netdev_info(netdev, ... then dev_info(dev, ... then pr_info(... to printk(KERN_INFO ... Signed-off-by: Monam Agarwal <monamagarwal123@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-10-19Merge tag 'iio-for-3.12d' of ↵Greg Kroah-Hartman
git://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio into staging-next Jonathan writes: Fourth round of IIO new drivers, functionality and cleanups for the 3.13 cycle. New Drivers * cm36651 combined RGB light and proximity sensor. Core improvements * Some more fixes and cleanups related to buffers. These include the second half of a series which went is as fixes. The basis for delaying until the next merge window is that some are too invasive for this late in a cycle and others only effect code paths current unused in the mainline tree. In this case we have: * protecting against concurrent userspace access * fixing a memory leak if a device goes away * avoiding always reallocating the buffer whether or not it has changed (a bug fix, but one with no functional changes other than a small speed improvement.) * Add reference counting for buffers to ensure they hang around if open from userspace or in kernel when the device is forcefully removed. * Return -ENODEV for buffer access operations when the device has gone away. * Add proper locking for iio_update_buffers (currently we only have one buffer per device in mainline, but an input bridge driver is under development which would make this bug 'real'.) * Wake up anyone waiting on a buffer if the device is unregistered. A subsequent read will fail, notifying userspace that the device is no longer there rather than having it wait possibly for ever. * Move the iio_sw_preenable functionality into the core. This avoids drivers having to 'know' about how the buffers are implemented and is called by almost all drivers anyway. Those that don't call it are not harmed by it being called. * New registration approach for information (i.e. sysfs attributes) about events. Much more generic and now similar to how the equivalent is handled for channel information. The events infrastructure had been left behind by other changes so this brings it back in line. * Using the new events registration approach, add a hysterisis event_info element and apply this to those drivers with this property. * A little unitialized variable bug in the generic_buffer.c example. * Factor out the code for freeing lists of IIO Device attributes to avoid some repitition. Driver cleanups * At91 driver gains touch screen support and some related fixes. * Follow up series of patches removing the now redundant iio_sw_buffer_preenable calls. * Lots of conversions to the new event registration methods. * Another round of hmc5843 cleanups as that driver moves towards graduating from staging. * Make some SoC drivers buildable if COMPILE_TEST is used. Follow up fixes for a few bits and bobs that revealed. * Add explicit includes of linux/of.h to those drivers making us of linux/of.h
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-10-11Staging: iio: fix sizeof *ring should be sizeof(*ring)Ebru Akagunduz
Fix checkpatch.pl issues with sizeof *ring should be sizeof(*ring) in sca3000_ring.c Signed-off-by: Ebru Akagunduz <ebru.akagunduz@gmail.com> Reviewed-by: Josh Triplett <josh@joshtriplett.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-09-08staging: iio: replace strict_strto*() with kstrto*()Jingoo Han
The usage of strict_strto*() is not preferred, because strict_strto*() is obsolete. Thus, kstrto*() should be used. Previously, there were only strict_strtol(), strict_strtoul(), strict_strtoull(), and strict_strtoll(). Thus, when converting to the variables, only long, unsigned long, unsigned long long, and long long can be used. However, kstrto*() provides various functions handling all types of variables. Therefore, the types of variables can be changed properly. Signed-off-by: Jingoo Han <jg1.han@samsung.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2013-02-09staging:iio: Use spi_sync_transfer()Lars-Peter Clausen
Use the new spi_sync_transfer() helper function instead of open-coding it. Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2012-09-03staging:iio: Update email address for Jonathan Cameron.iio-for-v3.7bJonathan Cameron
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2012-05-14staging:iio:accel: 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 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>
2011-12-08staging:iio:buffer struct iio_buffer doesn't need an indio_dev pointer.Jonathan Cameron
In all existing cases, the calls are coming from a location where the indio_dev is already available. Signed-off-by: Jonathan Cameron <jic23@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-12-08staging:iio:buffer move setup ops from buffer instance to iio_devJonathan Cameron
These callbacks should not be buffer instance specific. Hence move them out of the buffer. Signed-off-by: Jonathan Cameron <jic23@cam.ac.uk> Acked-by: Lars-Peter Clausen <lars@metafoo.de> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-12-08staging:iio:buffer drop bpe field.Jonathan Cameron
Has no remaining users. Signed-off-by: Jonathan Cameron <jic23@cam.ac.uk> Acked-by: Lars-Peter Clausen <lars@metafoo.de> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-11-26staging:iio: header reorganizationJonathan Cameron
Issue brought up by Lars-Peter Clausen. This is a varient of what he suggested. io/iio.h for driver stuff (has to include types.h) Sub files for the bits drivers may or may not use iio/sysfs.h iio/buffer.h (contents of current buffer_generic.h) (obviously anything offering events will need events.h as well) iio/types.h for the enums that matter to both iio_chan_type, iio_modifier iio/events.h for the event code stuff IIO_EVENT_CODE and friends. + everything in chrdev.h So this is the stuff that userspace cares about. Also include iio_event_type, iio_event_direction Thus iio drivers include iio.h + as required events.h sysfs.h buffer.h in kernel users (once that interface is merged) will need inkern.h which will pull in types.h Userspace will need just events.h (which pulls in types.h) to get everything they need to know about. Buffer userspace access doesn't currently need any core defines. All information about the data format is passed through sysfs. Signed-off-by: Jonathan Cameron <jic23@cam.ac.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-09-26staging:iio: replacing term ring with buffer in the IIO core.Jonathan Cameron
They aren't always ring buffers, so just use buffer for all naming. Signed-off-by: Jonathan Cameron <jic23@cam.ac.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-09-26staging:iio: rename ring_generic.h -> buffer_generic.hJonathan Cameron
Nothing in this file is specific to RING buffers so rename it. Signed-off-by: Jonathan Cameron <jic23@cam.ac.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-09-26staging:iio: tree wide IIO_RING_TRIGGERED -> IIO_BUFFER_TRIGGEREDJonathan Cameron
also, IIO_RING_HARDWARE_BUFFER -> IIO_BUFFER_HARDWARE These aren't always rings so the naming should not imply that. Signed-off-by: Jonathan Cameron <jic23@cam.ac.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-09-16staging:iio:tree wide. abi fixup for in_ out_ prefix introduction.Jonathan Cameron
This patch set should bring all the attributes created outside of chan_spec registration inline with the new abi. Signed-off-by: Jonathan Cameron <jic23@cam.ac.uk> Acked-by: Michael Hennerich <michael.hennerich@analog.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-09-06staging:iio:various move default scan mask setting after ring register or removeJonathan Cameron
The scan mask will be dynamically assigned in register, so don't use it before that. In adis16260 I've moved it as I know this driver has userspace code. Same for sca3000 where it is cost free due to hardware buffer. Can do that for the others, but in theory userspace code should always have been checking these and setting them appropriately anyway! V2: Clear default mask out of adis16400 as reported by Michael Signed-off-by: Jonathan Cameron <jic23@cam.ac.uk> Reported-by: Michael Hennerich <michael.hennerich@analog.com> Acked-by: Michael Hennerich <Michael.Hennerich@analog.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-09-06staging: iio: push the main buffer chrdev down to the top level.Jonathan Cameron
Sorry all, this one is very invasive, though the driver changes are just trivial interface fixes. Not all done yet. V2 - bring the sca3000 with us. V3 - fix ade7758 bugs in conversion. V4 - add ad5933 Signed-off-by: Jonathan Cameron <jic23@cam.ac.uk> Acked-by: Michael Hennerich <michael.hennerich@analog.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-08-23staging:iio:accel header housekeeping - remove unecessary includes.Jonathan Cameron
Signed-off-by: Jonathan Cameron <jic23@cam.ac.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-08-23staging:iio:accel: usused header removals.Jonathan Cameron
Missing from the iio_chan_spec conversion patches. Signed-off-by: Jonathan Cameron <jic23@cam.ac.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-08-23staging:iio:trivial sparse related cleanups.Jonathan Cameron
Getting rid of messages that make it harder to spot important issues. Some code removed that will be useful one day. Can put it back then. Signed-off-by: Jonathan Cameron <jic23@cam.ac.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-06-28staging:iio:accel:sca3000: allocate state in iio_dev and use iio_priv to access.Jonathan Cameron
Mechanical change. Signed-off-by: Jonathan Cameron <jic23@cam.ac.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-05-19staging:iio: rationalization of different buffer implementation hooks.Jonathan Cameron
1) move a generic helper function out of ring_sw. It applies to other buffers as well. 2) Get rid of a lot of left over function definitions. 3) Move all the access functions into static structures. 4) Introduce and use a static structure for the setup functions, preenable etc. Some driver conversions thanks to Michael Hennerich (pulled out of patches that would otherwise sit after this). Signed-off-by: Jonathan Cameron <jic23@cam.ac.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-05-19staging:iio:buffering remove unused parameter dead_offset from read_last_n ↵Jonathan Cameron
in all buffer implementations. This element has been usused by the core for quite some time. sca3000 set it none the less until the rewrite in the previous patch (and hence didn't work). Signed-off-by: Jonathan Cameron <jic23@cam.ac.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-05-19staging:iio:sca3000 extract old event handling and move to poll for events ↵Jonathan Cameron
from buffer Fairly substantial rewrite as the code had bitrotted. A rethink is needed for how to handle variable types in the new chan_spec world. This patch restores sca3000 buffer usage to a working state. V3: Rebase fixups. V2: Move to new version of IIO_CHAN macro Signed-off-by: Jonathan Cameron <jic23@cam.ac.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-05-19staging:iio: remove legacy event chrdev for the buffersJonathan Cameron
part of sca3000 driver temporarily disabled (buffer won't run anyway). This section is replaced later in this patch set. Signed-off-by: Jonathan Cameron <jic23@cam.ac.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-05-19staging:iio: remove ability to escalate events.Jonathan Cameron
Whilst it is possible to output events to say buffers have passed a particular level there are no obvious reasons to actually do so. The upshot of this patch is that buffers will only ever have one threshold turned on at a time. For now sca3000 has it's ring buffer effectively disabled. Fixed later in series. Signed-off-by: Jonathan Cameron <jic23@cam.ac.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-04-25staging:iio: replace rip_lots naming with read_first_nJonathan Cameron
Change suggested by Arnd Bergmann, Related patch to remove pointless (now) dead_offset parameter will have await proper fix for the sca3000 driver. That depends on some intermediate patches so may be a little while. Signed-off-by: Jonathan Cameron <jic23@cam.ac.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-03-31Fix common misspellingsLucas De Marchi
Fixes generated by 'codespell' and manually reviewed. Signed-off-by: Lucas De Marchi <lucas.demarchi@profusion.mobi>
2010-10-07staging: iio: sca3000 fix bug due to scan_element directory move.Jonathan Cameron
The device found passed to the attr functions is that of the ring buffer, not the the iio_dev so we need to bounce through one more hop to get the right address. Reported-by: Michael Hennerich <michael.hennerich@analog.com> Signed-off-by: Jonathan Cameron <jic23@cam.ac.uk> Acked-by: Michael Hennerich <michael.hennerich@analog.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2010-09-21staging: iio: sca3000 add _index attribute registrationJonathan Cameron
Signed-off-by: Jonathan Cameron <jic23@cam.ac.uk> Signed-off-by: Manuel Stahl <manuel.stahl@iis.fraunhofer.de> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2010-09-21staging: iio: Remove unused bit_count from struct iio_scan_elJonathan Cameron
The job this was intended to do (never implemented) is now done by explicit definition of _type attributes in all drivers Signed-off-by: Jonathan Cameron <jic23@cam.ac.uk> Signed-off-by: Manuel Stahl <manuel.stahl@iis.fraunhofer.de> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2010-09-21staging: iio: sca3000 add _type attributes for all scan elementsJonathan Cameron
Signed-off-by: Jonathan Cameron <jic23@cam.ac.uk> Signed-off-by: Manuel Stahl <manuel.stahl@iis.fraunhofer.de> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>