summaryrefslogtreecommitdiff
AgeCommit message (Collapse)Author
2015-05-31tools:iio:iio_utils: add error handlingHartmut Knaack
Add error handling to calls which can indicate a major problem by returning an error code. This also sets ret to -ENOENT in iioutils_get_type() and iioutils_get_param_float() to indicate if no matching directory entry was found. Signed-off-by: Hartmut Knaack <knaack.h@gmx.de> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2015-05-31tools:iio:iio_event_monitor: add error handlingHartmut Knaack
Add error handling to calls which can indicate a major problem by returning an error code. Signed-off-by: Hartmut Knaack <knaack.h@gmx.de> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2015-05-31tools:iio:generic_buffer: add error handlingHartmut Knaack
Add error handling to calls which can indicate a major problem by returning an error code. Signed-off-by: Hartmut Knaack <knaack.h@gmx.de> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2015-05-31tools:iio:generic_buffer: catch errors for arguments conversionHartmut Knaack
Add handler to catch errors on conversion of numerical arguments. Signed-off-by: Hartmut Knaack <knaack.h@gmx.de> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2015-05-31tools:iio: catch errors in string allocationHartmut Knaack
This patch catches errors in string allocation in generic_buffer.c, iio_event_monitor.c, iio_utils.c and lsiio.c. Signed-off-by: Hartmut Knaack <knaack.h@gmx.de> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2015-05-31tools:iio:iio_utils: mark private function staticHartmut Knaack
Functions _write_sysfs_int() and _write_sysfs_string() are supposed to be called only by public wrappers, so make them static. Signed-off-by: Hartmut Knaack <knaack.h@gmx.de> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2015-05-31tools:iio:iio_utils: implement digit calculationHartmut Knaack
Previously, the return value of sscanf() was treated as an indication of the digits it would have read. Yet, sscanf() only returns the amount of valid matches. Therefore, introduce a function to calculate the decimal digits of the read number and use this one to commence a colon search, as originally intended. Signed-off-by: Hartmut Knaack <knaack.h@gmx.de> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2015-05-31tools:iio:iio_utils: check amount of matchesHartmut Knaack
fscanf() usually returns the number of input items successfully matched and assigned, which can be fewer than provided (or even zero). Add a check in iioutils_get_type() to make sure all items are matched. Signed-off-by: Hartmut Knaack <knaack.h@gmx.de> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2015-05-31tools:iio:generic_buffer: sign-extend and shift dataHartmut Knaack
Refactor process_scan() to handle signed and unsigned data, respect shifts and the data mask for 2, 4 and 8 byte sized scan elements. Signed-off-by: Hartmut Knaack <knaack.h@gmx.de> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2015-05-31tools:iio:generic_buffer: pass up right error codeHartmut Knaack
find_type_by_name() returns a valid error code in case of an error. Pass this code up instead of an artificial one. Signed-off-by: Hartmut Knaack <knaack.h@gmx.de> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2015-05-31tools:iio:generic_buffer: fix check of errnoHartmut Knaack
Since errno contains the value of any of the defined error names, a negation will not lead to the desired match. Signed-off-by: Hartmut Knaack <knaack.h@gmx.de> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2015-05-31tools:iio:iio_event_monitor: save right errnoHartmut Knaack
Move up error handling code to preserve the errno coming from ioctl(), before it may be changed by close(). Signed-off-by: Hartmut Knaack <knaack.h@gmx.de> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2015-05-31tools:iio: save errno firstHartmut Knaack
The man-page of errno states, that errno should be saved before doing any library call, as that call may have changed the value of errno. So, when encountering any error, save errno first. This patch affects generic_buffer.c, iio_event_monitor.c and iio_utils.c. Signed-off-by: Hartmut Knaack <knaack.h@gmx.de> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2015-05-31tools:iio:lsiio: add closedir before exitHartmut Knaack
In dump_channels() the DIR *dp was left open on exit. Close it and check for errors. Signed-off-by: Hartmut Knaack <knaack.h@gmx.de> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2015-05-31tools:iio:iio_utils: fix allocation handlingHartmut Knaack
In build_channel_array(), count needs to be decreased in more places since current->name and current->generic_name would be freed on the error path, although they have not been allocated, yet. This also requires to free current->name, when it is allocated, but current->generic_name is not yet allocated. Signed-off-by: Hartmut Knaack <knaack.h@gmx.de> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2015-05-31tools:iio: free channel-array completelyHartmut Knaack
In iio_utils.c build_channel_array() dynamically allocates the string generic_name in the current iio_channel_info, which doesn't got freed in case of an error. This dynamically allocated channel-array is used by generic_buffer, and needs to be freed on the error/exit path. Signed-off-by: Hartmut Knaack <knaack.h@gmx.de> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2015-05-31tools:iio:iio_utils: free scan_el_dir on exitHartmut Knaack
In the error path, the string scan_el_dir got freed, while it was missing when build_channel_array() finished without errors. Signed-off-by: Hartmut Knaack <knaack.h@gmx.de> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2015-05-31tools:iio:generic_buffer: free dev_dir_name on exitHartmut Knaack
Make sure to free dev_dir_name in case of an error or regular exit. Signed-off-by: Hartmut Knaack <knaack.h@gmx.de> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2015-05-31tools:iio:generic_buffer: fix order of freeing dataHartmut Knaack
data gets allocated before buffer_access, so it should be freed in reverse order. Otherwise, if allocating buffer_access fails, an attempt to free it would be taken, which should not happen. Signed-off-by: Hartmut Knaack <knaack.h@gmx.de> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2015-05-23iio: accel: Add support for Sensortek STK8BA50Tiberiu Breana
Minimal implementation of an IIO driver for the Sensortek STK8BA50 3-axis accelerometer. Datasheet: http://szgsensor.com/uploads/soft/141229/STK8BA50%D2%E5%BC%CE.pdf Includes: - ACPI support; - read_raw for x,y,z axes; - reading and setting the scale (range) parameter. - power management Signed-off-by: Tiberiu Breana <tiberiu.a.breana@intel.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2015-05-23iio: __iio_update_buffers: Leave device in sane state on errorLars-Peter Clausen
Currently when something goes wrong at some step when disabling the buffers we immediately abort. This has the effect that the enable/disable calls are no longer balanced. So make sure that even if one step in the disable sequence fails the other steps are still executed. The other issue is that when either enable or disable fails buffers that were active at that time stay active while the device itself is disabled. This leaves things in a inconsistent state and can cause unbalanced enable/disable calls. Furthermore when enable fails we restore the old scan mask, but still keeps things disabled. Given that verification of the configuration was performed earlier and it is valid at the point where we try to enable/disable the most likely reason of failure is a communication failure with the device or maybe a out-of-memory situation. There is not really a good recovery strategy in such a case, so it makes sense to leave the device disabled, but we should still leave it in a consistent state. What the patch does if disable/enable fails is to deactivate all buffers and make sure that the device will be in the same state as if all buffers had been manually disabled. Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2015-05-23iio: __iio_update_buffers: Split enable and disable path into helper functionsLars-Peter Clausen
__iio_update_buffers is already a rather large function with many different error paths and it is going to get even larger. This patch factors out the device enable and device disable paths into separate helper functions. The patch also re-implements iio_disable_all_buffers() using the new iio_disable_buffers() function removing a fair bit of redundant code. Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2015-05-23iio: __iio_update_buffers: Verify configuration before starting to apply itLars-Peter Clausen
Currently __iio_update_buffers() verifies whether the new configuration will work in the middle of the update sequence. This means if the new configuration is invalid we need to rollback the changes already made. This patch moves the validation of the new configuration at the beginning of __iio_update_buffers() and will not start to make any changes if the new configuration is invalid. Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2015-05-23iio:adc128s052: add support for adc122s021Urs Fässler
Signed-off-by: Urs Fässler <urs.fassler@bytesatwork.ch> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2015-05-23iio: Add I/Q modifiersLars-Peter Clausen
I/Q modifiers can be used to denote signals which are represented by a in-phase and a quadrature component. The ABI documentation describes the I and Q modifiers for current and voltage channels for now as those will be the most likely users. Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2015-05-23Documentation: bindings: document the Berlin ADC driverAntoine Tenart
Following the addition of a Berlin ADC driver, this patch adds the corresponding bindings documentation. Signed-off-by: Antoine Tenart <antoine.tenart@free-electrons.com> Acked-by: Jonathan Cameron <jic23@kernel.org> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2015-05-23iio: adc: add support for BerlinAntoine Tenart
This patch adds the support of the Berlin ADC, available on Berlin SoCs. This ADC has 8 channels available, with one connected to a temperature sensor. The particularity here, is that the temperature sensor connected to the ADC has its own registers, and both the ADC and the temperature sensor must be configured when using it. Signed-off-by: Antoine Tenart <antoine.tenart@free-electrons.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2015-05-17iio: accel: Add support for Sensortek STK8312Tiberiu Breana
Minimal implementation of an IIO driver for the Sensortek STK8312 3-axis accelerometer. Datasheet: http://www.syi-group.com/uploadpic/data/201361817562681623.pdf Includes: - ACPI support; - read_raw for x,y,z axes; - reading and setting the scale (range) parameter. - power management Signed-off-by: Tiberiu Breana <tiberiu.a.breana@intel.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2015-05-17iio: accel: bmc150: decouple buffer and triggersVlad Dogaru
If the interrupt pins are not available, we should still be able to use the buffer with an external trigger. However, we won't be able to use the hardware fifo since we have no means of signalling when the watermark is reached. I also added a comment to indicate that the timestamps in bmc150_accel_data are only used for hardware fifo, since initially I was confused about duplication with pf->timestamp. Signed-off-by: Vlad Dogaru <vlad.dogaru@intel.com> Reviewed-by: Octavian Purdila <octavian.purdila@intel.com> Reviewed-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2015-05-17iio: core: add high pass filter attributesMartin Fuzzey
Add a high pass filter attribute for measurements (like the existing low pass) Also add both high and low pass attributes for events. Signed-off-by: Martin Fuzzey <mfuzzey@parkeon.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2015-05-17iio: mma8452: Add access to registers via DebugFSMartin Fuzzey
Signed-off-by: Martin Fuzzey <mfuzzey@parkeon.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2015-05-17iio: mma8452: Initialise before activatingMartin Fuzzey
Many of the hardware configuration registers may only be modified while the device is inactive. Currently the probe code first activates the device and then modifies the registers (eg to set the scale). This doesn't actually work but is not noticed since the scale used is the default value. While at it also issue a hardware reset command at probe time. Signed-off-by: Martin Fuzzey <mfuzzey@parkeon.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2015-05-17iio: gyro: bmg160: decouple buffer and triggersVlad Dogaru
Make it possible to use buffering with an external trigger, such as one based on sysfs or hrtimer. Signed-off-by: Vlad Dogaru <vlad.dogaru@intel.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2015-05-17iio: gyro: bmg160: remove redundant fieldVlad Dogaru
Replace the 'timestamp' field in struct bmg160_data with the identically named field in iio_poll_func and with calls to iio_get_time_ns(). The reported timestamps may be slightly different, but the advantage is that we no longer assume that the buffer of bmg160 is triggered by its own trigger. Signed-off-by: Vlad Dogaru <vlad.dogaru@intel.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2015-05-17iio: __iio_update_buffers: Perform request_update() only for new buffersLars-Peter Clausen
We only have to call the request_update() callback for a newly inserted buffer. The configuration of the already previously active buffers will not have changed. This also allows us to move the request_update() call to the beginning of __iio_update_buffers(), before any currently active buffers are stopped. This makes the error handling a lot easier since no changes were made to the buffer list and no rollback needs to be performed. Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2015-05-17iio: __iio_update_buffers: Slightly refactor scan mask memory managementLars-Peter Clausen
Add a small helper function iio_free_scan_mask() that takes a mask and frees its memory if the scan masks for the device are dynamically allocated, otherwise does nothing. This means we don't have to open-code the same check over and over again in __iio_update_buffers. Also free compound_mask as soon a we are done using it. This constrains its usage to a specific region of the function will make further refactoring and splitting the function into smaller sub-parts more easier. Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2015-05-17iio: Replace printk in __iio_update_buffers with dev_dbgLars-Peter Clausen
While more verbose error messages are useful for debugging we should really not put those error messages into the kernel log for normal errors that are already reported to the application via the error code, when running in non-debug mode. Otherwise application authors might expect that this is part of the ABI and to get the error they should scan the kernel log. Which would be rather error prone itself since there is no direct mapping between a operation and the error message so it is impossible to find out which error message belongs to which error. Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2015-05-17iio: add m62332 DAC driverDmitry Eremin-Solenikov
m62332 is a simple 2-channel DAC used on several Sharp Zaurus boards to control LCD voltage, backlight and sound. The driver use regulators to control the reference voltage and enabling/disabling the DAC. Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2015-05-17iio: ltr501: Add light channel supportKuppuswamy Sathyanarayanan
Added support to calculate lux value from visible and IR spectrum adc count values. Also added IIO_LIGHT channel to enable user read the lux value directly from device using illuminance input ABI. Signed-off-by: Kuppuswamy Sathyanarayanan <sathyanarayanan.kuppuswamy@linux.intel.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2015-05-17iio: pressure: hid-sensor-press: Fix memory leak in probe()Fabio Estevam
'channels' is allocated via kmemdup and it is never freed in the subsequent error paths. Use 'indio_dev->channels' directly instead, so that we avoid such memory leak problem. Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com> Reviewed-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2015-05-17iio: orientation: hid-sensor-rotation: Fix memory leak in probe()Fabio Estevam
'channels' is allocated via kmemdup and it is never freed in the subsequent error paths. Use 'indio_dev->channels' directly instead, so that we avoid such memory leak problem. Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com> Reviewed-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2015-05-17iio: orientation: hid-sensor-incl-3d: Fix memory leak in probe()Fabio Estevam
'channels' is allocated via kmemdup and it is never freed in the subsequent error paths. Use 'indio_dev->channels' directly instead, so that we avoid such memory leak problem. Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com> Reviewed-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2015-05-17iio: light: hid-sensor-als.c: Fix memory leak in probe()Fabio Estevam
'channels' is allocated via kmemdup and it is never freed in the subsequent error paths. Use 'indio_dev->channels' directly instead, so that we avoid such memory leak problem. Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com> Reviewed-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2015-05-17iio: gyro: hid-sensor-gyro-3d: Fix memory leak in probe()Fabio Estevam
'channels' is allocated via kmemdup and it is never freed in the subsequent error paths. Use 'indio_dev->channels' directly instead, so that we avoid such memory leak problem. Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com> Reviewed-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2015-05-17iio: accel: hid-sensor-accel-3d: Fix memory leak in probe()Fabio Estevam
'channels' is allocated via kmemdup and it is never freed in the subsequent error paths. Use 'indio_dev->channels' directly instead, so that we avoid such memory leak problem. Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com> Reviewed-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2015-05-16iio: ltr501: Fix proximity threshold boundary checkKuppuswamy Sathyanarayanan
Currently, proximity sensor boundary check is done inside the switch block but outside the case statement.Since this code will never get executed, moved the check outside the switch case statement. 867 case IIO_PROXIMITY: 868 switch (dir) { // Following line has been moved outside the switch block. 869 if (val > LTR501_PS_THRESH_MASK) 870 return -EINVAL; 871 case IIO_EV_DIR_RISING: Signed-off-by: Kuppuswamy Sathyanarayanan <sathyanarayanan.kuppuswamy@linux.intel.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2015-05-13iio:temp:mlx90614 trivial drop of unnecessary ret return from write_raw.Jonathan Cameron
This is mostly part of an effort to clean out our current warnings and make the autobuilder build reports more useful. Still a worthwhile if trivial cleanup! Signed-off-by: Jonathan Cameron <jic23@kernel.org> Reported-by: kbuild test robot <fengguang.wu@intel.com> Cc: Vianney le Clément de Saint-Marcq <vianney.leclement@essensium.com> Cc: Peter Meerwald <pmeerw@pmeerw.net>
2015-05-13iio: adc: ti_am335x_adc: make sample delay, open delay, averaging DT parametersVignesh R
Add optional DT properties to set open delay, sample delay and number of averages per sample for each adc step. Open delay, sample delay and averaging are some of the parameters that affect the sampling rate and accuracy of the sample. Making these parameters configurable via DT will help in balancing speed vs accuracy. Signed-off-by: Vignesh R <vigneshr@ti.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2015-05-10iio: acpi: Add support for ACPI0008 Ambient Light SensorGabriele Mazzotta
This driver adds the initial support for the ACPI Ambient Light Sensor as defined in Section 9.2 of the ACPI specification (Revision 5.0) [1]. Sensors complying with the standard are exposed as ACPI devices with ACPI0008 as hardware ID and provide standard methods by which the OS can query properties of the ambient light environment the system is currently operating in. This driver currently allows only to get the current ambient light illuminance reading through the _ALI method, but is ready to be extended extended to handle _ALC, _ALT and _ALP as well. [1] http://www.acpi.info/DOWNLOADS/ACPIspec50.pdf Signed-off-by: Martin Liska <marxin.liska@gmail.com> Signed-off-by: Marek Vasut <marex@denx.de> Signed-off-by: Gabriele Mazzotta <gabriele.mzt@gmail.com> Cc: Zhang Rui <rui.zhang@intel.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2015-05-10imu: inv_mpu6050: adds device tree bindingsVarka Bhadram
Signed-off-by: Varka Bhadram <varkab@cdac.in> Signed-off-by: Jonathan Cameron <jic23@kernel.org>