[go: nahoru, domu]

History log of /drivers/iio/industrialio-core.c
Revision Date Author Comments
11b8ddab817eb8070a542d33caeb93cccfa4e383 17-Jul-2014 Reyad Attiyat <reyad.attiyat@gmail.com> iio: types: Added support for rotation from north usage attributes

Added the rotation from north usage attributes to the iio modifier enum and to the iio modifier names array.

Signed-off-by: Reyad Attiyat <reyad.attiyat@gmail.com>
Acked-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
638b43b347216bab1a989b036a92eb7d9d9ee421 05-Feb-2014 Peter Meerwald <pmeerw@pmeerw.net> iio: Add TEMP_AMBIENT and TEMP_OBJECT channel modifiers

useful for contactless temperature sensors to distinguish
between the ambient temperature and the temperature of the object

Signed-off-by: Peter Meerwald <pmeerw@pmeerw.net>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
5082f405b74ad1b69aa9595555ce55b75b59b2ec 29-Apr-2014 Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com> IIO: core: Add quaternion modifier

Added quaternion in the list of supported modifiers.

Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
9fbfb4b37ed23f71aa9484484266381c6c6964cb 29-Apr-2014 Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com> IIO: core: Introduce read_raw_multi

This callback is introduced to overcome some limitations of existing
read_raw callback. The functionality of both existing read_raw and
read_raw_multi is similar, both are used to request values from the
device. The current read_raw callback allows only two return values.
The new read_raw_multi allows returning multiple values. Instead of
passing just address of val and val2, it passes length and pointer
to values. Depending on the type and length of passed buffer, iio
client drivers can return multiple values.

Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
ef4b4856593fc3d9d169bededdaf7acf62f83a52 03-Jan-2014 Jonathan Cameron <jic23@kernel.org> iio:core: Fix bug in length of event info_mask and catch unhandled bits set in masks.

The unhandled bits case was highlighted by smatch:
CHECK drivers/iio/industrialio-core.c
drivers/iio/industrialio-core.c:719 iio_device_add_info_mask_type() error: buffer overflow 'iio_chan_info_postfix' 17 <= 31
CC [M] drivers/iio/industrialio-core.o
CHECK drivers/iio/industrialio-event.c
drivers/iio/industrialio-event.c:327 iio_device_add_event() error: buffer overflow 'iio_ev_info_text' 3 <= 3

The incorrect limit for the for_each_set_bit loop was noticed whilst fixing
this other case. Note that as we only have 3 possible entries a the moment
and the value was set to 4, the bug would not have any effect currently.
It will bite fairly soon though, so best fix it now.

Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Cc: Lars-Peter Clausen <lars@metafoo.de>
Cc: Dan Carpenter <dan.carpenter@oracle.com>
598db5816664472e1649ef94b0ba4c5cc1b9f3b4 13-Mar-2014 Kees Cook <keescook@chromium.org> iio: force snprintf for PAGE_SIZE bufs

This is a tiny preventative measure to make sure we can't write beyond
PAGE_SIZE on the buffers being used in sysfs for iio. There is currently
no way for this to happen, but the change makes this code more robust
for the future.

Signed-off-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
7bbcf7e13695c70f13b2cae59392016c0fa2e7a6 14-Feb-2014 Lars-Peter Clausen <lars@metafoo.de> iio: Avoid unnecessary kasprintf

name_format already contains the final name and no format characters. So the
code basically reads:

dev_attr->attr.name = kstrdup(GFP_KERNEL, name_format);
if (dev_attr->attr.name == NULL)
...
kfree(name_format);

Which means we can save one alloc and free pair per attribute name if we
directly assign name_format to dev_attr->attr.name.

The patch also renames name_format to name to denote that this is indeed the
final name and has no format characters in it.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
77bfa8baa0c230eb3d8acccd7d341f406a32cdf4 14-Feb-2014 Lars-Peter Clausen <lars@metafoo.de> iio: Don't include extended name in shared attributes

The extended name is channel specific and should not be included in shared
attributes.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
92825ff97411f0121166485798cdaf2deb6b5952 16-Feb-2014 Hartmut Knaack <knaack.h@gmx.de> iio get rid of unneccessary error_ret

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>
ac216aa290c48a5e9d7b9f2473abb977a175683a 01-Dec-2013 Harald Geyer <harald@ccbib.org> iio: Add support for humidity sensors

There are already humidity sensors in the hwmon subsystem,
so we use their unit (milli percent) here as well.

Signed-off-by: Harald Geyer <harald@ccbib.org>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
a7e57dce02ceb8212f106191fdfbc0fcb61ce9e0 29-Oct-2013 Sachin Kamat <sachin.kamat@linaro.org> iio: core: Move kernel doc to the right location

Documentation related to function should be placed above
its implementation. Move it accordingly.

Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>
Cc: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
8caa07c0e565a15f49f290ca4c6a3adf968ddd38 29-Oct-2013 Sachin Kamat <sachin.kamat@linaro.org> iio: core: Implement devm_iio_device_{register,unregister}

Add device managed devm_iio_device_{register,unregister}()
to automatically unregister IIO drivers thus leading to
simplified IIO driver code.

Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>
Cc: Lars-Peter Clausen <lars@metafoo.de>
Tested-by: Lars-Peter Clausen <lars@metafoo.de>
Reviewed-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
670c11033dc57c1cf5d9e0056e3c6734e6554d91 24-Oct-2013 Sachin Kamat <sachin.kamat@linaro.org> iio: core: Add misssing braces

Silences the following checkpatch warning:
WARNING: sizeof *iio_attr should be sizeof(*iio_attr)

Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
3176dd5d3b591b22abe28dc0f3aace089f10ebe7 24-Oct-2013 Sachin Kamat <sachin.kamat@linaro.org> iio: core: Use pr_err instead of printk

Use of pr_err is preferred to printk.

Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
3661f3f5e961f73d40d93495c0de6711dabe6f8d 07-Oct-2013 Lars-Peter Clausen <lars@metafoo.de> iio: Factor IIO value formating into its own function

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
84088ebd14aebf1b8499409a037094b9b88e2796 07-Oct-2013 Lars-Peter Clausen <lars@metafoo.de> iio: Add a helper to free a list of IIO device attributes

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>
d2f0a48f36aea38e0a5c4b439d5d9c96aecabad9 04-Oct-2013 Lars-Peter Clausen <lars@metafoo.de> iio: Wakeup poll and blocking reads when the device is unregistered

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>
f18e7a068a0a31250cdb251810f8f6224931c3f5 04-Oct-2013 Lars-Peter Clausen <lars@metafoo.de> iio: Return -ENODEV for file operations if the device has been unregistered

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>
9e69c935fad9fd5f0550c51e3bd251cd30033136 04-Oct-2013 Lars-Peter Clausen <lars@metafoo.de> iio: Add reference counting for buffers

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>
bc4c9612922524ce3eba64c5e7d6323f8e174ca1 21-Sep-2013 Lars-Peter Clausen <lars@metafoo.de> iio: Remove debugfs entries in iio_device_unregister()

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>
0d5b7dae897b61a2372916b1c93f6cee6b8049b1 18-Sep-2013 Lars-Peter Clausen <lars@metafoo.de> iio: Prevent race between IIO chardev opening and IIO device free

Set the IIO device as the parent for the character device

We need to make sure that the IIO device is not freed while the character device
exists, otherwise the freeing of the IIO device might race against the file open
callback. Do this by setting the character device's parent to the IIO device,
this will cause the character device to grab a reference to the IIO device and
only release it once the character device itself has been removed.

Also move the registration of the character device before the registration of
the IIO device to avoid the (rather theoretical case) that the IIO device is
already freed again before we can add the character device and grab a reference
to the IIO device.

We also need to move the call to cdev_del() from iio_dev_release() to
iio_device_unregister() (where it should have been in the first place anyway) to
avoid a reference cycle. As iio_dev_release() is only called once all reference
are dropped, but the character device holds a reference to the IIO device.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
cadc2125e140f7122bf1b59d42486cfc778c7286 18-Sep-2013 Lars-Peter Clausen <lars@metafoo.de> iio: fix: Keep a reference to the IIO device for open file descriptors

Make sure that the IIO device is not freed while we still have file descriptors
for it.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
a87c82e454f184a9473f8cdfd4d304205f585f65 18-Sep-2013 Lars-Peter Clausen <lars@metafoo.de> iio: Stop sampling when the device is removed

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>
c006ec838414d910bdd63ba8d919e602425e194e 08-Sep-2013 Jonathan Cameron <jic23@kernel.org> 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>
3704432fb1fd8ab2df114bad6df752381246b609 08-Sep-2013 Jonathan Cameron <jic23@kernel.org> 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>
899d90bdf4d4ef4c3ac0b33cd337c9b3e999ec2d 08-Sep-2013 Peter Meerwald <pmeerw@pmeerw.net> 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>
d9a0134e7aa048f3de4477d93598974ea8ecae7a 22-Jul-2013 Oleksandr Kravchenko <o.v.kravchenko@globallogic.com> iio: core: Avoid double minus in sysfs output

This patch fixes the issue with double minus in output when
reading channels from sysfs for IIO_VAL_INT_PLUS_MICRO and
IIO_VAL_INT_PLUS_NANO cases. Until this patch if val and val2
both are negatives output string contains "--" before
digits. It is result of "-%d..." in sprintf() format.

Signed-off-by: Oleksandr Kravchenko <o.v.kravchenko@globallogic.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
9dabaf5eddbafa21aded7c063cb38d2e8936c237 18-Jul-2013 Grygorii Strashko <grygorii.strashko@ti.com> iio: core: implement devm_iio_device_alloc/devm_iio_device_free

Add a resource managed devm_iio_device_alloc()/devm_iio_device_free()
to automatically clean up any allocations made by IIO drivers,
thus leading to simplified IIO drivers code.

In addition, this will allow IIO drivers to use other devm_*() API
(like devm_request_irq) and don't care about the race between
iio_device_free() and the release of resources by Device core
during driver removing.

Signed-off-by: Grygorii Strashko <grygorii.strashko@ti.com>
Signed-off-by: Oleksandr Kravchenko <o.v.kravchenko@globallogic.com>
Tested-by: Oleksandr Kravchenko <o.v.kravchenko@globallogic.com>
Reviewed-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
b9606e2aa97d3d831d1236c0e789a33a2f867a8a 27-Feb-2013 Jonathan Cameron <jic23@kernel.org> iio:core drop info_mask from struct iio_info

This has been replaced by the pair of masks info_mask_separate
and info_mask_shared_by_type. Other variants may follow.

Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Acked-by: Lars-Peter Clausen <lars@metafoo.de>
8655cc490e83f66476de8c1294411860325c3531 19-Feb-2013 Jonathan Cameron <jic23@kernel.org> iio: Add broken out info_mask fields for shared_by_type and separate

This simplifies the code, removes an extensive layer of 'helper' macros
and gives us twice as much room to play with in these masks before we
have any need to be clever.

Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Acked-by: Lars-Peter Clausen <lars@metafoo.de>
17d82b47a215ded05ee3fb8d93b7c1269dbe0083 07-Feb-2013 Guenter Roeck <linux@roeck-us.net> iio: Add OF support

Provide bindings and parse OF data during initialization.

Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Reviewed-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
6807d7211327dbdd8df3692f3d26ca711514ba71 20-Nov-2012 Lars-Peter Clausen <lars@metafoo.de> iio: Factor out fixed point number parsing into its own function

Factor out the code for parsing fixed point numbers into its own function and
make this function globally available. This allows us to reuse the code to parse
fixed point numbers in individual IIO drivers.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
c4f0c6936762ecd6b453275611a785dfdee0d417 20-Nov-2012 Lars-Peter Clausen <lars@metafoo.de> iio: Add pressure channel type

This patch adds support for a new IIO channel type for pressure measurements.
This can for example be used for barometric pressure sensors.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
84b36ce5f79c01f792c623f14e92ed86cdccb42f 30-Jun-2012 Jonathan Cameron <jic23@kernel.org> staging:iio: Add support for multiple buffers

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>
ef4f92c064697a66a2a61977dd690af40dc01ff0 22-Oct-2012 Lars-Peter Clausen <lars@metafoo.de> iio: Accept a leading '+' sign when parsing fixed point numbers

If we encounter a leading '+' sign just skip over it.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
02330acda7ef88865e62e2763df2cdd735607cb4 22-Oct-2012 Lars-Peter Clausen <lars@metafoo.de> iio: Reject trailing garbage when parsing fixed point numbers

When parsing a fixed point number IIO stops parsing the string once it has
reached the last requested decimal place. This means that the remainder of the
string is silently accepted regardless, of whether it is part of a valid number
or not. This patch modifies the code to scan the whole string and only accept
valid numbers. Since fract_mult is 0 after the last decimal place any digit that
may follows won't affect the result.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
8f1b7eb11422d28fbc7432f0dee2f97aead09417 22-Oct-2012 Lars-Peter Clausen <lars@metafoo.de> iio: Do not accept multiple '.' in fixed point numbers

Currently when parsing a fix-point number we silently skip any additional '.'
found in the string. E.g. '1.2.3.4' gets parsed as '1.234'. This patch
disallows this and returns an error if more than one '.' is encountered.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
103d9fb907058e4eb052f4f7302d1b07eb6a7792 16-Oct-2012 Lars-Peter Clausen <lars@metafoo.de> iio: Add a logarithmic fractional value type

For ADCs or DACs the denominator for fractional types often is a power of two.
In this case we can use a shift operation instead of the rather expensive 64 bit
division. This patch adds a new fractional type which expects the denominator to
be specified as the log2 of the actual denominator. E.g. for ADCs and DACs this
will usually be the number of significant bits.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
7985e7c1003bc5cdfa20755f8cfdada946ed8e18 14-Sep-2012 Lars-Peter Clausen <lars@metafoo.de> iio: Introduce a new fractional value type

Currently IIO uses a decimal fixed point representations for real type numbers.
This patch introduces a new representation for rational type numbers. The number
will be expressed by specifying a numerator and denominator. For converting a
raw value to a processed value multiply it by the numerator and divide it by the
denominator.

The reasoning for introducing this new type is that for a lot of devices the
scale can be represented easily by a fractional number, but it is not possible
to represent it as fixed point number without rounding. E.g. for a simple DAC
the scale is often the reference voltage divided by the number of possible
values (Usually 2**n_bits - 1). Each driver currently implements the conversion
of this fraction to a fixed point number on its own.

Also when it comes to the in-kernel interface this allows to directly use the
fractional factors to convert a raw value to a processed value. This should on
one hand require less instructions and on the other hand increase the
precision.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
7c9ab035acb4088dbbf1fec2f478a3a9e47ba15b 05-Sep-2012 srinivas pandruvada <srinivas.pandruvada@intel.com> iio: core: Add hysteresis in channel spec

Added hysteresis to the list of channel info enumeration, shared
/separate bit defines and to postfix channel info strings.

Signed-off-by: srinivas pandruvada <srinivas.pandruvada@intel.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
c8b95952e7ad2ff850153a12f090f810bf90f27c 02-Sep-2012 Jonathan Cameron <jic23@kernel.org> IIO: Update email address for Jonathan Cameron.

Signed-off-by: Jonathan Cameron <jic23@kernel.org>
99698b45670a37b5304d5c6a743c8e96baa9ed8f 26-Aug-2012 Peter Meerwald <pmeerw@pmeerw.net> iio: whitespace cleanup and removal of semicolon after functions

Signed-off-by: Peter Meerwald <pmeerw@pmeerw.net>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
d25b3808db3a03deb12ffc0660c757b4a619f262 26-Aug-2012 Peter Meerwald <pmeerw@pmeerw.net> iio: fix typos

Signed-off-by: Peter Meerwald <pmeerw@pmeerw.net>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
21cd1fab058671313f7c178b640999fcd0d8de21 16-May-2012 Jon Brenner <jbrenner@taosinc.com> IIO channel type and modifiers for CCT and RGBC data

Add iio channel type and modifiers for Correlated Color Temperature (CCT)
and RGBC (red/green/blue/clear) data.
Add CCT and RGBC descriptions to documentation.

Changes:
Revised/condensed RGBC descriptions.

Merge and trivial fix done by Jonathan Cameron.

Signed-off-by: Jon Brenner <jbrenner@taosinc.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
cf82cb8128496955a38fa62e1819ceb1d596e2eb 05-May-2012 Jonathan Cameron <jic23@kernel.org> IIO: Add a modifier for x^2+y^2+z^2

There will probably be a number of such modifiers eventually but
this one is used in the adis16240 accelerometer driver.

Signed-off-by: Jonathan Cameron <jic23@kernel.org>
8f5879b20be7f918cdc4b3d831cfd8f3dc02c74c 05-May-2012 Jonathan Cameron <jic23@kernel.org> IIO: Add a modifier for sqrt(x^2+y^2)

There will probably be a number of such modifiers eventually but
this one is used in the adis16204 accelerometer driver.

Signed-off-by: Jonathan Cameron <jic23@kernel.org>
74dcd439bf8c16b01f9f5a9dffb2b171ed94e2e5 05-Jun-2012 Lars-Peter Clausen <lars@metafoo.de> iio: iio_enum_available_read: Prevent possible buffer overflow

Use scnprint instead of snprintf, because snprintf returns the number of bytes
that would have been written to the buffer if there was enough space, and as a
result writing to buf[len-1] might cause a access beyond the buffers limits.

Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
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>
5212cc8a9d833791a7aec566db136e78951f203d 04-Jun-2012 Lars-Peter Clausen <lars@metafoo.de> iio: Add helper functions for enum style channel attributes

We often have the case were we do have a enum style channel attribute. These
attributes have in common that they are a list of string values which usually
map in a 1-to-1 fashion to integer values.

This patch implements some common helper code for implementing enum style
channel attributes using extended channel attributes. The helper functions take
care of converting between the string and integer values, as well providing a
function for "_available" attributes which list all available enum items.

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>
e407fd655bf9b40c38cba29aa7d38149989798bb 04-Jun-2012 Lars-Peter Clausen <lars@metafoo.de> iio: Fix potential use after free

There is no guarantee that the last reference to the iio device has already been
dropped when iio_device_free is called. This means that we can up calling
iio_dev_release after iio_device_free which will lead to a use after free. As
the general rule the struct containing the device should always be freed in the
release callback.

This is what this patch does, it moves freeing the iio device struct as well as
releasing the idr reference to the release callback. To ensure that the device
is not freed before calling iio_device_free the device_unregister call in
iio_device_unregister is broken apart. iio_device_unregister will now only call
device_del to remove the device from the system and iio_device_free will call
put_device to drop the reference we obtained in iio_devce_alloc.

We also have to take care that calling iio_device_free without having called
iio_device_register still works (i.e. this can happen if something failed during
device initialization). For this to work properly two minor changes were
necessary: channel_attr_list needs to be initialized in iio_device_alloc and we
have to check whether the chrdev has been registered before releasing it in
iio_device_release.

This change also brings iio_device_unregister and iio_device_free more in sync
with iio_device_register and iio_device_alloc which call device_add and
device_initialize respectively.

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>
e53f5ac52ec19c8c606aeacdd13fed2a03d7365a 12-May-2012 Lars-Peter Clausen <lars@metafoo.de> iio: Use dev_to_iio_dev()

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>
b65d62122fa57035fae06a78e0b65622a1e1bc34 11-May-2012 Michael Hennerich <michael.hennerich@analog.com> iio: core: introduce IIO_CHAN_INFO_HARDWAREGAIN

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>
67eedba39ed1ac29908453647652c02fbbeeca1b 11-May-2012 Michael Hennerich <michael.hennerich@analog.com> iio: core: introduce dB scle: IIO_VAL_INT_PLUS_MICRO_DB

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>
abd5a2fb3957b5a6eb8083044a61e1b95b770abf 03-May-2012 Axel Lin <axel.lin@gmail.com> IIO: industrialio-core: Checking NULL instead of IS_ERR for debugfs_create_dir()

If defined CONFIG_DEBUG_FS, debugfs_create_dir returns NULL on failure.

Signed-off-by: Axel Lin <axel.lin@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
5a28c87397655cb0d791d04e45bd7cd5691ba0f2 03-May-2012 Axel Lin <axel.lin@gmail.com> IIO: industrialio-core: Use simple_open

Use simple_open to replace iio_debugfs_open.

Signed-off-by: Axel Lin <axel.lin@gmail.com>
Acked-by: Michael Hennerich <michael.hennerich@analog.com>
Acked-by: Jonathan Cameron <jic23@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
fc6d11398e22a3b2cfd7c3b8421653c6075b624b 27-Apr-2012 Michael Hennerich <michael.hennerich@analog.com> iio: core: iio_chan_spec_ext_info: Add private handle

There is currently no user, but we might need it in future.
So better add it now, before we have to convert drivers afterwards.

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>
a6b12855b58bff429f3961e2577b8bbbb48fe470 27-Apr-2012 Michael Hennerich <michael.hennerich@analog.com> iio: core: Introduce IIO_ALTVOLTAGE and appropriate channel info elements

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>
7cbb753701d11f3c71e8543e1ae0fc0772edac06 26-Apr-2012 Lars-Peter Clausen <lars@metafoo.de> staging:iio: Streamline API function naming

Currently we use two different naming schemes in the IIO API, iio_verb_object
and iio_object_verb. E.g iio_device_register and iio_allocate_device. This
patches renames instances of the later to the former. The patch also renames allocate to
alloc as this seems to be the preferred form throughout the kernel.

In particular the following renames are performed by the patch:
iio_put_device -> iio_device_put
iio_allocate_device -> iio_device_alloc
iio_free_device -> iio_device_free
iio_get_trigger -> iio_trigger_get
iio_put_trigger -> iio_trigger_put
iio_allocate_trigger -> iio_trigger_alloc
iio_free_trigger -> iio_trigger_free

The conversion was done with the following coccinelle patch with manual fixes to
comments and documentation.

<smpl>
@@
@@
-iio_put_device
+iio_device_put
@@
@@
-iio_allocate_device
+iio_device_alloc
@@
@@
-iio_free_device
+iio_device_free
@@
@@
-iio_get_trigger
+iio_trigger_get
@@
@@
-iio_put_trigger
+iio_trigger_put
@@
@@
-iio_allocate_trigger
+iio_trigger_alloc
@@
@@
-iio_free_trigger
+iio_trigger_free
</smpl>

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>
a980e046098b0a40eaff5e4e7fcde6cf035b7c06 25-Apr-2012 Jonathan Cameron <jic23@kernel.org> IIO: Move the core files to drivers/iio

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>