Commit Graph

448 Commits

Author SHA1 Message Date
Lars-Peter Clausen
6bf9d87756 iio:bma180: Use iio_push_buffers_with_timestamp()
Makes the code shorter and a bit less ugly.

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-09-21 19:23:50 +01:00
Peter Meerwald
183f41734c iio: Pass scan mask as unsigned long
Signed-off-by: Peter Meerwald <pmeerw@pmeerw.net>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2013-09-21 19:23:48 +01:00
Peter Meerwald
4caf279a28 iio: Fix tcs3472 dev-to-indio_dev conversion in suspend/resume
dev_to_iio_dev() is a false friend

Signed-off-by: Peter Meerwald <pmeerw@pmeerw.net>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2013-09-21 19:23:47 +01:00
Zubair Lutfullah
ca9a563805 iio: ti_am335x_adc: Add continuous sampling support
Previously the driver had only one-shot reading functionality.
This patch adds continuous sampling support to the driver.

Continuous sampling starts when buffer is enabled.
HW IRQ wakes worker thread that pushes samples to userspace.
Sampling stops when buffer is disabled by userspace.

Patil Rachna (TI) laid the ground work for ADC HW register access.
Russ Dill (TI) fixed bugs in the driver relevant to FIFOs and IRQs.

I fixed channel scanning so multiple ADC channels can be read
simultaneously and pushed to userspace.
Restructured the driver to fit IIO ABI.
And added INDIO_BUFFER_HARDWARE mode.

Signed-off-by: Zubair Lutfullah <zubair.lutfullah@gmail.com>
Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Russ Dill <Russ.Dill@ti.com>
Acked-by: Lee Jones <lee.jones@linaro.org>
Acked-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2013-09-21 19:23:47 +01:00
Zubair Lutfullah
0f6fc7d56f iio: ti_am335x_adc: optimize memory usage
12 bit ADC data is stored in 32 bits of storage.
Change from u32 to u16 to reduce wasted memory.

Signed-off-by: Zubair Lutfullah <zubair.lutfullah@gmail.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2013-09-21 11:47:53 +01:00
Thomas Meyer
4287723616 iio: at91_adc: Cocci spatch "noderef"
sizeof when applied to a pointer typed expression gives the size of the
pointer.
Found by coccinelle spatch "misc/noderef.cocci"

Signed-off-by: Thomas Meyer <thomas@m3y3r.de>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2013-09-20 19:41:41 +01:00
Peter Meerwald
2bdb3afcec iio: Make available scan_masks const in ad7266
Signed-off-by: Peter Meerwald <pmeerw@pmeerw.net>
Acked-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2013-09-18 22:56:43 +01:00
Peter Meerwald
9572588c91 iio: Minor cleanups of industrialio-buffer
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-18 21:44:13 +01:00
Lars-Peter Clausen
7a1aeba7ed iio:max1361: Use default triggered buffer setup ops
The max1361 driver uses the same callbacks as the triggered buffer default
buffer setup ops, so just remove the max1361 specific ops and let it use the
default ops.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2013-09-16 22:37:37 +01:00
Lars-Peter Clausen
8c60c7e75d iio: Remove unnecessary casts for iio_push_to_buffers()
Now that iio_push_to_buffers() takes a void pointer for the data parameter we
can remove those casts to u8*.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2013-09-15 19:05:07 +01:00
Lars-Peter Clausen
5d65d92045 iio: iio_push_to_buffers(): Change type of 'data' to const void *
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-15 19:02:07 +01:00
Lars-Peter Clausen
c7a22c3680 iio:buffer_cb: Constify iio_cb_access
The iio_cb_access struct is never modified so we can mark it as const.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2013-09-15 18:58:26 +01:00
Peter Meerwald
6a2f39b78b iio: Fix tcs3472 buffer size
and drop obsolete #define

Signed-off-by: Peter Meerwald <pmeerw@pmeerw.net>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2013-09-15 17:53:56 +01:00
Jonathan Cameron
da1690e6ca iio:temperature:tmp006 put sampling_frequency in info_mask_shared_by_all
Doing this makes it possible to access this control from within the kernel.

Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Acked-by: Peter Meerwald <pmeerw@pmeerw.net>
Reviewed-by: Lars-Peter Clausen <lars@metafoo.de>
2013-09-15 17:47:38 +01:00
Jonathan Cameron
c006ec8384 iio: add info_mask_[shared_by_dir/shared_by_all]
These two additional info_mask bitmaps should allow all 'standard'
numeric attributes to be handled using the read_raw and write_raw
callbacks.  Whilst this should reduce code, the more important element
is that this makes these values easily accessible to in kernel users
of IIO devices.

Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Reviewed-by: Lars-Peter Clausen <lars@metafoo.de>
2013-09-15 17:45:49 +01:00
Jonathan Cameron
3704432fb1 iio: refactor info mask and ext_info attribute creation.
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-15 17:43:20 +01:00
Lars-Peter Clausen
623c334c1a iio:kfifo_buf: Use wake_up_interruptible_poll()
Use wake_up_interruptible_poll() instead of wake_up_interruptible() to only wake
up those threads that listen for input poll notifications.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2013-09-15 17:39:04 +01:00
Lars-Peter Clausen
705ee2c98a iio:buffer: Simplify iio_buffer_is_active()
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-09-15 17:35:31 +01:00
Yann Droneaud
a646fbf0fd iio: use anon_inode_getfd() with O_CLOEXEC flag
IIO uses anon_inode_get() to allocate file descriptors as part
of its ioctls. But those ioctls are lacking a flag argument
allowing userspace to choose options for the newly opened file
descriptor.

In such case it's advised to use O_CLOEXEC by default so that
userspace is allowed to choose, without race, if the file descriptor
is going to be inherited across exec().

KVM usage of anon_inode_getfd() was fixed in a previous patchset [1],
so IIO is the only subsystem using anon_inode_getfd() with a fixed set
of flags not including O_CLOEXEC.

This patch set O_CLOEXEC flag on the event file descriptor created
with anon_inode_getfd() to not leak file descriptors across exec().

Links:

- Secure File Descriptor Handling (Ulrich Drepper, 2008)
  http://udrepper.livejournal.com/20407.html

- Excuse me son, but your code is leaking !!! (Dan Walsh, March 2012)
  http://danwalsh.livejournal.com/53603.html

- [1] kvm: use anon_inode_getfd() with O_CLOEXEC flag
  http://lkml.kernel.org/r/cover.1377372576.git.ydroneaud@opteya.com

Signed-off-by: Yann Droneaud <ydroneaud@opteya.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2013-09-15 17:27:15 +01:00
Jacek Anaszewski
bf29fbeaa1 iio: gp2ap020a00f: Add a driver for the device
Add a new driver for the ambient light/proximity sensor
device. The driver exposes three channels: light_clear
light_ir and proximity. It also supports triggered buffer,
high and low ambient light threshold event and proximity
detection events.

Signed-off-by: Jacek Anaszewski <j.anaszewski@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2013-09-15 11:07:49 +01:00
Peter Meerwald
eb869ade30 iio: Add tcs3472 color light sensor driver
chip has four 16-bit channels for red, green, blue, clear color
intensity; driver supports the TCS3x7x family of devices and was
tested with a TCS34725 chip; further information here:
http://www.ams.com/eng/Products/Light-Sensors/Color-Sensor/TCS34725

v2 (thanks to Jonathan Cameron):
* drop dynamic buffer allocation, buffer is in tcs3472_data
* limit sysfs output to PAGE_SIZE
* check val2 == 0 when writing CALIBSCALE

Signed-off-by: Peter Meerwald <pmeerw@pmeerw.net>
Cc: Jon Brenner <jon.brenner@ams.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2013-09-14 21:44:29 +01:00
Lee Jones
ea01f2c18a iio: pressure-core: st: Allow for number of channels to vary
At the moment the number of channels specified is dictated by the first
sensor supported by the driver. As we add support for more sensors this
is likely to vary. Instead of using the ARRAY_SIZE() of the LPS331AP's
channel specifier we'll use a new adaptable 'struct st_sensors' element
instead.

Signed-off-by: Lee Jones <lee.jones@linaro.org>
Acked-by: Denis Ciocca <denis.ciocca@st.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2013-09-14 21:17:17 +01:00
Lee Jones
2f5effcbd0 iio: pressure-core: st: Expand and rename LPS331AP's channel descriptor
Due to the MACRO used, the task of reading, understanding and maintaining
the LPS331AP's channel descriptor is substantially difficult. This patch
is based on the view that it's better to have easy to read, maintainable
code than to save a few lines here and there. For that reason we're
expanding the array so initialisation is completed in full.

Signed-off-by: Lee Jones <lee.jones@linaro.org>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2013-09-14 21:17:17 +01:00
Lee Jones
302fbd50ef iio: pressure-core: st: Describe LPS331AP defines by name
They're currently named *_1_*, for 'Sensor 1', but the code will be much
more readable if we use the naming convention *_LPS331AP_* instead.

Signed-off-by: Lee Jones <lee.jones@linaro.org>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2013-09-14 21:17:16 +01:00
Lee Jones
5bb8e72d5d iio: sensors-core: st: Clean-up error handling in st_sensors_read_info_raw()
Saving a few lines of code.

Signed-off-by: Lee Jones <lee.jones@linaro.org>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2013-09-14 21:17:16 +01:00
Lee Jones
362f2f8647 iio: sensors-core: st: Allow full-scale to be an optional feature
Some chips either don't support it or fail to provide adequate documentation,
so sometimes it's impossible to enable the feature even if it is supported.

Signed-off-by: Lee Jones <lee.jones@linaro.org>
Acked-by: Denis Ciocca <denis.ciocca@st.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2013-09-14 21:17:15 +01:00
Peter Meerwald
aab9ba7eb2 iio: Add tsl4531 ambient light sensor driver
driver for the TSL4531 family of 16-bit I2C ambient light
sensors; information is here:
http://www.ams.com/eng/Products/Light-Sensors/Ambient-Light-Sensor-ALS/TSL45315

the chip offers simple lux output

v3 (thanks Lars-Peter Clausen):
* add mutex to when updating integration time
* fix chip ID checking
* code cleanups
v2:
* rename to tsl4351
* use INT_TIME

Signed-off-by: Peter Meerwald <pmeerw@pmeerw.net>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2013-09-14 21:17:15 +01:00
Peter Meerwald
caeac37422 iio: adjd_s311: Use INT_TIME channel info
Signed-off-by: Peter Meerwald <pmeerw@pmeerw.net>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2013-09-14 21:17:01 +01:00
Peter Meerwald
899d90bdf4 iio: Add INT_TIME (integration time) channel info attribute
Integration time is in seconds; it controls the measurement
time and influences the gain of a sensor.

There are two typical ways that scaling is implemented in a device:
1) input amplifier,
2) reference to the ADC is changed.
These both result in the accuracy of the ADC varying (by applying its
sampling over a more relevant range).

Integration time is a way of dealing with noise inherent in the analog
sensor itself.  In the case of a light sensor, a mixture of photon noise
and device specific noise.  Photon noise is dealt with by either improving
the efficiency of the sensor, (more photons actually captured) which is not
easily varied dynamically, or by integrating the measurement over a longer
time period.  Note that this can also be thought of as an averaging of a
number of individual samples and is infact sometimes implemented this way.
Altering integration time implies that the duration of a measurement changes,
a fact the device's user may be interested in.

Hence it makes sense to distinguish between integration time and simple
scale. In some devices both types of control are present and whilst they
will have similar effects on the amplitude of the reading, their effect
on the noise of the measurements will differ considerably.

Used by adjd_s311, tsl4531, tcs3472
The following drivers have similar controls (and could be adapted):
* tsl2563 (integration time is controlled via CALIBSCALE among other things)
* tsl2583 (has integration_time device_attr, but driver doesn't use channels yet)
* tsl2x7x (has integration_time attr)

Signed-off-by: Peter Meerwald <pmeerw@pmeerw.net>
Cc: Jon Brenner <jon.brenner@ams.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2013-09-14 21:16:44 +01:00
Sachin Kamat
540e4dbead iio: dac: ad5686: Remove redundant break
'break' after return is redundant. Remove it.

Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2013-09-14 11:37:01 +01:00
Sachin Kamat
52c77c3dcb iio: gyro: adxrs450: Remove redundant break
'break' after return is redundant. Remove it.

Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2013-09-14 11:37:01 +01:00
Sachin Kamat
356e9fa4e5 iio: gyro: adis16260: Remove redundant break
'break' after return is redundant. Remove it.

Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2013-09-14 11:37:00 +01:00
Sachin Kamat
3c533efca0 iio: gyro: adis16130: Remove redundant break
'break' after return is redundant. Remove it.

Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2013-09-14 11:36:59 +01:00
Angelo Compagnucci
07914c84ba iio: adc: Add driver for Microchip MCP3422/3/4 high resolution ADC
Sysfs access to all channels.

Signed-off-by: Angelo Compagnucci <angelo.compagnucci@gmail.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2013-09-07 22:17:44 +01:00
Josh Wu
9120c0bea9 iio: at91: Use different prescal, startup mask in MR for different IP
For at91 boards, there are different IPs for adc. Different IPs has different
STARTUP & PRESCAL mask in ADC_MR.

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-08-29 21:49:28 +01:00
Josh Wu
e1811f97ba iio: at91: introduce the multiple compatible string for different IPs.
As use the multiple compatible string, we can remove hardware register in dt.

CC: devicetree@vger.kernel.org
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-08-29 21:45:04 +01:00
Wei Yongjun
2d2da9fc71 iio: adc: twl6030-gpadc: fix error return code in twl6030_gpadc_read_raw()
Fix to return -EINTR in the error handling case instead
of 0 (ret is assigned after goto, which has no effect),
as done elsewhere in this function.

Signed-off-by: Wei Yongjun <yongjun_wei@trendmicro.com.cn>
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2013-08-28 20:45:43 +01:00
Oleksandr Kravchenko
fdadbce0da iio: add Bosch BMA180 acceleration sensor driver
This patch adds IIO driver for Bosch BMA180 triaxial
acceleration sensor.
http://dlnmh9ip6v2uc.cloudfront.net/datasheets/
		Sensors/Accelerometers/BST-BMA180-DS000-07_2.pdf

Signed-off-by: Oleksandr Kravchenko <o.v.kravchenko@globallogic.com>
Acked-by: Stephen Warren <swarren@nvidia.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2013-08-28 20:12:22 +01:00
Sachin Kamat
cc566fd5e5 iio: dac: max517: Use devm_iio_device_alloc
Using devm_iio_device_alloc makes code simpler.

Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>
Cc: Roland Stigge <stigge@antcom.de>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2013-08-19 20:38:50 +01:00
Sachin Kamat
66e670aa08 iio: dac: ad7303: Use devm_* APIs
devm_* APIs are device managed and make code simpler.

Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2013-08-19 20:37:20 +01:00
Sachin Kamat
0d7c04d33f iio: dac: ad5791: Use devm_* APIs
devm_* APIs are device managed and make code simpler.

Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2013-08-19 20:35:35 +01:00
Sachin Kamat
7ff0de3faa iio: dac: ad5764: Use devm_* APIs
devm_* APIs are device managed and make code simpler.

Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2013-08-19 20:35:32 +01:00
Sachin Kamat
fd047294e2 iio: dac: ad5755: Use devm_iio_device_alloc
Using devm_iio_device_alloc makes code simpler.

Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2013-08-19 20:32:53 +01:00
Sachin Kamat
edf3fd4141 iio: dac: ad5686: Use devm_* APIs
devm_* APIs are device managed and make code simpler.

Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2013-08-19 20:31:04 +01:00
Sachin Kamat
75238230cc iio: dac: ad5624r_spi: Use devm_* APIs
devm_* APIs are device managed and make code simpler.

Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2013-08-19 20:29:34 +01:00
Sachin Kamat
8571ebf7fc iio: dac: ad5504: Use devm_* APIs
devm_* APIs are device managed and make code simpler.

Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2013-08-19 20:27:24 +01:00
Sachin Kamat
cd5e578541 iio: dac: ad5449: Use devm_* APIs
devm_* APIs are device managed and make code simpler.

Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2013-08-19 20:26:25 +01:00
Sachin Kamat
ba7272954e iio: dac: ad5446: Use devm_* APIs
devm_* APIs are device managed and make code simpler.

Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2013-08-19 20:25:43 +01:00
Sachin Kamat
62a308a62d iio: dac: ad5421: Use devm_* APIs
devm_* APIs are device managed and make code simpler.

Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2013-08-19 20:24:52 +01:00
Sachin Kamat
c815ad372b iio: dac: ad5380: Use devm_* APIs
devm_* APIs are device managed and make code simpler.

Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2013-08-19 20:23:53 +01:00