Commit Graph

2527 Commits

Author SHA1 Message Date
simran singhal 98b6d2b676 iio: light: lm3533-als: constify attribute_group structures
Check for attribute_group structures that are only stored in the
event_attrs filed of iio_info structure. As the event_attrs field of
iio_info structures is constant, so these attribute_group structures can
also be declared constant. Done using coccinelle:

@r1 disable optional_qualifier @
identifier i;
position p;
@@
static struct attribute_group i@p = {...};

@ok1@
identifier r1.i;
position p;
struct iio_info x;
@@
x.event_attrs=&i@p;

@bad@
position p!={r1.p,ok1.p};
identifier r1.i;
@@
i@p

@depends on !bad disable optional_qualifier@
identifier r1.i;
@@
static
+const
struct attribute_group i={...};

@depends on !bad disable optional_qualifier@
identifier r1.i;
@@
+const
struct attribute_group i;

As the attrs field of iio_info structures is also constant, so these
attribute_group structures can also be declared constant. Done manually.

File size before:
   text    data     bss     dec     hex filename
   5798    2376       0    8174    1fee drivers/iio/light/lm3533-als.o

File size after:
   text	   data	    bss	    dec	    hex	filename
   5926	   2248	      0	   8174	   1fee	drivers/iio/light/lm3533-als.o

Signed-off-by: simran singhal <singhalsimran0@gmail.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2017-04-02 09:08:55 +01:00
Rick Altherr 573803234e iio: Aspeed ADC
Aspeed BMC SoCs include a 16 channel, 10-bit ADC. Low and high threshold
interrupts are supported by the hardware but are not currently implemented.

Signed-off-by: Rick Altherr <raltherr@google.com>
Tested-by: Xo Wang <xow@google.com>
Reviewed-by: Joel Stanley <joel@jms.id.au>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2017-04-01 11:53:20 +01:00
simran singhal 4214dc1807 iio: adc: hx711: constify attribute_group structures
Check for attribute_group structures that are only stored in the
attrs filed of iio_info structure. As the attrs field of iio_info
structures is constant, so these attribute_group structures can also be
declared constant.
Done using coccinelle:

@r1 disable optional_qualifier @
identifier i;
position p;
@@
static struct attribute_group i@p = {...};

@ok1@
identifier r1.i;
position p;
struct iio_info x;
@@
x.attrs=&i@p;

@bad@
position p!={r1.p,ok1.p};
identifier r1.i;
@@
i@p

@depends on !bad disable optional_qualifier@
identifier r1.i;
@@
static
+const
struct attribute_group i={...};

@depends on !bad disable optional_qualifier@
identifier r1.i;
@@
+const
struct attribute_group i;

File size before:
   text	   data	    bss	    dec	    hex	filename
   3042	    480	      0	   3522	    dc2	drivers/iio/adc/hx711.o

File size after:
   text	   data	    bss	    dec	    hex	filename
   3098	    416	      0	   3514	    dba	drivers/iio/adc/hx711.o

Signed-off-by: simran singhal <singhalsimran0@gmail.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2017-04-01 11:39:04 +01:00
simran singhal 757cff86a8 iio: humidity: hdc100x: constify attribute_group structures
Check for attribute_group structures that are only stored in the
attrs filed of iio_info structure. As the attrs field of iio_info
structures is constant, so these attribute_group structures can also be
declared constant.
Done using coccinelle:

@r1 disable optional_qualifier @
identifier i;
position p;
@@
static struct attribute_group i@p = {...};

@ok1@
identifier r1.i;
position p;
struct iio_info x;
@@
x.attrs=&i@p;

@bad@
position p!={r1.p,ok1.p};
identifier r1.i;
@@
i@p

@depends on !bad disable optional_qualifier@
identifier r1.i;
@@
static
+const
struct attribute_group i={...};

@depends on !bad disable optional_qualifier@
identifier r1.i;
@@
+const
struct attribute_group i;

File size before:
   text	   data	    bss	    dec	    hex	filename
   3459	    488	      0	   3947	    f6b	drivers/iio/humidity/hdc100x.o

File size after:
   text	   data	    bss	    dec	    hex	filename
   3507	    424	      0	   3931	    f5b	drivers/iio/humidity/hdc100x.o

Signed-off-by: simran singhal <singhalsimran0@gmail.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2017-04-01 11:37:06 +01:00
simran singhal 3ca437c052 iio: light: apds9960: constify attribute_group structures
Check for attribute_group structures that are only stored in the
attrs filed of iio_info structure. As the attrs field of iio_info
structures is constant, so these attribute_group structures can also be
declared constant.
Done using coccinelle:

@r1 disable optional_qualifier @
identifier i;
position p;
@@
static struct attribute_group i@p = {...};

@ok1@
identifier r1.i;
position p;
struct iio_info x;
@@
x.attrs=&i@p;

@bad@
position p!={r1.p,ok1.p};
identifier r1.i;
@@
i@p

@depends on !bad disable optional_qualifier@
identifier r1.i;
@@
static
+const
struct attribute_group i={...};

@depends on !bad disable optional_qualifier@
identifier r1.i;
@@
+const
struct attribute_group i;

File size before:
   text	   data	    bss	    dec	    hex	filename
   8503	    488	      0	   8991	   231f	drivers/iio/light/apds9960.o

File size after:
   text	   data	    bss	    dec	    hex	filename
   8567	    424	      0	   8991	   231f	drivers/iio/light/apds9960.o

Signed-off-by: simran singhal <singhalsimran0@gmail.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2017-04-01 11:36:22 +01:00
simran singhal c2869498d0 iio: light: bh1750: constify attribute_group structures
Check for attribute_group structures that are only stored in the
attrs filed of iio_info structure. As the attrs field of iio_info
structures is constant, so these attribute_group structures can also be
declared constant.
Done using coccinelle:

@r1 disable optional_qualifier @
identifier i;
position p;
@@
static struct attribute_group i@p = {...};

@ok1@
identifier r1.i;
position p;
struct iio_info x;
@@
x.attrs=&i@p;

@bad@
position p!={r1.p,ok1.p};
identifier r1.i;
@@
i@p

@depends on !bad disable optional_qualifier@
identifier r1.i;
@@
static
+const
struct attribute_group i={...};

@depends on !bad disable optional_qualifier@
identifier r1.i;
@@
+const
struct attribute_group i;

File size before:
   text	   data	    bss	    dec	    hex	filename
   2276	    352	      0	   2628	    a44	drivers/iio/light/bh1750.o

File size after:
   text	   data	    bss	    dec	    hex	filename
   2340	    320	      0	   2660	    a64	drivers/iio/light/bh1750.o

Signed-off-by: simran singhal <singhalsimran0@gmail.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2017-04-01 11:27:22 +01:00
simran singhal 7ab89e1e23 iio: proximity: as3935: constify attribute_group structures
Check for attribute_group structures that are only stored in the
attrs filed of iio_info structure. As the attrs field of iio_info
structures is constant, so these attribute_group structures can also be
declared constant.
Done using coccinelle:

@r1 disable optional_qualifier @
identifier i;
position p;
@@
static struct attribute_group i@p = {...};

@ok1@
identifier r1.i;
position p;
struct iio_info x;
@@
x.attrs=&i@p;

@bad@
position p!={r1.p,ok1.p};
identifier r1.i;
@@
i@p

@depends on !bad disable optional_qualifier@
identifier r1.i;
@@
static
+const
struct attribute_group i={...};

@depends on !bad disable optional_qualifier@
identifier r1.i;
@@
+const
struct attribute_group i;

File size before:
   text	   data	    bss	    dec	    hex	filename
   4037	    288	      0	   4325	   10e5	drivers/iio/proximity/as3935.o

File size after:
   text	   data	    bss	    dec	    hex	filename
   4101	    256	      0	   4357	   1105	drivers/iio/proximity/as3935.o

Signed-off-by: simran singhal <singhalsimran0@gmail.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2017-04-01 11:26:10 +01:00
Tony Lindgren 25ec249632 iio: adc: cpcap: Add minimal support for CPCAP PMIC ADC
On Motorola phones like droid 4 there is a custom CPCAP PMIC. This PMIC
has ADCs that are used for battery charging and USB PHY VBUS and ID pin
detection.

Unfortunately the only documentation for this ADC seems to be the
Motorola mapphone Linux kernel tree. I have tested that reading raw and
scaled values works, but I have not used the timed sampling that the ADC
seems to support.

Let's add a minimal support for it so we can eventually provide IIO
channels for the related battery charging and USB PHY drivers.

Cc: devicetree@vger.kernel.org
Cc: Marcel Partap <mpartap@gmx.net>
Cc: Michael Scott <michael.scott@linaro.org>
Cc: Sebastian Reichel <sre@kernel.org>
Signed-off-by: Tony Lindgren <tony@atomide.com>
Acked-by: Rob Herring <robh@kernel.org>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2017-03-30 19:25:23 +01:00
Arushi Singhal 5e13b6f0e7 drivers: iio: chemical: replace comma with a semicolon
Replace a comma between expression statements by a semicolon. This
changes the semantics of the code, but given the current indentation
appears to be what is intended.
A simplified version of the Coccinelle semantic patch that performs this
transformation is as follows:

// <smpl>
@r@
expression e1,e2;
@@

 e1
-,
+;
 e2;
// </smpl>

Signed-off-by: Arushi Singhal <arushisinghal19971997@gmail.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2017-03-30 19:13:23 +01:00
Arushi Singhal bb4787f520 iio: adc: replace comma with a semicolon
Replace a comma between expression statements by a semicolon. This
changes the semantics of the code, but given the current indentation
appears to be what is intended.
A simplified version of the Coccinelle semantic patch that performs this
transformation is as follows:

// <smpl>
@r@
expression e1,e2;
@@

 e1
-,
+;
 e2;
// </smpl>

Signed-off-by: Arushi Singhal <arushisinghal19971997@gmail.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2017-03-30 19:11:27 +01:00
simran singhal 612dc0e2e8 iio: adc: ad799x: constify attribute_group structures
Check for attribute_group structures that are only stored in the
event_attrs filed of iio_info structure. As the event_attrs field of
iio_info structures is constant, so these attribute_group structures can
also be declared constant.
Done using coccinelle:

@r1 disable optional_qualifier @
identifier i;
position p;
@@
static struct attribute_group i@p = {...};

@ok1@
identifier r1.i;
position p;
struct iio_info x;
@@
x.event_attrs=&i@p;

@bad@
position p!={r1.p,ok1.p};
identifier r1.i;
@@
i@p

@depends on !bad disable optional_qualifier@
identifier r1.i;
@@
static
+const
struct attribute_group i={...};

@depends on !bad disable optional_qualifier@
identifier r1.i;
@@
+const
struct attribute_group i;

File size before:
   text    data     bss     dec     hex filename
  26051     464       0   26515    6793 drivers/iio/adc/ad799x.o

File size after:
   text	   data	    bss	    dec	    hex	filename
  26115	    400	      0	  26515	   6793	drivers/iio/adc/ad799x.o

Signed-off-by: simran singhal <singhalsimran0@gmail.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2017-03-29 22:12:41 +01:00
simran singhal c94645b1b1 iio: adc: max1363: constify attribute_group structures
Check for attribute_group structures that are only stored in the
event_attrs filed of iio_info structure. As the event_attrs field of
iio_info structures is constant, so these attribute_group structures can
also be declared constant. Done using coccinelle:

@r1 disable optional_qualifier @
identifier i;
position p;
@@
static struct attribute_group i@p = {...};

@ok1@
identifier r1.i;
position p;
struct iio_info x;
@@
x.event_attrs=&i@p;

@bad@
position p!={r1.p,ok1.p};
identifier r1.i;
@@
i@p

@depends on !bad disable optional_qualifier@
identifier r1.i;
@@
static
+const
struct attribute_group i={...};

@depends on !bad disable optional_qualifier@
identifier r1.i;
@@
+const
struct attribute_group i;

File size before:
   text    data     bss     dec     hex filename
  36951     448       0   37399    9217 drivers/iio/adc/max1363.o

File size after:
   text	   data	    bss	    dec	    hex	filename
  37015	    384	      0	  37399	   9217	drivers/iio/adc/max1363.o

Signed-off-by: simran singhal <singhalsimran0@gmail.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2017-03-29 22:10:58 +01:00
simran singhal e36020fd69 iio: dac: ad5504: constify attribute_group structures
Check for attribute_group structures that are only stored in the
event_attrs filed of iio_info structure. As the event_attrs field of
iio_info structures is constant, so these attribute_group structures can
also be declared constant. Done using coccinelle:

@r1 disable optional_qualifier @
identifier i;
position p;
@@
static struct attribute_group i@p = {...};

@ok1@
identifier r1.i;
position p;
struct iio_info x;
@@
x.event_attrs=&i@p;

@bad@
position p!={r1.p,ok1.p};
identifier r1.i;
@@
i@p

@depends on !bad disable optional_qualifier@
identifier r1.i;
@@
static
+const
struct attribute_group i={...};

@depends on !bad disable optional_qualifier@
identifier r1.i;
@@
+const
struct attribute_group i;

File size before:
   text    data     bss     dec     hex filename
   3046     360       0    3406     d4e drivers/iio/dac/ad5504.o

File size after:
   text	   data	    bss	    dec	    hex	filename
   3110	    296	      0	   3406	    d4e	drivers/iio/dac/ad5504.o

Signed-off-by: simran singhal <singhalsimran0@gmail.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2017-03-29 22:08:51 +01:00
Greg Kroah-Hartman 57c0eabbd5 Merge 4.11-rc4 into char-misc-next
We want the char-misc fixes in here as well.

Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-03-27 09:13:04 +02:00
Greg Kroah-Hartman 1c816bad41 Merge 4.11-rc4 into staging-next
We need the IIO fixes in here as well to handle merge issues.

Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-03-27 09:11:25 +02:00
Quentin Schulz 4bdc902968 iio: bmg160: reset chip when probing
The gyroscope chip might need to be reset to be used.

Without the chip being reset, the driver stopped at the first
regmap_read (to get the CHIP_ID) and failed to probe.

The datasheet of the gyroscope says that a minimum wait of 30ms after
the reset has to be done.

This patch has been checked on a BMX055 and the datasheet of the BMG160
and the BMI055 give the same reset register and bits.

Signed-off-by: Quentin Schulz <quentin.schulz@free-electrons.com>
Cc: <Stable@vger.kernel.org>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2017-03-25 16:36:25 +00:00
Song Hongyan d7ed89d5aa iio: hid: Add humidity sensor support
Environmental humidity sensor is a hid defined sensor,
it shows raw humidity measurement of air.

More information can be found in:
http://www.usb.org/developers/hidpage/HUTRR39b.pdf

According to IIO ABI definition, humidityrelative data output unit is
milli percent. Add the unit convert from percent to milli percent.

Signed-off-by: Song Hongyan <hongyan.song@intel.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2017-03-25 16:32:24 +00:00
Song Hongyan e0ad9b73e8 iio: hid-sensor-attributes: Fix gravity sensor scale value not right issue
Scale value include two parts: unit conversion and exponent conversion.
Add gravity unit convert table to fix gravity sensor scale value not
right issue.

Signed-off-by: Song Hongyan <hongyan.song@intel.com>
Acked-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2017-03-25 16:25:11 +00:00
Manivannan Sadhasivam 5e7f47e495 iio:light: Add support for STMicro VL6180 sensor
This patch adds support for STMicro VL6180 - ALS, range and proximity sensor. Sensor is capable of measuring the light
intensity as well as object distance using TOF (Time of Flight) technology.

Signed-off-by: Manivannan Sadhasivam <manivannanece23@gmail.com>
Signed-off-by: Peter Meerwald-Stadler <pmeerw@pmeerw.net>
Acked-by: Rob Herring <robh@kernel.org>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2017-03-25 16:20:46 +00:00
Enric Balletbo i Serra 754434c445 iio: cros_ec_sensors: Use devm to setup the triggered buffer.
Use resourced managed function devm_iio_triggered_buffer_setup
to make error path simpler and be able to get rid of the remove
function.

Signed-off-by: Enric Balletbo i Serra <enric.balletbo@collabora.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2017-03-25 15:08:29 +00:00
Enric Balletbo i Serra a096926ed4 iio: cros_ec_sensors: Fix return value to get raw and calibbias data.
The cros_ec_sensors_read function must return the type of value on all
cases. This was always true except for RAW and CALIBBIAS data which
returned an error or 0. This patch just fixes the mistake I introduced
when submitting the series.

Fixes: commit c14dca07a3 (iio: cros_ec_sensors: add ChromeOS EC
Contiguous Sensors driver)

Signed-off-by: Enric Balletbo i Serra <enric.balletbo@collabora.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2017-03-25 15:06:14 +00:00
Heiner Kallweit 48ba7c3c0b iio: adc: meson-saradc: add calibration
This patch adds calibration for the Meson SAR ADC.
Points 25% vref and 75% vref are used for calibration.
It uses a simple linear calibration function: SCALE * val + BIAS

Successfully tested on a Odroid C2.

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
Tested-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
Reviewed-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2017-03-25 14:55:03 +00:00
Ksenija Stanojevic 0d690cc41b iio: adc: mxs-lradc: Remove driver
Since the driver has been split into MFD there is no reason for it to
stay, so remove it.

Signed-off-by: Ksenija Stanojevic <ksenija.stanojevic@gmail.com>
Acked-by: Jonathan Cameron <jic23@kernel.org>
Reviewed-by: Marek Vasut <marex@denx.de>
Signed-off-by: Lee Jones <lee.jones@linaro.org>
2017-03-23 12:29:01 +00:00
Ksenija Stanojevic 6dd112b9f8 iio: adc: mxs-lradc: Add support for ADC driver
Add support for sixteen-channel 12-bit resolution ADC and its functions,
which include general-purpose ADC readings, battery voltage measurement,
and die temperature measurement.

Signed-off-by: Ksenija Stanojevic <ksenija.stanojevic@gmail.com>
Reviewed-by: Jonathan Cameron <jic23@kernel.org>
Reviewed-by: Marek Vasut <marex@denx.de>
Signed-off-by: Lee Jones <lee.jones@linaro.org>
2017-03-23 12:28:43 +00:00
Maxime Roussin-Belanger 02b829f9e1 iio: dac: Add support for ltc2632 DACs
Add support for Linear Technology LTC2632 (SPI) family of·
dual 12- 10-, and 8-bits output DACs.

Signed-off-by: Maxime Roussin-Belanger <maxime.roussinbelanger@gmail.com>
Signed-off-by: Jean-Francois Dagenais <jeff.dagenais@gmail.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2017-03-21 18:43:56 +00:00
Logan Gunthorpe 38923911dc iio:core: utilize new cdev_device_add helper function
Replace the open coded registration of the cdev and dev with the
new device_add_cdev() helper. The helper replaces a common pattern by
taking the proper reference against the parent device and adding both
the cdev and the device.

In doing so we have to remove a guard statement from cdev_del,
but this doesn't appear to be required in any way.

Signed-off-by: Logan Gunthorpe <logang@deltatee.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-03-21 06:44:33 +01:00
Javier Martinez Canillas 91b4b16617 iio: gyro: itg3200: Add OF device ID table
The driver doesn't have a struct of_device_id table but supported devices
are registered via Device Trees. This is working on the assumption that a
I2C device registered via OF will always match a legacy I2C device ID and
that the MODALIAS reported will always be of the form i2c:<device>.

But this could change in the future so the correct approach is to have an
OF device ID table if the devices are registered via OF.

Signed-off-by: Javier Martinez Canillas <javier@osg.samsung.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2017-03-19 10:58:31 +00:00
Javier Martinez Canillas f1c088a769 iio: accel: mma7660: Add OF device ID table
The driver doesn't have a struct of_device_id table but supported devices
are registered via Device Trees. This is working on the assumption that a
I2C device registered via OF will always match a legacy I2C device ID and
that the MODALIAS reported will always be of the form i2c:<device>.

But this could change in the future so the correct approach is to have an
OF device ID table if the devices are registered via OF.

Signed-off-by: Javier Martinez Canillas <javier@osg.samsung.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2017-03-19 10:58:28 +00:00
Javier Martinez Canillas 77496c078c iio: pressure: mpl3115: Add OF device ID table
The driver doesn't have a struct of_device_id table but supported devices
are registered via Device Trees. This is working on the assumption that a
I2C device registered via OF will always match a legacy I2C device ID and
that the MODALIAS reported will always be of the form i2c:<device>.

But this could change in the future so the correct approach is to have an
OF device ID table if the devices are registered via OF.

Signed-off-by: Javier Martinez Canillas <javier@osg.samsung.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2017-03-19 10:58:01 +00:00
Javier Martinez Canillas f414bb19b7 iio: accel: mma7455_i2c: Add OF device ID table
The driver doesn't have a struct of_device_id table but supported devices
are registered via Device Trees. This is working on the assumption that a
I2C device registered via OF will always match a legacy I2C device ID and
that the MODALIAS reported will always be of the form i2c:<device>.

But this could change in the future so the correct approach is to have an
OF device ID table if the devices are registered via OF.

Signed-off-by: Javier Martinez Canillas <javier@osg.samsung.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2017-03-19 10:57:43 +00:00
Javier Martinez Canillas ee9a90735b iio: magnetometer: mag3110: Add OF device ID table
The driver doesn't have a struct of_device_id table but supported devices
are registered via Device Trees. This is working on the assumption that a
I2C device registered via OF will always match a legacy I2C device ID and
that the MODALIAS reported will always be of the form i2c:<device>.

But this could change in the future so the correct approach is to have an
OF device ID table if the devices are registered via OF.

Signed-off-by: Javier Martinez Canillas <javier@osg.samsung.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2017-03-19 10:57:24 +00:00
Javier Martinez Canillas c172d22d33 iio: adc: ti-ads1015: Add OF device ID table
The driver doesn't have a struct of_device_id table but supported devices
are registered via Device Trees. This is working on the assumption that a
I2C device registered via OF will always match a legacy I2C device ID and
that the MODALIAS reported will always be of the form i2c:<device>.

But this could change in the future so the correct approach is to have an
OF device ID table if the devices are registered via OF.

Signed-off-by: Javier Martinez Canillas <javier@osg.samsung.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2017-03-19 10:56:58 +00:00
Javier Martinez Canillas 7373340367 iio: dac: max5821: Set .of_match_table to OF device ID table
The driver has a OF device ID table but the struct i2c_driver
.of_match_table field is not set.

Signed-off-by: Javier Martinez Canillas <javier@osg.samsung.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2017-03-19 10:56:26 +00:00
Javier Martinez Canillas ae4e825b88 iio: light: apds9960: Add OF device ID table
The driver doesn't have a struct of_device_id table but supported devices
are registered via Device Trees. This is working on the assumption that a
I2C device registered via OF will always match a legacy I2C device ID and
that the MODALIAS reported will always be of the form i2c:<device>.

But this could change in the future so the correct approach is to have an
OF device ID table if the devices are registered via OF.

Signed-off-by: Javier Martinez Canillas <javier@osg.samsung.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2017-03-19 10:55:42 +00:00
Javier Martinez Canillas 16f1b4f0ba iio: accel: bma180: Add OF device ID table
The driver doesn't have a struct of_device_id table but supported devices
are registered via Device Trees. This is working on the assumption that a
I2C device registered via OF will always match a legacy I2C device ID and
that the MODALIAS reported will always be of the form i2c:<device>.

But this could change in the future so the correct approach is to have an
OF device ID table if the devices are registered via OF.

Signed-off-by: Javier Martinez Canillas <javier@osg.samsung.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2017-03-19 10:55:17 +00:00
Javier Martinez Canillas 34591a162f iio: imu: inv_mpu6050: Add OF device ID table
The driver doesn't have a struct of_device_id table but supported devices
are registered via Device Trees. This is working on the assumption that a
I2C device registered via OF will always match a legacy I2C device ID and
that the MODALIAS reported will always be of the form i2c:<device>.

But this could change in the future so the correct approach is to have an
OF device ID table if the devices are registered via OF.

Signed-off-by: Javier Martinez Canillas <javier@osg.samsung.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2017-03-19 10:54:43 +00:00
Javier Martinez Canillas 72fc0270a9 iio: pressure: hp03: Add OF device ID table
The driver doesn't have a struct of_device_id table but supported devices
are registered via Device Trees. This is working on the assumption that a
I2C device registered via OF will always match a legacy I2C device ID and
that the MODALIAS reported will always be of the form i2c:<device>.

But this could change in the future so the correct approach is to have an
OF device ID table if the devices are registered via OF.

Signed-off-by: Javier Martinez Canillas <javier@osg.samsung.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2017-03-19 10:53:39 +00:00
Javier Martinez Canillas 9d3922b236 iio: light: tsl2563: Add OF device ID table
The driver doesn't have a struct of_device_id table but supported devices
are registered via Device Trees. This is working on the assumption that a
I2C device registered via OF will always match a legacy I2C device ID and
that the MODALIAS reported will always be of the form i2c:<device>.

But this could change in the future so the correct approach is to have an
OF device ID table if the devices are registered via OF.

Signed-off-by: Javier Martinez Canillas <javier@osg.samsung.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2017-03-19 10:52:56 +00:00
Javier Martinez Canillas 152abf3770 iio: light: us5182d: Add OF device ID table
The driver doesn't have a struct of_device_id table but supported devices
are registered via Device Trees. This is working on the assumption that a
I2C device registered via OF will always match a legacy I2C device ID and
that the MODALIAS reported will always be of the form i2c:<device>.

But this could change in the future so the correct approach is to have an
OF device ID table if the devices are registered via OF.

Signed-off-by: Javier Martinez Canillas <javier@osg.samsung.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2017-03-19 10:52:03 +00:00
Javier Martinez Canillas 8414af1ed1 iio: dac: mcp4725: Add OF device ID table
The driver doesn't have a struct of_device_id table but supported devices
are registered via Device Trees. This is working on the assumption that a
I2C device registered via OF will always match a legacy I2C device ID and
that the MODALIAS reported will always be of the form i2c:<device>.

But this could change in the future so the correct approach is to have an
OF device ID table if the devices are registered via OF.

Signed-off-by: Javier Martinez Canillas <javier@osg.samsung.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2017-03-19 10:51:04 +00:00
Javier Martinez Canillas 49926b1216 iio: magnetometer: bmc150_magn_i2c: Add OF device ID table
The driver doesn't have a struct of_device_id table but supported devices
are registered via Device Trees. This is working on the assumption that a
I2C device registered via OF will always match a legacy I2C device ID and
that the MODALIAS reported will always be of the form i2c:<device>.

But this could change in the future so the correct approach is to have an
OF device ID table if the devices are registered via OF.

Signed-off-by: Javier Martinez Canillas <javier@osg.samsung.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2017-03-19 10:50:10 +00:00
Javier Martinez Canillas 58623b3377 iio: mlx96014: Add OF device ID table
The driver doesn't have a struct of_device_id table but supported devices
are registered via Device Trees. This is working on the assumption that a
I2C device registered via OF will always match a legacy I2C device ID and
that the MODALIAS reported will always be of the form i2c:<device>.

But this could change in the future so the correct approach is to have an
OF device ID table if the devices are registered via OF.

Signed-off-by: Javier Martinez Canillas <javier@osg.samsung.com>
Tested-by: Crt Mori <cmo@melexis.com>
Acked-by: Crt Mori <cmo@melexis.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2017-03-19 10:49:24 +00:00
Javier Martinez Canillas 62aaca0de9 iio: adc: ina2xx: Add OF device ID table
The driver doesn't have a struct of_device_id table but supported devices
are registered via Device Trees. This is working on the assumption that a
I2C device registered via OF will always match a legacy I2C device ID and
that the MODALIAS reported will always be of the form i2c:<device>.

But this could change in the future so the correct approach is to have an
OF device ID table if the devices are registered via OF.

Signed-off-by: Javier Martinez Canillas <javier@osg.samsung.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2017-03-19 10:47:53 +00:00
Lorenzo Bianconi 6985bd5e21 iio: imu: st_lsm6dsx: fix FIFO_CTRL2 overwrite during watermark configuration
Fixes: 290a6ce11d (iio: imu: add support to lsm6dsx driver)
Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@st.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2017-03-19 10:44:42 +00:00
Miguel Robles 7fa6790c22 iio: accel: Prefer unsigned int to bare use of unsigned
Fix checkpatch warnings:
WARNING: Prefer 'unsigned int' to bare use of 'unsigned'

Signed-off-by: Miguel Robles <miguel.robles@farole.net>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2017-03-19 10:37:21 +00:00
William Breathitt Gray 3c1de602f6 iio: pc104: Mask PC/104 drivers via the PC104 Kconfig option
PC/104 drivers should be hidden on machines which do not support PC/104
devices. This patch adds the PC104 Kconfig option as a dependency for
the relevant PC/104 device driver Kconfig options.

Cc: Jonathan Cameron <jic23@kernel.org>
Cc: Hartmut Knaack <knaack.h@gmx.de>
Cc: Lars-Peter Clausen <lars@metafoo.de>
Cc: Peter Meerwald-Stadler <pmeerw@pmeerw.net>
Signed-off-by: William Breathitt Gray <vilhelm.gray@gmail.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2017-03-15 21:59:08 +00:00
Michael Engl e83bb3e6f3 iio: adc: ti_am335x_adc: fix fifo overrun recovery
The tiadc_irq_h(int irq, void *private) function is handling FIFO
overruns by clearing flags, disabling and enabling the ADC to
recover.

If the ADC is running in continuous mode a FIFO overrun happens
regularly. If the disabling of the ADC happens concurrently with
a new conversion. It might happen that the enabling of the ADC
is ignored by the hardware. This stops the ADC permanently. No
more interrupts are triggered.

According to the AM335x Reference Manual (SPRUH73H October 2011 -
Revised April 2013 - Chapter 12.4 and 12.5) it is necessary to
check the ADC FSM bits in REG_ADCFSM before enabling the ADC
again. Because the disabling of the ADC is done right after the
current conversion has been finished.

To trigger this bug it is necessary to run the ADC in continuous
mode. The ADC values of all channels need to be read in an endless
loop. The bug appears within the first 6 hours (~5.4 million
handled FIFO overruns). The user space application will hang on
reading new values from the character device.

Fixes: ca9a563805 ("iio: ti_am335x_adc: Add continuous sampling
support")
Signed-off-by: Michael Engl <michael.engl@wjw-solutions.com>
Cc: <Stable@vger.kernel.org>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2017-03-15 19:47:23 +00:00
Quentin Schulz d1caa99055 iio: adc: add support for Allwinner SoCs ADC
The Allwinner SoCs all have an ADC that can also act as a touchscreen
controller and a thermal sensor. This patch adds the ADC driver which is
based on the MFD for the same SoCs ADC.

This also registers the thermal adc channel in the iio map array so
iio_hwmon could use it without modifying the Device Tree. This registers
the driver in the thermal framework.

The thermal sensor requires the IP to be in touchscreen mode to return
correct values. Therefore, if the user is continuously reading the ADC
channel(s), the thermal framework in which the thermal sensor is
registered will switch the IP in touchscreen mode to get a temperature
value and requires a delay of 100ms (because of the mode switching),
then the ADC will switch back to ADC mode and requires also a delay of
100ms. If the ADC readings are critical to user and the SoC temperature
is not, this driver is capable of not registering the thermal sensor in
the thermal framework and thus, "quicken" the ADC readings.

This driver probes on three different platform_device_id to take into
account slight differences (registers bit and temperature computation)
between Allwinner SoCs ADCs.

Signed-off-by: Quentin Schulz <quentin.schulz@free-electrons.com>
Acked-by: Maxime Ripard <maxime.ripard@free-electrons.com>
Acked-by: Jonathan Cameron <jic23@kernel.org>
Acked-for-MFD-by: Lee Jones <lee.jones@linaro.org>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2017-03-08 20:27:25 +00:00
Wei Yongjun db233ef8a3 iio: adc: max11100: remove .owner field for driver
Remove .owner field if calls are used which set it automatically.

Generated by: scripts/coccinelle/api/platform_no_drv_owner.cocci

Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2017-03-08 20:27:14 +00:00
Greg Kroah-Hartman 34ff6c2fe3 First set of IIO new device support, features and cleanup for the 4.12 cycle.
Quite a bit of outreachy activity here with a driver from a current intern
 and a number of cleanup patches as part of the next round.
 
 Getting a pull request in early this cycle as it's looking like another large
 cycle for IIO.
 
 New device support
 * adxl345
   - initial device support. Note, once complete support is done the intent
     is to superceded the driver in input/misc.
   - bindings.
   - conversion from i2c direct calls to regmap and driver split.
   - spi support.
 * chromeos light and proximity.
   - new driver.
 * devantech srf04 ultrasonic ranger
   - new driver with device tree bindings.
 * hid temperature
   - new driver for environemntal temperature support from hid devices.
 * max30102 oximeter
   - new driver with device tree bindings.
 * st lsm6dsx
   - refactor and addition of device support for lsm6dsl and lsm6ds3h.
 
 Staging graduation
 * isl29028 including copyright notice update to reflect Brian's work.
 * lpc32xx_adc.
 * spear adc. It's not perfect and there are some datasheet disagreements, but
   it works and is good enough to graduate.
 
 New features
 * documentation
   - abi docs for in_proximity_sampling_frequency_available.
   - generalise counting direction ABI docs as a second driver is going to
   use them.
 * hid-sensor-prox
   - Add support for HID_USAGE_SENSOR_HUMAN_PRESENCE if used on a particular
   device.
 * isl29028
   - runtime pm.
 * meson-saradc
   - switch from polling to interrupt mode and improved read_raw_sample function
   to avoid unnecessary loop.
 * tmp007
   - interrupt and threshold event support.
 
 Cleanups and minor fixes
 * ad2s1210
   - permissions to octal.
 * ad7192
   - permissions to octal.
   - use BIT macro.
 * ad9832
   - merge header definitions into source file.
 * ad9834
   - merge header definitions into source file.
 * ade7753
   - merge header definitions into source file.
   - cleanup include ordering.
 * ade7854
   - simplify return logic.
 * adis16201
   - merge header definitions into source file.
   - rename _core.c to .c as there is nothing else.
 * adis16203
   - merge header definitions into source file.
   - rename _core.c to .c as there is nothing else.
 * adis16209
   - merge header definitions into source file.
   - rename _core.c to .c as there is nothing else.
 * adis16240
   - permissions to octal.
   - merge header definitions into source file.
   - rename _core.c to .c as there is nothing else.
 * adt7136
   - permissions to octal.
 * cio-dac
   - set missing parent device.
 * documentation
   - update version numbers on sysfs ABI for counter bits that didn't quite.
   make 4.9.
 * isl29028
   - mdelay to msleep.
   - incorrrect sleep time when taking first proximity reading.
 * lmp91000
   - set missing parent device.
 * lpc32xx
   - Consistent prefixes for defines.
   - rename local state structure to _state.
 * max30100
   - set missing parent device.
 * max30102
   - set missing parent device.
 * maxim-thermocouple
   - set missing parent device.
 * meter driver header
   - permissions to octal.
 * pulsedlight-lidar-lite-v2
   - set missing parent device.
 * quad-8
   - set missing parent device.
 * st104
   - set missing parent device.
 
 Other
 * Mailmap
   - update Matt Ranostay's email address to the Konsolko one.
 -----BEGIN PGP SIGNATURE-----
 
 iQJFBAABCAAvFiEEbilms4eEBlKRJoGxVIU0mcT0FogFAli8K40RHGppYzIzQGtl
 cm5lbC5vcmcACgkQVIU0mcT0FogLWBAAoclyQ3AwUecfujFcGx/ZJuba63M+qPIk
 SvmUCocnCjfgLI5WnB4J6rMldoD7CMAhrOpFeFuJlr/g6f4WMToJVT6PdHEtMqvB
 Rci/ODa9QNDPBpA1sLGCFu704yzBxQTmq53V1d9kZBJ/FxTqwOZamStjKAC2EskX
 yuslGGGSdveIYfmBfHIY1VlT2xwuf9xmyhi0STAIn86ViATH/Hhz2xWNBjaHxTrs
 gJ6sLGmwh9RYO1KlXSUmbXHd9mWoME2iIsEVGsPzILPkHuHsjvVtjPmQkHB6cT8v
 W1OvYJqHz7CbOmcqOVCUbtho/sdw9uhdGkc+Vm9ilxukfVFu9I3cnTTV6um7rj76
 /bKf4qB0B/BlXgyfGdGY/gmotSI53sPeG7Vp0nd/5ZmYXKhP4NS+rRB1ipy71nGV
 YY/fmgrAobm3wrmWdMUOhBCH/hfN8aSR3S6exJarEejfIpOzu3GeVP8706krKvwO
 1HOHBVyJ5gt+WI18kvYC78Mhs5HVeKCSuHf8eJ1bZHOUoVtIHtN4HnF5wCa0on/t
 Qu0am0SW596J95EUVMsodNYXUTP6JwcQeKt65VvXSq2jcnqylPT95SuroVqZ3NNH
 Lpq7kfjfV4p/n6G9EUE/7+RBXZL0BboI7v8GbIvodfXmFk099mkEbHnpMRffc6XQ
 o1TUYqzAQPI=
 =rlqq
 -----END PGP SIGNATURE-----

Merge tag 'iio-for-4.12a' of git://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio into staging-next

Jonathan writes:

First set of IIO new device support, features and cleanup for the 4.12 cycle.

Quite a bit of outreachy activity here with a driver from a current intern
and a number of cleanup patches as part of the next round.

Getting a pull request in early this cycle as it's looking like another large
cycle for IIO.

New device support
* adxl345
  - initial device support. Note, once complete support is done the intent
    is to superceded the driver in input/misc.
  - bindings.
  - conversion from i2c direct calls to regmap and driver split.
  - spi support.
* chromeos light and proximity.
  - new driver.
* devantech srf04 ultrasonic ranger
  - new driver with device tree bindings.
* hid temperature
  - new driver for environemntal temperature support from hid devices.
* max30102 oximeter
  - new driver with device tree bindings.
* st lsm6dsx
  - refactor and addition of device support for lsm6dsl and lsm6ds3h.

Staging graduation
* isl29028 including copyright notice update to reflect Brian's work.
* lpc32xx_adc.
* spear adc. It's not perfect and there are some datasheet disagreements, but
  it works and is good enough to graduate.

New features
* documentation
  - abi docs for in_proximity_sampling_frequency_available.
  - generalise counting direction ABI docs as a second driver is going to
  use them.
* hid-sensor-prox
  - Add support for HID_USAGE_SENSOR_HUMAN_PRESENCE if used on a particular
  device.
* isl29028
  - runtime pm.
* meson-saradc
  - switch from polling to interrupt mode and improved read_raw_sample function
  to avoid unnecessary loop.
* tmp007
  - interrupt and threshold event support.

Cleanups and minor fixes
* ad2s1210
  - permissions to octal.
* ad7192
  - permissions to octal.
  - use BIT macro.
* ad9832
  - merge header definitions into source file.
* ad9834
  - merge header definitions into source file.
* ade7753
  - merge header definitions into source file.
  - cleanup include ordering.
* ade7854
  - simplify return logic.
* adis16201
  - merge header definitions into source file.
  - rename _core.c to .c as there is nothing else.
* adis16203
  - merge header definitions into source file.
  - rename _core.c to .c as there is nothing else.
* adis16209
  - merge header definitions into source file.
  - rename _core.c to .c as there is nothing else.
* adis16240
  - permissions to octal.
  - merge header definitions into source file.
  - rename _core.c to .c as there is nothing else.
* adt7136
  - permissions to octal.
* cio-dac
  - set missing parent device.
* documentation
  - update version numbers on sysfs ABI for counter bits that didn't quite.
  make 4.9.
* isl29028
  - mdelay to msleep.
  - incorrrect sleep time when taking first proximity reading.
* lmp91000
  - set missing parent device.
* lpc32xx
  - Consistent prefixes for defines.
  - rename local state structure to _state.
* max30100
  - set missing parent device.
* max30102
  - set missing parent device.
* maxim-thermocouple
  - set missing parent device.
* meter driver header
  - permissions to octal.
* pulsedlight-lidar-lite-v2
  - set missing parent device.
* quad-8
  - set missing parent device.
* st104
  - set missing parent device.

Other
* Mailmap
  - update Matt Ranostay's email address to the Konsolko one.
2017-03-06 13:17:21 +01:00
Dmitry Torokhov 3ff861f59f iio: magnetometer: ak8974: remove incorrect __exit markups
Even if bus is not hot-pluggable, devices can be unbound from the
driver via sysfs, so we should not be using __exit annotations on
remove() methods. The only exception is drivers registered with
platform_driver_probe() which specifically disables sysfs bind/unbind
attributes.

Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Cc: <stable@vger.kernel.org>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2017-03-05 13:52:01 +00:00
Song Hongyan 3bec247474 iio: hid-sensor-trigger: Change get poll value function order to avoid sensor properties losing after resume from S3
In function _hid_sensor_power_state(), when hid_sensor_read_poll_value()
is called, sensor's all properties will be updated by the value from
sensor hardware/firmware.
In some implementation, sensor hardware/firmware will do a power cycle
during S3. In this case, after resume, once hid_sensor_read_poll_value()
is called, sensor's all properties which are kept by driver during S3
will be changed to default value.
But instead, if a set feature function is called first, sensor
hardware/firmware will be recovered to the last status. So change the
sensor_hub_set_feature() calling order to behind of set feature function
to avoid sensor properties lose.

Signed-off-by: Song Hongyan <hongyan.song@intel.com>
Acked-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Cc: <Stable@vger.kernel.org>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2017-03-05 10:26:47 +00:00
Linus Torvalds 91aff98b79 Staging/IIO driver fixes for 4.11-rc1
Here are a few small staging and IIO driver fixes for issues that showed
 up after the big set if changes you merged last week.
 
 Nothing major, just small bugs resolved in some IIO drivers, a lustre
 allocation fix, and some RaspberryPi driver fixes for reported problems,
 as well as a MAINTAINERS entry update.
 
 All of these have been in linux-next for a week with no reported issues.
 
 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
 -----BEGIN PGP SIGNATURE-----
 
 iG0EABECAC0WIQT0tgzFv3jCIUoxPcsxR9QN2y37KQUCWLpyRg8cZ3JlZ0Brcm9h
 aC5jb20ACgkQMUfUDdst+ynFRwCglHKVpiXmfJmXhP5PwYlc2Ji/0TEAnAhsFKgA
 PZCq+XiZqerupIobBbm6
 =oHZ8
 -----END PGP SIGNATURE-----

Merge tag 'staging-4.11-rc1-part2' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging

Pull staging/IIO driver fixes from Greg KH:
 "Here are a few small staging and IIO driver fixes for issues that
  showed up after the big set if changes you merged last week.

  Nothing major, just small bugs resolved in some IIO drivers, a lustre
  allocation fix, and some RaspberryPi driver fixes for reported
  problems, as well as a MAINTAINERS entry update.

  All of these have been in linux-next for a week with no reported
  issues"

* tag 'staging-4.11-rc1-part2' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging:
  staging: fsl-mc: fix warning in DT ranges parser
  MAINTAINERS: Remove Noralf Trønnes as fbtft maintainer
  staging: vchiq_2835_arm: Make cache-line-size a required DT property
  staging: bcm2835/mmal-vchiq: unlock on error in buffer_from_host()
  staging/lustre/lnet: Fix allocation size for sv_cpt_data
  iio: adc: xilinx: Fix error handling
  iio: 104-quad-8: Fix off-by-one error when addressing flag register
  iio: adc: handle unknow of_device_id data
2017-03-04 11:26:18 -08:00
Song Hongyan 59d0f2da35 iio: hid: Add temperature sensor support
Environmental temperature sensor is a hid defined sensor,
it measures temperature.

More information can be found in:
http://www.usb.org/developers/hidpage/HUTRR39b.pdf

According to IIO ABI definition, IIO_TEMP data output unit is
milli degrees Celsius. Add the unit convert from degree to milli degree.

Signed-off-by: Song Hongyan <hongyan.song@intel.com>
Acked-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2017-03-04 18:45:26 +00:00
Eva Rachel Retuya fb0e5250a8 iio: accel: adxl345: Add SPI support
Add SPI driver that initializes SPI regmap for the adxl345 core driver.
The driver supports the same functionality as I2C namely the x, y, z and
scale readings.

Signed-off-by: Eva Rachel Retuya <eraretuya@gmail.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2017-03-04 16:49:28 +00:00
Eva Rachel Retuya 5170512cf6 iio: accel: adxl345: Split driver into core and I2C
Move I2C-specific code into its own file and rely on regmap to access
registers. The core code provides access to x, y, z and scale readings.

Signed-off-by: Eva Rachel Retuya <eraretuya@gmail.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2017-03-04 16:45:08 +00:00
Eva Rachel Retuya 31fd2c70b2 iio: accel: adxl345: Use I2C regmap instead of direct I2C access
Convert the driver to use regmap instead of I2C-specific functions. This
is done in preparation for splitting this driver into core and
I2C-specific code as well as introduction of SPI driver.

Signed-off-by: Eva Rachel Retuya <eraretuya@gmail.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2017-03-04 16:41:27 +00:00
Ingo Molnar 174cd4b1e5 sched/headers: Prepare to move signal wakeup & sigpending methods from <linux/sched.h> into <linux/sched/signal.h>
Fix up affected files that include this signal functionality via sched.h.

Acked-by: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Ingo Molnar <mingo@kernel.org>
2017-03-02 08:42:32 +01:00
Greg Kroah-Hartman 7aa2a92c49 Second set of IIO fixes for IIO in the 4.11 cycle.
This series consists of fixes that either came in after the merge window
 had opened or are fixes for work that merged during the merge window so had
 to wait for that to hit mainline.
 
 * 104-quad-8
   - Fix an off by one error in the register address for the flag register.
 * rcar-gyroadc
   - protect against possible issues in future by dealing with childmode not
     being in a valid state.  This also deals with some build warnings.
 * xilinx
   - fix some error handling paths to ensure resources are released in
     reverse order of being acquired.
 -----BEGIN PGP SIGNATURE-----
 
 iQJFBAABCAAvFiEEbilms4eEBlKRJoGxVIU0mcT0FogFAlixzPgRHGppYzIzQGtl
 cm5lbC5vcmcACgkQVIU0mcT0FohnJw/+JQa8wHUc0RORLD42ahAdjxZBpGyEjvYo
 R/F22n/kOlyUarGLyRql3RnlT5gxKA+DCLu9B5w0U888LCQMixl+EmbG+lOtI0yf
 OPBsop4iVp4S65D6LYjWxYCWcYd9uaahFykQX6ODbOGrmMcIzpXAqzoLAaiF/sMX
 jleXlczU0a++t1yOkjKvGjGHIbtm7BbOK4K4W4WCdZ/PExgeYgmw97XtKS1YXyXO
 GEK0cgFTAS8uGBKYxkZaY4i7V0SCsstlyF/aZmm8YVJOrK+3vtNR7/KtpgXjMEgF
 6JbA16QKlr730BH6iPVXWJngL5qQSIAUjaRNumIlfXQou5QLW/geycjtfKVrhc/K
 Z8V1t8U9BJH8DCCP6NzZYmfsZWnRVDpQcIMfOWs9i9d2PzHKItUt2T/xSw3DatnD
 U9HymqIQrKhMcva0j0BW/H4qRqqSyy82+eAq9/99IwPrga3Hh+e1RIOd1TkCTIZK
 tu4LlEeW7Q7ne2MYhVjghQ/741/c1P79rXgvKfKoVe4DurKcA0dDO798oDicMVGc
 nflShEO7qjKwEeEXl0NLfzEUrdatIXVSoC2/spiNXI+7xWwdEnmJFZueI8RU8Xpq
 LxAKwaov6E/KrA/Lbmn5AqJF89/rP5NjkyyyKC+mTNG29dx/QuXXqPSRe+pyM2TZ
 pGNdH/se8Ko=
 =FhF5
 -----END PGP SIGNATURE-----

Merge tag 'iio-fixes-for-4.11b' of git://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio into staging-linus

Jonathan writes:

Second set of IIO fixes for IIO in the 4.11 cycle.

This series consists of fixes that either came in after the merge window
had opened or are fixes for work that merged during the merge window so had
to wait for that to hit mainline.

* 104-quad-8
  - Fix an off by one error in the register address for the flag register.
* rcar-gyroadc
  - protect against possible issues in future by dealing with childmode not
    being in a valid state.  This also deals with some build warnings.
* xilinx
  - fix some error handling paths to ensure resources are released in
    reverse order of being acquired.
2017-02-26 16:59:15 +01:00
Song Hongyan b010500281 hid: hid-sensor-prox: Add more data field for hysteresis parsing
Add HID_USAGE_SENSOR_HUMAN_PRESENCE support for Human Presence sensitivity
parsing, in case some implementation uses it as sensitivity modifier.

Signed-off-by: Song Hongyan <hongyan.song@intel.com>
Acked-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2017-02-25 16:43:18 +00:00
Christophe JAILLET ca1c39ef76 iio: adc: xilinx: Fix error handling
Reorder error handling labels in order to match the way resources have
been allocated.

Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Acked-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2017-02-25 16:39:32 +00:00
Heiner Kallweit 6a882a2cbe iio: adc: meson-saradc: improve meson_sar_adc_read_raw_sample
After sampling there should always be only one value in the FIFO.
This also applies to averaging mode as the averaging is done
chip-internally. So we don't have to loop and let the driver
complain if there's not exactly one value in the FIFO.

If the value belongs to a different channel then don't silently
swallow the value but complain.

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
Acked-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2017-02-19 12:53:27 +00:00
Heiner Kallweit 3af109131b iio: adc: meson-saradc: switch from polling to interrupt mode
Switch from polling to interrupt mode.

Successfully tested on a S905GXBB-based Odroid C2.

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
Acked-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
Tested-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2017-02-19 12:51:42 +00:00
Lars-Peter Clausen 74e2419b00 iio: maxim_thermocouple: Set parent device
Initialize the parent of the IIO device to the device that registered it.
This makes sure that the IIO device appears the right level in the device
hierarchy.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2017-02-19 12:03:33 +00:00
Lars-Peter Clausen b2027d16df iio: pulsedlight-lidar-lite-v2: Set parent device
Initialize the parent of the IIO device to the device that registered it.
This makes sure that the IIO device appears the right level in the device
hierarchy.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Reviewed-by: Matt Ranostay <matt.ranostay@konsulko.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2017-02-19 12:02:31 +00:00
Lars-Peter Clausen e78c1f5710 iio: lmp91000: Set parent device
Initialize the parent of the IIO device to the device that registered it.
This makes sure that the IIO device appears the right level in the device
hierarchy.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Reviewed-by: Matt Ranostay <matt.ranostay@konsulko.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2017-02-19 12:01:52 +00:00
Lars-Peter Clausen fa722499bb iio: max30102: Set parent device
Initialize the parent of the IIO device to the device that registered it.
This makes sure that the IIO device appears the right level in the device
hierarchy.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2017-02-19 12:00:16 +00:00
Lars-Peter Clausen 5d548b733e iio: max30100: Set parent device
Initialize the parent of the IIO device to the device that registered it.
This makes sure that the IIO device appears the right level in the device
hierarchy.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2017-02-19 11:59:36 +00:00
Lars-Peter Clausen 83535359c4 iio: cio-dac: Set parent device
Initialize the parent of the IIO device to the device that registered it.
This makes sure that the IIO device appears the right level in the device
hierarchy.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Acked-by: William Breathitt Gray <vilhelm.gray@gmail.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2017-02-19 11:58:19 +00:00
Lars-Peter Clausen ed165e9171 iio: quad-8: Set parent device
Initialize the parent of the IIO device to the device that registered it.
This makes sure that the IIO device appears the right level in the device
hierarchy.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Acked-by: William Breathitt Gray <vilhelm.gray@gmail.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2017-02-19 11:57:16 +00:00
Lars-Peter Clausen c5c7d1f34c iio: stx104: Set parent device
Initialize the parent of the IIO device to the device that registered it.
This makes sure that the IIO device appears the right level in the device
hierarchy.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Acked-by: William Breathitt Gray <vilhelm.gray@gmail.com
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2017-02-19 11:53:05 +00:00
Greg Kroah-Hartman b96dea60bc First set of IIO fixes for the 4.11 cycle. Regression fixes from 4.10.
These are fixes that came in just to late for the 4.10 cycle.
 
 Two drivers made an accidental assumption of structure arrangement for
 struct iio_dev that are no longer true.  It was a typo in the first place
 that happened to work until some elements were added to the structure.
 
 * mpl3115
   - don't rely on structure field ordering
 * mpl115
   - don't rely on structure field ordering.
 -----BEGIN PGP SIGNATURE-----
 
 iQJFBAABCAAvFiEEbilms4eEBlKRJoGxVIU0mcT0FogFAlie07IRHGppYzIzQGtl
 cm5lbC5vcmcACgkQVIU0mcT0Fohcpg//XXnNnUq4K90bM7krxcM0+0iQze5ZJOUJ
 BqXV8IfFicbeeo0a463g0wcYAJ1kmzNJV3eqMhCUC7seYoqQ6ji1FCPN0qw/TSv1
 Mc9pE15i3GJ3vjsWKWMr0Bc0Gg+Ccah0aO/P3eatuwtvakZfPeUpvZakWBdkr1mP
 97OlBm0BdOBF8tXJ9KAEe3rB/pJDLc2JNpIIlRi8hitw+GRpnhdZzLpwbZKG6Ytf
 ozT3IUC7LpnolCfpnzvCkSpHZnAr22MVPXkHLK7a4Vb/C3mTjJVsKjTdXN60luh3
 C0hcN3IWyb/KAwLPSK9dqbkQBvoDSOtG8EGBeZoXdc1lHtia90Qp3hTeINDwRvPl
 un37OUYdEOtZ4JPG7FGHvgdc8bhkUJv2ZHITZWaIdZJAVj8DOWfQcydtxjHP/t8k
 mtgcg+OMCkgihN97kLqYS1dJnZIy3PwxoooDOJ0KB8/S8N3SbaWOFfuGWYaQikVL
 IIRA7CyWI3yEjioqfWc/ujXUgjhFNc7XC9M44huEg+ysExW5OamsoVtbEoqCOVIm
 s7NwoyRbjaDHzaLiulX/eCzb1C02PV0wof3NrPMv4T3Ao4L4cG34Pe5zOcKAPWr4
 WefoZATobg6AmMEuK4CYtP3l0mInVw7vSGPfW9+D+3PppA8QRLCWgFbO0CENnMVM
 K4oBg9E7Sd0=
 =DW22
 -----END PGP SIGNATURE-----

Merge tag 'iio-fixes-for-4.11a' of git://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio into staging-next

Jonathan writes:

First set of IIO fixes for the 4.11 cycle. Regression fixes from 4.10.

These are fixes that came in just to late for the 4.10 cycle.

Two drivers made an accidental assumption of structure arrangement for
struct iio_dev that are no longer true.  It was a typo in the first place
that happened to work until some elements were added to the structure.

* mpl3115
  - don't rely on structure field ordering
* mpl115
  - don't rely on structure field ordering.
2017-02-11 16:46:03 +01:00
Jonathan Cameron 0097e20e77 staging:iio:adc:lpc32xx Move out of staging.
There are a few more little cleanups that could be done on this driver, but
I don't think any are sufficient to justify not moving it out of staging.

It's a very simple driver (presumably for a simple part) so not much that can
go wrong.  I think it was only ever in staging because that's where IIO was
as a whole at the time and then we forgot about it!

Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Cc: Roland Stigge <stigge@antcom.de>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2017-02-11 11:19:25 +00:00
Jonathan Cameron af8f651b39 staging:iio:adc:spear Move out of staging.
There are some unanswered questions due to disagreements between the code
and various datasheets (including between different datasheets for the same
part).

I don't think that is necessarily a reason to keep it in staging however.
I'm partly posting this patch inorder to reignite debate and with a bit
of luck find someone who has one of these to test!

Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2017-02-11 11:17:33 +00:00
William Breathitt Gray ca8d8e03b4 iio: 104-quad-8: Fix off-by-one error when addressing flag register
The flag register is offset by 1 from the respective channel data
register. This patch fixes an off-by-one error when attempting to read a
channel flag register where the base address was not properly offset.

Fixes: 28e5d3bb03 ("iio: 104-quad-8: Add IIO support for the ACCES 104-QUAD-8")
Signed-off-by: William Breathitt Gray <vilhelm.gray@gmail.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2017-02-11 09:36:38 +00:00
Peter Rosin 6a6e1d56a0 iio: pressure: mpl115: do not rely on structure field ordering
Fixes a regression triggered by a change in the layout of
struct iio_chan_spec, but the real bug is in the driver which assumed
a specific structure layout in the first place. Hint: the three bits were
not OR:ed together as implied by the indentation prior to this patch,
there was a comma between the first two, which accidentally moved the
..._SCALE and ..._OFFSET bits to the next structure field. That field
was .info_mask_shared_by_type before the _available attributes was added
by commit 5123960007 ("iio:core: add a callback to allow drivers to
provide _available attributes") and .info_mask_separate_available
afterwards, and the regression happened.

info_mask_shared_by_type is actually a better choice than the originally
intended info_mask_separate for the ..._SCALE and ..._OFFSET bits since
a constant is returned from mpl115_read_raw for the scale/offset. Using
info_mask_shared_by_type also preserves the behavior from before the
regression and is therefore less likely to cause other interesting side
effects.

The above mentioned regression causes unintended sysfs attibutes to
show up that are not backed by code, in turn causing a NULL pointer
defererence to happen on access.

Fixes: 3017d90e89 ("iio: Add Freescale MPL115A2 pressure / temperature sensor driver")
Fixes: 5123960007 ("iio:core: add a callback to allow drivers to provide _available attributes")
Signed-off-by: Peter Rosin <peda@axentia.se>
Cc: <Stable@vger.kernel.org>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2017-02-11 09:00:44 +00:00
Peter Rosin 9cf6cdba58 iio: pressure: mpl3115: do not rely on structure field ordering
Fixes a regression triggered by a change in the layout of
struct iio_chan_spec, but the real bug is in the driver which assumed
a specific structure layout in the first place. Hint: the two bits were
not OR:ed together as implied by the indentation prior to this patch,
there was a comma between them, which accidentally moved the ..._SCALE
bit to the next structure field. That field was .info_mask_shared_by_type
before the _available attributes was added by commit 5123960007
("iio:core: add a callback to allow drivers to provide _available
attributes") and .info_mask_separate_available afterwards, and the
regression happened.

info_mask_shared_by_type is actually a better choice than the originally
intended info_mask_separate for the ..._SCALE bit since a constant is
returned from mpl3115_read_raw for the scale. Using
info_mask_shared_by_type also preserves the behavior from before the
regression and is therefore less likely to cause other interesting side
effects.

The above mentioned regression causes an unintended sysfs attibute to
show up that is not backed by code, in turn causing the following NULL
pointer defererence to happen on access.

Segmentation fault

Unable to handle kernel NULL pointer dereference at virtual address 00000000
pgd = ecc3c000
[00000000] *pgd=87f91831
Internal error: Oops: 80000007 [#1] SMP ARM
Modules linked in:
CPU: 1 PID: 1051 Comm: cat Not tainted 4.10.0-rc5-00009-gffd8858-dirty #3
Hardware name: Freescale i.MX6 Quad/DualLite (Device Tree)
task: ed54ec00 task.stack: ee2bc000
PC is at 0x0
LR is at iio_read_channel_info_avail+0x40/0x280
pc : [<00000000>]    lr : [<c06fbc1c>]    psr: a0070013
sp : ee2bdda8  ip : 00000000  fp : ee2bddf4
r10: c0a53c74  r9 : ed79f000  r8 : ee8d1018
r7 : 00001000  r6 : 00000fff  r5 : ee8b9a00  r4 : ed79f000
r3 : ee2bddc4  r2 : ee2bddbc  r1 : c0a86dcc  r0 : ee8d1000
Flags: NzCv  IRQs on  FIQs on  Mode SVC_32  ISA ARM  Segment none
Control: 10c5387d  Table: 3cc3c04a  DAC: 00000051
Process cat (pid: 1051, stack limit = 0xee2bc210)
Stack: (0xee2bdda8 to 0xee2be000)
dda0:                   ee2bddc0 00000002 c016d720 c016d394 ed54ec00 00000000
ddc0: 60070013 ed413780 00000001 edffd480 ee8b9a00 00000fff 00001000 ee8d1018
dde0: ed79f000 c0a53c74 ee2bde0c ee2bddf8 c0513c58 c06fbbe8 edffd480 edffd540
de00: ee2bde3c ee2bde10 c0293474 c0513c40 c02933e4 ee2bde60 00000001 ed413780
de20: 00000001 ed413780 00000000 edffd480 ee2bde4c ee2bde40 c0291d00 c02933f0
de40: ee2bde9c ee2bde50 c024679c c0291ce0 edffd4b0 b6e37000 00020000 ee2bdf78
de60: 00000000 00000000 ed54ec00 ed013200 00000817 c0a111fc edffd540 ed413780
de80: b6e37000 00020000 00020000 ee2bdf78 ee2bded4 ee2bdea0 c0292890 c0246604
dea0: c0117940 c016ba50 00000025 c0a111fc b6e37000 ed413780 ee2bdf78 00020000
dec0: ee2bc000 b6e37000 ee2bdf44 ee2bded8 c021d158 c0292770 c0117764 b6e36004
dee0: c0f0d7c4 ee2bdfb0 b6f89228 00021008 ee2bdfac ee2bdf00 c0101374 c0117770
df00: 00000000 00000000 ee2bc000 00000000 ee2bdf34 ee2bdf20 c016ba04 c0171080
df20: 00000000 00020000 ed413780 b6e37000 00000000 ee2bdf78 ee2bdf74 ee2bdf48
df40: c021e7a0 c021d130 c023e300 c023e280 ee2bdf74 00000000 00000000 ed413780
df60: ed413780 00020000 ee2bdfa4 ee2bdf78 c021e870 c021e71c 00000000 00000000
df80: 00020000 00020000 b6e37000 00000003 c0108084 00000000 00000000 ee2bdfa8
dfa0: c0107ee0 c021e838 00020000 00020000 00000003 b6e37000 00020000 0001a2b4
dfc0: 00020000 00020000 b6e37000 00000003 7fffe000 00000000 00000000 00020000
dfe0: 00000000 be98eb4c 0000c740 b6f1985c 60070010 00000003 00000000 00000000
Backtrace:
[<c06fbbdc>] (iio_read_channel_info_avail) from [<c0513c58>] (dev_attr_show+0x24/0x50)
 r10:c0a53c74 r9:ed79f000 r8:ee8d1018 r7:00001000 r6:00000fff r5:ee8b9a00
 r4:edffd480
[<c0513c34>] (dev_attr_show) from [<c0293474>] (sysfs_kf_seq_show+0x90/0x110)
 r5:edffd540 r4:edffd480
[<c02933e4>] (sysfs_kf_seq_show) from [<c0291d00>] (kernfs_seq_show+0x2c/0x30)
 r10:edffd480 r9:00000000 r8:ed413780 r7:00000001 r6:ed413780 r5:00000001
 r4:ee2bde60 r3:c02933e4
[<c0291cd4>] (kernfs_seq_show) from [<c024679c>] (seq_read+0x1a4/0x4e0)
[<c02465f8>] (seq_read) from [<c0292890>] (kernfs_fop_read+0x12c/0x1cc)
 r10:ee2bdf78 r9:00020000 r8:00020000 r7:b6e37000 r6:ed413780 r5:edffd540
 r4:c0a111fc
[<c0292764>] (kernfs_fop_read) from [<c021d158>] (__vfs_read+0x34/0x118)
 r10:b6e37000 r9:ee2bc000 r8:00020000 r7:ee2bdf78 r6:ed413780 r5:b6e37000
 r4:c0a111fc
[<c021d124>] (__vfs_read) from [<c021e7a0>] (vfs_read+0x90/0x11c)
 r8:ee2bdf78 r7:00000000 r6:b6e37000 r5:ed413780 r4:00020000
[<c021e710>] (vfs_read) from [<c021e870>] (SyS_read+0x44/0x90)
 r8:00020000 r7:ed413780 r6:ed413780 r5:00000000 r4:00000000
[<c021e82c>] (SyS_read) from [<c0107ee0>] (ret_fast_syscall+0x0/0x1c)
 r10:00000000 r8:c0108084 r7:00000003 r6:b6e37000 r5:00020000 r4:00020000
Code: bad PC value
---[ end trace 9c4938ccd0389004 ]---

Fixes: cc26ad455f ("iio: Add Freescale MPL3115A2 pressure / temperature sensor driver")
Fixes: 5123960007 ("iio:core: add a callback to allow drivers to provide _available attributes")
Reported-by: Ken Lin <ken.lin@advantech.com>
Tested-by: Ken Lin <ken.lin@advantech.com>
Signed-off-by: Peter Rosin <peda@axentia.se>
Cc: <Stable@vger.kernel.org>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2017-02-11 09:00:20 +00:00
Greg Kroah-Hartman a769f30c7b Merge 4.10-rc7 into staging-next
This resolves the merge errors that were reported in linux-next and it
picks up the staging and IIO fixes that we need/want in here as well.

Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-02-06 09:36:10 +01:00
Manivannan Sadhasivam 7c5bc7e87c iio:temperature:tmp007: Add irq and threshold events support
This patch adds ALERT irq and limit threshold events support for TI TMP007 - 16 bit IR thermopile sensor with integrated
math engine.

Following threshold events are supported:
1. TObj high limit
2. TObj low limit
3. TDie high limit
4. TDie low limit

Signed-off-by: Manivannan Sadhasivam <manivannanece23@gmail.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2017-02-05 10:28:25 +00:00
Matt Ranostay b3c590ce14 iio: health: add MAX30102 oximeter driver support
MAX30102 is an heart rate and pulse oximeter sensor that works using
two LEDS of different wavelengths, and detecting the light reflected
back.

This patchset adds support for both IR and RED LED channels which can
be processed in userspace to determine heart rate and blood oxygen
levels. The MAX30102 part isn't completely register and functional
compatible with the existing MAX30100 driver.

Signed-off-by: Matt Ranostay <matt@ranostay.consulting>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2017-02-05 09:45:00 +00:00
Arnd Bergmann 17fa2dcbd6 iio: adc: handle unknow of_device_id data
If we get an unknown 'childmode' value, a number of variables are not
initialized properly:

drivers/iio/adc/rcar-gyroadc.c: In function 'rcar_gyroadc_probe':
drivers/iio/adc/rcar-gyroadc.c:390:5: error: 'num_channels' may be used uninitialized in this function [-Werror=maybe-uninitialized]
drivers/iio/adc/rcar-gyroadc.c:426:22: error: 'sample_width' may be used uninitialized in this function [-Werror=maybe-uninitialized]
drivers/iio/adc/rcar-gyroadc.c:428:23: error: 'channels' may be used uninitialized in this function [-Werror=maybe-uninitialized]

The driver is currently correct, but handling this properly is more robust
for possible modifications.

There is also a false-positive warning about adcmode being possibly uninitialized,
but that cannot happen as we also check the 'first' flag:

drivers/iio/adc/rcar-gyroadc.c:398:26: error: 'adcmode' may be used uninitialized in this function [-Werror=maybe-uninitialized]

This adds an initialization for 'adcmode' and bails out for any unknown childmode.

Fixes: 059c53b323 ("iio: adc: Add Renesas GyroADC driver")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Acked-by: Marek Vasut <marek.vasut@gmail.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2017-02-05 09:30:15 +00:00
Eva Rachel Retuya c62360753e iio: accel: Add driver for the Analog Devices ADXL345 3-axis accelerometer
Add basic IIO support for the Analog Devices ADXL345 3-axis accelerometer.
The datasheet can be found here:
http://www.analog.com/media/en/technical-documentation/data-sheets/ADXL345.pdf

Signed-off-by: Eva Rachel Retuya <eraretuya@gmail.com>
Cc: Michael Hennerich <michael.hennerich@analog.com>
Cc: Daniel Baluta <daniel.baluta@gmail.com>
Cc: Alison Schofield <amsfield22@gmail.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2017-02-05 09:08:40 +00:00
Gwendal Grignou 48458b0c19 iio: cros_ec_light_prox: add ChromeOS EC Light and Proximity Sensors
Handle Light and Proximity sensors presented by the ChromeOS EC Sensor hub.
Creates an IIO device for each functions.

Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
Signed-off-by: Guenter Roeck <groeck@chromium.org>
Signed-off-by: Enric Balletbo i Serra <enric.balletbo@collabora.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2017-02-04 12:29:52 +00:00
Lorenzo Bianconi df47710a6e iio: imu: st_lsm6dsx: add support to lsm6ds3h
Add support to STM LSM6DS3H 6-axis (acc + gyro) Mems sensor

http://www.st.com/resource/en/datasheet/lsm6ds3h.pdf
Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@st.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2017-02-04 12:25:05 +00:00
Lorenzo Bianconi 0b2a3e5f17 iio: imu: st_lsm6dsx: add support to lsm6dsl
Add support to STM LSM6DSL 6-axis (acc + gyro) Mems sensor

http://www.st.com/resource/en/datasheet/lsm6dsl.pdf
Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@st.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2017-02-04 12:23:37 +00:00
Lorenzo Bianconi d068e4a0f9 iio: imu: st_lsm6dsx: add support to multiple devices with the same settings
Add capability to support multiple devices with the same
st_lsm6dsx_settings like LSM6DSM/LSM6DSL

Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@st.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2017-02-04 12:22:51 +00:00
Andreas Klinger feda284004 iio: distance: add devantech us ranger srf04
This patch adds support for the ultrasonic ranger srf04 of devantech.

This device is measuring the distance of objects in a range between 1 cm
and 3 meters and a theoretical resolution of 3 mm.

There are two GPIOs used:
  - trigger: set as output to the device when the measurement should start
  - echo: set by the device when the ultrasonic wave is sent out and reset
    when the echo is recognized; this needs to be an interrupt input

The time between setting and resetting the echo pin is the time the
waveform needed for one round trip. This time is recorded in the interrupt
handler.

The distance is calculated in the read function by using the ultrasonic
speed at 20 degrees celsius which is about 343 m/s.

Signed-off-by: Andreas Klinger <ak@it-klinger.de>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2017-02-04 12:19:20 +00:00
William Breathitt Gray bfe7288e0d iio: stx104: Add GPIO set_multiple callback function support
The Apex Embedded Systems STX104 series provides a digital output
register where 4 lines may be set at a time. This patch add support for
the set_multiple callback function, thus allowing multiple digital
output lines to be set more efficiently in groups.

Cc: Jonathan Cameron <jic23@kernel.org>
Cc: Hartmut Knaack <knaack.h@gmx.de>
Cc: Lars-Peter Clausen <lars@metafoo.de>
Cc: Peter Meerwald-Stadler <pmeerw@pmeerw.net>
Signed-off-by: William Breathitt Gray <vilhelm.gray@gmail.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2017-02-01 18:50:54 +00:00
William Breathitt Gray 7d816e54b8 iio: stx104: Add support for GPIO names
This patch sets the gpio_chip names option with an array of GPIO line
names that match the manual documentation for the Apex Embedded Systems
STX104. This should make it easier for users to identify which GPIO line
corresponds to a respective GPIO pin on the device.

Signed-off-by: William Breathitt Gray <vilhelm.gray@gmail.com>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2017-01-31 18:54:04 +00:00
Lars-Peter Clausen 87ac0c24bd iio: tmp007: Fix `name` attribute ABI
The IIO ABI specifies the name field of the IIO device as:

	Description of the physical chip / device for device X.
	Typically a part number.

The tmp007 driver currently uses the name of the parent device instead.
Change this to the part name to be in accordance with the ABI.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2017-01-30 20:38:13 +00:00
William Breathitt Gray 6705e1277c iio: stx104: Remove unneeded struct stx104_dev code
The stx104_dev structure was used to hold private data for use in the
stx104_remove function. Now that the stx104_remove function is gone, the
stx104_dev structure and relevant code is no longer needed. This patch
removes the unnecessary code.

Signed-off-by: William Breathitt Gray <vilhelm.gray@gmail.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2017-01-30 20:05:14 +00:00
Fabrice Gasnier 2763ea0585 iio: adc: stm32: add optional dma support
Add DMA optional support to STM32 ADC, as there is a limited number DMA
channels (request lines) that can be assigned to ADC. This way, driver
may fall back using interrupts when all DMA channels are in use for
other IPs.
Use dma cyclic mode with two periods. Allow to tune period length by
using watermark. Coherent memory is used for dma (max buffer size is
fixed to PAGE_SIZE).

Signed-off-by: Fabrice Gasnier <fabrice.gasnier@st.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2017-01-29 12:49:17 +00:00
Fabrice Gasnier 732f2dc468 iio: adc: stm32: add trigger polarity extended attribute
Define extended attribute so that user may choose rising, falling or both
edges for external trigger sources.
Default to rising edge in case it isn't set.

Signed-off-by: Fabrice Gasnier <fabrice.gasnier@st.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2017-01-28 18:24:57 +00:00
Fabrice Gasnier f24a33b3e2 iio: adc: stm32: Enable use of stm32 timer triggers
STM32 ADC has external timer trigger sources. Use stm32 timer triggers
API (e.g. is_stm32_timer_trigger()) with local ADC lookup table to
validate a trigger can be used.
This also provides correct trigger selection value (e.g. extsel).

Signed-off-by: Fabrice Gasnier <fabrice.gasnier@st.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2017-01-28 18:24:12 +00:00
Fabrice Gasnier da9b948514 iio: adc: stm32: add support for triggered buffer mode
STM32 ADC conversions can be launched using hardware triggers.
It can be used to start conversion sequences (group of channels).
Selected channels are select via sequence registers.
Trigger source is selected via 'extsel' (external trigger mux).
Trigger polarity is set to rising edge by default.

Signed-off-by: Fabrice Gasnier <fabrice.gasnier@st.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2017-01-28 18:23:46 +00:00
Jonathan Cameron 6db0f7ccc9 Immutable branch between MFD, IIO and PWM due for the v4.11 merge window
-----BEGIN PGP SIGNATURE-----
 Version: GnuPG v1
 
 iQIcBAABAgAGBQJYiNNFAAoJEFGvii+H/HdhqSEP/jNBWmiCKvci3hR0T6ujyqoR
 A7GM5soFkw25ZWi0hRPYUewA4KOn+laFnHJsHfx6h2fTeZHk3Phx/9f6uBhVENG5
 gSmAkSTsRaFGUyDU1Enq6hH9CIhdUuJh2ybIc2Fq8T1Z8hg3sGjcDfBC8T3uT/fM
 y1fdlhNzlSB1DnRO9niHQJMCGXRx7V6C4jH9epxXY2Tf5WjcFgQTpf7XrXyz7gxy
 8Zn1oLHt6nT6H70AHb3hbV48IVcVVpIN/qVHMDAXd8kvTTFh7OTi7zJIGqQKzOFr
 y83mv5fBF6V67WOLsRcd0diNgOUSFLxxp4D2j8EAjSB386V+9wfm42A04z9HNXE5
 XD2gmaVpm0H3OH3YjOHo+s/lbWAYvzb3NJ0pOHXis8dcKGW/3MH33cWHsUBe+ytv
 SOfd9u+OYbe0o2xKPUVIF6m/HXrLqWBM5+wT2F/5Z0nbIXlhXK96km4T16JD5L+A
 QWyilHmP/shDCuZ4ORl7sf0V/FY7BicOzPBpHZKOGjX+3RmCn1fo++WgdFIyVkCG
 tvIUtSONxeidaDUJ8J1tn2OR8DtdyMag7pagzypZF4JSpjfJ+IMj/6wFftgTzZgh
 yDtkfUYk9sJsBy3Bp1pfcVrcnERlIq7FND9HySQTbRFRX0+5ARx7ZXzjqidKHy6l
 yvFfnhxy1vcy8RdEh21e
 =tG0h
 -----END PGP SIGNATURE-----

Merge tag 'ib-mfd-iio-pwm-4.11' into test

Immutable branch between MFD, IIO and PWM due for the v4.11 merge window

Pulled into IIO to allow follow up series of triggered capture for the
STM32 ADCs.
2017-01-28 18:21:49 +00:00
Andreas Klinger 78f839029e iio: distance: srf08: add IIO driver for us ranger
This is the IIO driver for devantech srf08 ultrasonic ranger which can be
used to measure the distances to an object.

The sensor supports I2C with some registers.

Supported Features include:
 - read the distance in ranging mode in centimeters
 - output of the driver is directly the read value
 - together with the scale the driver delivers the distance in meters
 - only the first echo of the nearest object is delivered
 - set sensitivity as analog value in the range of 0-31  means setting
   gain register on device
 - set range registers; userspace enters max. range in millimeters in
   43 mm steps

Features not supported by this driver:
 - ranging mode in inches or in microseconds
 - ANN mode
 - change I2C address through this driver
 - light sensor

The driver was added in the directory "proximity" of the iio subsystem and
the menu in den config is now called "Proximity and distance sensors"

Signed-off-by: Andreas Klinger <ak@it-klinger.de>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2017-01-28 16:38:24 +00:00
Gwendal Grignou d732248fdb iio: cros_ec: Add cros_ec barometer driver
Handle the barometer sensor presented by the ChromeOS EC Sensor hub.

Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
Signed-off-by: Enric Balletbo Serra <enric.balletbo@collabora.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2017-01-28 15:07:46 +00:00
William Breathitt Gray b2d226caec iio: stx104: Utilize devm_ functions in driver probe callback
The devm_ resource manager functions allow memory to be automatically
released when a device is unbound. This patch takes advantage of the
resource manager functions and replaces the gpiochip_add_data call and
iio_device_register call with the devm_gpiochip_add_data call and
devm_iio_device_register call respectively. In addition, the
stx104_remove function has been removed as no longer necessary due to
the use of the relevant devm_ resource manager functions.

Signed-off-by: William Breathitt Gray <vilhelm.gray@gmail.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2017-01-28 12:44:05 +00:00
Lorenzo Bianconi dba329048e iio: imu: st_lsm6dsx: add possibility to select drdy pin
Add capability to route data ready signal on pin 1 or pin 2 of the package

Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@st.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2017-01-28 12:41:53 +00:00
Martin Blumenstingl 3adbf34273 iio: adc: add a driver for the SAR ADC found in Amlogic Meson SoCs
This adds support for the SAR (Successive Approximation Register) ADC
on the Amlogic Meson SoCs.

The code is based on the public S805 (Meson8b) and S905 (GXBB)
datasheets (see [0] and [1]), as well as by reading (various versions
of) the vendor driver and by inspecting the registers on the vendor
kernels of my testing-hardware.

Currently the GXBB, GXL and GXM SoCs are supported. GXBB hardware has
10-bit ADC resolution, while GXL and GXM have 12-bit ADC resolution.
The code was written to support older SoCs (Meson8 and Meson8b) as well,
but due to lack of actual testing-hardware no of_device_id was added for
these.

Two "features" from the vendor driver are currently missing:
- the vendor driver uses channel #7 for calibration (this improves the
  accuracy of the results - in my tests the results were less than 3%
  off without calibration compared to the vendor driver). Adding support
  for this should be easy, but is not required for most applications.
- channel #6 is connected to the SoCs internal temperature sensor.
  Adding support for this is probably not so easy since (based on the
  u-boot sources) most SoC versions are using different registers and
  algorithms for the conversion from "ADC value" to temperature.

Supported by the hardware but currently not supported by the driver:
- reading multiple channels at the same time (the hardware has a FIFO
  buffer which stores multiple results)
- continuous sampling (this would require a way to enable this
  individually because otherwise the ADC would be drawing power
  constantly)
- interrupt support (similar to the vendor driver this new driver is
  polling the results. It is unclear if the IRQ-mode is supported on
  older (Meson6 or Meson8) hardware as well or if there are any errata)

[0]
http://dn.odroid.com/S805/Datasheet/S805_Datasheet%20V0.8%2020150126.pdf
[1] http://dn.odroid.com/S905/DataSheet/S905_Public_Datasheet_V1.1.4.pdf

Signed-off-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
Tested-by: Neil Armstrong <narmstrong@baylibre.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2017-01-28 12:29:50 +00:00
Wei Yongjun 752d01d990 iio: common: ssp_sensors: gyro: use devm_iio_device_register()
Use devm_iio_device_register() for IIO subsystem device
registration and delete the remove function since there
is no need after this change.

Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2017-01-28 12:16:17 +00:00
Wei Yongjun fa4c115ca5 iio: common: ssp_sensors: accel: use devm_iio_device_register()
Use devm_iio_device_register() for IIO subsystem device
registration and delete the remove function since there
is no need after this change.

Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2017-01-28 12:15:22 +00:00
Matt Weber df1fd2de11 iio: max5481: Add support for Maxim digital potentiometers
Add implementation for Maxim Integrated 5481, 5482, 5483,
and 5484 digital potentiometer devices.

Datasheet:
http://datasheets.maximintegrated.com/en/ds/MAX5481-MAX5484.pdf

Signed-off-by: Maury Anderson <maury.anderson@rockwellcollins.com>
Signed-off-by: Matthew Weber <matthew.weber@rockwellcollins.com>
Signed-off-by: Slawomir Stepien <sst@poczta.fm>
Acked-by: Rob Herring <robh@kernel.org>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2017-01-28 12:13:31 +00:00
Marek Vasut 059c53b323 iio: adc: Add Renesas GyroADC driver
Add IIO driver for the Renesas RCar GyroADC block. This block is a
simple 4/8-channel ADC which samples 12/15/24 bits of data every
cycle from all channels.

Signed-off-by: Marek Vasut <marek.vasut+renesas@gmail.com>
Cc: Geert Uytterhoeven <geert+renesas@glider.be>
Cc: Simon Horman <horms+renesas@verge.net.au>
Cc: Jonathan Cameron <jic23@kernel.org>
Cc: linux-renesas-soc@vger.kernel.org
Cc: Wolfram Sang <wsa@the-dreams.de>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2017-01-28 11:33:53 +00:00
Benjamin Gaignard 93fbe91b55 iio: Add STM32 timer trigger driver
Timers IPs can be used to generate triggers for other IPs like
DAC or ADC.
Each trigger may result of timer internals signals like counter enable,
reset or edge, this configuration could be done through "master_mode"
device attribute.

Since triggers could be used by DAC or ADC their names are defined
in include/ nux/iio/timer/stm32-timer-trigger.h and is_stm32_iio_timer_trigger
function could be used to check if the trigger is valid or not.

"trgo" trigger have a "sampling_frequency" attribute which allow to configure
timer sampling frequency.

version 8:
- change kernel version from 4.10 to 4.11 in ABI documentation

version 7:
- remove all iio_device related code
- move driver into trigger directory

version 5:
- simplify tables of triggers
- only create an IIO device when needed

version 4:
- get triggers configuration from "reg" in DT
- add tables of triggers
- sampling frequency is enable/disable when writing in trigger
  sampling_frequency attribute
- no more use of interruptions

version 3:
- change compatible to "st,stm32-timer-trigger"
- fix attributes access right
- use string instead of int for master_mode and slave_mode
- document device attributes in sysfs-bus-iio-timer-stm32

version 2:
- keep only one compatible
- use st,input-triggers-names and st,output-triggers-names
  to know which triggers are accepted and/or create by the device

Signed-off-by: Benjamin Gaignard <benjamin.gaignard@st.com>
Acked-by: Jonathan Cameron <jic23@kernel.org>
Signed-off-by: Lee Jones <lee.jones@linaro.org>
2017-01-25 16:11:56 +00:00
Linus Walleij ed8959f40a iio: accel: fix Kconfig warning
commit 762227721f
"iio: accel: st_accel: handle deprecated bindings"
attempted to be smart and let users use the old I2C
driver and the new SPI driver, or the old SPI driver and
the new I2C driver in combination for the LIS3LV02,
and put the restrictions on the I2C and SPI subdrivers
not not be combined with the old subdrivers.

This doesn't work since the IIO ST accel top-level
component selects the I2C and SPI subdrivers, resulting
in the following Kconfig noise:

warning: (IIO_ST_ACCEL_3AXIS) selects IIO_ST_ACCEL_I2C_3AXIS
which has unmet direct dependencies (IIO && !SENSORS_LIS3_I2C
&& IIO_ST_ACCEL_3AXIS && IIO_ST_SENSORS_I2C)
warning: (IIO_ST_ACCEL_3AXIS) selects IIO_ST_ACCEL_SPI_3AXIS
which has unmet direct dependencies (IIO && !SENSORS_LIS3_SPI
&& IIO_ST_ACCEL_3AXIS && IIO_ST_SENSORS_SPI)
(...)

This fixes the issue by putting the dependencies directly
in the top-level component instead, so that it never gets
to select its unselectable subcomponent.

Fixes: 762227721f ("iio: accel: st_accel: handle deprecated bindings")
Reported-by: Stephen Rothwell <sfr@canb.auug.org.au>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Acked-by: Jonathan Cameron <jic23@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-01-23 09:27:30 +01:00
Greg Kroah-Hartman 08cad739ba Second round of IIO new device support, cleanups and features for the 4.11 cycle
New device support:
 * lsm6dsx imu
   - new driver and bindings.
 * max11100 adc
   - new driver and bindings.
 * tlc4541
   - new driver
 * tmp007 thermopile
   - new driver.
 
 Core
 * in kernel interfaces
   - pass through raw values if no scaling provided and a processed value is
     requested.
 * trigger
   - close a race condition in acquiring trigger reference.
   - constify device_type structures.
   - rework the viio_trigger_alloc function to be much neater and easier to
   read.
   - free trigger resources correctly on some error paths. Avoids putting a
   module we don't have.
 
 Documentation
 * ABI
   - specify a unit for proximity measurements.
 
 Cleanups and features
 * ads1015
   - constify iio_info structure.
 * ads7950 cleanups following merge in previous pull
   - Add device tree bindings
   - Drop the ti prefix from the module name in common with other drivers.
   - Change regulator name to vref to match datasheet and other drivers.
 * ak8974
   - remove a redundant zero timeout check.
 * bmi160
   - use variable names for sizeof instead of types.
 * cm3605
   - mark PM functions as __maybe_unused to avoid a build warning.
 * isl29028 (on it's way towards moving out of staging).
   - alignment fixes and newline improvements.
   - combine proxim_get and read_proxim for simpler code.
   - drop unused ISL29028_DEV_ATTR macro
   - move some error logging into functions to cut out repitition.
   - make error messages more consistent.
   - tidy up some brackets.
   - drop the enable flag that nothing uses.
   - only set proximity rate and ALS scale when relevant channel type is enabled.
   - runtime pm support.
 * lsm6dsx
   - fix wrong values for gyro sensitivitiy.
 * mag3110
   - claim direct mode during sysfs reads to avoid a race condition.
 * max1363
   - export OF device table IDs as module aliases.
 * max30100
   - use msleep for long uncritical delays.
 * mcp4531
   - export OF device table as module aliases.
 * ms5611
   - claim direct mode during sysfs reads to avoid a race condition.
 * opt3001
   - export OF device table as module aliases.
 * sx9500
   - claim direct mode during oversampling changes to avoid a race condition.
 -----BEGIN PGP SIGNATURE-----
 
 iQJFBAABCAAvFiEEbilms4eEBlKRJoGxVIU0mcT0FogFAliFK5sRHGppYzIzQGtl
 cm5lbC5vcmcACgkQVIU0mcT0FoixSQ/+PrWf4PWdYSy+YlxxVzWMkJ3QhHYvDxpz
 mmH5GmsUB0RGi205VqAsvEF55Gcp5tzMYPXkjoxD1nXtuZ8sbVzkTSvrEGIqgA8b
 QUDdu76ntzJYWHVqouh8SywCJJbR/ssjZbIMzHvpYL/pty7+ICnaevauQf6n93Hh
 51yaPdtDNu4hq/lQdUz0QySGn9UJG7HUUKIfSDgZCh9q8VcQ8bmCf8MaRilJTzo9
 q8ONaziyB77w07JVeQLR/W8WO+KCRor0qqlokNtGDNAE2EOre6ul64Ded6TXLEez
 9ag/IYkECN3tImuHHJ9AKlCPOl39viZeP6sjvJc4glujZ0WKVuT76tlVP5XknuCE
 myy74d9Jt5/N43SYiQpRRm4Eadje56kCZtZhFidhRaEV74eQaOYG6fMNJ9Q/HJ4B
 d9Ykw7ZjU08DDOdQNtfQ5DGH72bKu94DSImqjmxXskUL6quZbxCnKPvI/vm//9xb
 7jSHtORTT8WxX/Ut9MTE59S0FS5x/8ivNxWxzqLDS0phcA4e1cLXJyFh0npxxYeu
 XdvJb+BefcfsPNbhhPl/anz577TJPTgNL4P2j1ano0duVCNV33p3y9Z2YNCkgaI1
 PtRVCBzMhaV60EQGBzBheNmN1+jeGu7q8o3UDhaoc4sX4ILut0oDE4PIDROmuItc
 QPLTmZkG20o=
 =Wvje
 -----END PGP SIGNATURE-----

Merge tag 'iio-for-4.11b' of git://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio into work-next

Jonathan writes:

Second round of IIO new device support, cleanups and features for the 4.11 cycle

New device support:
* lsm6dsx imu
  - new driver and bindings.
* max11100 adc
  - new driver and bindings.
* tlc4541
  - new driver
* tmp007 thermopile
  - new driver.

Core
* in kernel interfaces
  - pass through raw values if no scaling provided and a processed value is
    requested.
* trigger
  - close a race condition in acquiring trigger reference.
  - constify device_type structures.
  - rework the viio_trigger_alloc function to be much neater and easier to
  read.
  - free trigger resources correctly on some error paths. Avoids putting a
  module we don't have.

Documentation
* ABI
  - specify a unit for proximity measurements.

Cleanups and features
* ads1015
  - constify iio_info structure.
* ads7950 cleanups following merge in previous pull
  - Add device tree bindings
  - Drop the ti prefix from the module name in common with other drivers.
  - Change regulator name to vref to match datasheet and other drivers.
* ak8974
  - remove a redundant zero timeout check.
* bmi160
  - use variable names for sizeof instead of types.
* cm3605
  - mark PM functions as __maybe_unused to avoid a build warning.
* isl29028 (on it's way towards moving out of staging).
  - alignment fixes and newline improvements.
  - combine proxim_get and read_proxim for simpler code.
  - drop unused ISL29028_DEV_ATTR macro
  - move some error logging into functions to cut out repitition.
  - make error messages more consistent.
  - tidy up some brackets.
  - drop the enable flag that nothing uses.
  - only set proximity rate and ALS scale when relevant channel type is enabled.
  - runtime pm support.
* lsm6dsx
  - fix wrong values for gyro sensitivitiy.
* mag3110
  - claim direct mode during sysfs reads to avoid a race condition.
* max1363
  - export OF device table IDs as module aliases.
* max30100
  - use msleep for long uncritical delays.
* mcp4531
  - export OF device table as module aliases.
* ms5611
  - claim direct mode during sysfs reads to avoid a race condition.
* opt3001
  - export OF device table as module aliases.
* sx9500
  - claim direct mode during oversampling changes to avoid a race condition.
2017-01-23 09:23:23 +01:00
Alison Schofield 10e840dfb0 iio: trigger: free trigger resource correctly
These stand-alone trigger drivers were using iio_trigger_put()
where they should have been using iio_trigger_free().  The
iio_trigger_put() adds a module_put which is bad since they
never did a module_get.

In the sysfs driver, module_get/put's are used as triggers are
added & removed. This extra module_put() occurs on an error path
in the probe routine (probably rare).

In the bfin-timer & interrupt trigger drivers, the module resources
are not explicitly managed, so it's doing a put on something that
was never get'd.  It occurs on the probe error path and on the
remove path (not so rare).

Tested with the sysfs trigger driver.
The bfin & interrupt drivers were build tested & inspected only.

Signed-off-by: Alison Schofield <amsfield22@gmail.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2017-01-22 16:14:21 +00:00
Dan Carpenter 2c99f1a09d iio: trigger: clean up viio_trigger_alloc()
1) Reverse the test for kmalloc() failure so we can pull everything
   back one tab.
2) Use gotos for unwinding.
3) Some of the extra line breaks for the 80 character limit are no
   longer needed so we can remove them.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2017-01-22 13:37:34 +00:00
John Brooks 5c113b5e00 iio: dht11: Use usleep_range instead of msleep for start signal
The DHT22 (AM2302) datasheet specifies that the LOW start pulse should not
exceed 20ms. However, observations with an oscilloscope of an RPi Model 2B
(rev 1.1) communicating with a DHT22 sensor showed that the driver was
consistently sending start pulses longer than 20ms:

Kernel 4.7.10-v7+ (n=132):
    Minimum pulse length: 20.20ms
    Maximum:              29.84ms
    Mean:                 24.96ms
    StDev:                2.82ms
    Sensor response rate: 100%
    Read success rate:    76%

On kernel 4.8, the start pulse was so long that the sensor would not even
respond 97% of the time:

Kernel 4.8.16-v7+ (n=100):
    Minimum pulse length: 30.4ms
    Maximum:              74.4ms
    Mean:                 39.3ms
    StDev:                10.2ms
    Sensor response rate: 3%
    Read success rate:    3%

The driver would return ETIMEDOUT and write log messages like this:

[   51.430987] dht11 dht11@0: Only 1 signal edges detected
[   66.311019] dht11 dht11@0: Only 0 signal edges detected

Replacing msleep(18) with usleep_range(18000, 20000) made the pulse length
sane again and restored responsiveness:

Kernel 4.8.16-v7+ with usleep_range (n=123):
    Minimum pulse length: 18.16ms
    Maximum:              20.20ms
    Mean:                 19.85ms
    StDev:                0.51ms
    Sensor response rate: 100%
    Read success rate:    84%

Cc: stable@vger.kernel.org
Signed-off-by: John Brooks <john@fastquake.com>
Reviewed-by: Harald Geyer <harald@ccbib.org>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2017-01-22 13:35:40 +00:00
Bhumika Goyal 99a22f062b iio: adc: constify iio_info structures
Declare iio_info structures as const as they are only stored in
the info field of a iio_dev structure. This field is of type const,
so iio_info structures having similar properties can be made const too.

File size before:
   text	   data	    bss	    dec	    hex	filename
   6944	    792	      0	   7736	   1e38	drivers/iio/adc/ti-ads1015.o

File size after:
   text   data	    bss	    dec	    hex	filename
   7264	    472	      0	   7736	   1e38	drivers/iio/adc/ti-ads1015.o

Signed-off-by: Bhumika Goyal <bhumirks@gmail.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2017-01-22 13:21:43 +00:00
Bhumika Goyal 3bdafc49f5 iio: industrialio-trigger: constify device_type structures
Declare device_type structure as const as it is only stored in the
type field of a device structure. This field is of type const, so add
const to declaration of device_type structure.

File size before:
   text	   data	    bss	    dec	    hex	filename
   5389	    208	     48	   5645	   160d	iio/industrialio-trigger.o

File size after:
   text	   data	    bss	    dec	    hex	filename
   5453	    176	     48	   5677	   162d	iio/industrialio-trigger.o

Signed-off-by: Bhumika Goyal <bhumirks@gmail.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2017-01-22 13:21:42 +00:00
Alison Schofield d5d24bcc0a iio: trigger: close race condition in acquiring trigger reference
In iio_trigger_write_current() we find the trigger we want while
holding mutex on the list of triggers, but we don't actually do a
get on it while holding mutex.  We wait until further validations
are completed and we're sure it's the one we want.  Race condition
is that it could be freed by the time we do the get.

Solution is to grab the trigger (iio_trigger_get) as soon as we
find it while holding mutex on the list of triggers.  If later
we decide it's not the right one, put it back. (iio_trigger_put).

Signed-off-by: Alison Schofield <amsfield22@gmail.com>
Suggested-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2017-01-22 13:21:41 +00:00
Lorenzo Bianconi dfebd8d81d iio: imu: st_lsm6dsx: fix typo in gyro sensitivity definition
Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@st.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2017-01-22 13:21:41 +00:00
Javier Martinez Canillas 99be230db9 iio: adc: max1363: Export OF device ID table as module aliases
The I2C core always reports a MODALIAS of the form i2c:<foo> even if the
device was registered via OF, this means that exporting the OF device ID
table device aliases in the module is not needed. But in order to change
how the core reports modaliases to user-space, it's better to export it.

Signed-off-by: Javier Martinez Canillas <javier@osg.samsung.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2017-01-22 13:21:30 +00:00
Javier Martinez Canillas 9c6e4efded iio: potentiometer: mcp4531: Export OF device ID table as module aliases
The I2C core always reports a MODALIAS of the form i2c:<foo> even if the
device was registered via OF, this means that exporting the OF device ID
table device aliases in the module is not needed. But in order to change
how the core reports modaliases to user-space, it's better to export it.

Signed-off-by: Javier Martinez Canillas <javier@osg.samsung.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2017-01-22 13:21:29 +00:00
Javier Martinez Canillas b1450ae9b6 iio: light: opt3001: Export OF device ID table as module aliases
The I2C core always reports a MODALIAS of the form i2c:<foo> even if the
device was registered via OF, this means that exporting the OF device ID
table device aliases in the module is not needed. But in order to change
how the core reports modaliases to user-space, it's better to export it.

Signed-off-by: Javier Martinez Canillas <javier@osg.samsung.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2017-01-22 13:21:29 +00:00
Nicholas Mc Guire 18e2452a3c iio: health: max30100: use msleep() for long uncritical delays
ulseep_range() uses hrtimers and provides no advantage over msleep()
for larger delays. Fix up the 35ms delays here to use msleep() and
reduce the load on the hrtimer subsystem.

Fixes: commit 4d33615df5 ("iio: light: add MAX30100 oximeter driver support")
Link: http://lkml.org/lkml/2017/1/11/377
Signed-off-by: Nicholas Mc Guire <hofrat@osadl.org>
Reviewed-by: Matt Ranostay <matt.ranostay@konsulko.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2017-01-22 13:21:28 +00:00
Phil Reid ac2bec9d58 iio: adc: tlc4541: add support for TI tlc4541 adc
This adds TI's tlc4541 16-bit ADC driver. Which is a single channel
ADC. Supports raw and trigger buffer access.
Also supports the tlc3541 14-bit device, which has not been tested.
Implementation of the tlc3541 is fairly straight forward thou.

Acked-by: Rob Herring <robh@kernel.org>
Signed-off-by: Phil Reid <preid@electromag.com.au>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2017-01-22 13:21:28 +00:00
Alison Schofield d1aaf20ee6 iio: adc: palmas_gpadc: retrieve a valid iio_dev in suspend/resume
The suspend/resume functions were using dev_to_iio_dev() to get
the iio_dev. That only works on IIO dev's.  Use dev_get_drvdata()
for a platform device to get the correct iio_dev.

Signed-off-by: Alison Schofield <amsfield22@gmail.com>
Cc: <Stable@vger.kernel.org>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2017-01-21 14:26:03 +00:00
Matt Ranostay 828f84ee8f iio: health: max30100: fixed parenthesis around FIFO count check
FIFO was being read every sample after the "almost full" state was
reached. This was due to an incorrect placement of the parenthesis
in the while condition check.

Note - the fixes tag is not actually correct, but the fix in this patch
would also be needed for it to function correctly so we'll go with that
one.  Backports should pick up both.

Signed-off-by: Matt Ranostay <matt@ranostay.consulting>
Fixes: b74fccad7 ("iio: health: max30100: correct FIFO check condition")
Cc: Stable@vger.kernel.org>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2017-01-21 14:16:20 +00:00
Jacopo Mondi a8e7e88df9 iio: adc: Add Maxim MAX11100 driver
Add iio driver for Maxim MAX11100 single-channel ADC.

Signed-off-by: Jacopo Mondi <jacopo+renesas@jmondi.org>
Tested-by: Marek Vasut <marek.vasut@gmail.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2017-01-21 13:16:38 +00:00
Alison Schofield 802ecfc113 iio: health: afe4404: retrieve a valid iio_dev in suspend/resume
The suspend/resume functions were using dev_to_iio_dev() to get
the iio_dev. That only works on IIO dev's.  Replace it with i2c
functions to get the correct iio_dev.

Signed-off-by: Alison Schofield <amsfield22@gmail.com>
Acked-by: Andrew F. Davis <afd@ti.com>
Cc: <Stable@vger.kernel.org>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2017-01-21 13:12:41 +00:00
Alison Schofield a5badd1e97 iio: health: afe4403: retrieve a valid iio_dev in suspend/resume
The suspend/resume functions were using dev_to_iio_dev() to get
the iio_dev. That only works on IIO dev's.  Replace it with spi
functions to get the correct iio_dev.

Signed-off-by: Alison Schofield <amsfield22@gmail.com>
Acked-by: Andrew F. Davis <afd@ti.com>
Cc: <Stable@vger.kernel.org>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2017-01-21 13:11:06 +00:00
Alison Schofield 2d3f956e2e iio: bmi160: use variable names for sizeof() operator
Replace the types with the actual variable names when using the
sizeof() operator.  This is kernel preferred style as it's
more obvious that it is correct.

Signed-off-by: Alison Schofield <amsfield22@gmail.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2017-01-21 13:06:03 +00:00
Arnd Bergmann d1242acc56 iio: light: cm3605: mark PM functions as __maybe_unused
When CONFIG_PM_SLEEP is disabled, we get a harmless warning

drivers/iio/light/cm3605.c:292:12: error: 'cm3605_pm_resume' defined but not used [-Werror=unused-function]
drivers/iio/light/cm3605.c:281:12: error: 'cm3605_pm_suspend' defined but not used [-Werror=unused-function]

Marking the functions as possibly unused avoids the warning without
needing to add an #ifdef.

Fixes: 8afa505c12 ("iio: light: add driver for Capella CM3605")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2017-01-21 12:34:54 +00:00
Alison Schofield 3bc1abcddb iio: pressure: ms5611: claim direct mode during oversampling changes
Driver was checking for direct mode before changing oversampling
ratios, but was not locking it.  Use the claim/release helper
functions to guarantee the device stays in direct mode while the
oversampling ratios are being updated.  Continue to use the drivers
private state lock to protect against conflicting direct mode access
of the state data.

Signed-off-by: Alison Schofield <amsfield22@gmail.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2017-01-21 12:31:05 +00:00
Alison Schofield 6b2e7589b8 iio: proximity: sx9500: claim direct mode during raw proximity reads
Driver was checking for direct mode but not locking it.  Use the
claim/release helper functions to guarantee the device stays in
direct mode during raw reads of proximity data.

Signed-off-by: Alison Schofield <amsfield22@gmail.com>
Reviewed-by: Vlad Dogaru <ddvlad@gmail.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2017-01-21 12:21:53 +00:00
Alison Schofield 80dea21f95 iio: magnetometer: mag3110: claim direct mode during raw writes
Driver was checking for direct mode but not locking it.  Use
claim/release helper functions to guarantee the device stays
in direct mode during raw writes.

Signed-off-by: Alison Schofield <amsfield22@gmail.com>
Acked-by: Peter Meerwald-Stadler <pmeerw@pmeerw.net>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2017-01-21 12:20:40 +00:00
Greg Kroah-Hartman 4463c3e72d First round of new device support, features and cleanups for IIO in the 4.11 cycle.
It's shaping to be another fairly busy cycle. Lots more on the way!
 
 New device support
 * ads7950
   - new driver supporting ads7950, ads7951, ads7952, ads7953, ads7954,
   ads7955, ads7956, ads7957, ads7958, ads7959, ads7960, and ads7961 ADCs.
 * cm3605
   - New driver for this light sensor and proximity sensor  which is an
   analog part with some additional digital controls.
 * hx711
   - New driver.
 
 Core new stuff
 * Gravity sensor type.  This is a processed datastream in which the device
 will try to work out which way is down.
 * Split the buffer.h file into two parts. One provides the interface to 'use'
 a buffer, the second provides the internals of the buffer functionality as
 needed by implementations of buffers.
   - Move documentation inline so as to allow use of private: tag when
   generating documentation.
   - Add some utility functions for the few things that are directly done
   with the buffers.
   - Stop exporting functions that no-one uses outside of the core code.
   - Push docs down by the code in the c file where they should have always
   been.
   - Fix typo in kernel-doc for buffer.
   - push down some includes that were previously happening implicitly.
   - stop enabling the timestamp of the dummy device.
 
 Features and cleanups
 * ad5592r
   - ACPI support
 * ad5593r
   -ACPI support.
 * ad5933
   - Fix a false comment about size of a particular register.
 * ad7150
   - replace S_IRUGO | S_IWUSR with 0644.  I'm not that keen on these patches
   in general, but as it was nicely presented I took this one anyway. As a
   general rule will only take these as part of a larger driver cleanup.
   - don't eat an error but rather reutnr it in the write_event_config callback.
 * ad7606
   - replace non standard range attibute with _scale
 * ade7753
   - use usleep_range for short sleeps
 * ade7754
   - use usleep_range for short sleeps
 * ade7758
   - use usleep_range for short sleeps
 * ade7759
   - use usleep_range for short sleeps
 * ade7854
   - use usleep_range for short sleeps
 * adis16201
   - fix description
 * adis16203
   - fix description
   - fix copyright year
 * adis16209
   - fix description
 * adt7316
   - Add braces to arms of if else statement (for consistency)
   - Alignment fixes.
 * axp288
   - Fix up an issue with accidental overwrites of data.
 * bmi160
   - add deivce tables for i2c and spi to support correctly identifying the
   full dt name (including manufacturer).
   - device tree binding.
 * bmp280
   - use usleep_range for short sleeps.
 * cm3232
   - return error from cm3232_reg_init rather than eating it if the last write
   fails.
 * dummy driver
   - remove a semicolor found at end of a function defintition.
 * exynos-adc
   - use usleep_range for short sleeps.
 * hid-sensor (accel)
   - Add timestamp support.  The hardware can provide timestamps so lets support
   them. If not fall back to timestamps estimated in kernel.
 * hid-sensor (light)
   - Add a duplicate ID for the light channels so as to keep existing interface
   whilst also using the more standard IIO interface.
 * hts221
   - acpi probing
 * imx25-gcq
   - Add a macro call to allow this driver to be automatically loaded.
 * isl29028
   - reorganise code to avoid deep nesting of if statements.
   - move chip test and default regs into a function suitable or sharing with
   power management code.
   - tidy up some code alignment.
 * lidar-lite-v3
   - introduce compatible strings that make it clear Garmin have consideral
   friends.
 * mma8452
   - avoid returning signed value when unsigned is appropriate
 * spmi-vadc
   - Update function for generic voltage conversion to take into account that
   different channels on this device should be handled differently.
   - Rework code to allow per channel voltage scaling and support the standard
   options for this hardware.
   - Fixup three minor issues with the above patches for this part. These all
   effect test builds rather than the native builds for the part, but good to
   clean them up anyway.
 * st_sensors
   - support device matching from the ACPI DST tables.
   - acpi based probing for accelerometers
   - acpi based probing for pressure sensors
   - Allow pressure sensors to read negative values.
   - Export sampling frequency for lps25h and lps331ap.
   - Add support for the old DT bindings from the period when these deivces
   were often supported through windows.
 
 Docs fixup:
 * typo in sysfs-bus-iio
 -----BEGIN PGP SIGNATURE-----
 
 iQJFBAABCAAvFiEEbilms4eEBlKRJoGxVIU0mcT0FogFAlh2bhcRHGppYzIzQGtl
 cm5lbC5vcmcACgkQVIU0mcT0FogdSQ/9Hyd3ic5AgWyDKr9JI1vJPj3kT0PIYHLk
 4ucbQ8HUJQBBLnsausTb+UwuGV277DkVjGVsI4epn59H3CvkNh3Egl3XCmbhIpt2
 oyl9Pw9dSon6n/7I5pNSwmqD45O+aB7qFLigIfLmciwpMHZly3ExzGBMpqUkgjf9
 bVzndDqrfoNIrU7UaMD6QgrSxrgYJJJJwBDig/0zjAkGvu9L8a8ghrKkrRzMy62O
 nGP5mmEagivFF9lpGzzrw2pYBQWY4AFbsNvuLElE7nUz0PKKG+9J0oaBiglTYv2p
 mkNlYl7iTZfI3eFOXa+7HdSmeNhYX2dvbEM2jAA/Mr6ojWg2mSRu7Y19Kl2KP7K7
 BDRKBw+Cp0wkVvJ8LU/6PiDSmqp09VfjjqevzVGJi/BmWLzG0Mi2OsQmmynbw2SV
 hxiGETRV7vBoyJWDJuwJoftZaRnHWJbiQ6ftEUbWOFA9RIBMgOJBiL+RtxerJkHv
 FWlCFpv/618TUB/uM15+EOLVJAT5b7K+6+l6EGEjWdjiS/7vL7QM5DL8w4zV43zz
 cQ98UeIlqCkvoFmx9uHbl44COLQgzNtxAjytLxqbsOmEb40wlzoNzgSoUGu73SaG
 8qwznH0w0p8P1nyzwe9qKKK6SmFhj/tF6jKVmIi/H7wJdA1J5dAAmwFUBSxLs2DX
 u1eM3ikCl/M=
 =yjUA
 -----END PGP SIGNATURE-----

Merge tag 'iio-for-4.11a' of git://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio into staging-next

Jonathan writes:

First round of new device support, features and cleanups for IIO in the 4.11 cycle.

It's shaping to be another fairly busy cycle. Lots more on the way!

New device support
* ads7950
  - new driver supporting ads7950, ads7951, ads7952, ads7953, ads7954,
  ads7955, ads7956, ads7957, ads7958, ads7959, ads7960, and ads7961 ADCs.
* cm3605
  - New driver for this light sensor and proximity sensor  which is an
  analog part with some additional digital controls.
* hx711
  - New driver.

Core new stuff
* Gravity sensor type.  This is a processed datastream in which the device
will try to work out which way is down.
* Split the buffer.h file into two parts. One provides the interface to 'use'
a buffer, the second provides the internals of the buffer functionality as
needed by implementations of buffers.
  - Move documentation inline so as to allow use of private: tag when
  generating documentation.
  - Add some utility functions for the few things that are directly done
  with the buffers.
  - Stop exporting functions that no-one uses outside of the core code.
  - Push docs down by the code in the c file where they should have always
  been.
  - Fix typo in kernel-doc for buffer.
  - push down some includes that were previously happening implicitly.
  - stop enabling the timestamp of the dummy device.

Features and cleanups
* ad5592r
  - ACPI support
* ad5593r
  -ACPI support.
* ad5933
  - Fix a false comment about size of a particular register.
* ad7150
  - replace S_IRUGO | S_IWUSR with 0644.  I'm not that keen on these patches
  in general, but as it was nicely presented I took this one anyway. As a
  general rule will only take these as part of a larger driver cleanup.
  - don't eat an error but rather reutnr it in the write_event_config callback.
* ad7606
  - replace non standard range attibute with _scale
* ade7753
  - use usleep_range for short sleeps
* ade7754
  - use usleep_range for short sleeps
* ade7758
  - use usleep_range for short sleeps
* ade7759
  - use usleep_range for short sleeps
* ade7854
  - use usleep_range for short sleeps
* adis16201
  - fix description
* adis16203
  - fix description
  - fix copyright year
* adis16209
  - fix description
* adt7316
  - Add braces to arms of if else statement (for consistency)
  - Alignment fixes.
* axp288
  - Fix up an issue with accidental overwrites of data.
* bmi160
  - add deivce tables for i2c and spi to support correctly identifying the
  full dt name (including manufacturer).
  - device tree binding.
* bmp280
  - use usleep_range for short sleeps.
* cm3232
  - return error from cm3232_reg_init rather than eating it if the last write
  fails.
* dummy driver
  - remove a semicolor found at end of a function defintition.
* exynos-adc
  - use usleep_range for short sleeps.
* hid-sensor (accel)
  - Add timestamp support.  The hardware can provide timestamps so lets support
  them. If not fall back to timestamps estimated in kernel.
* hid-sensor (light)
  - Add a duplicate ID for the light channels so as to keep existing interface
  whilst also using the more standard IIO interface.
* hts221
  - acpi probing
* imx25-gcq
  - Add a macro call to allow this driver to be automatically loaded.
* isl29028
  - reorganise code to avoid deep nesting of if statements.
  - move chip test and default regs into a function suitable or sharing with
  power management code.
  - tidy up some code alignment.
* lidar-lite-v3
  - introduce compatible strings that make it clear Garmin have consideral
  friends.
* mma8452
  - avoid returning signed value when unsigned is appropriate
* spmi-vadc
  - Update function for generic voltage conversion to take into account that
  different channels on this device should be handled differently.
  - Rework code to allow per channel voltage scaling and support the standard
  options for this hardware.
  - Fixup three minor issues with the above patches for this part. These all
  effect test builds rather than the native builds for the part, but good to
  clean them up anyway.
* st_sensors
  - support device matching from the ACPI DST tables.
  - acpi based probing for accelerometers
  - acpi based probing for pressure sensors
  - Allow pressure sensors to read negative values.
  - Export sampling frequency for lps25h and lps331ap.
  - Add support for the old DT bindings from the period when these deivces
  were often supported through windows.

Docs fixup:
* typo in sysfs-bus-iio
2017-01-19 10:40:44 +01:00
David Lechner 0bf1a2aac6 iio: adc: ti-ads7950: Change regulator matching string to "vref"
This changes the reference voltage regulator matching string from "refin"
to "vref". This is to be consistent with other A/DC chips that also use
"vref-supply" in their device tree bindings.

Signed-off-by: David Lechner <david@lechnology.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2017-01-15 13:56:08 +00:00
David Lechner 2b84f4ded4 iio: adc: ti-ads7950: Drop "ti-" prefix from module name
This drops the "ti-" prefix from the module name. It makes the module name
consistent with other iio ti-ads* drivers and it makes the driver work
with device tree (the spi subsystem drops the "ti," prefix when matching
compatible strings from device tree).

Tested working on LEGO MINDSTORMS EV3 with the following device tree node:

	adc@3 {
		compatible = "ti,ads7957";
		reg = <3>;
		#io-channel-cells = <1>;
		spi-max-frequency = <10000000>;
		vref-supply = <&adc_ref>;
	};

Signed-off-by: David Lechner <david@lechnology.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2017-01-15 13:52:51 +00:00
Colin Ian King e2eb179c00 iio: magnetometer: ak8974: remove redundant zero timeout check
At the end of the delay loop timeout will always be zero
and hence the check for !timeout will always be true. Remove
the redundant check and the redundant return 0 at the end of
the function.

Fixes CoverityScan CID#1357168 ("Logically dead code")

Signed-off-by: Colin Ian King <colin.king@canonical.com>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2017-01-14 13:10:04 +00:00
Lorenzo Bianconi 290a6ce11d iio: imu: add support to lsm6dsx driver
Add support to STM LSM6DS3-LSM6DSM 6-axis (acc + gyro) Mems sensor

http://www.st.com/resource/en/datasheet/lsm6ds3.pdf
http://www.st.com/resource/en/datasheet/lsm6dsm.pdf

- continuous mode support
- i2c support
- spi support
- sw fifo mode support
- supported devices: lsm6ds3, lsm6dsm

Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@st.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2017-01-14 12:40:37 +00:00
Linus Walleij adc8ec5ff1 iio: inkern: pass through raw values if no scaling
When a consumer calls iio_read_channel_processed() the IIO core
tries to apply scaling to the value, but if the channel only
supports reading raw values, we should return that raw value
to the cosumer instead of an error.

This is what userspace is expected to do with sensors only
providing raw values so the kernel should do the same, so as to
avoid adding scaling boilerplate to drivers for hardware that
actually return processed values from raw reads.

A sensor not providing a scale, but providing a _raw attribute
could be valid if for example the scale is the default of 1,
but an offset needs to be applied to convert to the _processed
form.

Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2017-01-14 12:20:18 +00:00
Manivannan Sadhasivam 948b707df8 iio:temperature: Add support for TI TMP007 sensor
This patch adds support for TI TMP007 - 16 bit IR thermopile sensor with integrated Math engine.
Sensor takes care of calculating the object temperature with the help of calibrated constants stored in non-volatile memory,
thereby reducing the calculation overhead.

Signed-off-by: Manivannan Sadhasivam <manivannanece23@gmail.com>
Acked-by: Rob Herring <robh@kernel.org>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2017-01-14 10:45:05 +00:00
Jonathan Cameron e30eca0e69 iio:adc:qcom-spmi-vadc: use div64_s64 instead of direct 64 bit division.
Another one of these that we missed previously which prevents test builds
of this driver on 32 bit platforms as it gives an undefined __divdi3 warning.

Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2017-01-10 21:13:39 +00:00
Jonathan Cameron 292ccbd3c4 iio:adc:qcom-spmi-vadc silence a long constant warning.
It is meant to be long and is only added to an s64.

Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Cc: Rama Krishna Phani A <rphani@codeaurora.org>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2017-01-10 19:55:00 +00:00
Jonathan Cameron 2bd72d84f6 iio:adc:qcom-spmi-vadc : fix undefined __divdi3
A simple do_div call works here as all the signed 64 bit is
actually small and unsigned at this point, and the numerator is
u32.

Introduce a temporary u64 variable to avoid type comparison warnings
on some architectures.

Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Reported-by: kbuild test robot <fengguang.wu@intel.com>
Cc: Rama Krishna Phani A <rphani@codeaurora.org>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2017-01-10 19:54:59 +00:00
Andreas Klinger c3b2fdd0ea iio: adc: hx711: Add IIO driver for AVIA HX711
This is the IIO driver for AVIA HX711 ADC which is mostly used in weighting
cells.

The protocol is quite simple and using GPIOs:
One GPIO is used as clock (SCK) while another GPIO is read (DOUT)

The raw value read from the chip is delivered.
To get a weight one needs to subtract the zero offset and scale it.

Signed-off-by: Andreas Klinger <ak@it-klinger.de>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2017-01-10 19:54:59 +00:00
Hans de Goede fa2849e964 iio: adc: axp288: Drop bogus AXP288_ADC_TS_PIN_CTRL register modifications
For some reason the axp288_adc driver was modifying the
AXP288_ADC_TS_PIN_CTRL register, changing bits 0-1 depending on
whether the GP_ADC channel or another channel was written.

These bits control when a bias current is send to the TS_PIN, the
GP_ADC has its own pin and a separate bit in another register to
control the bias current.

Not only does changing when to enable the TS_PIN bias current
(always or only when sampling) when reading the GP_ADC make no sense
at all, the code is modifying these bits is writing the entire register,
assuming that all the other bits have their default value.

So if the firmware has configured a different bias-current for either
pin, then that change gets clobbered by the write, likewise if the
firmware has set bit 2 to indicate that the battery has no thermal sensor,
this will get clobbered by the write.

This commit fixes all this, by simply removing all writes to the
AXP288_ADC_TS_PIN_CTRL register, they are not needed to read the
GP_ADC pin, and can actually be harmful.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Acked-by: Chen-Yu Tsai <wens@csie.org>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2017-01-10 19:54:57 +00:00
Javier Martinez Canillas 8f0d7daf53 iio: adc: imx25-gcq: Fix module autoload
If the driver is built as a module, autoload won't work because the module
alias information is not filled. So user-space can't match the registered
device with the corresponding module.

Export the module alias information using the MODULE_DEVICE_TABLE() macro.

Before this patch:

$ modinfo drivers/iio/adc/fsl-imx25-gcq.ko | grep alias
$

After this patch:

$ modinfo drivers/iio/adc/fsl-imx25-gcq.ko | grep alias
alias:          of:N*T*Cfsl,imx25-gcqC*
alias:          of:N*T*Cfsl,imx25-gcq

Signed-off-by: Javier Martinez Canillas <javier@osg.samsung.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2017-01-10 19:54:56 +00:00
Jonathan Cameron 33dd94cb97 iio:buffer.h - split into buffer.h and buffer_impl.h
buffer.h supplies everything needed for devices using buffers.
buffer_impl.h supplies access to the internals as needed to write
a buffer implementation.

This was really motivated by the mess that turned up in the
kernel-doc documentation pulled in by the new sphinx docs.
It made it clear that our logical separations in headers were
generally terrible.  The buffer case was easy to sort out without
greatly effecting drivers so here it is.

Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Reviewed-by: Lars-Peter Clausen <lars@metafoo.de>
2017-01-10 19:54:55 +00:00
Jonathan Cameron c56b7d80e3 iio:dummy: Stop enabling timestamp by default.
It's bad practice and only done in this fake driver + it breaks my
attempt to take struct buffer opaque. Not worth an access function
as it shouldn't be done anyway.

Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Reviewed-by: Lars-Peter Clausen <lars@metafoo.de>
2017-01-10 19:54:55 +00:00
Jonathan Cameron 2b827ad541 iio:buffer: Push implementation of iio_device_attach_buffer into .c file
This is a precursor to the splitting of buffer.h into parts relevant
to buffer implementation vs those for devices using buffers.
struct buffer is about to become opaque as far as the header is
concerned.

Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Reviewed-by: Lars-Peter Clausen <lars@metafoo.de>
2017-01-10 19:54:54 +00:00
Jonathan Cameron 19a5a8a5dc iio:buffer.h include pushdown into buffer implementations
These were only getting access to the internals of struct iio_dev via
the include of iio.h within buffer.h.  This should always have been
explicitly included by the buffer implementations themselves.

Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Reviewed-by: Lars-Peter Clausen <lars@metafoo.de>
2017-01-10 19:54:53 +00:00
Jonathan Cameron 8abd5ba539 iio:kfifo_buf header include push down.
As a precursor to splitting buffer.h, lets make sure all drivers
include the relevant headers rather than relying on picking them
up from kfifo_buf.h.

Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Reviewed-by: Lars-Peter Clausen <lars@metafoo.de>
2017-01-10 19:54:53 +00:00
Jonathan Cameron 315a19eca0 iio:buffers: Push some docs down into the .c file.
Ancient legacy of me doing it wrong which it is nice to clear
up whilst we are here.

Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Reviewed-by: Lars-Peter Clausen <lars@metafoo.de>
2017-01-10 19:54:51 +00:00
Jonathan Cameron c2bf8d5f32 iio:buffer: Stop exporting iio_scan_mask_query
Nothing uses it outside of core code.

Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Reviewed-by: Lars-Peter Clausen <lars@metafoo.de>
2017-01-10 19:54:51 +00:00
Jonathan Cameron 9f4667776c iio:buffer: Introduced a function to assign the buffer specific attrs.
This is a necessary step in taking the buffer implementation
opaque.

Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Reviewed-by: Lars-Peter Clausen <lars@metafoo.de>
2017-01-10 19:54:50 +00:00
Jonathan Cameron 78c9981f61 iio:buffer: Stop exporting iio_update_demux
Nothing outside of indiustrialio-buffer.c should be using this.
Requires a large amount of juggling of functions to avoid a
forward definition.

Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Reviewed-by: Lars-Peter Clausen <lars@metafoo.de>
2017-01-10 19:54:49 +00:00
Linus Walleij 762227721f iio: accel: st_accel: handle deprecated bindings
The earlier deployed LIS3LV02DL driver had already defined a few
DT bindings that need to be supported by the new more generic
driver and listed as compatible but deprecated bindings in the
documentation.

After this we can start to activate the new driver with the old
systems where applicable.

As part of this enablement: make us depend on the old drivers
not being in use so we don't get a kernel with two competing
drivers.

Cc: devicetree@vger.kernel.org
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Acked-by: Rob Herring <robh@kernel.org>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2017-01-10 19:54:16 +00:00
Song Hongyan 0e377f3b9a iio: Add gravity sensor support
Gravity sensor is a soft sensor, which derives value from
standard accelerometer device by filtering out the acceleration
which is not caused by gravity.

Gravity sensor provides a three dimensional vector indicating
the direction and magnitude of gravity. Typically, this sensor
is used to determine the device's relative orientation in space.
The units and the coordinate system is the same as the one used by
the acceleration sensor.
When a device is at rest, the output of the gravity sensor should
be identical to that of the accelerometer.

More information can be found in:
http://www.usb.org/developers/hidpage/HUTRR59_-_Usages_for_Wearables.pdf

Gravity sensor and accelerometer have similar channels and
share channel usage ids. So the most of the code for accel_3d
can be reused.

Signed-off-by: Song Hongyan <hongyan.song@intel.com>
Acked-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2017-01-05 13:07:24 +00:00
Song Hongyan 571299d099 iio: Add channel for Gravity
Add new channel types support for gravity sensor.

Gravity sensor provides an application-level or physical collection that
identifies a device that measures exclusively the force of Earth's
gravity along any number of axes.

More information can be found in:
http://www.usb.org/developers/hidpage/HUTRR59_-_Usages_for_Wearables.pdf

Signed-off-by: Song Hongyan <hongyan.song@intel.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2017-01-05 13:02:25 +00:00
Greg Kroah-Hartman 890b73af6b First round of IIO fixes for the 4.10 cycle.
* 104-quad-8
   - Fix selecting wrong register when the index control register is desired.
   - Fix an off by one error when addressing the input/output control register.
   - Fix inverted logic on the active high / low control
 * bmi160
   - Sleep for worst case rather than best case amount of time after cmd
   execution begins.
 * max44000
   - typo fix in illuminance_integration_time_available listing.
 * st-sensors
   - Fix channel data passing.  This one took a while to get tested on 24bit
   parts. Definitely one for stable asap as the bug broke quite a few parts.
   - lis3lv02 needs a data alignment bit set and the scaling was wrong.
 * ti_am335x
   - depend on HAS_DMA
 -----BEGIN PGP SIGNATURE-----
 
 iQJFBAABCAAvFiEEbilms4eEBlKRJoGxVIU0mcT0FogFAlhnxPERHGppYzIzQGtl
 cm5lbC5vcmcACgkQVIU0mcT0Fojkwg//TD9jlh6x/Xt7qi0EgC1c8Ie0Dr6iUsQr
 gYgvVMtIsjSlThXGtLWxjDLzLeW1DUpxwjy9Kqnwt5onBgBnQj5PAL/lptH7/e6z
 hxj6lXvz5j1pcjjyXzhMa4JPIZJUU75Jj4airhGoHdvTFQDzqKr9GpLKUnrf4lwt
 HWFtCcT90ckhg/PTTaxfIhI4gEHBHoVx9h1/3Tn4VImhE693rLPSs1nS7+hEQIn2
 LZbCMAtxMh3qcCIK9fYrri3e+28KJ7veiWE8mYynxBd6Wa6OGq/D316Ml616mRgZ
 3SpyDWy05YtM4nVNi1kFwKTHb3v6Ljeyno0lmP0joJlIGLwHJS1qDGL0Wps6RI87
 utrfcZKOI2hcoFm49OMYdV3MJ18umGo0asOFMlH6u0RaLXXAz7hN1l9nyB5VzejT
 8culF/8XgNYuzFhkD65Ecksoz0azfMwXphwyPm3WEt1EE5meMeXt6bVsfI+8vyhp
 e/TfhloVfLUobau5yF2C+ih7xrHkVta+f860jqCkiHqngUgzksLoah53mA2Wh36f
 2+D6RbEFEo6Fx4DoELm55CZKpVFv9Ia1ICkg2kuJCFBXL8aTAAYmyphyPDccXGSs
 G2DZCAUjJ1sP7xPVMGuLD7A/IvggUDbs8m0i2sVq4JRZVLRfBW9khjGaCmjOAWBY
 ijWzzZtUywo=
 =aYfF
 -----END PGP SIGNATURE-----

Merge tag 'iio-fixes-for-4.10a' of git://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio into staging-linus

Jonathan writes:

First round of IIO fixes for the 4.10 cycle.

* 104-quad-8
  - Fix selecting wrong register when the index control register is desired.
  - Fix an off by one error when addressing the input/output control register.
  - Fix inverted logic on the active high / low control
* bmi160
  - Sleep for worst case rather than best case amount of time after cmd
  execution begins.
* max44000
  - typo fix in illuminance_integration_time_available listing.
* st-sensors
  - Fix channel data passing.  This one took a while to get tested on 24bit
  parts. Definitely one for stable asap as the bug broke quite a few parts.
  - lis3lv02 needs a data alignment bit set and the scaling was wrong.
* ti_am335x
  - depend on HAS_DMA
2017-01-02 16:59:44 +01:00
Matt Ranostay b257c1a45e iio: pulsedlight-lidar-lite-v2: add lidar-lite-v3 property
Signed-off-by: Matt Ranostay <matt@ranostay.consulting>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2016-12-31 15:18:31 +00:00
Linus Walleij 65e4345c8e iio: accel: st_accel: fix LIS3LV02 reading and scaling
The LIS3LV02 has a special bit that need to be set to get the
read values left aligned. Before this patch we get gibberish
like this:

iio_generic_buffer -a -c10 -n lis3lv02dl_accel
(...)
0.000000 -0.010042 -0.642688 19155832931907
0.000000 -0.010042 -0.642688 19155858751073

Which is because we read a raw value for 1g as 64 which is
the nominal 1024 for 1g shifted 4 bits to the left by being
right-aligned rather than left aligned.

Since all other sensors are left aligned, add some code to
set the special DAS (data alignment setting) bit to 1 so that
the right value is now read like this:

iio_generic_buffer -a -c10 -n lis3lv02dl_accel
(...)
0.000000 -0.147095 -10.120135 24761614364956
-0.029419 -0.176514 -10.120135 24761631624540

The scaling was weird as well: we have a gain of 1000 for 1g
and 3000 for 6g. I don't even remember how I came up with the
old values but they are wrong.

Fixes: 3acddf74f8 ("iio: st-sensors: add support for lis3lv02d accelerometer")
Cc: Lorenzo Bianconi <lorenzo.bianconi@st.com>
Cc: Giuseppe Barba <giuseppe.barba@st.com>
Cc: Denis Ciocca <denis.ciocca@st.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2016-12-31 14:35:04 +00:00
Lorenzo Bianconi 65c8aea07d iio: common: st_sensors: fix channel data parsing
Using realbits as i2c/spi read len, when that value is not byte aligned
(e.g 12 bits), lead to skip msb part of out data registers.
Fix this taking into account scan_type.shift in addition to
scan_type.realbits as read length:

read_len = DIV_ROUND_UP(realbits + shift, 8)

This fix has been tested on 8, 12, 16, 24 bit sensors

Fixes: e7385de529 ("iio:st_sensors: align on storagebits boundaries")
Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@st.com>
Tested-by: Linus Walleij <linus.walleij@linaro.org>
Cc: <Stable@vger.kernel.org>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2016-12-31 14:32:09 +00:00
Akinobu Mita b4e8a0eb71 iio: max44000: correct value in illuminance_integration_time_available
According to the datasheet, the shortest available integration time for
ALS ADC conversion is 1.5625ms but illuminance_integration_time_available
sysfs file shows wrong value.

Cc: Crestez Dan Leonard <leonard.crestez@intel.com>
Cc: Jonathan Cameron <jic23@kernel.org>
Cc: Hartmut Knaack <knaack.h@gmx.de>
Cc: Lars-Peter Clausen <lars@metafoo.de>
Cc: Peter Meerwald-Stadler <pmeerw@pmeerw.net>
Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
Fixes: d5d8f49b6 ("max44000: Expose ambient sensor scaling")
Cc: <Stable@vger.kernel.org>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2016-12-30 20:20:23 +00:00
Peter Meerwald-Stadler 83b0b397b9 iio: dummy: No semicolon at end of function definition
Signed-off-by: Peter Meerwald-Stadler <pmeerw@pmeerw.net>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2016-12-30 18:35:05 +00:00
Michael Hennerich 2cc5b0df86 iio: dac: ad5593r: Add ACPI support
This patch adds the ACPI/PNP ID. The AD5592/3 driver core is already
designed around the unified device property API.

Signed-off-by: Michael Hennerich <michael.hennerich@analog.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2016-12-30 17:20:14 +00:00
Michael Hennerich b0570bcee3 iio: dac: ad5592r: Add ACPI support
This patch adds the ACPI/PNP ID. The AD5592/3 driver core is already
designed around the unified device property API.

Signed-off-by: Michael Hennerich <michael.hennerich@analog.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2016-12-30 17:19:36 +00:00
Linus Walleij 8afa505c12 iio: light: add driver for Capella CM3605
This adds a driver for the Capella Microsystems CM3605 Ambient
Light Sensor and proximity sensor. This is a pretty simple entirely
analog device that is interfaced with the target system using
the POUT (proximity out) and AOUT (ambient light out) signals.

The POUT signal is a simple high/low signal that indicates whether
an object is in proximity, most typically used to detect a face
in front of a mobile device. The signal requires that an infrared
LED is mounted next to the device, making IR light reflect off
the object in proximity and triggering the POUT signal. We grab
a GPIO pin to handle the POUT signal as an interrupt line and
register this as an event channel for the sensor.

Since the proximity sensor requires an IR LED, we add a LED trigger
named "cm3605" so that the infrared LED can just associate with
this trigger to be sure it is always on when the proximity sensor
needs it.

The AOUT is an analog voltage between 0 and 1550 mV that indicate
the LUX value in the ambient light: this is orthogonal to the
proximity sensor functionality. Since this analog voltage needs
to be converted into a digital value, the driver grabs an IIO
channel named "aout" associated with the device.

This patch created a combined ALS and proximity sensor driver.
The former supports raw reads of the LUX value and the latter
will generate proximity events.

To integrate this properly with Linux we also add a supply
regulator for the VDD pin (driving both functions) and add device
tree bindings to define the RSET resistor that in turn configures
the luminosity range of the ALS sensor.

Since the sensor needs to be on more or less constantly, we
restrict the power management to system suspend/resume: we
disable the IR LED and disable the regulator for VDD on suspend
and take them back up on resume.

Tests:
cd /sys/bus/iio/devices/iio:device1
cat in_illuminance_raw
304
(hold hand over sensor)
cat in_illuminance_raw
17
iio_event_monitor cm3605
Found IIO device with name cm3605 with device number 1
(hold hand over sensor)
Event: time: 2444842301447, type: proximity, channel: 0,
  evtype: thresh, direction: falling
(remove hand over sensor)
Event: time: 2445583440706, type: proximity, channel: 0,
  evtype: thresh, direction: rising

Cc: Capella Microsystems <capellamicro@gmail.com>
Cc: Kevin Tsai <ktsai@capellamicro.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2016-12-30 17:17:39 +00:00
Kweh, Hock Leong 578f8d7708 iio: light: hid-sensor-als: Add duplicate IIO_LIGHT channel
There is one light sensor type defined in the sensor hub specification,
which has one Illuminance field. It doesn't distinguish between ambient
light sensor or color sensor. Currently it is presented as IIO_INTENSITY
channel. There are some user spaces specifically looking for IIO_LIGHT
channel.
To satisfy such user spaces this change also add a duplicate IIO_LIGHT
channel. The units of measurement of Illuminance field is Lux, so it is
still compatible to IIO ABI.

Signed-off-by: Kweh, Hock Leong <hock.leong.kweh@intel.com>
Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2016-12-30 17:06:34 +00:00
Geert Uytterhoeven b1448ea9cd iio: adc: TI_AM335X_ADC should depend on HAS_DMA
If NO_DMA=y:

    ERROR: "bad_dma_ops" [drivers/iio/adc/ti_am335x_adc.ko] undefined!

Add a dependency on HAS_DMA to fix this.

Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
Fixes: f438b9da (" drivers: iio: ti_am335x_adc: add dma support")
Cc: <stable@vger.kernel.org>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2016-12-30 16:37:48 +00:00
Marcin Niestroj 7f0d874036 iio: st_pressure: Export sampling frequency for lps25h and lps331ap
Both devices are using the same iio_chan_spec to define which settings
are exported with sysfs. Both are properly configured to set/get
sampling frequency for pressure and temperature. They also properly
export available sampling frequencies. The only missing thing is
sampling_frequency sysfs file, which allows to set/get this property
from userspace.

Add sampling frequency to iio channel info mask, so sampling_frequency
file is properly exported using sysfs.

Signed-off-by: Marcin Niestroj <m.niestroj@grinn-global.com>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2016-12-30 11:33:56 +00:00
Marcin Niestroj 1b211d48ab iio: st_pressure: Fix data sign
Datasheet of each device (lps331ap, lps25h, lps001wp, lps22hb) says that
the pressure and temperature data is a 2's complement.

I'm sending this the slow way, as negative pressures on these are pretty
unusual and the nature of the fixing of multiple device introduction patches
will make it hard to apply to older kernels - Jonathan.

Fixes: 217494e5b7 ("iio:pressure: Add STMicroelectronics pressures driver")
Fixes: 2f5effcbd0 ("iio: pressure-core: st: Expand and rename LPS331AP's channel descriptor")
Fixes: 7885a8ce68 ("iio: pressure: st: Add support for new LPS001WP pressure sensor")
Fixes: e039e2f5b4 ("iio:st_pressure:initial lps22hb sensor support")
Signed-off-by: Marcin Niestroj <m.niestroj@grinn-global.com>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2016-12-30 11:31:16 +00:00
Marcin Niestroj 01d1f7a99e iio: bmi160: Fix time needed to sleep after command execution
Datasheet specifies typical and maximum execution times for which CMD
register is occupied after previous command execution. We took these
values as minimum and maximum time for usleep_range() call before making
a new command execution.

To be sure, that the CMD register is no longer occupied we need to wait
*at least* the maximum time specified by datasheet.

Signed-off-by: Marcin Niestroj <m.niestroj@grinn-global.com>
Cc: <Stable@vger.kernel.org>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2016-12-30 10:52:00 +00:00
Marcin Niestroj 75eadb8fe0 iio: bmi160: Add of device table for spi
From now on we can add bmi160 device to device-tree by specifying
compatible string.

Signed-off-by: Marcin Niestroj <m.niestroj@grinn-global.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2016-12-30 10:38:19 +00:00
Marcin Niestroj 968bdbf8f3 iio: bmi160: Add of device table for i2c
From now on we can add bmi160 device to device-tree by specifying
compatible string.

Signed-off-by: Marcin Niestroj <m.niestroj@grinn-global.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2016-12-30 10:32:39 +00:00
Thomas Gleixner 8b0e195314 ktime: Cleanup ktime_set() usage
ktime_set(S,N) was required for the timespec storage type and is still
useful for situations where a Seconds and Nanoseconds part of a time value
needs to be converted. For anything where the Seconds argument is 0, this
is pointless and can be replaced with a simple assignment.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Peter Zijlstra <peterz@infradead.org>
2016-12-25 17:21:22 +01:00
Rama Krishna Phani A 7c271eea7b iio: adc: spmi-vadc: Changes to support different scaling
Several ADC channels are supported in PMIC which can be used to
measure voltage, temperature, current etc. Different scaling can be
applied on the obtained voltage to report in physical units. Scaling
functionality can be different per channel. Add scaling support per
channel. Every channel present in adc has an unique conversion formula
for obtained voltage. Add support to report in Raw as well as in
processed format. Scaling is applied when processed read is requested
and is not applied when a Raw read is requested.

Signed-off-by: Rama Krishna Phani A <rphani@codeaurora.org>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2016-12-10 17:28:21 +00:00
Rama Krishna Phani A ba71704af4 iio: adc: spmi-vadc: Update function for generic voltage conversion
Several channels are supported in ADC of PMIC which can be used to
measure voltage, temperature, current etc., Hardware provides
readings for all channels in adc code. That adc code needs to be
converted to voltage. Logic for conversion of adc code to voltage
is common for all ADC channels(voltage, temperature, current
.,etc). Implement separate function for generic conversion logic.

Signed-off-by: Rama Krishna Phani A <rphani@codeaurora.org>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2016-12-10 17:25:48 +00:00
Pan Bian db4e5376d0 iio: light: fix improper return value
In function cm3232_reg_init(), it returns 0 even if the last call to
i2c_smbus_write_byte_data() returns a negative value (indicates error).
As a result, the return value may be inconsistent with the execution
status, and the caller of cm3232_reg_init() will not be able to detect
the error. This patch fixes the bug.

Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=188641

Signed-off-by: Pan Bian <bianpan2016@163.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2016-12-04 10:56:26 +00:00
William Breathitt Gray e91c3dfcd3 iio: 104-quad-8: Fix active level mismatch for the preset enable option
The set_to_preset_on_index sysfs attribute provides a boolean
configuration option to enable a preset operation on the respective
channel's counter when Index occurs. However, the corresponding
configuration bit on the Input/Output Control register must be set low
to enable the preset operation.

This patch inverts the internal driver boolean logic exposed via the
set_to_preset_on_index attribute in order to correctly configure the
device which expects an active low bit.

Fixes: 28e5d3bb03 ("iio: 104-quad-8: Add IIO support for the ACCES 104-QUAD-8")
Signed-off-by: William Breathitt Gray <vilhelm.gray@gmail.com>
Cc: <Stable@vger.kernel.org>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2016-12-03 10:08:09 +00:00
Srinivas Pandruvada a96cd0f901 iio: accel: hid-sensor-accel-3d: Add timestamp
Added timestamp channel. With this change, each sample has a timestamp.
This timestamp can be from the sensor hub when present or local kernel
timestamp. HID sensors can send timestamp with input data using usage id
HID_USAGE_SENSOR_TIME_TIMESTAMP. This timestamp value is converted to
nano seconds before pushing this sample to the iio core.

Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2016-12-03 10:06:13 +00:00
William Breathitt Gray 7e1c4058e7 iio: 104-quad-8: Fix off-by-one errors when addressing IOR
The Input/Output Control register (IOR) is offset by 1 from the
respective channel data register. This patch fixes off-by-one errors
when attempting to write to a channel IOR where the base address was not
properly offset.

Fixes: 28e5d3bb03 ("iio: 104-quad-8: Add IIO support for the ACCES 104-QUAD-8")
Signed-off-by: William Breathitt Gray <vilhelm.gray@gmail.com>
Cc: <Stable@vger.kernel.org>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2016-12-03 10:03:07 +00:00
William Breathitt Gray 47af2c676a iio: 104-quad-8: Fix index control configuration
The LS7266R1 requires bits 5 & 6 to be high in order to select the Index
Control Register. This patch fixes a typo that incorrectly selects the
Input/Output Control Register where the Index Control Register was
desired.

Fixes: 28e5d3bb03 ("iio: 104-quad-8: Add IIO support for the ACCES 104-QUAD-8")
Signed-off-by: William Breathitt Gray <vilhelm.gray@gmail.com>
Cc: <Stable@vger.kernel.org>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2016-12-03 10:00:24 +00:00
David Lechner 902c4b2446 iio: adc: New driver for TI ADS7950 chips
This adds a new driver for the TI ADS7950 family of ADC chips. These
communicate using SPI and come in 8/10/12-bit and 4/8/12/16 channel
varieties.

Signed-off-by: David Lechner <david@lechnology.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2016-12-03 09:57:21 +00:00
Aniroop Mathur 071cf24943 IIO: Change msleep to usleep_range for small msecs
msleep(1~20) may not do what the caller intends, and will often sleep longer.
(~20 ms actual sleep for any value given in the 1~20ms range)
This is not the desired behaviour for many cases like device resume time,
device suspend time, device enable time, data reading time, etc.
Thus, change msleep to usleep_range for precise wakeups.

Signed-off-by: Aniroop Mathur <a.mathur@samsung.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2016-12-03 08:58:40 +00:00
Martin Kepplinger 32b2807680 iio: accel: mma8452: define unsigned return values where appropriate
smatch warned:
	sval_binop_signed: invalid divide LLONG_MIN/-1

and this fixes it. It's actually good to have, in order to avoid accidental
checking for negative return values here.

Signed-off-by: Martin Kepplinger <martink@posteo.de>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2016-12-03 08:56:28 +00:00
Shrirang Bagul 25fc503e2d iio: humidity: Support acpi probe for hts211
Support driver probe by reading unique HID on systems based on ACPI instead
of DT compatible strings.

Signed-off-by: Shrirang Bagul <shrirang.bagul@canonical.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2016-12-03 08:56:28 +00:00
Shrirang Bagul 9d317724cf iio: st_pressure: Support i2c probe using acpi
Compatible strings are not available on ACPI based systems. This patch adds
support to use DSDT information read from platform BIOS instead for probing
st pressure sensors.

Signed-off-by: Shrirang Bagul <shrirang.bagul@canonical.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2016-12-03 08:56:27 +00:00
Shrirang Bagul 89a2a93f3b iio: st_accel: Support sensor i2c probe using acpi
Add support to probe st_accel sensors on i2c bus using ACPI. Compatible
strings are not avaialable on ACPI based systems.

Signed-off-by: Shrirang Bagul <shrirang.bagul@canonical.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2016-12-03 08:56:26 +00:00
Shrirang Bagul 3dc59262f7 iio: st_sensors: match sensors using ACPI handle
Add support to match st sensors using information passed from ACPI DST
tables.

Signed-off-by: Shrirang Bagul <shrirang.bagul@canonical.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2016-12-03 08:56:26 +00:00
Ooi, Joyce 6f771d0b33 iio: magnetometer: separate the values of attributes based on their usage type for HID compass sensor
There are 2 usage types (Magnetic Flux and Heading data field) for HID
compass sensor, thus the values of offset, scale, and sensitivity should
be separated according to their respective usage type. The changes made
are as below:
1. Hysteresis: A struct hid_sensor_common rot_attributes is created in
struct magn_3d_state to contain the sensitivity for IIO_ROT.
2. Scale: scale_pre_decml and scale_post_decml are separated for IIO_MAGN
and IIO_ROT.
3. Offset: Same as scale, value_offset is separated for IIO_MAGN and
IIO_ROT.

For sensitivity, HID_USAGE_SENSOR_ORIENT_MAGN_FLUX and
HID_USAGE_SENSOR_ORIENT_MAGN_HEADING are used for sensivitity fields based
on the HID Sensor Usages specifications. Hence, these changes are added on
the sensitivity field.

Signed-off-by: Ooi, Joyce <joyce.ooi@intel.com>
Acked-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2016-11-24 20:41:30 +00:00
Dan Carpenter 0e8d2b0f74 iio: tsl2583: make array large enough
This array is supposed to have 10 elements.  Smatch complains that with
the current code we can have n == max_ints and read beyond the end of
the array.

Fixes: ac4f6eee8f ("staging: iio: TAOS tsl258x: Device driver")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Acked-by: Brian Masney <masneyb@onstation.org>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2016-11-24 20:09:55 +00:00
Linus Walleij 9049531c91 iio: accel: st_accel: inline per-sensor data
We have #defines for all the individual sensor registers and
value/mask pairs #defined at the top of the file and used at
exactly one spot.

This is usually good if the #defines give a meaning to the
opaque magic numbers.

However in this case, the semantic meaning is inherent in the
name of the C99-addressable fields, and that means duplication
of information, and only makes the code hard to maintain since
you every time have to add a new #define AND update the site
where it is to be used.

Get rid of the #defines and just open code the values into the
appropriate struct elements. Make sure to explicitly address
the .hz and .value fields in the st_sensor_odr_avl struct
so that the meaning of all values is clear.

This patch is purely syntactic should have no semantic effect.

Cc: Lorenzo Bianconi <lorenzo.bianconi83@gmail.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Acked-by: Lorenzo Bianconi <lorenzo.bianconi@st.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2016-11-19 12:25:36 +00:00
Fabrice Gasnier 0f883b223a iio: adc: Add support for STM32 ADC
This patch adds support for STMicroelectronics STM32 MCU's analog to
digital converter.

Signed-off-by: Fabrice Gasnier <fabrice.gasnier@st.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2016-11-19 12:18:33 +00:00
Fabrice Gasnier 1add698802 iio: adc: Add support for STM32 ADC core
Add core driver for STMicroelectronics STM32 ADC (Analog to Digital
Converter). STM32 ADC can be composed of up to 3 ADCs with shared
resources like clock prescaler, common interrupt line and analog
reference voltage.
This core driver basically manages shared resources.

Signed-off-by: Fabrice Gasnier <fabrice.gasnier@st.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2016-11-19 12:17:45 +00:00
Greg Kroah-Hartman 2c52b1efd6 Third set of IIO new device support, features and cleanup for the 4.10 cycle.
Includes Peter Rosin's interesting drivers for a comparator. First complex
 use we have had with an analog front end made from discrete components.
 
 Brian Masney's work on moving the tsl2583 driver out of staging also
 feature extensively!
 
 New Drivers
 * DAC based on a digital potentiometer
   - New driver for the use of a dpot as a DAC. Includes bindings and Axentia
   entry in vendor prefixes.
 * Envelope detector baed on DAC and a comparator including device tree
   bindings.
 
 Staging Graduation
 * tsl2583.
 
 Core new features
 - Core provision for _available attributes.   This one had been stalled for
   a long time until Peter picked it up and ran with it!
 - In kernel interface helpers to retrieve available info from channels.
 
 Driver new features
 * mcp4531
   - Add range of available raw values (used for the dpot dac driver).
 
 Driver cleanups and fixes for issues introduced
 * ad7766
   - Testing the wrong variable following devm_regulator_bulk_get introduced
   with the driver earlier in this cycle.
 * ad9832
   - Fix a wrong ordering in the probe introduced in the previous set of
     patches.  A use before allocation bug.
 * cros_ec_sensors
   - Testing for an error in a u8 will never work.
 * mpu3050
   - Remove duplicate initializer for the module owner.
   - Add missing i2c dependency.
   - Inform the i2c mux core how it is used - step one in implifying device
   tree bindings.
 * st-sensors
   - Get rid of large number of uninformative defines in favour of putting the
   constants where they are relevant. It is clear what they are from where
   they are used.
 * tsl2583
   - Fix unused function warning when CONFIG_PM disabled and remove the
   ifdefs in favour of __maybe_unused.
   - Refactor taos_chip_on  to only read relevant registers.
   - Make sure calibscale and integration time are being set.
   - Verify chip is in ready to be used before calibration.
   - Remove some repeated checks for chip status (it's protected by a mutex
   so can't change until it's released)
   - Change current state storage from a tristate enum to a boolean seeing as
   only two values are actually used now.
   - Drop a redundant write to the control regiser in taos_probe (it's a noop)
   - Drop the FSF mailing address.
   - Clean up logging to not use hard coded function names (use __func__
   instead).
   - Cleanup up variable and function name prefixes.
   - Alignment of #define fixes.
   - Fix comparison between signed and unsigned integer warnings.
   - Add some newlines in favour of readability.
   - Combine the two sysfs ABI docs that somehow ended up in different places.
   - Fix multiline comment syntax.
   - Move a code block to inside an else statement as it makes more sense there.
   - Change tsl2583_als_calibrate to return 0 rather than a value nothing
   reads.
   - Drop some pointless brackets
   - Don't assume 32bit unsigned int.
   - Change to a per device instance lux table.
   - Add missing tsl2583 to the list of supported devices in the intro comments.
   - Improve commment on clearing of interrupts.
   - Drop some uninformative comments.
   - Drop a memset call that doesn't do anything useful any more.
   - Don't initialize some return variables that are always set.
   - Add Brian Masney as a module author after all these changes.
 -----BEGIN PGP SIGNATURE-----
 
 iQIuBAABCAAYBQJYKMYhERxqaWMyM0BrZXJuZWwub3JnAAoJEFSFNJnE9BaIiNMP
 /00ZTTfPR/I5VtriTchGTgXN6lDTnypFk9Z4niynK3EIdF6Mw5XphQjtUzg7sJl4
 U7yH89lzt0PxAJHylW5x0YOwrr6fyau+rNA2Kj26psaQpf5Yva0UDRexsomTZaad
 P005cf0yc4fuG/7KvjeONeLeaRXf9Qfs20r8htECLFhIGSE0qsGtfzUMn6tdbyn/
 r/hxHR7oE2YThuFytX2sNJEJVmCDz+tTOz7kJv5L0e6Cg6cvMFizYUsoFYcZYGOQ
 DNicdRfW5FOidBMCqXzYLDBn+oY+a35g90hFV3CvYsfEm+X6BzTgr3FI3PHmtXHT
 RRAmRdgxg2z/rqp475f5EamRtZxEg0uktbqcs9bH8Bx7IDe8KtoNKLdPdxIT3T1D
 ZYb0RkpPmfnBq3bDGh7DJVWl+Ht9Fj0jaKRNyWgiyopA9c6zN4MKRA+HNSxKRvD7
 Qizw0QIPbtEGkw6WbQrrOSSwzNY/dq51vrT0eBmMaGpjmdDpRKrK53/k7uwk3/Wv
 hjGWD5kdLRCAHL+EQKFssN/RgLS5PRhXsJQFeIYbH8VJFlEZ28j09gXJnjcpDucK
 CXv37q8CX6wJ2NB+i+skOvKpxArgv+Mr4oE9LNYZie65EUyN28/Ii1n9vYmTPTlG
 KXGKPynaR0sfrl+ir6+FCtuFXJnYC5WUqJH/yMRjA2z8
 =mPkb
 -----END PGP SIGNATURE-----

Merge tag 'iio-for-4.10c' of git://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio into staging-next

Jonathan writes:

Third set of IIO new device support, features and cleanup for the 4.10 cycle.

Includes Peter Rosin's interesting drivers for a comparator. First complex
use we have had with an analog front end made from discrete components.

Brian Masney's work on moving the tsl2583 driver out of staging also
feature extensively!

New Drivers
* DAC based on a digital potentiometer
  - New driver for the use of a dpot as a DAC. Includes bindings and Axentia
  entry in vendor prefixes.
* Envelope detector baed on DAC and a comparator including device tree
  bindings.

Staging Graduation
* tsl2583.

Core new features
- Core provision for _available attributes.   This one had been stalled for
  a long time until Peter picked it up and ran with it!
- In kernel interface helpers to retrieve available info from channels.

Driver new features
* mcp4531
  - Add range of available raw values (used for the dpot dac driver).

Driver cleanups and fixes for issues introduced
* ad7766
  - Testing the wrong variable following devm_regulator_bulk_get introduced
  with the driver earlier in this cycle.
* ad9832
  - Fix a wrong ordering in the probe introduced in the previous set of
    patches.  A use before allocation bug.
* cros_ec_sensors
  - Testing for an error in a u8 will never work.
* mpu3050
  - Remove duplicate initializer for the module owner.
  - Add missing i2c dependency.
  - Inform the i2c mux core how it is used - step one in implifying device
  tree bindings.
* st-sensors
  - Get rid of large number of uninformative defines in favour of putting the
  constants where they are relevant. It is clear what they are from where
  they are used.
* tsl2583
  - Fix unused function warning when CONFIG_PM disabled and remove the
  ifdefs in favour of __maybe_unused.
  - Refactor taos_chip_on  to only read relevant registers.
  - Make sure calibscale and integration time are being set.
  - Verify chip is in ready to be used before calibration.
  - Remove some repeated checks for chip status (it's protected by a mutex
  so can't change until it's released)
  - Change current state storage from a tristate enum to a boolean seeing as
  only two values are actually used now.
  - Drop a redundant write to the control regiser in taos_probe (it's a noop)
  - Drop the FSF mailing address.
  - Clean up logging to not use hard coded function names (use __func__
  instead).
  - Cleanup up variable and function name prefixes.
  - Alignment of #define fixes.
  - Fix comparison between signed and unsigned integer warnings.
  - Add some newlines in favour of readability.
  - Combine the two sysfs ABI docs that somehow ended up in different places.
  - Fix multiline comment syntax.
  - Move a code block to inside an else statement as it makes more sense there.
  - Change tsl2583_als_calibrate to return 0 rather than a value nothing
  reads.
  - Drop some pointless brackets
  - Don't assume 32bit unsigned int.
  - Change to a per device instance lux table.
  - Add missing tsl2583 to the list of supported devices in the intro comments.
  - Improve commment on clearing of interrupts.
  - Drop some uninformative comments.
  - Drop a memset call that doesn't do anything useful any more.
  - Don't initialize some return variables that are always set.
  - Add Brian Masney as a module author after all these changes.
2016-11-16 17:20:40 +01:00
Greg Kroah-Hartman ce0347c2b0 Merge 4.9-rc5 into staging-next
We want the staging/iio fixes in here as well to resolve issues and
merge problems.

Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-11-14 08:53:56 +01:00
Brian Masney f44d5c8ac3 staging: iio: tsl2583: move out of staging
Move tsl2580, tsl2581, tsl2583 driver out of staging into mainline.

Signed-off-by: Brian Masney <masneyb@onstation.org>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2016-11-13 13:07:33 +00:00
Peter Rosin b475f80b35 iio: envelope-detector: ADC driver based on a DAC and a comparator
The DAC is used to find the peak level of an alternating voltage input
signal by a binary search using the output of a comparator wired to
an interrupt pin. Like so:
                          _
                         | \
    input +------>-------|+ \
                         |   \
           .-------.     |    }---.
           |       |     |   /    |
           |    dac|-->--|- /     |
           |       |     |_/      |
           |       |              |
           |       |              |
           |    irq|------<-------'
           |       |
           '-------'

Signed-off-by: Peter Rosin <peda@axentia.se>
Acked-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2016-11-13 13:07:17 +00:00
Peter Rosin 7fde1484af iio: dpot-dac: DAC driver based on a digital potentiometer
It is assumed that the dpot is used as a voltage divider between the
current dpot wiper setting and the maximum resistance of the dpot. The
divided voltage is provided by a vref regulator.

                  .------.
   .-----------.  |      |
   | vref      |--'    .---.
   | regulator |--.    |   |
   '-----------'  |    | d |
                  |    | p |
                  |    | o |  wiper
                  |    | t |<---------+
                  |    |   |
                  |    '---'       dac output voltage
                  |      |
                  '------+------------+

Signed-off-by: Peter Rosin <peda@axentia.se>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2016-11-13 13:07:15 +00:00
Peter Rosin 2704e30014 iio: mcp4531: provide range of available raw values
Example:

$ cat '/sys/bus/iio/devices/iio:device0/out_resistance_raw_available'
[0 1 256]

Meaning: min 0, step 1 and max 256.

Signed-off-by: Peter Rosin <peda@axentia.se>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2016-11-13 11:40:26 +00:00
Peter Rosin 00c5f80c2f iio: inkern: add helpers to query available values from channels
Specifically a helper for reading the available maximum raw value of a
channel and a helper for forwarding read_avail requests for raw values
from one iio driver to an iio channel that is consumed.

These rather specific helpers are in turn built with generic helpers
making it easy to build more helpers for available values as needed.

Signed-off-by: Peter Rosin <peda@axentia.se>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2016-11-13 11:40:26 +00:00
Jonathan Cameron 5123960007 iio:core: add a callback to allow drivers to provide _available attributes
A large number of attributes can only take a limited range of values.
Currently in IIO this is handled by directly registering additional
*_available attributes thus providing this information to userspace.

It is desirable to provide this information via the core for much the same
reason this was done for the actual channel information attributes in the
first place.  If it isn't there, then it can only really be accessed from
userspace.  Other in kernel IIO consumers have no access to what valid
parameters are.

Two forms are currently supported:
* list of values in one particular IIO_VAL_* format.
	e.g. 1.300000 1.500000 1.730000
* range specification with a step size:
	e.g. [1.000000 0.500000 2.500000]
	equivalent to 1.000000 1.5000000 2.000000 2.500000

An addition set of masks are used to allow different sharing rules for the
*_available attributes generated.

This allows for example:

in_accel_x_offset
in_accel_y_offset
in_accel_offset_available.

We could have gone with having a specification for each and every
info_mask element but that would have meant changing the existing userspace
ABI.  This approach does not.

Signed-off-by: Jonathan Cameron <jic23@kernel.org>
[forward ported, added some docs and fixed buffer overflows /peda]
Acked-by: Daniel Baluta <daniel.baluta@intel.com>
Signed-off-by: Peter Rosin <peda@axentia.se>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2016-11-13 11:40:25 +00:00
Arnd Bergmann d70674eeaa iio: maxim_thermocouple: detect invalid storage size in read()
As found by gcc -Wmaybe-uninitialized, having a storage_bytes value other
than 2 or 4 will result in undefined behavior:

drivers/iio/temperature/maxim_thermocouple.c: In function 'maxim_thermocouple_read':
drivers/iio/temperature/maxim_thermocouple.c:141:5: error: 'ret' may be used uninitialized in this function [-Werror=maybe-uninitialized]

This probably cannot happen, but returning -EINVAL here is appropriate
and makes gcc happy and the code more robust.

Fixes: 231147ee77 ("iio: maxim_thermocouple: Align 16 bit big endian value of raw reads")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
(cherry picked from commit 32cb7d27e6)
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-11-13 10:08:32 +01:00