aboutsummaryrefslogtreecommitdiff
path: root/drivers/staging/iio/industrialio-core.c
AgeCommit message (Collapse)Author
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>
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>
2012-04-18staging:iio: drop procesed_val element of chan_spec.Jonathan Cameron
There is no longer any need for this as we have separate info_mask elements for raw and processed value reads. Signed-off-by: Jonathan Cameron <jic23@kernel.org> Acked-by: Lars-Peter Clausen <lars@metafoo.de> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2012-04-18staging:iio: Make read / write attributes for channel values optional.Jonathan Cameron
Until now all channels have had read/write attributes. This patch allows for channels where we can't actually read the value (or for output devices, write it!) v2 introduces separate elements for processed and raw thus removing some special case code from the core. Thanks to Lars-Peter for an excellent suggestion! Signed-off-by: Jonathan Cameron <jic23@kernel.org> Acked-by: Lars-Peter Clausen <lars@metafoo.de> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2012-04-18staging:iio: add a raw and processed elements to info_maskJonathan Cameron
This will allow us to have drivers where the channel value may not be read or written but other information is available. Also adds the ability to have both processed and raw access to a given channel, though in most cases this doesn't make sense. Ultimately will lead to simpler code by allowing us to drop the special case handling for the value reading cases. Signed-off-by: Jonathan Cameron <jic23@kernel.org> Acked-by: Lars-Peter Clausen <lars@metafoo.de> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2012-04-13staging: iio: add channel info for sampling frequencyLaxman Dewangan
Adding channel info IIO_CHAN_INFO_SAMP_FREQ to select different sampling frequency per channel wise. Signed-off-by: Laxman Dewangan <ldewangan@nvidia.com> Acked-by: Jonathan Cameron <jic23@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2012-03-07staging:iio: Fix compile error without CONFIG_DEBUG_FSLars-Peter Clausen
commit e553f182d ("staging: iio: core: Introduce debugfs support, add support for direct register access") added a '#if defined(CONFIG_DEBUG_FS)' around iio_read_channel_ext_info and iio_write_channel_ext_info causing the following compile error if CONFIG_DEBUG_FS is not defined. drivers/staging/iio/industrialio-core.c:621:11: error: 'iio_read_channel_ext_info' undeclared (first use in this function) drivers/staging/iio/industrialio-core.c:623:11: error: 'iio_write_channel_ext_info' undeclared (first use in this function) This patch fixes the issue by moving the functions out of the '#if defined(CONFIG_DEBUG_FS)' section again. Reported-by: Randy Dunlap <rdunlap@xenotime.net> Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Acked-by: Randy Dunlap <rdunlap@xenotime.net> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2012-03-02staging: iio: core: Avoid NULL pointer de-ref in case indio_dev->setup_ops ↵Michael Hennerich
are not in use Drivers may not need setup_ops at all, so let the core supply some empty ops. Signed-off-by: Michael Hennerich <michael.hennerich@analog.com> Acked-by: Jonathan Cameron <jic23@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2012-03-02staging: iio: core: Introduce debugfs support, add support for direct ↵Michael Hennerich
register access Changes since V1: Exclude iio debugfs code in case CONFIG_DEBUG_FS isn't enabled. Introduce helper function iio_get_debugfs_dentry. Document additions to struct iio_dev iio_debugfs_read_reg: Use snprintf. Use a shorter fixed length. Introduce len instead of pointer math. iio_debugfs_write_reg: Fix return value use PT_ERR. Changes since V2: Use debugfs_remove. Fix whitespace damage. Signed-off-by: Michael Hennerich <michael.hennerich@analog.com> Acked-by: Jonathan Cameron <jic23@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2012-03-02drivers:staging:iio Fix typos and comments in staging iio.Justin P. Mattock
The below patch fixes some comments and some typos that I have found while reading drivers/staging/iio/* Signed-off-by: Justin P. Mattock <justinmattock@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2012-02-24staging:iio: Add extended IIO channel infoLars-Peter Clausen
Sometimes devices have per channel properties which either do not map nicely to the current channel info scheme (e.g. string properties) or are very device specific, so it does not make sense to add generic support for them. Currently drivers define these attributes by hand for each channel. Depending on the number of channels this can amount to quite a few lines of boilerplate code. Especially if a driver supports multiple variations of a chip with different numbers of channels. In this case it becomes necessary to have a individual attribute list per chip variation and also a individual iio_info struct. This patch introduces a new scheme for handling such per channel attributes called extended channel info attributes. A extended channel info attribute consist of a name, a flag whether it is shared and read and write callbacks. The read and write callbacks are similar to the {read,write}_raw callbacks and take a IIO device and a channel as their first parameters, but instead of pre-parsed integer values they directly get passed the raw string value, which has been written to the sysfs file. It is possible to assign a list of extended channel info attributes to a channel. For each extended channel info attribute the IIO core will create a new sysfs attribute conforming to the IIO channel naming spec for the channels type, similar as for normal info attributes. Read and write access to this sysfs attribute will be redirected to the extended channel info attributes read and write callbacks. 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-02-24staging:iio:core set the iio_dev.info pointer to null on unregister under lock.Jonathan Cameron
This prevents use of provider callbacks after it has been unregistered. Note that all code using this that can be called from a consumer *must* check the pointer before using and hold the info_exist_lock throughout the usage of the callbacks in info. Signed-off-by: Jonathan Cameron <jic23@kernel.org> Acked-by: Linus Walleij <linus.walleij@linaro.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2012-02-09staging:iio: Factor out event handling into its own fileLars-Peter Clausen
The core iio file has gotten quite cluttered over time. This patch moves the event handling code into its own file. Since the event handling code is largely independent from the core code the only code changes necessary for this are to make the moved iio_device_register_eventset, iio_device_unregister_eventset and iio_event_getfd functions non static. This has also the advantage that industrialio-core.c is now closer again to its counterpart in the outofstaging branch. 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-02-09staging:iio: Update iio_event_interface documentationLars-Peter Clausen
The documentation for the iio_event_interface does not match the actual struct anymore. This patch removes the documentation for non-existing fields and adds documentation for missing fields. 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>
2011-12-22staging:iio: Drop {mark,unmark}_in_use callbacksLars-Peter Clausen
These callbacks are currently used by the individual buffer implementations to ensure that the request_update callback is not issued while the buffer is in use. But the core already provides sufficient measures to prevent this from happening in the first place. So it is safe to remove them. There is one functional change due to this patch. Since the buffer is no longer marked as in use when the chrdev is opened, it is now possible to enable the buffer while it is opened. This did not work before, because mark_param_change did fail if the buffer was marked as in use. Acked-by: Jonathan Cameron <jic23@kernel.org> Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-12-22staging:iio: Make sure a device is only opened once at a timeLars-Peter Clausen
Our buffer implementation does not support multiple concurrent readers. So we have to ensure that a device is only opened once at a time. So do the same thing we do for the event fd and introduce a per device busy flag. The flag gets set when opening the device and gets cleared when closing the device. If a open is attempted while the busy flag is set we return -EBUSY. Acked-by: Jonathan Cameron <jic23@kernel.org> Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-12-09Merge 3.2-rc5 into staging-nextGreg Kroah-Hartman
This resolves the conflict in the drivers/staging/iio/industrialio-core.c file due to two different changes made to resolve the same problem. Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-12-08staging:iio:find iio channel from scan index util functionJonathan Cameron
Useful for getting to the channel based on scan mask alone. Signed-off-by: Jonathan Cameron <jic23@cam.ac.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-11-30staging: iio: Use kcalloc instead of kzalloc to allocate arrayThomas Meyer
The advantage of kcalloc is, that will prevent integer overflows which could result from the multiplication of number of elements and size and it is also a bit nicer to read. The semantic patch that makes this change is available in https://lkml.org/lkml/2011/11/25/107 Signed-off-by: Thomas Meyer <thomas@m3y3r.de> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-11-28staging:iio: filter description - low pass 3db frequency.Jonathan Cameron
Introduce the first data filtering related parameter. For now we are ignoring the filter type and merely specifying its approximate (I read them off tiny graphs) 3db point. Signed-off-by: Jonathan Cameron <jic23@cam.ac.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-11-26staging:iio: Make write_event_value callback optionalLars-Peter Clausen
Some devices have fixed thresholds which can not be modified so make the write_event_value callback optional, so the drivers for these devices do not have to implement a boilerplate no-op callback. Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Acked-by: Jonathan Cameron <jic23@cam.ac.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-11-26staging:iio:treewide only use shared to decide on interfacesJonathan Cameron
Internally the fact that say scale is shared across channels is actually of remarkably little interest. Hence lets not store it. Numerous devices have weird combinations of channels sharing scale anyway so it is not as though this was really telling us much. Note however that we do still use the shared sysfs attrs thus massively reducing the number of attrs in complex drivers. Side effect is that certain drivers that were abusing this (mostly my work) needed to do a few more checks on what the channel they are being queried on actually is. This is also helpful for in kernel interfaces where we just want to query the scale and don't care whether it is shared with other channels or not. 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: Do not use bitmasks for channel info addressesLars-Peter Clausen
Currently the iio framework uses bitmasks for the address field of channel info attributes. This is for historical reasons and no longer required since it will only ever query a single info attribute at once. This patch changes the code to use the non-shifted iio_chan_info_enum values for the info attribute address. Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Signed-off-by: Jonathan Cameron <jic23@cam.ac.uk> 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-11-26Subject: fix build breakage in drivers/staging/iio/industrialio-core.cGreg Kroah-Hartman
This was introduced in commit b46413367961c2e8bd827e067a231be982aaeee2 (iio: fix a leak due to improper use of anon_inode_getfd()) Cc: Al Viro <viro@zeniv.linux.org.uk> Cc: Jonathan Cameron <jic23@cam.ac.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-11-26staging:iio:events: Make sure userspace buffer is large enoughLars-Peter Clausen
Make sure that the userspace buffer is large enough to hold a iio_event_data struct before writing to it. Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Signed-off-by: Jonathan Cameron <jic23@cam.ac.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-11-26staging:iio:core shared attrs do not work with modifier.Jonathan Cameron
The logic building the name had a small bug where it did not verify if it was generic before applying the modifier. Signed-off-by: Jonathan Cameron <jic23@cam.ac.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-11-26iio: iio_event_getfd -- fix ev_int build failureAndy Whitcroft
Fix build failure in staging iio driver: .../drivers/staging/iio/industrialio-core.c: In function 'iio_event_getfd': .../drivers/staging/iio/industrialio-core.c:262:32: error: 'ev_int' undeclared (first use in this function) Also convert the rest of the function to use the new variable. Signed-off-by: Andy Whitcroft <apw@canonical.com> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-11-21iio: fix a leak due to improper use of anon_inode_getfd()Al Viro
it can fail and in that case ->release() will *not* be called... Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
2011-10-17staging:iio: fix removal path to allow correct freeing.Jonathan Cameron
Fix a dumb lack of consideration of the effect of combining the iio_device_unregister and iio_free_device calls into one. There is no valid place to free some of the sysfs array elements. Signed-off-by: Jonathan Cameron <jic23@cam.ac.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-10-11staging:iio:core:naming: dev_info to indio_dev for consistencyJonathan Cameron
We had a random missmatch of these two. Lets pick the most common and get rid of the other. This patch covers the core. Others will clean up the drivers. Signed-off-by: Jonathan Cameron <jic23@cam.ac.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-10-05staging:iio: rename gyro channels to anglvelJonathan Cameron
Ensure naming reflects what is measured, not how it is done. Resolvers can measure the same thing for starters. IIO_GYRO->IIO_ANGL_VEL to ensure consistent naming. 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-26staging:iio: Prevent reading from buffer chrdev when device has no buffer.Jonathan Cameron
Silly bug introduced during the chrdev merge series. 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: 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: move id and device name setting to iio_device_allocate.Jonathan Cameron
The recent reorganization of the sysfs attribute registration had the side effect of moving iio_device_register after registration of triggers etc. The side effect of this is that the id hadn't been allocated by the time of trigger registration. Thus all triggers based on device got the name <dev_name>-dev0 instead of <dev_name>-devN where N is the iio device id. This should also fix the lack of device name for some error messages that we have been seeing (and I'd been meaning to track down) as that has now moved earlier as well. Reported-by: Manuel Stahl <manuel.stahl@iis.fraunhofer.de> Signed-off-by: Jonathan Cameron <jic23@cam.ac.uk> Tested-by: Manuel Stahl <manuel.stahl@iis.fraunhofer.de> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-09-06staging:iio: Differential channel handling - use explicit flag rather than ↵Jonathan Cameron
types. Straight forward change in the core, but required some drivers to not use the IIO_CHAN macro as that doesn't allow setting this bit (and is going away anyway). Hence the churn. Tested on max1363 with a couple of supported parts. V2: differential bit in code got 7 bits and direction 1. Reversed that. Issue spotted by Michael - thanks! 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:add adaptive event types and missing extract_type macro.Jonathan Cameron
I'm not entirely sure this is the right way to go. Suggestions of other options welcome! Signed-off-by: Jonathan Cameron <jic23@cam.ac.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-09-06staging:iio: Add capacitance type and average_raw chan info.Jonathan Cameron
These are both needed for CAPADCs 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:naming in the EV_BIT macro fix.Jonathan Cameron
Should always have been IIO_EV_DIR_MAX as that's what it actually controls. Also reduced the number to 4 as not yet seen a case needing more and this is not userspace visible anyway. Signed-off-by: Jonathan Cameron <jic23@cam.ac.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-09-06staging:iio:attrs - make address a u64 to allow event codes to be used.Jonathan Cameron
Makes unusual event related attributes look a lot more like the core ones. V2: Make sure the utils that set these up can handle the codes. V3: rebase Reported-by: Michael Hennerich <michael.hennerich@analog.com> Signed-off-by: Jonathan Cameron <jic23@cam.ac.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-09-06staging:iio: rework of attribute registration.Jonathan Cameron
This set also includes quite a number of bug fixes of particularly remove functions. Necessary due to issue pointed out in Bart Van Assche's patch: docs/driver-model: Document device.groups V2: Rebase due to patch reordering. V3: Pull various error fixes and cleanups out into their own patches. 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:events - new 64 bit code structure and push out drivers.Jonathan Cameron
This costs us nothing in event storage (as we are carrying a 64 bit timestamp in the structure) and gives us lots more room to play with. Also allows for more channels which some parts need. V2: Cleanup some loose ends (such as the switch with only one option now). Signed-off-by: Jonathan Cameron <jic23@cam.ac.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-09-06staging:iio: ABI rework - add in_ or out_ prefix to channnelsJonathan Cameron
Also involves changing current inX outX to in_voltageX and out_voltageX V2: squash users of the IIO_CHAN_OUT macro and get rid of it. There are very few of these, so it is easier to fix them. 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: push "sysfs.h" and linux/irq.h out of iio.hJonathan Cameron
These are no longer needed. Requires a few driver updates for places "sysfs.h" should have been present but wasn't. Signed-off-by: Jonathan Cameron <jic23@cam.ac.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-09-06staging:iio:trivial add a string array for IIO_RAW and IIO_PROCESSED.Jonathan Cameron
Introduce IIO_RAW and IIO_PROCESSED and an array for their strings. Also move one function to just above where it is called. Signed-off-by: Jonathan Cameron <jic23@cam.ac.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-09-06staging:iio: remove defunct iio_put and iio_get.Jonathan Cameron
All iio dependent modules statically depend on industrialio so these aren't needed. Not sure why they originally existed, but they aren't now. Signed-off-by: Jonathan Cameron <jic23@cam.ac.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-09-06staging:iio: use ida_simple_get and ida_simple_remove + merge idsJonathan Cameron
Use new simple ida allocation functions to remove some boilerplate code. Also, now we only have one chdev per device we don't need to maintain a separate ida for minor numbers. Just use the devices id. Signed-off-by: Jonathan Cameron <jic23@cam.ac.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-09-06staging:iio: remove broken support for multiple event interfaces.Jonathan Cameron
We don't have a use case for these. Two drivers appeared to use them but both report all events on the first. V2: Remove now irrelevant comment. V3: Include fixup for adc/ad7280a.c 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: remove now defunct header definitions and add some staticsJonathan Cameron
Now we have combined all chrdevs into one, some bits and bobs are only needed in industrialio-core.c and don't need to be in the core header. Also remove some unused defines. Signed-off-by: Jonathan Cameron <jic23@cam.ac.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>