platform/kernel/linux-rpi.git
7 years agoiio: imu: st_lsm6dsx: do not apply ODR configuration in write_raw handler
Lorenzo Bianconi [Sun, 2 Apr 2017 12:58:45 +0000 (14:58 +0200)]
iio: imu: st_lsm6dsx: do not apply ODR configuration in write_raw handler

This patch allows to avoid a transitory that occurs when a given sensor
has been already enabled (e.g. gyroscope) and the user is configuring
the sample frequency of the other one (e.g. accelerometer).
The transitory lasts until the accelerometer is enabled.
During that time slice the gyroscope ODR is incorrectly modified as well.
At the end of the transitory both sensors work at the right frequency.
Fix it introducing st_lsm6dsx_check_odr() routine to check ODR consistency
in write_raw handler in order to apply frequency configuration just
in st_lsm6dsx_set_odr()

Fixes: 290a6ce11d93 (iio: imu: add support to lsm6dsx driver)
Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@st.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
7 years agoiio: adc: sun4i: add THERMAL dependency
Arnd Bergmann [Tue, 28 Mar 2017 10:07:23 +0000 (12:07 +0200)]
iio: adc: sun4i: add THERMAL dependency

With CONFIG_THERMAL=m and CONFIG_SUN4I_GPADC=y, we get a link error
from calling devm_thermal_zone_of_sensor_register:

drivers/iio/built-in.o: In function `sun4i_gpadc_probe':
:(.text+0x1c284): undefined reference to `devm_thermal_zone_of_sensor_register'

This adds a Kconfig dependency to ensure we can only have the ADC
driver as built-in when this function is also built-in, or when
we see the empty stub implementation. When the thermal code is
a module, we can still build the adc driver as a module, too.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Fixes: d1caa99055382 ("iio: adc: add support for Allwinner SoCs ADC")
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
7 years agoiio:adc: Driver for Linear Technology LTC2497 ADC
Michael Hennerich [Wed, 29 Mar 2017 09:42:58 +0000 (11:42 +0200)]
iio:adc: Driver for Linear Technology LTC2497 ADC

This patch adds support for the Analog Devices / Linear Technology
LTC2497 ADCs. The LTC2497 is a 16-channel (eight differential),
16-bit, high precision, delta-sigma ADC with an automatic, differential,
input current cancellation front end and a 2-wire, I2C interface.

Signed-off-by: Michael Hennerich <michael.hennerich@analog.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
7 years agostaging: iio: ad9832: use 4-digit octal permissions
Guru Das Srinagesh [Thu, 30 Mar 2017 09:55:39 +0000 (02:55 -0700)]
staging: iio: ad9832: use 4-digit octal permissions

This fixes the coding style issue of using S_IWUSR in place of 4-digit
octal numbers.

Issue detected by checkpatch.

Signed-off-by: Guru Das Srinagesh <gurooodas@gmail.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
7 years agoiio:imu:mpu6050 add explicit mpu9250 support
Jonathan Cameron [Sun, 26 Mar 2017 11:11:00 +0000 (12:11 +0100)]
iio:imu:mpu6050 add explicit mpu9250 support

The mpu9250 is a SIP containing an mpu6500 and an ak8975.  If this was all
there was too it there would be no need for explicit handling in the driver.
Arguably the bindings would also only reflect the presence of an mpu6500 with
the ak8975 hanging off it, as the kernel doesn't care that they are in one
package.

However, the WHOAMI value changes as well so best to add explicit support.

Signed-off-by: Jonathan Cameron <jic23@kernel.org>
7 years agoiio:imu:mpu6050 update i2c bindings to reflect i2c-gate and supported parts
Jonathan Cameron [Sun, 26 Mar 2017 11:10:59 +0000 (12:10 +0100)]
iio:imu:mpu6050 update i2c bindings to reflect i2c-gate and supported parts

These bindings are somewhat lagging the state of the driver.  The i2c-gate
bindings are documented elsewhere, but it seems sensible to at least have
an example and cross reference in here.  SPI bindings will need to be the
subject of a future patch.

Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Acked-by: Rob Herring <robh@kernel.org>
7 years agodt-bindings: iio: rockchip-saradc: add support for rk3328
Liang Chen [Mon, 27 Mar 2017 09:40:46 +0000 (17:40 +0800)]
dt-bindings: iio: rockchip-saradc: add support for rk3328

The rk3328 saradc is the same as rk3399.

Signed-off-by: Liang Chen <cl@rock-chips.com>
Reviewed-by: Heiko Stuebner <heiko@sntech.de>
Acked-by: Rob Herring <robh@kernel.org>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
7 years agoiio: pressure: zpa2326: Remove unnecessary cast on void pointer
simran singhal [Sat, 1 Apr 2017 14:18:39 +0000 (19:48 +0530)]
iio: pressure: zpa2326: Remove unnecessary cast on void pointer

The following Coccinelle script was used to detect this:
@r@
expression x;
void* e;
type T;
identifier f;
@@
(
  *((T *)e)
|
  ((T *)x)[...]
|
  ((T*)x)->f
|
- (T*)
  e
)

Signed-off-by: simran singhal <singhalsimran0@gmail.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
7 years agoiio: imu: st_lsm6dsx: Remove unnecessary cast on void pointer
simran singhal [Sat, 1 Apr 2017 14:16:24 +0000 (19:46 +0530)]
iio: imu: st_lsm6dsx: Remove unnecessary cast on void pointer

The following Coccinelle script was used to detect this:
@r@
expression x;
void* e;
type T;
identifier f;
@@
(
  *((T *)e)
|
  ((T *)x)[...]
|
  ((T*)x)->f
|
- (T*)
  e
)

Signed-off-by: simran singhal <singhalsimran0@gmail.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
7 years agoiio: humidity: hts221: Remove unnecessary cast on void pointer
simran singhal [Sat, 1 Apr 2017 14:14:15 +0000 (19:44 +0530)]
iio: humidity: hts221: Remove unnecessary cast on void pointer

The following Coccinelle script was used to detect this:
@r@
expression x;
void* e;
type T;
identifier f;
@@
(
  *((T *)e)
|
  ((T *)x)[...]
|
  ((T*)x)->f
|
- (T*)
  e
)

Signed-off-by: simran singhal <singhalsimran0@gmail.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
7 years agoiio: dac: ad5504: Remove unnecessary cast on void pointer
simran singhal [Sat, 1 Apr 2017 14:11:53 +0000 (19:41 +0530)]
iio: dac: ad5504: Remove unnecessary cast on void pointer

The following Coccinelle script was used to detect this:
@r@
expression x;
void* e;
type T;
identifier f;
@@
(
  *((T *)e)
|
  ((T *)x)[...]
|
  ((T*)x)->f
|
- (T*)
  e
)

Signed-off-by: simran singhal <singhalsimran0@gmail.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
7 years agoiio: common: ms_sensors: Remove unnecessary cast on void pointer
simran singhal [Sat, 1 Apr 2017 14:09:21 +0000 (19:39 +0530)]
iio: common: ms_sensors: Remove unnecessary cast on void pointer

The following Coccinelle script was used to detect this:
@r@
expression x;
void* e;
type T;
identifier f;
@@
(
  *((T *)e)
|
  ((T *)x)[...]
|
  ((T*)x)->f
|
- (T*)
  e
)

Signed-off-by: simran singhal <singhalsimran0@gmail.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
7 years agoiio: adc: Remove unnecessary cast on void pointer
simran singhal [Sat, 1 Apr 2017 14:06:14 +0000 (19:36 +0530)]
iio: adc: Remove unnecessary cast on void pointer

The following Coccinelle script was used to detect this:
@r@
expression x;
void* e;
type T;
identifier f;
@@
(
  *((T *)e)
|
  ((T *)x)[...]
|
  ((T*)x)->f
|
- (T*)
  e
)

Signed-off-by: simran singhal <singhalsimran0@gmail.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
7 years agoiio: gyro: adis16060: Change the name of function.
simran singhal [Fri, 31 Mar 2017 10:21:43 +0000 (15:51 +0530)]
iio: gyro: adis16060: Change the name of function.

Change the name of function from adis16060_spi_write_than_read()
to adis16060_spi_write_then_read(). change "than" to "then" as
its time depended.

Signed-off-by: simran singhal <singhalsimran0@gmail.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
7 years agoiio: light: lm3533-als: constify attribute_group structures
simran singhal [Thu, 30 Mar 2017 18:40:38 +0000 (00:10 +0530)]
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>
7 years agoiio: Aspeed ADC
Rick Altherr [Tue, 28 Mar 2017 21:52:59 +0000 (14:52 -0700)]
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>
7 years agoDocumentation: dt-bindings: Document bindings for Aspeed ADC
Rick Altherr [Tue, 28 Mar 2017 21:52:58 +0000 (14:52 -0700)]
Documentation: dt-bindings: Document bindings for Aspeed ADC

Signed-off-by: Rick Altherr <raltherr@google.com>
Acked-by: Joel Stanley <joel@jms.id.au>
Acked-by: Rob Herring <robh@kernel.org>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
7 years agostaging: iio: light: tsl2x7x constify attribute_group structures
simran singhal [Sat, 1 Apr 2017 02:28:56 +0000 (07:58 +0530)]
staging: iio: light: tsl2x7x constify attribute_group structures

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

File size before:
   text    data     bss     dec     hex filename
  15064    1528       0   16592    40d0
drivers/staging/iio/light/tsl2x7x_core.o

File size after:
   text    data     bss     dec     hex filename
  15192    1400       0   16592    40d0
drivers/staging/iio/light/tsl2x7x_core.o

Signed-off-by: simran singhal <singhalsimran0@gmail.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
7 years agoiio: adc: hx711: constify attribute_group structures
simran singhal [Sat, 1 Apr 2017 08:17:51 +0000 (13:47 +0530)]
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>
7 years agoiio: humidity: hdc100x: constify attribute_group structures
simran singhal [Sat, 1 Apr 2017 08:23:33 +0000 (13:53 +0530)]
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>
7 years agoiio: light: apds9960: constify attribute_group structures
simran singhal [Sat, 1 Apr 2017 08:29:10 +0000 (13:59 +0530)]
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>
7 years agoiio: light: bh1750: constify attribute_group structures
simran singhal [Sat, 1 Apr 2017 08:33:30 +0000 (14:03 +0530)]
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>
7 years agoiio: proximity: as3935: constify attribute_group structures
simran singhal [Sat, 1 Apr 2017 08:39:55 +0000 (14:09 +0530)]
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>
7 years agoiio: adc: cpcap: Add minimal support for CPCAP PMIC ADC
Tony Lindgren [Fri, 24 Mar 2017 03:38:42 +0000 (20:38 -0700)]
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>
7 years agostaging: iio: update locking method during frequency writes
Gargi Sharma [Thu, 30 Mar 2017 09:33:46 +0000 (15:03 +0530)]
staging: iio: update locking method during frequency writes

The driver needs to insure atomicity during frequency
changes of bus and device. The iiodev->mlock as used
was not doing that. Replace it with the drivers existing
buffer lock and introduce an auxiliary spi_write() that does
not hold the lock.

Signed-off-by: Gargi Sharma <gs051095@gmail.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
7 years agodrivers: iio: chemical: replace comma with a semicolon
Arushi Singhal [Thu, 30 Mar 2017 12:41:22 +0000 (18:11 +0530)]
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>
7 years agoiio: adc: replace comma with a semicolon
Arushi Singhal [Thu, 30 Mar 2017 12:46:03 +0000 (18:16 +0530)]
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>
7 years agoiio: adc: ad799x: constify attribute_group structures
simran singhal [Tue, 28 Mar 2017 20:07:45 +0000 (01:37 +0530)]
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>
7 years agoiio: adc: max1363: constify attribute_group structures
simran singhal [Tue, 28 Mar 2017 20:15:28 +0000 (01:45 +0530)]
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>
7 years agoiio: dac: ad5504: constify attribute_group structures
simran singhal [Tue, 28 Mar 2017 20:21:48 +0000 (01:51 +0530)]
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>
7 years agostaging: iio: adc: ad7280a: fix permission coding style issue
Olivier Leveque [Thu, 23 Mar 2017 13:18:09 +0000 (14:18 +0100)]
staging: iio: adc: ad7280a: fix permission coding style issue

Symbolic permissions 'S_IWUSR | S_IRUGO' are not preferred. Consider using
octal permissions '0644'. Found running checkpatch.

Signed-off-by: Olivier Leveque <o_leveque@orange.fr>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
7 years agostaging: iio: accel: remove unneeded braces around single statements
Mark Stenglein [Thu, 23 Mar 2017 06:18:12 +0000 (02:18 -0400)]
staging: iio: accel: remove unneeded braces around single statements

Fixes three checkpatch warnings due to braces used when single
statements are sufficient.

Signed-off-by: Mark Stenglein <mark@stengle.in>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
7 years agostaging: iio: tsl2x7x_core: Fix standard deviation calculation
Eva Rachel Retuya [Mon, 20 Mar 2017 11:27:05 +0000 (19:27 +0800)]
staging: iio: tsl2x7x_core: Fix standard deviation calculation

Standard deviation is calculated as the square root of the variance
where variance is the mean of sample_sum and length. Correct the
computation of statP->stddev in accordance to the proper calculation.

Fixes: 3c97c08b5735 ("staging: iio: add TAOS tsl2x7x driver")
Reported-by: Abhiram Balasubramanian <abhiram@cs.utah.edu>
Signed-off-by: Eva Rachel Retuya <eraretuya@gmail.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
7 years agoiio: hid: Add humidity sensor support
Song Hongyan [Mon, 20 Mar 2017 14:28:45 +0000 (22:28 +0800)]
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>
7 years agoiio: hid-sensor-attributes: Fix gravity sensor scale value not right issue
Song Hongyan [Mon, 20 Mar 2017 09:12:54 +0000 (17:12 +0800)]
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>
7 years agoiio:light: Add support for STMicro VL6180 sensor
Manivannan Sadhasivam [Sun, 19 Mar 2017 14:53:12 +0000 (20:23 +0530)]
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>
7 years agostaging: iio: Remove extra Parenthesis.
Arushi Singhal [Fri, 24 Mar 2017 13:55:33 +0000 (19:25 +0530)]
staging: iio: Remove extra Parenthesis.

Remove the extra parenthesis remove the checkpatch issue.

Signed-off-by: Arushi Singhal <arushisinghal19971997@gmail.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
7 years agoiio: cros_ec_sensors: Use devm to setup the triggered buffer.
Enric Balletbo i Serra [Fri, 24 Mar 2017 17:44:03 +0000 (18:44 +0100)]
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>
7 years agoiio: adc: meson-saradc: add calibration
Heiner Kallweit [Sat, 18 Mar 2017 18:38:19 +0000 (19:38 +0100)]
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>
7 years agostaging: adis16203: Remove locking on raw reads of IIO_CHAN_INFO_CALIBBIAS
Gargi Sharma [Mon, 20 Mar 2017 08:30:42 +0000 (14:00 +0530)]
staging: adis16203: Remove locking on raw reads of IIO_CHAN_INFO_CALIBBIAS

adis16203_read_raw does not need lock for IIO_CHAN_INFO_CALIBBIAS
since adis_read_reg_16 is already atomic and nothing else needs to be
protected.

Signed-off-by: Gargi Sharma <gs051095@gmail.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
7 years agostaging: iio: cdc: ad7746: Fix alignment with paranthesis
Narcisa Ana Maria Vasile [Mon, 20 Mar 2017 12:18:26 +0000 (14:18 +0200)]
staging: iio: cdc: ad7746: Fix alignment with paranthesis

This was reported by checkpatch.pl:
CHECK: Alignment should match open parenthesis

Signed-off-by: Narcisa Ana Maria Vasile <narcisaanamaria12@gmail.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
7 years agostaging: iio: Add blank lines after function declarations
Narcisa Ana Maria Vasile [Mon, 20 Mar 2017 12:18:03 +0000 (14:18 +0200)]
staging: iio: Add blank lines after function declarations

This was reported by checkpatch.pl:
CHECK: Please use a blank line after function/struct/union/enum
declarations

Signed-off-by: Narcisa Ana Maria Vasile <narcisaanamaria12@gmail.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
7 years agostaging: iio: adt7136: Remove unnecessary blank lines
Narcisa Ana Maria Vasile [Mon, 20 Mar 2017 12:17:50 +0000 (14:17 +0200)]
staging: iio: adt7136: Remove unnecessary blank lines

This was reported by checkpatch.pl

Signed-off-by: Narcisa Ana Maria Vasile <narcisaanamaria12@gmail.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
7 years agostaging: ad7606: Replace mlock with driver private lock
Arushi Singhal [Mon, 20 Mar 2017 19:51:34 +0000 (01:21 +0530)]
staging: ad7606: Replace mlock with driver private lock

The IIO subsystem is redefining iio_dev->mlock to be used by
the IIO core only for protecting device operating mode changes.
ie. Changes between INDIO_DIRECT_MODE, INDIO_BUFFER_* modes.

In this driver, mlock was being used to protect hardware state
changes.  Replace it with a lock in the devices global data.

Signed-off-by: Arushi Singhal <arushisinghal19971997@gmail.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
7 years agostaging: iio: ade7753: Remove trailing whitespaces
simran singhal [Tue, 21 Mar 2017 18:03:55 +0000 (23:33 +0530)]
staging: iio: ade7753: Remove trailing whitespaces

This patch removes trailing whitespaces in order to follow the Linux
coding style.

Signed-off-by: simran singhal <singhalsimran0@gmail.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
7 years agostaging: ade7754: Clean up #includes
simran singhal [Mon, 20 Mar 2017 15:15:05 +0000 (20:45 +0530)]
staging: ade7754: Clean up #includes

Alphabetize and separate kernel and subsystem headers.

Signed-off-by: simran singhal <singhalsimran0@gmail.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
7 years agostaging: iio: Replace a bit shift by a use of BIT.
Arushi Singhal [Wed, 22 Mar 2017 16:42:34 +0000 (22:12 +0530)]
staging: iio: Replace a bit shift by a use of BIT.

This patch replaces bit shifting on 1 with the BIT(x) macro.
This was done with coccinelle:
@@
constant c;
@@

-1 << c
+BIT(c)

Signed-off-by: Arushi Singhal <arushisinghal19971997@gmail.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
7 years agostaging: iio: adis16060: Remove iio_dev mlock and refactor code
simran singhal [Wed, 22 Mar 2017 16:20:43 +0000 (21:50 +0530)]
staging: iio: adis16060: Remove iio_dev mlock and refactor code

The IIO subsystem is redefining iio_dev->mlock to be used by
the IIO core only for protecting device operating mode changes.
ie. Changes between INDIO_DIRECT_MODE, INDIO_BUFFER_* modes.

In this driver, mlock was being used to protect hardware state changes.

In the driver, buf_lock protects both the adis16060_spi_write() and
adis16060_spi_read() functions and both are always called in
pair. First write, then read. Refactor the code to have
one single function adis16060_spi_write_than_read() protected by
the buf_lock.  This removes the need for additional locking via
mlock, so this locking is removed.

Signed-off-by: simran singhal <singhalsimran0@gmail.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
7 years agoMerge tag 'iio-for-4.12b' of git://git.kernel.org/pub/scm/linux/kernel/git/jic23...
Greg Kroah-Hartman [Wed, 22 Mar 2017 10:56:03 +0000 (11:56 +0100)]
Merge tag 'iio-for-4.12b' of git://git./linux/kernel/git/jic23/iio into staging-next

Jonathan writes:

2nd set of new device support, features and cleanups for IIO in the 4.12 cycle

A good collection of outreachy related patches in here - mostly staging
driver cleanup. Also a fair number of patches added explicit OF device ID
tables for i2c drivers - a precursor to dropping (eventually) the implicit
probing.

New Device Support
* Allwinner SoC ADC.
  - So far covers the sun4i-a10, sun5i-a13 and sun6i-a31 general purpose ADCs,
  including thermal side of things.
  This missed the last cycle due to my incompetence, so good to get in now,
  particularly as various patches dependent on it are appearing.
* ltc2632
  - new driver supporting ltc2632-l12, ltc2632-l10, ltc2632-l8, ltc2632-h12,
    ltc-2632-h10, ltc-2632-h8 dacs

Cleanups
* Documentation
  - drop a broken reference to i2c/trivial-devices
* ad2s1200
  - drop & from function pointers for consistency.
* ad2s1210
  - formatting fixes.
* ad7152
  - octal permissions instead of symbolic.
  - drop & from function pointers for consistent usage.
* ad7192
  - drop & from function pointers for consistent usage.
* ad7280
  - replace core mlock usage with a local lock as mlock is intended only to
  protect the current device state (direct reads, or triggered and buffered)
* ad7746
  - drop & from function pointers for consistent usage.
  - replace core mlock usage with a local lock as mlock is intended only to
  protect the current device state (direct reads, or triggered and buffered)
* ad7754
  - move contents of header file into source file as not used anywhere else.
* ad7759
  - move contents of header file into source file as not used anywhere else.
* ad7780
  - drop & from function pointers for consistent usage.
* ad7832
  - replace core mlock usage with a local lock as mlock is intended only to
  protect the current device state (direct reads, or triggered and buffered)
* ad9834
  - replace core mlock usage with a local lock as mlock is intended only to
  protect the current device state (direct reads, or triggered and buffered)
  - drop an unnecessary goto in favour of direct return.
* adis16060
  - drop & from function pointers as inconsistent.
* adis16201
  - drop a local mutex as the adis core already protects everything necessary.
  - drop & from function pointers for consistent usage.
* adis16203
  - drop & from function pointers for consistent usage.
* adis16209
  - drop a local mutex as the adis core already protects everything necessary.
  - use an enum for scan index giving slightly nicer code.
  - drop & from function pointers for consistent usage.
* adis16240
  - drop a local mutex as the adis core already protects everything necessary.
  - use an enum for scan index giving slightly nicer code.
  - drop & from function pointers for consistent usage.
* apds9960
  - add OF device ID table.
* bma180
  - add OF device ID table.
  - prefer unsigned int to bare use of unsigned.
* bmc150_magn
  - add OF device ID table.
* hmp03
  - add OF device ID table.
* ina2xx
  - add OF device ID table.
* itg3200
  - add OF device ID table.
* mag3110
  - add OF device ID table.
* max11100
  - remove .owner field as it is set by the spi core.
* max5821
  - add .of_match_table set to the ID table which was present but not used.
* mcp4725
  - add OF device ID table.
* mlx96014
  - add OF device ID table.
* mma7455
  - add OF device ID table.
* mma7660
  - add OF device ID table.
* mpl3115
  - add OF device ID table.
* mpu6050
  - add OF device ID table.
* pc104
  - mask pc104 drivers behind a global pc104 config option.
* ti-ads1015
  - add OF device ID table.
* tsl2563
  - add OF device ID table.
* us5182d
  - add OF device ID table.

7 years agoiio: dac: Add support for ltc2632 DACs
Maxime Roussin-Belanger [Fri, 17 Mar 2017 18:04:02 +0000 (14:04 -0400)]
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>
7 years agostaging: ks7010: rename return value identifier
Tobin C. Harding [Tue, 21 Mar 2017 02:37:12 +0000 (13:37 +1100)]
staging: ks7010: rename return value identifier

Driver uses multiple identifier names for the same task (retval, ret,
rc). It would be easier to read the code if a single task is
identified with a single name. 'ret' is the most common return value
identifier name found in the kernel tree, following the principle of
least surprise using 'ret' is a decent choice.

Rename rc -> ret
Rename retval -> ret

Signed-off-by: Tobin C. Harding <me@tobin.cc>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
7 years agostaging: ks7010: remove zero comparison
Tobin C. Harding [Tue, 21 Mar 2017 02:37:11 +0000 (13:37 +1100)]
staging: ks7010: remove zero comparison

Comparison, equal to zero, is redundant

'if (foo == 0)'  is equal to  'if (!foo)'

Typical kernel coding style is to use the shorter form.

Remove unnecessary zero comparison.

Signed-off-by: Tobin C. Harding <me@tobin.cc>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
7 years agostaging: ks7010: remove non-zero comparison
Tobin C. Harding [Tue, 21 Mar 2017 02:37:10 +0000 (13:37 +1100)]
staging: ks7010: remove non-zero comparison

Comparison, does not equal zero, is redundant

'if (foo != 0)'  is equal to  'if (foo)'

Typical kernel coding style is to use the shorter form.

Remove unnecessary non-zero comparison.

Signed-off-by: Tobin C. Harding <me@tobin.cc>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
7 years agostaging: ks7010: make goto labels uniform
Tobin C. Harding [Tue, 21 Mar 2017 02:37:09 +0000 (13:37 +1100)]
staging: ks7010: make goto labels uniform

Driver uses different label forms for similar purposes. It would be
more clear if single use case has uniform label. 'out' is generic and
adds no meaning to label.

Documentation/process/coding-style.rst:
Choose label names which say what the goto does or why the goto
exists.

Rename labels so as to better describe what they do. If an execution
path only exists for the label on an error, prefix the label with
'err_'. If a non-error execution path exist do not use prefix.

Signed-off-by: Tobin C. Harding <me@tobin.cc>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
7 years agostaging: ks7010: return directly on error
Tobin C. Harding [Tue, 21 Mar 2017 02:37:08 +0000 (13:37 +1100)]
staging: ks7010: return directly on error

Function uses goto label with no clean up code. In this case we
should just return directly.

Remove goto statement, return directly on error.

Signed-off-by: Tobin C. Harding <me@tobin.cc>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
7 years agostaging: ks7010: fix checkpatch MULTIPLE_ASSIGNMENTS
Tobin C. Harding [Tue, 21 Mar 2017 02:37:07 +0000 (13:37 +1100)]
staging: ks7010: fix checkpatch MULTIPLE_ASSIGNMENTS

Checkpatch emits CHECK: multiple assignments should be avoided.

Move multiple line assignment to individual lines.

Signed-off-by: Tobin C. Harding <me@tobin.cc>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
7 years agostaging: ks7010: fix checkpatch BRACES
Tobin C. Harding [Tue, 21 Mar 2017 02:37:06 +0000 (13:37 +1100)]
staging: ks7010: fix checkpatch BRACES

Checkpatch emits CHECK: Unbalanced braces around else
statement. Statements in question are single statements so we do not
need braces. Checkpatch also warns about multiple line dereference for
this code.

Fix if/else/else if statement use of braces. Fix function argument layout
at the same time since it is the same statement.

Signed-off-by: Tobin C. Harding <me@tobin.cc>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
7 years agostaging: ks7010: fix checkpatch PARENTHESIS_ALIGNMENT
Tobin C. Harding [Tue, 21 Mar 2017 02:37:05 +0000 (13:37 +1100)]
staging: ks7010: fix checkpatch PARENTHESIS_ALIGNMENT

Checkpatch emits CHECK: Alignment should match open parenthesis.

Fix alignment to open parenthesis in line with kernel coding style.

Signed-off-by: Tobin C. Harding <me@tobin.cc>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
7 years agostaging: ks7010: fix checkpatch SPACING
Tobin C. Harding [Tue, 21 Mar 2017 02:37:04 +0000 (13:37 +1100)]
staging: ks7010: fix checkpatch SPACING

Checkpatch emits CHECK: No space is necessary after a cast.

Remove unnecessary space after cast.

Signed-off-by: Tobin C. Harding <me@tobin.cc>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
7 years agostaging: ks7010: fix checkpatch LINE_SPACING
Tobin C. Harding [Tue, 21 Mar 2017 02:37:03 +0000 (13:37 +1100)]
staging: ks7010: fix checkpatch LINE_SPACING

Checkpatch emits CHECK: Please use a blank line after
function/struct/union/enum declarations.

Add blank line after function definition.

Signed-off-by: Tobin C. Harding <me@tobin.cc>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
7 years agostaging: vchiq_arm: Fix MODULE_LICENSE
Stefan Wahren [Sat, 18 Mar 2017 08:42:11 +0000 (08:42 +0000)]
staging: vchiq_arm: Fix MODULE_LICENSE

Regarding to the header the driver is licensed under BSD and GPL.

Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
7 years agoStaging: media: Unmap and release region obtained by ioremap_nocache
Arvind Yadav [Fri, 17 Mar 2017 06:51:23 +0000 (12:21 +0530)]
Staging: media: Unmap and release region obtained by ioremap_nocache

Free memory mapping, if vpfe_ipipe_init is not successful.

Signed-off-by: Arvind Yadav <arvind.yadav.cs@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
7 years agostaging:sm750fb: Code readability is improved.
Arushi Singhal [Mon, 20 Mar 2017 14:06:56 +0000 (19:36 +0530)]
staging:sm750fb: Code readability is improved.

New variables are added to make the code more readable.

Signed-off-by: Arushi Singhal <arushisinghal19971997@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
7 years agostaging: rtl8712: checkpatch: Avoid multiple line dereferences
Ding-Chi Wang [Sat, 18 Mar 2017 08:59:14 +0000 (16:59 +0800)]
staging: rtl8712: checkpatch: Avoid multiple line dereferences

"WARNING: Avoid multiple line dereference - prefer 'poid_par_priv->information_buf_len'"
"WARNING: Avoid multiple line dereference - prefer 'padapter->registrypriv.dev_network.Configuration'"
"WARNING: Avoid multiple line dereference - prefer 'Adapter->mppriv.workparam.io_value'"

Signed-off-by: Ding-Chi Wang <dcwang.tw@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
7 years agostaging: lustre: libcfs: Define pr_fmt() to include relevant name
Narcisa Ana Maria Vasile [Sat, 18 Mar 2017 16:56:00 +0000 (18:56 +0200)]
staging: lustre: libcfs: Define pr_fmt() to include relevant name

Define a pr_fmt() for tracefile.c
Remove redundant prefix 'Lustre' from pr_*() calls.

Signed-off-by: Narcisa Ana Maria Vasile <narcisaanamaria12@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
7 years agostaging: lustre: libcfs: Replace printk() with pr_*()
Narcisa Ana Maria Vasile [Sat, 18 Mar 2017 16:55:25 +0000 (18:55 +0200)]
staging: lustre: libcfs: Replace printk() with pr_*()

Convert printk() calls into corresponding pr_*() calls.

Signed-off-by: Narcisa Ana Maria Vasile <narcisaanamaria12@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
7 years agostaging: media: atomisp: fix build errors when PM is disabled
Jérémy Lefaure [Tue, 21 Mar 2017 02:48:26 +0000 (22:48 -0400)]
staging: media: atomisp: fix build errors when PM is disabled

The function atomisp_restore_iumit_reg is unused when PM is disabled.
Adding __maybe_unused to the function definition avoids a warning.

The function atomisp_mrfld_power_down is defined only when PM is
enabled. So in atomisp_pci_probe, it should be called only when PM is
enabled.

Signed-off-by: Jérémy Lefaure <jeremy.lefaure@lse.epita.fr>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
7 years agostaging: atomisp: remove useless condition in if-statements
Daeseok Youn [Tue, 21 Mar 2017 02:12:57 +0000 (11:12 +0900)]
staging: atomisp: remove useless condition in if-statements

The css_pipe_id was checked with 'CSS_PIPE_ID_COPY' in previous if-
statement. In this case, if the css_pipe_id equals to 'CSS_PIPE_ID_COPY',
it could not enter the next if-statement. But the "next" if-statement
has the condition to check whether the css_pipe_id equals to
'CSS_PIPE_ID_COPY' or not. It should be removed.

Signed-off-by: Daeseok Youn <daeseok.youn@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
7 years agostaging: media: atomisp: Remove unnecessary braces.
Varsha Rao [Sun, 19 Mar 2017 12:36:24 +0000 (18:06 +0530)]
staging: media: atomisp: Remove unnecessary braces.

Remove braces which are not required to fix the check patch issue. The
following coccinelle script is used to fix this issue.

@@
expression e,e1;
@@
if(e)
-{
 e1;
-}

Signed-off-by: Varsha Rao <rvarsha016@gmail.com>
Acked-by: Julia Lawall <julia.lawall@lip6.fr>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
7 years agostaging: media: atomisp: Remove unnecessary blank lines.
Varsha Rao [Sun, 19 Mar 2017 12:33:13 +0000 (18:03 +0530)]
staging: media: atomisp: Remove unnecessary blank lines.

Remove multiple blank lines, which are not required. This patch fixes
the following check patch issue:

CHECK: Please don't use multiple blank lines

Signed-off-by: Varsha Rao <rvarsha016@gmail.com>
Acked-by: Julia Lawall <julia.lawall@lip6.fr>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
7 years agostaging: media: atomisp: Fix block comments warning.
Varsha Rao [Sun, 19 Mar 2017 12:30:04 +0000 (18:00 +0530)]
staging: media: atomisp: Fix block comments warning.

Use kernel preferred block commenting style, to fix the checkpatch
issue.

Signed-off-by: Varsha Rao <rvarsha016@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
7 years agostaging: media: atomisp: Added spaces around arithmetic operators.
Varsha Rao [Sun, 19 Mar 2017 12:27:21 +0000 (17:57 +0530)]
staging: media: atomisp: Added spaces around arithmetic operators.

Add spaces around arithmetic operators (/, +, -), to fix the checkpatch
issue.

Signed-off-by: Varsha Rao <rvarsha016@gmail.com>
Acked-by: Julia Lawall <julia.lawall@lip6.fr>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
7 years agostaging: bcm2835-audio: Add support for simultanous HDMI and Headphone audio
Michael Zoran [Wed, 15 Mar 2017 00:01:25 +0000 (17:01 -0700)]
staging: bcm2835-audio: Add support for simultanous HDMI and Headphone audio

The firmware for the Raspberry PI already supports simultanous output
of audio through both the HDMI and the Headphone jack.  The current
implementation of ALSA doesn't expose this well to user mode since
the firmware audio is represented as a single card.

A newer approach is taken here and a virtual card is created for each
output(HDMI, Headphones, and Traditional ALSA).  The firmware has
the concept of channels or streams for which the number to use is
passed in the device tree. These streams are allocated to each of the
virtual cards.

As a side effect of this change, since each output is represented
independenly it's now very easy to use PulseAudio to control the
priorities of the outputs.

Testing:

Audacity and VLC were both loaded at the same time.  Each application
was assigned to a different card. With this change I was able to play
different music files at the same time through the HDMI and Headphones
jacks and control the audio independently.

Signed-off-by: Michael Zoran <mzoran@crowfest.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
7 years agobcm2835-v4l2: Fix buffer overflow problem
Dave Stevenson [Tue, 14 Mar 2017 15:10:40 +0000 (08:10 -0700)]
bcm2835-v4l2: Fix buffer overflow problem

https://github.com/raspberrypi/linux/issues/1447
port_parameter_get() failed to account for the header
(u32 id and u32 size) in the size before memcpying
the response into the response buffer, so overrunning
the provided buffer by 8 bytes.

Account for those bytes, and also a belt-and-braces
check to ensure we never copy more than *value_size
bytes into value.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.org>
Signed-off-by: Michael Zoran <mzoran@crowfest.net>
Tested-by: Michael Zoran <mzoran@crowfest.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
7 years agostaging: vc04_services: make BCM_VIDEOCORE tristate
Arnd Bergmann [Mon, 20 Mar 2017 09:35:28 +0000 (10:35 +0100)]
staging: vc04_services: make BCM_VIDEOCORE tristate

Adding the 'bool' symbol brought back a randconfig build bug that
I had fixed before:

drivers/staging/built-in.o: In function `vchiq_probe':
(.text+0x1da30): undefined reference to `rpi_firmware_get'
drivers/staging/built-in.o: In function `vchiq_platform_init':
(.text+0x27494): undefined reference to `rpi_firmware_property'

The problem is that when RASPBERRYPI_FIRMWARE is a loadable module,
but BCM2835_VCHIQ can again be built-in. Making BCM_VIDEOCORE
itself tristate will make Kconfig honor the dependency correctly.

Fixes: 6bbfe4a76158 ("staging: vc04_services: Create new BCM_VIDEOCORE setting for VideoCore services.")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
7 years agostaging: vc04_services: fix NULL pointer dereference on pointer 'service'
Colin Ian King [Mon, 20 Mar 2017 14:08:50 +0000 (14:08 +0000)]
staging: vc04_services: fix NULL pointer dereference on pointer 'service'

Currently, if pservice is null then service is set to NULL and immediately
afterwards service is dereferenced causing a null pointer dereference. Fix
this by bailing out early of the function with a null return.

Detected by CoverityScan, CID#1419681 ("Explicit null dereferenced")

Signed-off-by: Colin Ian King <colin.king@canonical.com>
Acked-by: Stefan Wahren <stefan.wahren@i2se.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
7 years agostaging: atomisp: simplify if statement in atomisp_get_sensor_fps()
Daeseok Youn [Mon, 20 Mar 2017 14:42:55 +0000 (14:42 +0000)]
staging: atomisp: simplify if statement in atomisp_get_sensor_fps()

If v4l2_subdev_call() gets the global frame interval values,
it returned 0 and it could be checked whether numerator is zero or not.

If the numerator is not zero, the fps could be calculated in this function.
If not, it just returns 0.

Signed-off-by: Daeseok Youn <daeseok.youn@gmail.com>
Signed-off-by: Alan Cox <alan@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
7 years agoatomisp: remove a sysfs error message that can be used to log spam
Alan Cox [Mon, 20 Mar 2017 14:42:41 +0000 (14:42 +0000)]
atomisp: remove a sysfs error message that can be used to log spam

Instead of logging this just report ERANGE as an error, which will give something close to the
right user space report.

The others of these were already removed by Dan Carpenter's patch.

Signed-off-by: Alan Cox <alan@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
7 years agostaging: atomisp: remove redudant condition in if-statement
Daeseok Youn [Mon, 20 Mar 2017 14:42:23 +0000 (14:42 +0000)]
staging: atomisp: remove redudant condition in if-statement

The V4L2_FIELD_ANY is zero, so the (!field) is same meaning
with (field == V4L2_FIELD_ANY) in if-statement.

Signed-off-by: Daeseok Youn <daeseok.youn@gmail.com>
Signed-off-by: Alan Cox <alan@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
7 years agostaging: atomisp: remove else statement after return
Daeseok Youn [Mon, 20 Mar 2017 14:42:15 +0000 (14:42 +0000)]
staging: atomisp: remove else statement after return

It doesn't need to have else statement after return.

Signed-off-by: Daeseok Youn <daeseok.youn@gmail.com>
Signed-off-by: Alan Cox <alan@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
7 years agostaging/atomisp: add ACPI dependency
Arnd Bergmann [Mon, 20 Mar 2017 14:42:05 +0000 (14:42 +0000)]
staging/atomisp: add ACPI dependency

Without ACPI, some of the code fails to build:

media/atomisp/platform/intel-mid/atomisp_gmin_platform.c: In function 'atomisp_register_i2c_module':
media/atomisp/platform/intel-mid/atomisp_gmin_platform.c:174:7: error: dereferencing pointer to incomplete type 'struct acpi_device'

We could work around that in the code, but since we already have a hard
dependency on x86, adding the ACPI dependency seems to be the easiest
solution.

Fixes: a49d25364dfb ("staging/atomisp: Add support for the Intel IPU v2")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Alan Cox <alan@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
7 years agostaging/atomisp: add PCI dependency
Arnd Bergmann [Mon, 20 Mar 2017 14:41:55 +0000 (14:41 +0000)]
staging/atomisp: add PCI dependency

Without CONFIG_PCI, config space reads never return any data,
leading to undefined behavior that gcc warns about:

platform/intel-mid/intel_mid_pcihelpers.c: In function 'intel_mid_msgbus_read32_raw':
platform/intel-mid/intel_mid_pcihelpers.c:66:9: error: 'data' is used uninitialized in this function [-Werror=uninitialized]
platform/intel-mid/intel_mid_pcihelpers.c: In function 'intel_mid_msgbus_read32_raw_ext':
platform/intel-mid/intel_mid_pcihelpers.c:84:9: error: 'data' is used uninitialized in this function [-Werror=uninitialized]
platform/intel-mid/intel_mid_pcihelpers.c: In function 'intel_mid_msgbus_read32':
platform/intel-mid/intel_mid_pcihelpers.c:137:9: error: 'data' is used uninitialized in this function [-Werror=uninitialized]

With a dependency on CONFIG_PCI, we don't get this warning. This seems
safe as PCI config space accessors should always return something
when PCI is enabled.

Fixes: a49d25364dfb ("staging/atomisp: Add support for the Intel IPU v2")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Alan Cox <alan@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
7 years agostaging/atomisp: add VIDEO_V4L2_SUBDEV_API dependency
Arnd Bergmann [Mon, 20 Mar 2017 14:41:47 +0000 (14:41 +0000)]
staging/atomisp: add VIDEO_V4L2_SUBDEV_API dependency

The driver fails to build if this is disabled, so we need an explicit
Kconfig dependency:

drivers/staging/media/atomisp/pci/atomisp2/./atomisp_cmd.c:6085:48: error: 'struct v4l2_subdev_fh' has no member named 'pad'

Fixes: a49d25364dfb ("staging/atomisp: Add support for the Intel IPU v2")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Alan Cox <alan@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
7 years agostaging/atomisp: remove sh_css_lace_stat code
Arnd Bergmann [Mon, 20 Mar 2017 14:41:38 +0000 (14:41 +0000)]
staging/atomisp: remove sh_css_lace_stat code

I ran into a build warning on my randconfig build box:

drivers/staging/media/atomisp/pci/atomisp2/css2400/sh_css_params.c: In function 'ia_css_lace_statistics_free':
drivers/staging/media/atomisp/pci/atomisp2/css2400/sh_css_params.c:2845:64: error: parameter 'me' set but not used [-Werror=unused-but-set-parameter]

It turns out that not only the parameter is unused but the entire function has no
caller. Let's just remove it.

Fixes: a49d25364dfb ("staging/atomisp: Add support for the Intel IPU v2")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Alan Cox <alan@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
7 years agostating/atomisp: fix -Wold-style-definition warning
Arnd Bergmann [Mon, 20 Mar 2017 14:41:29 +0000 (14:41 +0000)]
stating/atomisp: fix -Wold-style-definition warning

ia_css_dequeue_param_buffers does not have an arguement type, causing a warning:

drivers/staging/media/atomisp/pci/atomisp2/css2400/sh_css_params.c: In function 'ia_css_dequeue_param_buffers':
drivers/staging/media/atomisp/pci/atomisp2/css2400/sh_css_params.c:3728:6: error: old-style function definition [-Werror=old-style-definition]

This adds a 'void' keywork to silence the warning.

Fixes: a49d25364dfb ("staging/atomisp: Add support for the Intel IPU v2")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Alan Cox <alan@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
7 years agostaging/atomisp: fix empty-body warning
Arnd Bergmann [Mon, 20 Mar 2017 14:41:20 +0000 (14:41 +0000)]
staging/atomisp: fix empty-body warning

Defining a debug function to nothing causes a warning with an empty block
after if()/else():

drivers/staging/media/atomisp/i2c/ov2680.c: In function 'ov2680_s_stream':
drivers/staging/media/atomisp/i2c/ov2680.c:1208:55: error: suggest braces around empty body in an 'else' statement [-Werror=empty-body]

This changes the empty debug statement to dev_dbg(), which by default also
does nothing, but avoids this warning and also checks the format string.
As a side-effect, we can now use dynamic debugging to turn on the
output at runtime.

Fixes: a49d25364dfb ("staging/atomisp: Add support for the Intel IPU v2")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Alan Cox <alan@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
7 years agostaging: media: atomisp: add missing dependencies in Kconfig
Jérémy Lefaure [Mon, 20 Mar 2017 14:41:02 +0000 (14:41 +0000)]
staging: media: atomisp: add missing dependencies in Kconfig

Two dependencies were missing to build atomisp drivers:

_ MEDIA_CONTROLLER: to use the entity field of v4l2_subdev structure. Since
every atomisp driver needs MEDIA_CONTROLLER has a dependency, let's add it
to INTEL_ATOMISP

_ EFI: to use efivar_entry_get:
drivers/built-in.o: In function `gmin_get_config_var':
(.text+0xe062b): undefined reference to `efivar_entry_get'

Signed-off-by: Jérémy Lefaure <jeremy.lefaure@lse.epita.fr>
Signed-off-by: Alan Cox <alan@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
7 years agostaging: media: atomisp: select REGMAP_I2C needed by ap1302.c
Jérémy Lefaure [Mon, 20 Mar 2017 14:40:50 +0000 (14:40 +0000)]
staging: media: atomisp: select REGMAP_I2C needed by ap1302.c

REGMAP_I2C should be enabled to build the driver ap1302 because it uses
regmap functions.

Signed-off-by: Jérémy Lefaure <jeremy.lefaure@lse.epita.fr>
Signed-off-by: Alan Cox <alan@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
7 years agoStaging: atomisp: fix an uninitialized variable bug
Dan Carpenter [Mon, 20 Mar 2017 14:40:41 +0000 (14:40 +0000)]
Staging: atomisp: fix an uninitialized variable bug

There are some error paths in atomisp_css_frame_allocate() which don't
initialize "res" so it could lead us to try release random memory.

Fixes: a49d25364dfb ("staging/atomisp: Add support for the Intel IPU v2")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Alan Cox <alan@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
7 years agoStaging: atomisp: fix locking in alloc_user_pages()
Dan Carpenter [Mon, 20 Mar 2017 14:40:32 +0000 (14:40 +0000)]
Staging: atomisp: fix locking in alloc_user_pages()

We call this function with the lock held and should also return with the
lock held as well.  This one error path is not-consistent because we
should return without the lock held.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Alan Cox <alan@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
7 years agoatomisp: remove another pair of 2400/2401 differences
Alan Cox [Mon, 20 Mar 2017 14:40:20 +0000 (14:40 +0000)]
atomisp: remove another pair of 2400/2401 differences

The first of these checks the PCI identifier in order to decide what to do so needs no
ifdef. The other is simply a variation on what is dumped for debug - so favour dumping the
most.

Signed-off-by Alan Cox <alan@linux.intel.com>

Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
7 years agoatomisp/imx: Fix locking bug on error path
Alan Cox [Mon, 20 Mar 2017 14:40:06 +0000 (14:40 +0000)]
atomisp/imx: Fix locking bug on error path

This was reported by Dan Carpenter. When we error with an IMX 227 we don't release
the lock and the sensor would then hang.

Signed-off-by: Alan Cox <alan@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
7 years agoatomisp: ia_css_bh_hmem_encode is a no-op so remove it
Alan Cox [Mon, 20 Mar 2017 14:39:21 +0000 (14:39 +0000)]
atomisp: ia_css_bh_hmem_encode is a no-op so remove it

This is a do nothing function so we can replace it with nothing and eliminate it entirely.

Signed-off-by: Alan Cox <alan@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
7 years agoatomisp: remove another layer of allocator indirection
Alan Cox [Mon, 20 Mar 2017 14:38:59 +0000 (14:38 +0000)]
atomisp: remove another layer of allocator indirection

Our driver only ever uses one set of routines for the allocators used by the CSS layer to
manage memory and the memory management on the ISP. We can thus remove the function vectors
and simply call the intended routines directly.

These routines in turn are simply wrappers around another layer of code so remove this
second layer of wrappers and call the hrt methods directly. In time we can remove this layer
of indirection as well.

Signed-off-by: Alan Cox <alan@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
7 years agoatomisp: remove the unused debug wrapping from the mmgr layer
Alan Cox [Mon, 20 Mar 2017 14:38:42 +0000 (14:38 +0000)]
atomisp: remove the unused debug wrapping from the mmgr layer

We don't need this layer of indirection and the debugging information is not used. With
this removed we can then go on to try and remove the abstraction layer entirely.

Signed-off-by: Alan Cox <alan@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
7 years agoatomisp: remove aa kernel wrappers
Alan Cox [Mon, 20 Mar 2017 14:38:27 +0000 (14:38 +0000)]
atomisp: remove aa kernel wrappers

The aa kernel is used but it consists of nothing more than a set of wrappers
for a memset and an assignment. Replace these at the calling points with the
memset and assignment.

Keep the structures for now - those should disappear as the next layer up
gets unwrapped.

Signed-off-by: Alan Cox <alan@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
7 years agoatomisp: remove the iefd2 kernel
Alan Cox [Mon, 20 Mar 2017 14:38:13 +0000 (14:38 +0000)]
atomisp: remove the iefd2 kernel

While this is included and the headers pulled in nothing actually uses this
functionality in the driver, so remove it.

Signed-off-by: Alan Cox <alan@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
7 years agostaging: unisys: include: channel.h: Fix #define formatting
David Binder [Fri, 17 Mar 2017 15:27:27 +0000 (11:27 -0400)]
staging: unisys: include: channel.h: Fix #define formatting

In an effort to create a more uniform coding style within the Unisys
s-Par driver set, this patch adjusts the formatting of all #define
directives within this source file to match the following template,
and thereby eliminate irregular usage of whitespace:
Reviewed-by: Tim Sell <timothy.sell@unisys.com>
The amount of whitespace used between the <token> and the <value> is
dependent on what is needed to make the surrounding #define directives
as uniform as possible.

Signed-off-by: David Binder <david.binder@unisys.com>
Signed-off-by: David Kershner <david.kershner@unisys.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
7 years agostaging: unisys: include: visorbus.h: Fix #define formatting
David Binder [Fri, 17 Mar 2017 15:27:26 +0000 (11:27 -0400)]
staging: unisys: include: visorbus.h: Fix #define formatting

In an effort to create a more uniform coding style within the Unisys
s-Par driver set, this patch adjusts the formatting of all #define
directives within this source file to match the following template,
and thereby eliminate irregular usage of whitespace:
Reviewed-by: Tim Sell <timothy.sell@unisys.com>
The amount of whitespace used between the <token> and the <value> is
dependent on what is needed to make the surrounding #define directives
as uniform as possible.

Signed-off-by: David Binder <david.binder@unisys.com>
Signed-off-by: David Kershner <david.kershner@unisys.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
7 years agostaging: unisys: include: iochannel.h: Fix #define formatting
David Binder [Fri, 17 Mar 2017 15:27:25 +0000 (11:27 -0400)]
staging: unisys: include: iochannel.h: Fix #define formatting

In an effort to create a more uniform coding style within the Unisys
s-Par driver set, this patch adjusts the formatting of all #define
directives within this source file to match the following template,
and thereby eliminate irregular usage of whitespace:
Reviewed-by: Tim Sell <timothy.sell@unisys.com>
The amount of whitespace used between the <token> and the <value> is
dependent on what is needed to make the surrounding #define directives
as uniform as possible.

Signed-off-by: David Binder <david.binder@unisys.com>
Signed-off-by: David Kershner <david.kershner@unisys.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>