GitHub/moto-9609/android_kernel_motorola_exynos9610.git
8 years agostaging: iio: cdc/ad7746: fix missing return value
Arnd Bergmann [Tue, 25 Oct 2016 15:56:23 +0000 (17:56 +0200)]
staging: iio: cdc/ad7746: fix missing return value

As found by "gcc -Wmaybe-uninitialized", the latest change to the
driver lacked an initalization for the return code in one of the
added cases:

drivers/staging/iio/cdc/ad7746.c: In function ‘ad7746_read_raw’:
drivers/staging/iio/cdc/ad7746.c:655:2: error: ‘ret’ may be used uninitialized in this function [-Werror=maybe-uninitialized]

This sets it to IIO_VAL_INT, which I think is what we want here.

Fixes: 2296c0623eb7 ("staging: iio: cdc: ad7746: implement IIO_CHAN_INFO_SAMP_FREQ")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
8 years agoiio: gyro: Add driver for the MPU-3050 gyroscope
Linus Walleij [Tue, 25 Oct 2016 14:15:54 +0000 (16:15 +0200)]
iio: gyro: Add driver for the MPU-3050 gyroscope

This adds a new driver for the Invensense MPU-3050 gyroscope.
This driver is based on information from the rough input driver
in drivers/input/misc/mpu3050.c and the scratch misc driver
posted by Nathan Royer in 2011. Some years have passed but this
is finally a fully-fledged driver for this gyroscope. It was
developed and tested on the Qualcomm APQ8060 Dragonboard.

The driver supports both raw and buffered input. It also
supports the internal trigger mechanism by registering a trigger
that can fire in response to the internal sample engine of the
component. In addition to reading out the gyroscope sensor
values, the driver also supports reading the temperature from
the sensor.

The driver currently only supports I2C but the MPU-3050 can
also be used from SPI, so the I2C portions are split in their
own file and we just use regmap to access all registers, so
it will be trivial to plug in SPI support if/when someone has
a system requiring this.

To conserve power, the driver utilizes the runtime PM
framework and will put the sensor in off mode and disable the
regulators when unused, after a timeout of 10 seconds.

The fullscale can be set for the sensor to 250, 500, 1000 or
2000 deg/s. This corresponds to scale values of rougly 0.000122,
0.000275, 0.000512 or 0.001068. By writing such values (or close
to these) into "in_anglevel_scale", the corresponding fullscale
can be chosen. It will default to 2000 deg/s (~35 rad/s).

The gyro component can have DC offsets on all axes. These can be
compensated using the standard sysfs ABI property
"in_anglevel_[xyz]_calibbias". This is in positive/negative
values of the raw values, so a suitable calibration bias can be
determined by userspace by reading the "in_anglevel_[xyz]_raw"
for a few iterations while holding the sensor still, create an
average integer, and writing the negative inverse of that into
"in_anglevel_[xyz]_calibbias". After this the hardware will
automatically subtract the bias, also when using buffered
readings.

Since the MPU-3050 has an outgoing I2C port it needs to act as
an I2C mux. This means that the device is switching I2C traffic
to devices beyond it. On my system this is the only way to reach
the accelerometer. The "sensor fusion" ability of the MPU-3050
to directly talk to the device on the outgoing I2C port is
currently not used by the driver, but it has code to allow I2C
traffic to pass through so that the Linux kernel can reach the
device on the other side with a kernel driver.

Example usage with the native trigger:

$ generic_buffer -a -c10 -n mpu3050
iio device number being used is 0
iio trigger number being used is 0
No channels are enabled, enabling all channels
Enabling: in_anglvel_z_en
Enabling: in_timestamp_en
Enabling: in_anglvel_y_en
Enabling: in_temp_en
Enabling: in_anglvel_x_en
/sys/bus/iio/devices/iio:device0 mpu3050-dev0
29607.142578 -0.117493 0.074768 0.012817 180788797150
29639.285156 -0.117493 0.076904 0.013885 180888982335
29696.427734 -0.116425 0.076904 0.012817 180989178039
29742.857422 -0.117493 0.076904 0.012817 181089377742
29764.285156 -0.116425 0.077972 0.012817 181189574187
29860.714844 -0.115356 0.076904 0.012817 181289772705
29864.285156 -0.117493 0.076904 0.012817 181389971520
29910.714844 -0.115356 0.076904 0.013885 181490170483
29917.857422 -0.116425 0.076904 0.011749 181590369742
29975.000000 -0.116425 0.076904 0.012817 181690567075
Disabling: in_anglvel_z_en
Disabling: in_timestamp_en
Disabling: in_anglvel_y_en
Disabling: in_temp_en
Disabling: in_anglvel_x_en

The first column is the temperature in millidegrees, then the x,y,z
axes in succession followed by the timestamp. Also tested successfully
using the HRTimer trigger.

Cc: Nick Vaccaro <nvaccaro@google.com>
Cc: Ge Gao <ggao@invensense.com>
Cc: Anna Si <asi@invensense.com>
Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Cc: Crestez Dan Leonard <leonard.crestez@intel.com>
Cc: Daniel Baluta <daniel.baluta@intel.com>
Cc: Gregor Boirie <gregor.boirie@parrot.com>
Cc: Peter Rosin <peda@axentia.se>
Cc: Peter Meerwald-Stadler <pmeerw@pmeerw.net>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
8 years agoiio: gyro: Add MPU-3050 device tree bindings
Linus Walleij [Tue, 25 Oct 2016 14:15:53 +0000 (16:15 +0200)]
iio: gyro: Add MPU-3050 device tree bindings

This adds device tree bindings for the MPU-3050 gyroscope. Since it
is the first set of bindings for a gyroscope, the folder for it
is also created.

Cc: devicetree@vger.kernel.org
Cc: Peter Rosin <peda@axentia.se>
Acked-by: Rob Herring <robh@kernel.org>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
8 years agostaging: greybus: audio: remove redundant slot field
Pankaj Bharadiya [Mon, 17 Oct 2016 09:12:36 +0000 (14:42 +0530)]
staging: greybus: audio: remove redundant slot field

gb_audio_manager_module_descriptor's intf_id field maintains the
information about the interface on which module is connected hence
having an extra slot field is redundant.

Thus remove the slot field and its associated code.

Signed-off-by: Pankaj Bharadiya <pankaj.bharadiya@gmail.com>
Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
Reviewed-by: Vaibhav Agarwal <vaibhav.sr@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
8 years agoStaging: Greybus: Fix trailing */ in block comments
Rahul Krishnan [Fri, 21 Oct 2016 15:29:28 +0000 (20:59 +0530)]
Staging: Greybus: Fix trailing */ in block comments

This patch fixes the following checkpath.pl warning
WARNING: Block comments use a trailing */ on a separate line

Signed-off-by: Rahul Krishnan <mrahul.krishnan@gmail.com>
Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
8 years agostaging: greybus: es2: fix arpc request size
Rui Miguel Silva [Wed, 19 Oct 2016 12:44:25 +0000 (13:44 +0100)]
staging: greybus: es2: fix arpc request size

Fix size field of arpc message request by using the header size and not
the pointer size.

Signed-off-by: Rui Miguel Silva <rmfrfs@gmail.com>
Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
Reviewed-by: Johan Hovold <johan@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
8 years agostaging: greybus: audio_manager_sysfs: Replace sscanf with kstrto* to single variable...
Elise Lennion [Fri, 14 Oct 2016 22:00:11 +0000 (19:00 -0300)]
staging: greybus: audio_manager_sysfs: Replace sscanf with kstrto* to single variable conversion.

Fix checkpatch warning:

WARNING: Prefer kstrto<type> to single variable sscanf

kstrto* is designed to convert string to numerical value and makes
it easier to understand what the code does.

Signed-off-by: Elise Lennion <elise.lennion@gmail.com>
Reviewed-by: Mark Greer <mgreer@animalcreek.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
8 years agostaging: xgifb: Remove unnecessary parentheses.
Elise Lennion [Mon, 17 Oct 2016 23:57:58 +0000 (21:57 -0200)]
staging: xgifb: Remove unnecessary parentheses.

The removed parentheses are unnecessary and don't add readability.

Found using Coccinelle semantic patch:
@@ expression e, e1, e2; @@
e &=
(
        (e1 == e2)
|
-       (e1)
+       e1
)

@@ expression e, e1, e2; @@
e |=
(
        (e1 == e2)
|
-       (e1)
+       e1
)

Signed-off-by: Elise Lennion <elise.lennion@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
8 years agostaging: vt6656: Remove unnecessary parentheses.
Elise Lennion [Tue, 18 Oct 2016 00:01:26 +0000 (22:01 -0200)]
staging: vt6656: Remove unnecessary parentheses.

The removed parentheses are unnecessary and don't add readability.

Found using Coccinelle semantic patch:
@@ expression e, e1, e2; @@
e +=
(
        (e1 == e2)
|
-       (e1)
+       e1
)

@@ expression e, e1, e2; @@
e =
(
        (e1 == e2)
|
-       (e1)
+       e1
)

Signed-off-by: Elise Lennion <elise.lennion@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
8 years agoStaging: android: ion: Make a read-only structure
Mihaela Muraru [Mon, 17 Oct 2016 14:20:18 +0000 (17:20 +0300)]
Staging: android: ion: Make a read-only structure

This patch add const qualifier at the declaration of the structure.
The structure become a read-only data, this increase the security.

Found with Coccinelle:
@r disable optional_qualifier@
identifier s,i;
@@
* static struct s i ={...};

Signed-off-by: Mihaela Muraru <mihaela.muraru21@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
8 years agostaging: android: Remove unnecessary parentheses.
Elise Lennion [Tue, 18 Oct 2016 00:00:07 +0000 (22:00 -0200)]
staging: android: Remove unnecessary parentheses.

The removed parentheses are unnecessary and don't add readability.

Found using Coccinelle semantic patch:
@@ expression e, e1, e2; @@
e =
(
        (e1 == e2)
|
-       (e1)
+       e1
)

Signed-off-by: Elise Lennion <elise.lennion@gmail.com>
Acked-by: Laura Abbott <labbott@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
8 years agostaging: vc04_services: Add casts to remove warnings in vchiq_core.c
Michael Zoran [Wed, 19 Oct 2016 22:58:54 +0000 (15:58 -0700)]
staging: vc04_services: Add casts to remove warnings in vchiq_core.c

When compiling vchiq_core.c for 64 bit, the compiler
emits a few warnings that are not actual issues. This
change adds a few casts to remove the extra unnecessary
warnings.

Signed-off-by: Michael Zoran <mzoran@crowfest.net>
Reviewed-by: Eric Anholt <eric@anholt.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
8 years agostaging: vc04_services: Handle conversion from VCHIQ_SERVICE_HANDLE_T to VCHI_SERVICE...
Michael Zoran [Wed, 19 Oct 2016 22:58:48 +0000 (15:58 -0700)]
staging: vc04_services: Handle conversion from VCHIQ_SERVICE_HANDLE_T to VCHI_SERVICE_HANDLE_T

A VCHIQ_SERVICE_HANDLE_T which is an int is stuffed into a
VCHI_SERVICE_HANDLE_T which is a pointer, passed around, then
converted back to a VCHIQ_SERVICE_HANDLE_T. Since the data is
always actually a VCHIQ_SERVICE_HANDLE_T(int), never actually a
pointer, it is safe to simply cast the two back in forth.

Note that pointers are never stuffed into an int.

Signed-off-by: Michael Zoran <mzoran@crowfest.net>
Reviewed-by: Eric Anholt <eric@anholt.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
8 years agostaging: vc04_services: Convert pointers in shared state to offsets
Michael Zoran [Wed, 19 Oct 2016 22:58:34 +0000 (15:58 -0700)]
staging: vc04_services: Convert pointers in shared state to offsets

The arm processor core and the GPU have a shared data structure.
This structure contains pointers to base linux kernel objects such as
events.  The size of the pointer changes between 32 bit and 64 bit,
so it is necessary to convert these pointers to offsets from the
beginning of the state structure.

Luckly, the GPU does not interpret these pointers/offsets,
but this change is necessary to keep the structure the same since
the GPU code is outside the scope of the linux kernel
and can't be easily changed.

Signed-off-by: Michael Zoran <mzoran@crowfest.net>
Reviewed-by: Eric Anholt <eric@anholt.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
8 years agostaging: vc04_services: Change fields of page list structure to fixed length
Michael Zoran [Wed, 19 Oct 2016 22:58:27 +0000 (15:58 -0700)]
staging: vc04_services: Change fields of page list structure to fixed length

The arm processor core and the GPU have shared data structures.
One of these structures is a list of pages of data for messages.
This structure can not change since it is dependent on the GPU
firmware which is external to the kernel.  Convert the fields
of this structure to fixed length fields.

Signed-off-by: Michael Zoran <mzoran@crowfest.net>
Reviewed-by: Eric Anholt <eric@anholt.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
8 years agostaging: vc04_services: Convert dsb() to dsb(sy)
Michael Zoran [Wed, 19 Oct 2016 22:58:09 +0000 (15:58 -0700)]
staging: vc04_services: Convert dsb() to dsb(sy)

The dsb() macro for 32 arm compiles to dsb(sy) in the binary file.
This macro is no longer supported on arm64, so instead use dsb(sy)
which is completely binary compatible.

Signed-off-by: Michael Zoran <mzoran@crowfest.net>
Reviewed-by: Eric Anholt <eric@anholt.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
8 years agoMerge tag 'iio-for-4.10a' of git://git.kernel.org/pub/scm/linux/kernel/git/jic23...
Greg Kroah-Hartman [Mon, 24 Oct 2016 09:34:22 +0000 (11:34 +0200)]
Merge tag 'iio-for-4.10a' of git://git./linux/kernel/git/jic23/iio into staging-next

Jonathan writes:

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

Fair number of outreachy related patches in here. Some of these may well
have already been picked up by Greg but git will sort that out for us.

Also some good staging cleanup work from other sources. Thanks Brian and Lars
in particular for this.

New device support
* ACCES 104-quad-8
  - New driver for this 8 channel encoder input board. Lots of new ABI with
    this one.
* AD7766
  - New driver supporting AD7766, AD7766-1, AD7766-2, AD7767, AD7767-1 and
    AD7767-2 24 bit ADCs.
* dmard 10
  - New driver for this 3 axis accelerometer.
* Honeywell ABP pressure sensors.
  - New driver covering 56 parts in this series (too many to list here!)
* HTS221
  - New driver to support this relative humidiy and temperature device.
* LMP91000
  - New driver for this potentiostat (form of chemical sensor). Nice example
    of use of the buffered consumer interfaces and the use of a consumer
    provided trigger.
* MiraMEMS DA311
  - New driver for this 3 axis accelerometer.
* MiraMEMS DA280
  - New driver for this 3 axis accelerometer. Follow up caught up with
  vendor prefixes for these.

Staging graduations
* isl29018 light sensor
  - Fixes and cleanups listed below (thanks for your hard work on this Brian!)
* sca3000
  - Fixes and cleanups listed below.  This was one of the small set of drivers
  that went into staging when IIO was first added.  Turns out it had a few
  bugs and needed to be brought into the modern era!  Not clear if I am
  the only person who actually has one of these still wired to a board.

New features (Core)
 - Add an iio_trigger_validate_own_device helper which relies on the device
   and trigger having the same parent.  Convenient to have this for some
   of the more complex trigger / device interactions. Was hand rolled in
   a few drivers already so good to bring it into the core.
 - Add an iio_read_channel_offset in kernel access helper (similar to
   the existing one for scale).
 - IIO_ATTR_{RO, WO, RW} and IIO_DEVICE_ATTR_{RO, WO, RW} macros.  These
   lead some rather contrived function naming, but there is no denying they
   do reduced boilerplate.  I'm going to resist their introduction in
   drivers 'unless' they form part of a larger set of cleanups.
 - Counter channel type and index type.

New features (Drivers)
* hdc100x
  - Triggered buffer support.
* mcp4725
  - Device tree bindings and support.
  - Voltage reference selection.
* ti-adc0832
  - Triggered buffer support.
* ti-adc161s626
  - Add regulator support allowing _scale and _offset values to be established
  and exported.

New features (Tools)
* iio_generic_buffer
  - -A option to force enable all channels rather than faulting if some are
  already enabled (like -a does).  Followup patches tidied this support up.

Cleanups (Core)
 - Use kmalloc_array in iio_scan_mask_set.
 - Take event_attrs field of iio_info structure constant
 - Staging todo list updates. Most of it was long done.
 - MAINTAINERS had a wrong directory listing.

Cleanups (Drivers)
* Missing i2c trivial devices entries.
* ad5592r
  - Fix an endian type related sparse warnings.
* ad7150
  - Constify the event attribute_group structures.
* ad7152
  - Add some blank lines to improve readability.
  - Sampling frequency control via chan-info element rather than hand rolled
  attributes.
  - add a new lock to avoid use of mlock for non state change related locking.
* ad7280
  - Constify atrribute_group structure (second patch covers the event ones)
* ad7606 (Lars is driving most of the cleanup on this with some additions from
  Eva)
  - Fix improper setting of oversampling pins.  This has been broken a very
  long time in this staging driver, so not going to push this back to stable.
  - Implement oversampling configuration via the chan_info mask element.
  - Remove an unused int_vref_mv field.
  - Remove a reundant name field from ad7606_chip_info.
  - Remove default device configuration from platform_data in favour of
  whatever the power on defaults are.
  - Remove out of band error reporting in the kernel log as not providing
  much information.
  - Fix oversampling ratio by having 1 be the value for no oversampling.
  - Avoid allocating buffer for each data capture.
  - Factor out common code between periodic and one-shot capture.
  - Move set_drvdat into common code.
  - Let the common probe function return int rather than jumping through
  an ERR_PTR.
  - Pass struct device * into common remove to simplify code.
  - Always run trigger handler only once per event (no one can remember why
  it was being possibly done twice).
  - Move over to the GPIO descriptor API to shorten and clarify code.
  - Move the buffer code into the main file as it's not optional and is
  now rather short in this driver.
  - Fix the naming of the supply regulator.
  - Rework regulator handling to handle errors including deferred probing.
  - Tidy up a ptr_err or 0 return.
* ad7746
  - Sampling frequency control via info_mask element rather than hand rolled
* ad7758
  - Sampling frequency control via info_mask element rather than hand rolled
  attributes.
* ad7816
  - Constify the event attribute_group structure.
* adt7316
  - Constify the event attribute group structures.
* ak8974
  - Cleanup some sparse warnings about endian types.
* ak8975
  - Cleanup some sparse warnings about endian types.
* bmi160
  - Spare endian warning cleanups.
* isl29018 (towards staging graduation)
  - Remove unusedvariables and defines.
  - Improve consistency of error handling.
  - Signed / unsigned comparison fixes.
  - Use the IIO_DEVICE_ATTR_{RO, RW} macros
  - Fix a race in in_illuminance_scale_available_show.
  - Cleanup exit points of _read_raw
  - Sanity check if in suspended state during a write_raw call as was already
    done for read_raw.
  - Document device tree bidnings.
  - Document infrared supression controls.
  - Add some newlines to improve readability and drop one that shouldn't be
    there.
  - Fix a poorly named functions name.
  - Fix multiline coment syntax.
  - Tidy up a pair or return statements by unifying them.
  - Rename description in Kconfig for consistency with similar drivers.
* lidar
  - cleanup power management by dropping unnecessary call.
* ltr501
  - Use the claim_direct_mode helpers. Fix a race condition along the way.
* max1027
  - Fix a dubious x | !y sparse warning.
  - Use the new iio_trigger_validate_own_device helper.
* max440000
  - Clean up some sparse warnings about endian types.
* mcp4725
  - Use the regulator framework to establish the reference voltage rather than
    getting it from platform data.
  - Tidy up a comment typo.
  - Fix a wrong PTR_ERR query (wrong regulator).
* mma7660
  - Take a mma7660_nscale static.
* mma8452
  - Use the new iio_trigger_validate_own_device helper.
  - Use claim_direct_mode helpers - fix a race condition along the way.
* mpl3115
  - Use claim_direct_mode helpers - fix a race condition along the way.
* ms65611
  - Tidy up regulator error handling and clean out a static warning in the mix.
* sca3000
  - Avoid a potential unitialized variable if a hardware read returns a value
  that isn't actually supported (mostly warning supression).
  - Fix a use before setting of the indio_dev->buffer pointer. Broken for
  a very long time so not going to rush this into stable.
  - Merge buffer file with core file.  We used to always split these.
  Sometimes it's just not worth the hassle. In this case the device's main
  feature is it's hardware fifos so unlikely anyone would want to run it
  without.
  - Drop the sca3000_register_ring_funcs function as it's a pointless wrapper
  once we have only one file.
  - Fix cleaning of flag + setting of size of scan. Without this you can't
  start the buffer twice and expect sensible (or any) results.  Again,
  broken for a long time so not heading for stable.
  - Drop the custom watershed setting ABI - for now we'll just support one
  value.
  - Move to a hybrid hard / soft buffer design (how we've been doing it
  for similar devices for a while now!)
  - Cleanup some unusued variables.
  - Use a fake channel to support core handling of freefall event registration.
  - Cleanup the register defines.
  - Fix an off by one error in axis due to IIO_NO_MOD taking up the 0 value.
  Been broken since first admission of IIO to the staging tree.
  - Add readback of the 3db low pass filter frequency and later writing
    allowing droppign of custom measurement mode attributes as they can
    be represented by the filter choices that is their main characteristic.
  - Drop non standard revision attr and replace with dev_info on probe.
  - Avoid a race in probe.
  - Various formatting fixes.
  - Kernel-docify docs that were very nearly in the write format.
* tsl2583
  - Constify attribute_group structure.
* zpa2326
  - Drop a redundant DEBUG ifdef.

Cleanups (Tools)
* iio_generic_buffer
  - Fix the ? arguement. Previously it sort of worked as you got the help
    message as a result of it not recognising the arguement.

8 years agoiio: dac: mcp4725: fix odd_ptr_err.cocci warnings
Julia Lawall [Sat, 22 Oct 2016 20:41:32 +0000 (22:41 +0200)]
iio: dac: mcp4725: fix odd_ptr_err.cocci warnings

PTR_ERR should access the value just tested by IS_ERR

Generated by: scripts/coccinelle/tests/odd_ptr_err.cocci

CC: Tomas Novotny <tomas@novotny.cz>
Signed-off-by: Julia Lawall <julia.lawall@lip6.fr>
Signed-off-by: Fengguang Wu <fengguang.wu@intel.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
8 years agostaging:iio:ad7606: fix ptr_ret.cocci warnings
kbuild test robot [Sat, 22 Oct 2016 19:12:42 +0000 (03:12 +0800)]
staging:iio:ad7606: fix ptr_ret.cocci warnings

drivers/staging/iio/adc/ad7606.c:357:1-3: WARNING: PTR_ERR_OR_ZERO can be used

 Use PTR_ERR_OR_ZERO rather than if(IS_ERR(...)) + PTR_ERR

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

CC: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Fengguang Wu <fengguang.wu@intel.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
8 years agoiio: proximity: pulsedlight-lidar-lite-v2: cleanup power management
Matt Ranostay [Sat, 15 Oct 2016 18:04:37 +0000 (11:04 -0700)]
iio: proximity: pulsedlight-lidar-lite-v2: cleanup power management

Remove pm_runtime_mark_last_busy() call that wasn't need in the probe
since the device should be put to sleep.

Clarification from Matt:
Basically it going to be suspended once pm_runtime_idle() is called,
and setting the last busy is useless and not needed.
Clearly this doesn't affect the device running but just makes the code
more consistent with other uses.

Signed-off-by: Matt Ranostay <matt@ranostay.consulting>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
8 years agoiio: ti-adc0832: add triggered buffer support
Akinobu Mita [Sun, 16 Oct 2016 15:59:42 +0000 (00:59 +0900)]
iio: ti-adc0832: add triggered buffer support

This adds triggered buffer support for the ti-adc0832 driver.  Tested with
ADC0831 and ADC0832 by using SYSFS trigger.

Signed-off-by: Akinobu Mita <akinobu.mita@gmail.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: Jonathan Cameron <jic23@kernel.org>
8 years agoiio: humidity: hdc100x: add triggered buffer support for HDC100X
Alison Schofield [Fri, 2 Sep 2016 17:23:17 +0000 (10:23 -0700)]
iio: humidity: hdc100x: add triggered buffer support for HDC100X

Triggered buffer support uses the HDC100X's dual acquisition mode
to read both humidity and temperature in one shot.

This patch depends on
447136effbf4 ("iio: humidity: hdc100x: fix sensor data reads of
       temp and humidity")

Signed-off-by: Alison Schofield <amsfield22@gmail.com>
Cc: Daniel Baluta <daniel.baluta@gmail.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
8 years agoiio: dac: mcp4725: add devicetree support
Tomas Novotny [Tue, 18 Oct 2016 17:43:09 +0000 (19:43 +0200)]
iio: dac: mcp4725: add devicetree support

Signed-off-by: Tomas Novotny <tomas@novotny.cz>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
8 years agoiio: dac: mcp4725: support voltage reference selection
Tomas Novotny [Tue, 18 Oct 2016 17:43:08 +0000 (19:43 +0200)]
iio: dac: mcp4725: support voltage reference selection

MCP47x6 chip supports selection of a voltage reference (VDD, VREF buffered
or unbuffered). MCP4725 doesn't have this feature thus the eventual setting
is ignored and user is warned.

The setting is stored only in the volatile memory of the chip. You need to
manually store it to the EEPROM of the chip via 'store_eeprom' sysfs entry.

Signed-off-by: Tomas Novotny <tomas@novotny.cz>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
8 years agoDocumentation: dt: iio: add mcp4725/6 dac device binding
Tomas Novotny [Tue, 18 Oct 2016 17:43:07 +0000 (19:43 +0200)]
Documentation: dt: iio: add mcp4725/6 dac device binding

Signed-off-by: Tomas Novotny <tomas@novotny.cz>
Acked-by: Rob Herring <robh@kernel.org>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
8 years agoiio: dac: mcp4725: fix incorrect comment
Tomas Novotny [Tue, 18 Oct 2016 17:43:06 +0000 (19:43 +0200)]
iio: dac: mcp4725: fix incorrect comment

Number 2 is referencing to the settings with the largest available
resistor.

No functional change.

Signed-off-by: Tomas Novotny <tomas@novotny.cz>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
8 years agostaging: iio: ad7606: rework regulator handling
Eva Rachel Retuya [Thu, 20 Oct 2016 13:08:23 +0000 (21:08 +0800)]
staging: iio: ad7606: rework regulator handling

Currently, this driver ignores all errors from regulator_get(). The way
it is now, it also breaks probe deferral (EPROBE_DEFER). The correct
behavior is to propagate the error to the upper layers so they can
handle it accordingly.

Rework the regulator handling so that it matches the standard behavior.
If the specific design uses a static always-on regulator and does not
explicitly specify it, regulator_get() will return the dummy regulator.

Suggested-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Eva Rachel Retuya <eraretuya@gmail.com>
Acked-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
8 years agostaging: iio: ad7606: set proper supply name to devm_regulator_get()
Eva Rachel Retuya [Thu, 20 Oct 2016 13:08:22 +0000 (21:08 +0800)]
staging: iio: ad7606: set proper supply name to devm_regulator_get()

The name passed to devm_regulator_get() should match the name of the
supply as specified in the device datasheet. The supply on this device
is called 'AVcc' while currently, the driver uses just 'vcc'.

Use 'avcc' to specify the supply voltage since it is custom to use the
lower-caps version of the datasheet name.

Suggested-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Eva Rachel Retuya <eraretuya@gmail.com>
Acked-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
8 years agostaging:iio:ad7606: Move buffer code to main source file
Lars-Peter Clausen [Wed, 19 Oct 2016 17:07:08 +0000 (19:07 +0200)]
staging:iio:ad7606: Move buffer code to main source file

Currently the ad7606 buffer handling code resides in its own source file.
But this file contains only 4 small functions of which half are just
wrappers around other functions. Buffer support is also always enabled for
this driver, so move them over to the main source file. This reduces the
amount of boilerplate code.

Also rename the main function from ad7606_core.c to ad7606.c since there is
only a single file now.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
8 years agostaging:iio:ad7606: Use GPIO descriptor API
Lars-Peter Clausen [Wed, 19 Oct 2016 17:07:07 +0000 (19:07 +0200)]
staging:iio:ad7606: Use GPIO descriptor API

Convert the ad7606 driver away from the deprecated legacy GPIO API and use
the new GPIO descriptor API.

This also means that the platform data struct is now empty and can be
removed.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
8 years agostaging:iio:ad7606: Run trigger handler only once per trigger event
Lars-Peter Clausen [Wed, 19 Oct 2016 17:07:06 +0000 (19:07 +0200)]
staging:iio:ad7606: Run trigger handler only once per trigger event

Currently the ad7606 driver installs the same function for the hard-irq and
threaded trigger handlers. This was introduced in commit 1caf7cb46135
("staging:iio:adc:ad7606 Convert to new channel registration method Update
Add missing call to iio_trigger_notify_done() Set pollfunc top and bottom
half handler"). Unfortunately the commit message does not mention why this
was done and Michael does not remember either.

Since the trigger handler function is idempotent (set a GPIO to 1) running
it twice does not do any harm, but is simply not necessary either. So set
the threaded trigger handler for the driver to NULL.

While we are at it also remove the function description comment that does
no say anything that can't be derived from the function name itself.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
8 years agostaging:iio:ad7606: Let common remove function take a struct device *
Lars-Peter Clausen [Wed, 19 Oct 2016 17:07:05 +0000 (19:07 +0200)]
staging:iio:ad7606: Let common remove function take a struct device *

Currently the common remove function takes a struct iio_dev *. This
parameter is retrieved by the individual driver remove functions by calling
get_drvdata() on their device. To simplify the code let the common remove
function directly take a struct dev * and do the IIO device in retrieval
the common remove function.

This also aligns the interface with the common probe function.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
8 years agostaging:iio:ad7606: Let the common probe function return int
Lars-Peter Clausen [Wed, 19 Oct 2016 17:07:04 +0000 (19:07 +0200)]
staging:iio:ad7606: Let the common probe function return int

The common probe function for the ad7606 currently returns a struct iio_dev
pointer. The returned value is not used by the individual driver probe
functions other than for error checking.

Let the common probe function return a int instead to report the error
value directly (or 0 on success). This allows to simplify the code.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
8 years agostaging:iio:ad7606: Move set_drvdata() into common code
Lars-Peter Clausen [Wed, 19 Oct 2016 17:07:03 +0000 (19:07 +0200)]
staging:iio:ad7606: Move set_drvdata() into common code

Both the platform_device and SPI driver call set_drvdata() at the end of
their probe function. Move this into the common probe() function to reduce
duplicated code.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
8 years agostaging:iio:ad7606: Factor out common code between periodic and one-shot capture
Lars-Peter Clausen [Wed, 19 Oct 2016 17:07:02 +0000 (19:07 +0200)]
staging:iio:ad7606: Factor out common code between periodic and one-shot capture

Both the periodic buffer based and one-shot sysfs based capture methods
share a large portion of their code. Factor this out into a common helper
function.

Also provide a comment that better explains in more detail what is going on
in the capture function.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
8 years agostaging:iio:ad7606: Avoid allocating buffer for each data capture
Lars-Peter Clausen [Wed, 19 Oct 2016 17:07:01 +0000 (19:07 +0200)]
staging:iio:ad7606: Avoid allocating buffer for each data capture

Currently the ad7606 driver dynamically allocates and frees a transfer
buffer each time a sample capture is performed in buffered mode, which
introduces unnecessary overhead. The driver state struct already contains a
buffer that is used for transfers in one-shot mode. This buffer is large
enough to hold all samples, but not the timestamp that might be present in
buffered mode. Extend the buffer size to be able to contain the timestamp
and update the buffered capture function to use this buffer.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
8 years agostaging:iio:ad7606: Use oversampling ratio of 1 for no oversampling
Lars-Peter Clausen [Wed, 19 Oct 2016 17:07:00 +0000 (19:07 +0200)]
staging:iio:ad7606: Use oversampling ratio of 1 for no oversampling

Currently the ad7606 driver uses a value of 0 for the oversampling ratio to
express that no oversampling is done. Strictly speaking this means though
that no data capture is done at all. Instead change the driver to use a
value of 1, this is in accordance with what other drivers do and what the
IIO spec suggests.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
8 years agostaging:iio:ad7606: Remove out-of-band error reporting
Lars-Peter Clausen [Wed, 19 Oct 2016 17:06:59 +0000 (19:06 +0200)]
staging:iio:ad7606: Remove out-of-band error reporting

Currently the ad7606 driver prints a error message to the kernel log when
an application writes an invalid value to a sysfs attribute. While for
initial driver development and testing this might be useful it is quite
disadvantageous in a production environment. The write() call to the sysfs
attribute will already return an error if the value was invalid so the
application is aware that the operation failed. And generally speaking it
is impossible for an application to reliably match a log message in the
kernel log to a specific operation it performed, so the message becomes
just noise and might distract from more critical messages.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
8 years agostaging:iio:ad7606: Remove default device configuration from platform data
Lars-Peter Clausen [Wed, 19 Oct 2016 17:06:58 +0000 (19:06 +0200)]
staging:iio:ad7606: Remove default device configuration from platform data

While for some very selected setups it might be useful to be able to
provide default configuration data via the platform data, generally this
becomes very impractical as the number of configuration options increases.
So the general policy is to use the power-on default values of the device
and let the application using the device configure it according to its
needs.

Implement this scheme for the ad7606 driver by removing support for
specifying a default configuration via the platform data.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
8 years agostaging:iio:ad7606: Remove redundant name field from ad7606_chip_info
Lars-Peter Clausen [Wed, 19 Oct 2016 17:06:57 +0000 (19:06 +0200)]
staging:iio:ad7606: Remove redundant name field from ad7606_chip_info

The name field in the ad7606_chip_info struct is set to the same value as
the as the name field in the corresponding {platform,spi}_device_id table
entry. Remove it from the ad7606_chip_info struct and pass the name from
the ID to the probe function. This slightly reduces the size of the
chip_info table and adding new entries requires less boilerplate.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
8 years agostaging:iio:ad7606: Remove unused int_vref_mv field
Lars-Peter Clausen [Wed, 19 Oct 2016 17:06:56 +0000 (19:06 +0200)]
staging:iio:ad7606: Remove unused int_vref_mv field

Remove the int_vref_mv field from the ad7606_chip_info struct since the
field is never used by the driver. The value is also the same for all
derivatives of this chip, so if it will ever be used in the driver a
constant value will work just fine.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
8 years agotools: iio: iio_generic_buffer: drop unneeded parentheses
Eva Rachel Retuya [Thu, 20 Oct 2016 09:19:24 +0000 (17:19 +0800)]
tools: iio: iio_generic_buffer: drop unneeded parentheses

Remove extra parentheses introduced in commit <73e176a tools: iio:
iio_generic_buffer: add -A to force-enable all channels>.

Suggested-by: Peter Meerwald-Stadler <pmeerw@pmeerw.net>
Signed-off-by: Eva Rachel Retuya <eraretuya@gmail.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
8 years agotools: iio: iio_generic_buffer: rename and change type of force variable
Eva Rachel Retuya [Thu, 20 Oct 2016 09:19:23 +0000 (17:19 +0800)]
tools: iio: iio_generic_buffer: rename and change type of force variable

Replace the type of 'force' flag from int to bool and at the same time
rename it to 'force_autochannels' for better readability.

Suggested-by: Peter Meerwald-Stadler <pmeerw@pmeerw.net>
Signed-off-by: Eva Rachel Retuya <eraretuya@gmail.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
8 years agoDocumentation: dt: iio: humidity: add hts221 sensor device binding
Lorenzo Bianconi [Thu, 13 Oct 2016 20:06:05 +0000 (22:06 +0200)]
Documentation: dt: iio: humidity: add hts221 sensor device binding

Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@st.com>
Acked-by: Rob Herring <robh@kernel.org>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
8 years agoiio: humidity: add support to hts221 rh/temp combo device
Lorenzo Bianconi [Thu, 13 Oct 2016 20:06:04 +0000 (22:06 +0200)]
iio: humidity: add support to hts221 rh/temp combo device

Add support to STM HTS221 humidity + temperature sensor

http://www.st.com/resource/en/datasheet/hts221.pdf

- continuous mode support
- i2c support
- spi support
- trigger mode support

Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@st.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
8 years agoiio: light: ltr501: claim direct mode during raw writes
Alison Schofield [Sun, 16 Oct 2016 05:02:19 +0000 (22:02 -0700)]
iio: light: ltr501: 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 all raw write operations.

Signed-off-by: Alison Schofield <amsfield22@gmail.com>
Acked-by: Peter Meerwald-Stadler <pmeerw@pmeerw.net>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
8 years agoiio: light: ltr501: claim direct mode during select raw reads
Alison Schofield [Sun, 16 Oct 2016 05:00:53 +0000 (22:00 -0700)]
iio: light: ltr501: claim direct mode during select raw reads

Driver was checking for direct mode but not locking it.  Use
claim/release helper functions to guarantee the device stays
in direct mode during required raw read cases.

Signed-off-by: Alison Schofield <amsfield22@gmail.com>
Acked-by: Peter Meerwald-Stadler <pmeerw@pmeerw.net>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
8 years agostaging:iio:accel:sca3000 Move out of staging.
Jonathan Cameron [Sat, 8 Oct 2016 16:39:18 +0000 (17:39 +0100)]
staging:iio:accel:sca3000 Move out of staging.

Now the driver is in a reasonable state, lets get it (finally) out
of staging.

Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Reviewed-by: Lars-Peter Clausen <lars@metafoo.de>
8 years agostaging:iio:accel:sca3000 kernel docify comments that were nearly kernel doc.
Jonathan Cameron [Sat, 8 Oct 2016 16:39:17 +0000 (17:39 +0100)]
staging:iio:accel:sca3000 kernel docify comments that were nearly kernel doc.

Basic tidy up of comments to bring them into a standard style.

Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Reviewed-by: Lars-Peter Clausen <lars@metafoo.de>
8 years agostaging:iio:accel:sca3000 small checkpatch fixes (alignment etc)
Jonathan Cameron [Sat, 8 Oct 2016 16:39:16 +0000 (17:39 +0100)]
staging:iio:accel:sca3000 small checkpatch fixes (alignment etc)

Tidied up where checkpatch warning suppressions doesn't effect the
readability of the code.

Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Reviewed-by: Lars-Peter Clausen <lars@metafoo.de>
8 years agostaging:iio:accel:sca3000 Tidy up probe order to avoid a race.
Jonathan Cameron [Sat, 8 Oct 2016 16:39:15 +0000 (17:39 +0100)]
staging:iio:accel:sca3000 Tidy up probe order to avoid a race.

Previously the device was exposed to userspace and in kernel consumers
before the interrupts had been configured. As nothing stopped them being
enabled in the interval this could cause unhandled interrupts.

Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Reviewed-by: Lars-Peter Clausen <lars@metafoo.de>
8 years agostaging:iio:accel:sca3000 replace non standard revision attr with dev_info on probe
Jonathan Cameron [Sat, 8 Oct 2016 16:39:14 +0000 (17:39 +0100)]
staging:iio:accel:sca3000 replace non standard revision attr with dev_info on probe

There seems little point in being able to query the part revision number
via sysfs.  Hence just put it in the kernel logs during probe incase
anyone ever wants to know.

Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Reviewed-by: Lars-Peter Clausen <lars@metafoo.de>
8 years agostaging:iio:accel:sca3000 Drop custom measurement mode attributes
Jonathan Cameron [Sat, 8 Oct 2016 16:39:13 +0000 (17:39 +0100)]
staging:iio:accel:sca3000 Drop custom measurement mode attributes

This is now represented by the standard 3db filter frequency controls.
Things get complex wrt to the sampling frequency as these modes change
but that is fine under the IIO ABI where any value is allowed to effect
any other.

Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Reviewed-by: Lars-Peter Clausen <lars@metafoo.de>
8 years agostaging:iio:accel:sca3000 Add write support to the low pass filter control
Jonathan Cameron [Sat, 8 Oct 2016 16:39:12 +0000 (17:39 +0100)]
staging:iio:accel:sca3000 Add write support to the low pass filter control

Also includes an available attribute.  The ordering of values appears
a bit random, but as the ABI doesn't specify this and we already have
both rising and falling lists I think this is fine.

Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Reviewed-by: Lars-Peter Clausen <lars@metafoo.de>
8 years agostaging:iio:accel:sca3000: Fix off by one error in axis due to IIO_NO_MOD
Jonathan Cameron [Sat, 8 Oct 2016 16:39:11 +0000 (17:39 +0100)]
staging:iio:accel:sca3000: Fix off by one error in axis due to IIO_NO_MOD

Given the introduction of IIO_NO_MOD was prior to the first submission
prior to IIO entering staging this has been broken for a while.

Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Reviewed-by: Lars-Peter Clausen <lars@metafoo.de>
8 years agostaging:iio:accel:sca3000 add readback of the 3db low pass filter frequency
Jonathan Cameron [Sat, 8 Oct 2016 16:39:10 +0000 (17:39 +0100)]
staging:iio:accel:sca3000 add readback of the 3db low pass filter frequency

Driving towards getting rid of the non standard mode control interface.

Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Reviewed-by: Lars-Peter Clausen <lars@metafoo.de>
8 years agostaging:iio:accel:sca3000 Clean up register defines.
Jonathan Cameron [Sat, 8 Oct 2016 16:39:09 +0000 (17:39 +0100)]
staging:iio:accel:sca3000 Clean up register defines.

Introduce some more masks and generally drive towards consistent naming.
Note the small indents used to indicate parts of registers + parts of
multiplexed registers.

Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Reviewed-by: Lars-Peter Clausen <lars@metafoo.de>
8 years agostaging:iio:accel:sca3000 use a 'fake' channel to handle freefall event registration.
Jonathan Cameron [Sat, 8 Oct 2016 16:39:08 +0000 (17:39 +0100)]
staging:iio:accel:sca3000 use a 'fake' channel to handle freefall event registration.

This is an approach used in some newer drivers as it exposes the
compound channel events to the core rather than hiding their control
in sysfs attributes entirely via the driver.

Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Reviewed-by: Lars-Peter Clausen <lars@metafoo.de>
8 years agostaging:iio:accel:sca3000 drop some unused variables.
Jonathan Cameron [Sat, 8 Oct 2016 16:39:07 +0000 (17:39 +0100)]
staging:iio:accel:sca3000 drop some unused variables.

Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Reviewed-by: Lars-Peter Clausen <lars@metafoo.de>
8 years agostaging:iio:accel:sca3000 move to hybrid hard / soft buffer design.
Jonathan Cameron [Sat, 8 Oct 2016 16:39:06 +0000 (17:39 +0100)]
staging:iio:accel:sca3000 move to hybrid hard / soft buffer design.

In a similar fashion to other newer drivers (e.g. ti_am335x), instead
of using the hardware buffer support in IIO to directly access the hardware
fifo, insert a software fifo and feed that from the hardware one when
interrupts occur.  This gives a simpler structure to the data flows and
allows more flexibility over how often data is shipped to userspace etc.

This was also the only direct user of the simplistic generalization found
in ring_hw.h so that header is removed.

Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Reviewed-by: Lars-Peter Clausen <lars@metafoo.de>
8 years agostaging:iio:accel:sca3000 Drop custom ABI for watersheds.
Jonathan Cameron [Sat, 8 Oct 2016 16:39:05 +0000 (17:39 +0100)]
staging:iio:accel:sca3000 Drop custom ABI for watersheds.

For now we support only the 50% watershed interrupt and start and stop it
as part of the buffer bring up.  The 75% case may come back in future.

Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Reviewed-by: Lars-Peter Clausen <lars@metafoo.de>
8 years agostaging:iio:accel:sca3000 Fix clearing of flag + setting of size of scan.
Jonathan Cameron [Sat, 8 Oct 2016 16:39:04 +0000 (17:39 +0100)]
staging:iio:accel:sca3000 Fix clearing of flag + setting of size of scan.

Not clearing the stuff_to_read flag can lead to a false flag being set
on restarting the buffer if the data was not all read the previous time.

The size of the scan is needed to ensure the function
iio_buffer_read_first_n_outer actually tries to read the data.

This stuff has been broken for some time so not stable material.

Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Reviewed-by: Lars-Peter Clausen <lars@metafoo.de>
8 years agostaging:iio:accel:sca3000 drop sca3000_register_ring_funcs
Jonathan Cameron [Sat, 8 Oct 2016 16:39:03 +0000 (17:39 +0100)]
staging:iio:accel:sca3000 drop sca3000_register_ring_funcs

This was needed when the buffer support was optional. Pointless wrapper
now so drop it.

Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Reviewed-by: Lars-Peter Clausen <lars@metafoo.de>
8 years agostaging:iio:accel:sca3000 merge files into one.
Jonathan Cameron [Sat, 8 Oct 2016 16:39:02 +0000 (17:39 +0100)]
staging:iio:accel:sca3000 merge files into one.

In the early days of IIO we were much more inclined to keep the impact
of the core IIO elements to the minimum.  As time has moved on it has
become clear that hardly any builds are done without buffer support
and that it adds considerable complexity to the drivers.

Hence merge down the buffer and non buffer elements of the sca3000 driver
also allowing us to drop the header file used for the interfaces between
the two.

Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Reviewed-by: Lars-Peter Clausen <lars@metafoo.de>
8 years agostaging:iio:accel:sca3000 Fix a use before setting of the indio_dev->buffer pointer.
Jonathan Cameron [Sat, 8 Oct 2016 16:39:01 +0000 (17:39 +0100)]
staging:iio:accel:sca3000 Fix a use before setting of the indio_dev->buffer pointer.

Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Reviewed-by: Lars-Peter Clausen <lars@metafoo.de>
8 years agostaging: iio: isl29018: move out of staging
Brian Masney [Mon, 10 Oct 2016 07:20:02 +0000 (03:20 -0400)]
staging: iio: isl29018: move out of staging

Move ISL29018/ISL29023/ISL29035 driver out of staging into mainline.

Signed-off-by: Brian Masney <masneyb@onstation.org>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
8 years agostaging: iio: isl29018: add ABI documentation for infrared suppression
Brian Masney [Mon, 10 Oct 2016 07:20:01 +0000 (03:20 -0400)]
staging: iio: isl29018: add ABI documentation for infrared suppression

Add ABI documentation from the ISL29018 Data Sheet (FN6619.4, Oct 8,
2012) about the infrared suppression that can be controlled
with the proximity_on_chip_ambient_infrared_suppression sysfs attribute.

Signed-off-by: Brian Masney <masneyb@onstation.org>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
8 years agoiio: pressure: mpl3115: claim direct mode during raw reads
Alison Schofield [Tue, 11 Oct 2016 19:33:12 +0000 (12:33 -0700)]
iio: pressure: mpl3115: claim direct mode during raw reads

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 reads.

Signed-off-by: Alison Schofield <amsfield22@gmail.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
8 years agoiio: accel: mma8452: claim direct mode during write raw
Jonathan Cameron [Sat, 15 Oct 2016 14:55:06 +0000 (15:55 +0100)]
iio: accel: mma8452: claim direct mode during write raw

Driver was checking for direct mode but not locking it.  Use
claim/release helper functions to guarantee the device stays
in direct mode during all write raw operations.

Signed-off-by: Alison Schofield <amsfield22@gmail.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
8 years agoiio: accel: mma8452: claim direct mode during raw reads
Alison Schofield [Tue, 11 Oct 2016 19:31:36 +0000 (12:31 -0700)]
iio: accel: mma8452: claim direct mode during raw reads

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 reads.

Signed-off-by: Alison Schofield <amsfield22@gmail.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
8 years agotools: iio: iio_generic_buffer: add -A to force-enable all channels
Eva Rachel Retuya [Fri, 14 Oct 2016 10:18:39 +0000 (18:18 +0800)]
tools: iio: iio_generic_buffer: add -A to force-enable all channels

If attribute/s is/are already enabled (by default or via scripts or
manual interaction), issuing -a will fail to enable the channels thereby
one has to manually disable the said attribute/s before proceeding with
auto-enabling.

Add a command-line option -A to force-activate all channels regardless
of their current state.

Suggested-by: Alison Schofield <amsfield22@gmail.com>
Signed-off-by: Eva Rachel Retuya <eraretuya@gmail.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
8 years agoiio: dac: mcp4725: use regulator framework
Tomas Novotny [Tue, 11 Oct 2016 13:57:40 +0000 (15:57 +0200)]
iio: dac: mcp4725: use regulator framework

Use a standard framework to get the reference voltage. It is done that way
in the iio subsystem and it will simplify extending of the driver.

Structure mcp4725_platform_data is left undeleted because it used in the
next patch.

This change breaks the current users of the driver, but there is no
mainline user of struct mcp4725_platform_data.

Signed-off-by: Tomas Novotny <tomas@novotny.cz>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
8 years agoiio: ms65611_core: Fixes dereferencing regulator pointer
Crt Mori [Fri, 14 Oct 2016 13:43:14 +0000 (15:43 +0200)]
iio: ms65611_core: Fixes dereferencing regulator pointer

Change in handling of the regulator description means that static
checkers correctly assume we could be using dereferenced pointer to the
regulator. In reality we will never get the -ENODEV error, as current
behavior flow does not predict it, because:
If the device tree or board file does not define suitable regulators for
the component, it will be substituted by a dummy regulator, or, if
regulators are disabled altogether, by stubs.

Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Suggested-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Crt Mori <cmo@melexis.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
8 years agoStaging: iio: fix a MAINTAINERS entry
Dan Carpenter [Tue, 11 Oct 2016 11:12:29 +0000 (14:12 +0300)]
Staging: iio: fix a MAINTAINERS entry

The "drivers/" part of the path name was missing.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
8 years agoiio: bmi160_core: Fix sparse warning due to incorrect type in assignment
sayli karnik [Tue, 11 Oct 2016 11:37:21 +0000 (17:07 +0530)]
iio: bmi160_core: Fix sparse warning due to incorrect type in assignment

There is a type mismatch between the buffer which is of type s16 and the
samples stored, which are declared as __le16.

Fix the following sparse warning:
drivers/iio/imu/bmi160/bmi160_core.c:411:26: warning: incorrect type
in assignment (different base types)

drivers/iio/imu/bmi160/bmi160_core.c:411:26: expected signed short
[signed] [short] [explicitly-signed] <noident>
drivers/iio/imu/bmi160/bmi160_core.c:411:26: got restricted __le16
[addressable] [usertype] sample

This is a cosmetic-type patch since it does not alter code behaviour.
The le16 is going into a 16bit buf element, and is labelled as IIO_LE in the
channel buffer definition.

Signed-off-by: sayli karnik <karniksayli1995@gmail.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
8 years agostaging: iio: isl29018: rename description in Kconfig for consistency
Brian Masney [Mon, 10 Oct 2016 07:20:00 +0000 (03:20 -0400)]
staging: iio: isl29018: rename description in Kconfig for consistency

Rename description from "ISL 29018" to "Intersil 29018" in Kconfig for
consistency with other drivers in mainline.

Signed-off-by: Brian Masney <masneyb@onstation.org>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
8 years agostaging: iio: isl29018: remove blank line for consistency
Brian Masney [Mon, 10 Oct 2016 07:19:59 +0000 (03:19 -0400)]
staging: iio: isl29018: remove blank line for consistency

Remove blank line between MODULE_DEVICE_TABLE() and its corresponding
structure for consistency with the other device table entries.

Signed-off-by: Brian Masney <masneyb@onstation.org>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
8 years agostaging: iio: isl29018: combine two return statements into one
Brian Masney [Mon, 10 Oct 2016 07:19:58 +0000 (03:19 -0400)]
staging: iio: isl29018: combine two return statements into one

Use the return value from isl29018_set_integration_time() as the return
value for isl29018_chip_init() since this is the last piece of work
inside that function.

Signed-off-by: Brian Masney <masneyb@onstation.org>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
8 years agostaging: iio: isl29018: fix multiline comment syntax
Brian Masney [Mon, 10 Oct 2016 07:19:57 +0000 (03:19 -0400)]
staging: iio: isl29018: fix multiline comment syntax

Change multiline comments from:

/* line1
 * line2
 * ...
 */

to

/*
 * line1
 * line2
 * ...
 */

Signed-off-by: Brian Masney <masneyb@onstation.org>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
8 years agostaging: iio: isl29018: fix poorly named function
Brian Masney [Mon, 10 Oct 2016 07:19:56 +0000 (03:19 -0400)]
staging: iio: isl29018: fix poorly named function

isl29035_detect() did not just do chip detection. Move functionality directly
into isl29018_chip_init() to avoid naming confusion.

Signed-off-by: Brian Masney <masneyb@onstation.org>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
8 years agostaging: iio: isl29018: add newlines to improve readability
Brian Masney [Mon, 10 Oct 2016 07:19:55 +0000 (03:19 -0400)]
staging: iio: isl29018: add newlines to improve readability

Add newlines to improve code readability in preparation for moving the
driver out of staging.

Signed-off-by: Brian Masney <masneyb@onstation.org>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
8 years agostaging:iio:TODO drop outdated entries in this todo.
Jonathan Cameron [Sun, 9 Oct 2016 10:38:19 +0000 (11:38 +0100)]
staging:iio:TODO drop outdated entries in this todo.

There is still stuff to be done in the remaining drivers but pretty much
nothing was left from this original TODO.

Sorry Greg, should have been keeping this up to date.

Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
8 years agostaging: iio: cdc: ad7152: Replace mlock with a local mutex lock
sayli karnik [Mon, 10 Oct 2016 06:20:48 +0000 (11:50 +0530)]
staging: iio: cdc: ad7152: Replace mlock with a local mutex lock

mlock is intended to protect only switches between modes.
Given this driver doesn't support more than one mode (sysfs polled reads
only), replace mlock with a local mutex lock.

Signed-off-by: sayli karnik <karniksayli1995@gmail.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
8 years agostaging: iio: cdc: ad7746: implement IIO_CHAN_INFO_SAMP_FREQ
Eva Rachel Retuya [Mon, 10 Oct 2016 10:01:31 +0000 (18:01 +0800)]
staging: iio: cdc: ad7746: implement IIO_CHAN_INFO_SAMP_FREQ

This driver predates the availability of IIO_CHAN_INFO_SAMP_FREQ
attribute wherein usage has some advantages like it can be accessed by
in-kernel consumers as well as reduces the code size.

Therefore, use IIO_CHAN_INFO_SAMP_FREQ to implement the
sampling_frequency attribute instead of using IIO_DEVICE_ATTR() macro.

Move code from the functions associated with IIO_DEVICE_ATTR() into
respective read and write hooks with the mask set to
IIO_CHAN_INFO_SAMP_FREQ.

Signed-off-by: Eva Rachel Retuya <eraretuya@gmail.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
8 years agostaging: iio: cdc: ad7152: Implement IIO_CHAN_INFO_SAMP_FREQ attribute
sayli karnik [Mon, 10 Oct 2016 15:39:17 +0000 (21:09 +0530)]
staging: iio: cdc: ad7152: Implement IIO_CHAN_INFO_SAMP_FREQ attribute

Attributes that were once privately defined become standard with time
and hence a special global define is used. Hence update driver ad7152 to use
IIO_CHAN_INFO_SAMP_FREQ which is a global define instead of
IIO_DEV_ATTR_SAMP_FREQ.
Move functionality from IIO_DEV_ATTR_SAMP_FREQ attribute into
IIO_CHAN_INFO_SAMP_FREQ to implement the sampling_frequency attribute.
Modify ad7152_read_raw() and ad7152_write_raw() to allow reading and
writing the element as well. Also add a lock in the driver's private
data.

Signed-off-by: sayli karnik <karniksayli1995@gmail.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
8 years agoStaging: vt6655: Replace dwIoBase by iobase
Varsha Rao [Sat, 15 Oct 2016 10:32:58 +0000 (16:02 +0530)]
Staging: vt6655: Replace dwIoBase by iobase

In this patch dwIoBase is renamed as iobase. This is done to fix the
checkpatch issue of CamelCase.

Signed-off-by: Varsha Rao <rvarsha016@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
8 years agostaging: rtl8188eu: core: constify local structure
Elizabeth Ferdman [Mon, 17 Oct 2016 06:46:30 +0000 (23:46 -0700)]
staging: rtl8188eu: core: constify local structure

Constify the static struct RTW_CHANNEL_PLAN_MAP_REALTEK_DEFINE.

The only other instance was one of its properties being assigned to a
variable:
Index2G = RTW_CHANNEL_PLAN_MAP_REALTEK_DEFINE.Index2G;

Therefore this is a good candidate for constification.

Running size did not show any difference:
Before/After:
text    data     bss     dec     hex filename
44122     408    2974   47504    b990

Lastly, break up the long line to fix the checkpatch warning and conform
to kernel coding style.

Signed-off-by: Elizabeth Ferdman <gnudevliz@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
8 years agostaging: rtl8192e: Compress return logic into one line.
Elise Lennion [Mon, 17 Oct 2016 02:15:47 +0000 (00:15 -0200)]
staging: rtl8192e: Compress return logic into one line.

Simplify return logic to avoid unnecessary variable assignments.

Coccinelle was used with this semantic patch:
@@
local idexpression ret;
expression e;
@@

-ret =
+return
     e;
-return ret;

Signed-off-by: Elise Lennion <elise.lennion@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
8 years agostaging: xgifb: Compress return logic into one line.
Elise Lennion [Mon, 17 Oct 2016 02:17:20 +0000 (00:17 -0200)]
staging: xgifb: Compress return logic into one line.

Simplify return logic to avoid unnecessary variable assignments.

Coccinelle was used with this semantic patch:
@@
local idexpression ret;
expression e;
@@

-ret =
+return
     e;
-return ret;

Signed-off-by: Elise Lennion <elise.lennion@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
8 years agostaging: vt6656: Compress return logic into one line.
Elise Lennion [Mon, 17 Oct 2016 02:18:58 +0000 (00:18 -0200)]
staging: vt6656: Compress return logic into one line.

Compress the return logic into one line avoids unnecessary variable
declarations. In this case it also makes it easier to understand the
function.

Coccinelle was used to find this return statement. However, additional
compressions were done to make the function clearer.

Semantic patch:
@@
local idexpression ret;
expression e;
@@

-ret =
+return
     e;
-return ret;

Signed-off-by: Elise Lennion <elise.lennion@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
8 years agoStaging: unisys: visorbus: Make a read-only structure
Mihaela Muraru [Sat, 15 Oct 2016 22:41:14 +0000 (01:41 +0300)]
Staging: unisys: visorbus: Make a read-only structure

This patch add const qualifier at the declaration of the structure.
The structure become a read-only data, this increase the security.

Signed-off-by: Mihaela Muraru <mihaela.muraru21@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
8 years agostaging: ks7010: Remove braces around single statement blocks
Sabitha George [Sun, 16 Oct 2016 16:14:26 +0000 (21:44 +0530)]
staging: ks7010: Remove braces around single statement blocks

Fixes checkpatch warning: braces{} are not necessary for
single statment blocks

Signed-off-by: Sabitha George <sabitha.george@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
8 years agostaging: ks7010: Add blank line after declarations
Sabitha George [Sun, 16 Oct 2016 16:12:44 +0000 (21:42 +0530)]
staging: ks7010: Add blank line after declarations

Fixes checkpatch.pl warning :Missing a blank line
after declarations

Signed-off-by: Sabitha George <sabitha.george@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
8 years agostaging: wilc1000: Remove unnecessary extern variables.
Elise Lennion [Sat, 15 Oct 2016 22:26:26 +0000 (19:26 -0300)]
staging: wilc1000: Remove unnecessary extern variables.

Extern variables and functions used in only one file were removed
from .h files, and made static in the .c files they're used.

Extern variable wilc_initialized was declared and never used, so it was
removed.

Signed-off-by: Elise Lennion <elise.lennion@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
8 years agoStaging: vt6656: Make a read-only structure
Mihaela Muraru [Sat, 15 Oct 2016 21:55:22 +0000 (00:55 +0300)]
Staging: vt6656: Make a read-only structure

This patch add const qualifier at the declaration of the structure.
The structure become a read-only data, this increase the security.

Signed-off-by: Mihaela Muraru <mihaela.muraru21@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
8 years agostaging: unisys: visorbus: add missing include
Laurent Navet [Sat, 15 Oct 2016 09:50:11 +0000 (11:50 +0200)]
staging: unisys: visorbus: add missing include

this removes lots of sparse warnings :
warning: symbol 'visorchannel_destroy' was not declared. Should it be static?
warning: symbol 'visorchannel_get_physaddr' was not declared. Should it be static?
warning: symbol 'visorchannel_get_nbytes' was not declared. Should it be static?
warning: symbol 'visorchannel_uuid_id' was not declared. Should it be static?
warning: symbol 'visorchannel_id' was not declared. Should it be static?
warning: symbol 'visorchannel_zoneid' was not declared. Should it be static?
warning: symbol 'visorchannel_get_clientpartition' was not declared. Should it be static?
warning: symbol 'visorchannel_set_clientpartition' was not declared. Should it be static?
warning: symbol 'visorchannel_read' was not declared. Should it be static?
warning: symbol 'visorchannel_write' was not declared. Should it be static?
warning: symbol 'visorchannel_get_header' was not declared. Should it be static?
warning: symbol 'visorchannel_create' was not declared. Should it be static?
warning: symbol 'visorchannel_create_with_lock' was not declared. Should it be static?

Signed-off-by: Laurent Navet <laurent.navet@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
8 years agostaging:vt6656:baseband.h: fix function definition argument without identifier name...
Mikhail Golubev [Fri, 14 Oct 2016 08:58:08 +0000 (11:58 +0300)]
staging:vt6656:baseband.h: fix function definition argument without identifier name issue

Function definitions arguments should also have an identifier name as
reported by checkpatch.pl.

Signed-off-by: Mikhail Golubev <golubev.mikhail@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
8 years agostaging: dgnc: Add const qualifier to struct declaration.
Elise Lennion [Sat, 15 Oct 2016 00:35:13 +0000 (21:35 -0300)]
staging: dgnc: Add const qualifier to struct declaration.

Const qualifier added to struct declaration to avoid data overwrite
during runtime and improve security.

Signed-off-by: Elise Lennion <elise.lennion@gmail.com>
Acked-by: Julia Lawall <julia.lawall@lip6.fr>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
8 years agostaging: sm750fb: Add const qualifier to struct declaration.
Elise Lennion [Sat, 15 Oct 2016 00:32:03 +0000 (21:32 -0300)]
staging: sm750fb: Add const qualifier to struct declaration.

Const qualifier added to struct declaration to avoid data overwrite
during runtime and improve security.

Signed-off-by: Elise Lennion <elise.lennion@gmail.com>
Acked-by: Julia Lawall <julia.lawall@lip6.fr>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
8 years agoStaging: android: ion: constify dma_buf_ops structure
Bhumika Goyal [Sat, 15 Oct 2016 06:13:48 +0000 (11:43 +0530)]
Staging: android: ion: constify dma_buf_ops structure

The dma_buf_ops structure is stored in the ops field of a
dma_buf_export_info structure and also used as a condition inside the
if() statement. The if condition does not modify its value and the
ops field is of type const struct *dma_buf_ops, so dma_buf_ops
structures having this property can be declared as const.

File size before:
   text    data     bss     dec     hex filename
  14471     819     224   15514    3c9a
drivers/staging/android/ion/ion.o

File size after:
   text    data     bss     dec     hex filename
  14599     707     224   15530    3caa
drivers/staging/android/ion/ion.o

Signed-off-by: Bhumika Goyal <bhumirks@gmail.com>
Acked-by: Julia Lawall <julia.lawall@lip6.fr>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>