aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/iio (follow)
AgeCommit message (Collapse)AuthorFilesLines
2013-10-16iio: Update buffer's bytes per datum after updating the scan maskLars-Peter Clausen1-1/+17
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 Clausen1-0/+3
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-15iio:kfifo: Set update_needed to false after allocating a new bufferLars-Peter Clausen1-0/+1
update_needed is used to decide whether the kfifo buffer needs to be re-allocated. It is set to true whenever the size of the buffer is changed. It is never set to false though, causing the buffer to always be re-allocated. Setting update_needed to false after the new buffer has been allocated fixes the problem. Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2013-10-15iio:kfifo: Empty buffer on updateLars-Peter Clausen1-5/+7
The kfifo's request_update callback will free the current buffer and allocate a new one if the size has changed. This will remove any samples that might still be left in the buffer. If the size has not changed the buffer content is left untouched though. This is a bit inconsistent and might cause an application to see data from a previous capture. This patch inserts a call to kfifo_reset_out() when the size did not change. This makes sure that any pending samples are removed from the buffer. Note, due to a different bug the buffer is currently always re-allocated, even if the size did not change. So this patch will not change the behavior. In the next patch the bug will be fixed and this patch makes sure that the current behavior is kept. Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2013-10-15iio:kfifo: Protect against concurrent access from userspaceLars-Peter Clausen1-5/+15
It is possible for userspace to concurrently access the buffer from multiple threads or processes. To avoid corruption of the internal state of the buffer we need to add proper locking. It is possible for multiple processes to try to read from the buffer concurrently and it is also possible that one process causes a buffer re-allocation while a different process still access the buffer. Both can be fixed by protecting the calls to kfifo_to_user() and kfifo_alloc() by the same mutex. In iio_read_first_n_kfifo() we also use kfifo_recsize() instead of the buffers bytes_per_datum to avoid a race that can happen if bytes_per_datum has been changed, but the buffer has not been reallocated yet. Note that all access to the buffer from within the kernel is already properly synchronized, so there is no need for extra locking in iio_store_to_kfifo(). Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2013-10-15iio:kfifo: Fix memory leakLars-Peter Clausen1-1/+4
We need to free the kfifo when we release the buffer, otherwise the fifos memory will be leaked. Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2013-10-12iio: frequency: adf4350: add missing clk_disable_unprepare() on error in adf4350_probe()Wei Yongjun1-2/+4
Add the missing clk_disable_unprepare() before return from adf4350_probe() in the error handling case. Signed-off-by: Wei Yongjun <yongjun_wei@trendmicro.com.cn> Reviewed-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 Clausen1-0/+14
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 hysteresis event info attributeLars-Peter Clausen1-0/+1
For some devices it is possible to configure a hysteresis for threshold (or similar) events. This patch adds a new hysteresis event info type which allows for easy creation and read/write handling of the sysfs attribute. Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2013-10-12iio:apds9300: Use new event config interfaceLars-Peter Clausen1-17/+36
Switch the apds9300 driver to the new IIO event config interface as the old one is going to be removed. Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Cc: Oleksandr Kravchenko <o.v.kravchenko@globallogic.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2013-10-12iio:tsl2563: Switch to new event config interfaceLars-Peter Clausen1-19/+34
Switch the tsl2563 driver to the new IIO event config interface as the old one is going to be removed. Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2013-10-12iio:gp2ap020a00f: Switch to new event config interfaceLars-Peter Clausen1-34/+71
Switch the gp2ap020a00f driver to the new IIO event config interface as the old one is going to be removed. Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Cc: Jacek Anaszewski <j.anaszewski@samsung.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2013-10-12iio:ad5421: Switch to new event config interfaceLars-Peter Clausen1-18/+44
Switch the ad5421 driver to the new IIO event config interface as the old one is going to be removed. Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2013-10-12iio:max1363: Switch to new event config interfaceLars-Peter Clausen1-90/+110
Switch the max1363 driver to the new IIO event config interface as the old one is going to be removed. Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2013-10-12iio: Extend the event config interfaceLars-Peter Clausen1-22/+171
The event configuration interface of the IIO framework has not been getting the same attention as other parts. As a result it has not seen the same improvements as e.g. the channel interface has seen with the introduction of the channel spec struct. Currently all the event config callbacks take a u64 (the so called event code) to pass all the different information about for which event the callback is invoked. The callback function then has to extract the information it is interested in using some macros with rather long names. Most information encoded in the event code comes straight from the iio_chan_spec struct the event was registered for. Since we always have a handle to the channel spec when we call the event callbacks the first step is to add the channel spec as a parameter to the event callbacks. The two remaining things encoded in the event code are the type and direction of the event. Instead of passing them in one parameter, add one parameter for each of them and remove the eventcode from the event callbacks. The patch also adds a new iio_event_info parameter to the {read,write}_event_value callbacks. This makes it possible, similar to the iio_chan_info_enum for channels, to specify additional properties other than just the value for an event. Furthermore the new interface will allow to register shared events. This is e.g. useful if a device allows configuring a threshold event, but the threshold setting is the same for all channels. To implement this the patch adds a new iio_event_spec struct which is similar to the iio_chan_spec struct. It as two field to specify the type and the direction of the event. Furthermore it has a mask field for each one of the different iio_shared_by types. These mask fields holds which kind of attributes should be registered for the event. Creation of the attributes follows the same rules as the for the channel attributes. E.g. for the separate_mask there will be a attribute for each channel with this event, for the shared_by_type there will only be one attribute per channel type. The iio_chan_spec struct gets two new fields, 'event_spec' and 'num_event_specs', which is used to specify which the events for this channel. These two fields are going to replace the channel's event_mask field. For now both the old and the new event config interface coexist, but over the few patches all drivers will be converted from the old to the new interface. Once that is done all code for supporting the old interface will be removed. Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2013-10-12iio: Factor IIO value formating into its own functionLars-Peter Clausen2-12/+28
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 Clausen4-48/+23
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 Clausen1-3/+26
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 Clausen4-1/+43
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 Clausen3-0/+15
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 Clausen5-14/+91
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-09iio: at91: move the num_channels from DT to driver itselfJosh Wu1-7/+5
CC: devicetree@vger.kernel.org Signed-off-by: Josh Wu <josh.wu@atmel.com> Acked-by: Ludovic Desroches <ludovic.desroches@atmel.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2013-10-09iio: at91: ADC start-up time calculation changed since at91sam9x5Josh Wu1-7/+46
Since in at91sam9x5, sama5d3x chip. the start up time calucation is changed. This patch can choose different start up time calculation formula for different chips. Signed-off-by: Josh Wu <josh.wu@atmel.com> Acked-by: Maxime Ripard <maxime.ripard@free-electrons.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2013-10-06Merge 3.12-rc4 into staging-nextGreg Kroah-Hartman3-13/+11
We want the staging fixes in this branch as well. Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-10-05iio:adis16130: Use spi_sync_transfer()Lars-Peter Clausen1-5/+1
Use the spi_sync_transfer() helper function instead of open-coding it. Makes the code a bit shorter. Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2013-10-05iio:adxrs450: Use spi_sync_transfer()Lars-Peter Clausen1-10/+2
Use the spi_sync_transfer() helper function instead of open-coding it. Makes the code a bit shorter. Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2013-10-05iio:adis16080: Use spi_sync_transfer()Lars-Peter Clausen1-6/+1
Use the spi_sync_transfer() helper function instead of open-coding it. Makes the code a bit shorter. Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2013-10-05iio:ad5449: Use spi_sync_transfer()Lars-Peter Clausen1-6/+1
Use the spi_sync_transfer() helper function instead of open-coding it. Makes the code a bit shorter. Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2013-10-01iio:max1363: Report scale as fractional valueLars-Peter Clausen1-5/+3
Move the complexity of calculating the fixed point scale to the core. Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2013-10-01iio:at91: Report scale as fractional valueLars-Peter Clausen1-3/+3
Move the complexity of calculating the fixed point scale to the core. Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Cc: Josh Wu <josh.wu@atmel.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2013-10-01iio:ad7791: Report scale as fractional valueLars-Peter Clausen1-8/+10
Move the complexity of calculating the fixed point scale to the core. Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2013-10-01iio:ad7476: Report scale as fractional valueLars-Peter Clausen1-4/+3
Move the complexity of calculating the fixed point scale to the core. Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2013-10-01iio:ad7266: Report scale as fractional valueLars-Peter Clausen1-11/+10
Move the complexity of calculating the fixed point scale to the core. Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2013-10-01iio:mcp4725: Report scale as fractional valueLars-Peter Clausen1-5/+3
Move the complexity of calculating the fixed point scale to the core. Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Cc: Peter Meerwald <pmeerw@pmeerw.net> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2013-10-01iio:max517: Report scale as fractional valueLars-Peter Clausen1-5/+3
Move the complexity of calculating the fixed point scale to the core. Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2013-10-01iio:ad5791: Report scale as fractional valueLars-Peter Clausen1-3/+3
Move the complexity of calculating the fixed point scale to the core. Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2013-10-01iio:ad5764: Report scale as fractional valueLars-Peter Clausen1-6/+4
Move the complexity of calculating the fixed point scale to the core. Also fix a off by one error in the comment describing the transfer function. Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2013-10-01iio:ad5755: Report scale as fractional valueLars-Peter Clausen1-12/+5
Move the complexity of calculating the fixed point scale to the core. Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2013-10-01iio:ad5686: Report scale as fractional valueLars-Peter Clausen1-7/+3
Move the complexity of calculating the fixed point scale to the core. Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2013-10-01iio:ad5624r: Report scale as fractional valueLars-Peter Clausen1-6/+3
Move the complexity of calculating the fixed point scale to the core. Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2013-10-01iio:ad5504: Report scale as fractional valueLars-Peter Clausen1-6/+3
Move the complexity of calculating the fixed point scale to the core. Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2013-10-01iio:ad5446: Report scale as fractional valueLars-Peter Clausen1-6/+3
Move the complexity of calculating the fixed point scale to the core. Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2013-10-01iio:ad5421: Report scale as fractional valueLars-Peter Clausen1-11/+5
Move the complexity of calculating the fixed point scale to the core. Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2013-10-01iio:ad5380: Report scale as fractional valueLars-Peter Clausen1-21/+19
Move the complexity of calculating the fixed point scale to the core. Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2013-10-01iio:ad5360: Report scale as fractional valueLars-Peter Clausen1-6/+5
Move the complexity of calculating the fixed point scale to the core. Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2013-10-01iio:ad5064: Report scale as fractional valueLars-Peter Clausen1-4/+3
Move the complexity of calculating the fixed point scale to the core. Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2013-10-01IIO: call sensor hub open close functionSrinivas Pandruvada1-0/+6
Call hid_sensor_hub_device_open when user space opens device and call hid_sensor_hub_device_close when device is closed. This helps in saving power. Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2013-09-30iio:magnetometer: Bugfix magnetometer default output registersDenis CIOCCA1-9/+9
Signed-off-by: Denis Ciocca <denis.ciocca@st.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2013-09-30iio: Remove debugfs entries in iio_device_unregister()Lars-Peter Clausen1-1/+1
Remove the the debugfs entries in iio_device_unregister(). Otherwise the debugfs entries might still be accessible even though the device used in the debugfs callback has already been freed. Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2013-09-29Merge tag 'iio-for-3.13b' of git://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio into staging-nextGreg Kroah-Hartman5-8/+54
Jonathan writes: Second set of new functionality for IIO in the 3.13 cycle - with bug fixes for first set. This is a small, mainly to get a couple of compile bug related fixes into the tree ASAP. New device support: 1) Add ad5446 dac support to the ad5641 driver. New functionality and cleanups: 1) Optional power supply regulators for the st pressure sensors drivers using the new optional regulator interface. 2) Bit of tidying up of naming in the sysfs trigger. Bug fixes from the previous series: 1) Missing select IIO_BUFFER for ti_am335x_adc 2) Drop a bonus bracket in iio-trig-bfin-timmer