Commit Graph

3004 Commits

Author SHA1 Message Date
Venkat Prashanth B U 9aaea09b4c gyro:adis16136: fix debugfs_simple_attr.cocci warnings
Use DEFINE_DEBUGFS_ATTRIBUTE rather than DEFINE_SIMPLE_ATTRIBUTE
for debugfs files.

Semantic patch information:
Rationale: DEFINE_SIMPLE_ATTRIBUTE + debugfs_create_file()
imposes some significant overhead as compared to
DEFINE_DEBUGFS_ATTRIBUTE + debugfs_create_file_unsafe().

Generated by: scripts/coccinelle/api/debugfs/debugfs_simple_attr.cocci

Signed-off-by: Venkat Prashanth B U <venkat.prashanth2498@gmail.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-01-08 16:03:44 +01:00
Lorenzo Bianconi 5b6c65f41c iio: imu: st_lsm6dsx: remove st_lsm6dsx_write_with_mask() declaration
Remove st_lsm6dsx_write_with_mask() declaration since it has been removed
in commit 6674bef628e6 ("iio: imu: st_lsm6dsx: add regmap API support")

Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@redhat.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-01-08 16:03:43 +01:00
Lorenzo Bianconi 91a6b841a5 iio: imu: st_lsm6dsx: pre-allocate read buffer at bootstrap
Allocate device read buffer at bootstrap and do not put it on the stack
since it is pretty big (~200B) and its size will increase adding support
to device hw timestamp.
Moreover this patch fixes following sparse warnings:
drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_buffer.c:250:17: warning: Variable length
array is used.
drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_buffer.c:283:55: error: cannot size
expression

Fixes: 290a6ce11d ("iio: imu: add support to lsm6dsx driver")
Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@redhat.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-01-08 16:03:43 +01:00
Fabrice Gasnier 04e491ca9d iio: adc: stm32: fix scan of multiple channels with DMA
By default, watermark is set to '1'. Watermark is used to fine tune
cyclic dma buffer period. In case watermark is left untouched (e.g. 1)
and several channels are being scanned, buffer period is wrongly set
(e.g. to 1 sample). As a consequence, data is never pushed to upper layer.
Fix buffer period size, by taking scan channels number into account.

Fixes: 2763ea0585 ("iio: adc: stm32: add optional dma support")

Signed-off-by: Fabrice Gasnier <fabrice.gasnier@st.com>
Cc: <Stable@vger.kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-01-08 16:03:43 +01:00
Venkat Prashanth B U a540243f4d Drivers:iio:adc:ti_am335x_adc remove comparison to bool
This is the patch to the file ti_am335x_adc.c
which fixes the following coccinelle warning:

WARNING: Comparison to bool

Signed-off-by: Venkat Prashanth B U <venkat.prashanth2498@gmail.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-01-08 16:03:43 +01:00
Julia Lawall 13e6bac82a iio: common: ssp_sensors: account for const type of of_device_id.data
This driver creates a number of const structures that it stores in the
data field of an of_device_id array.

Add const to the declaration of the location that receives a value
from the data field to ensure that the compiler will continue to check
that the value is not modified and remove the const-dropping cast on
the access to the data field.

Done using Coccinelle.

Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-01-08 16:03:43 +01:00
Lorenzo Bianconi 51a8b70762 iio: imu: st_lsm6dsx: add regmap API support
Introduce regmap API support to access to i2c/spi bus instead of
using a custom support. Set max bulk read to
(32 / SAMPLE_SIZE) * SAMPLE_SIZE since spi_write_then_read() used in
regmap_spi indicates that is the max buffer length to use in order to
avoid a kmalloc for each bus access.
Remove lock mutex since concurrency is already managed by regmap API

Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@redhat.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-01-08 16:03:43 +01:00
Lorenzo Bianconi 335eaedce4 iio: imu: st_lsm6dsx: introduce conf_lock mutex
Add conf_lock mutex to prevent concurrent FIFO configuration update

Fixes: 290a6ce11d (iio: imu: add support to lsm6dsx driver)
Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@redhat.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-01-08 16:03:43 +01:00
Lorenzo Bianconi 7b9ebe4282 iio: imu: st_lsm6dsx: fix endianness in st_lsm6dsx_read_oneshot()
Apply le16_to_cpu() to data read from the sensor in order to take into
account architecture endianness

Fixes: 290a6ce11d (iio: imu: add support to lsm6dsx driver)
Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@redhat.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-01-08 16:03:43 +01:00
Lorenzo Bianconi e1ca114100 iio: humidity: hts221: move common code in hts221_core
Move duplicated i2c/spi probe code in hts221_probe()

Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@redhat.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-01-08 16:03:43 +01:00
Stefan Tatschner 2e419aec3b iio:pressure:bmp280: Read calibration data in probe
This patch affects BME280 and BMP280. The readout of the calibration
data is moved to the probe function. Each sensor data access triggered
reading the full calibration data before this patch. According to the
datasheet, Section 4.4.2., the calibration data is stored in non-volatile
memory.

Since the calibration data does not change, and cannot be changed by the
user, we can reduce bus traffic by reading the calibration data once.
Additionally, proper organization of the data types enables removing
some odd casts in the compensation formulas.

Signed-off-by: Stefan Tatschner <stefan.tatschner@gmail.com>
Tested-by: Andreas Klinger <ak@it-klinger.de>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-01-08 16:03:43 +01:00
Stefan Brüns 9273aa16b3 iio: adc: ina2xx: Actually align the loop with the conversion ready flag
Currently, the registers are read out once per conversion interval. If
the reading is delayed as the conversion has not yet finished, this extra
time is treated as being part of the readout, although it should delay
the start of the poll interval. This results in the interval starting
slightly earlier in each iteration, until all time between reads is
spent polling the status registers instead of sleeping.

To fix this, the delay has to account for the state of the conversion
ready flag. Whenever the conversion is already finished, schedule the next
read on the regular interval, otherwise schedule it one interval after the
flag bit has been set.

Split the work function in two functions, one for the status poll and one
for reading the values, to be able to note down the time when the flag
bit is raised.

Signed-off-by: Stefan Brüns <stefan.bruens@rwth-aachen.de>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-01-08 16:03:43 +01:00
Stefan Brüns 8c3a7b0a6c iio: adc: ina2xx: Align timestamp with conversion ready flag
As the timestamp is no longer (ab-)used to measure the function run time,
it can be taken at the correct time, i.e. when the conversion has finished.

Signed-off-by: Stefan Brüns <stefan.bruens@rwth-aachen.de>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-01-08 16:03:43 +01:00
Stefan Brüns 8ea2a63869 iio: adc: ina2xx: Use a monotonic clock for delay calculation
The iio timestamp clock is user selectable and may be non-monotonic. Also,
only part of the acquisition time is measured, thus the delay was longer
than intended.

Use a monotonic timestamp to track the time for the next poll iteration.
The timestamp is advanced by the sampling interval each iteration. In case
the conversion overrruns the register readout (i.e. fast sampling combined
with a slow bus), one or multiple samples will be dropped.

Signed-off-by: Stefan Brüns <stefan.bruens@rwth-aachen.de>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-01-08 16:03:42 +01:00
Maciej Purski a28caa7b8f iio: adc: ina2xx: Make calibration register value fixed
Calibration register is used for calculating current register in
hardware according to datasheet:
current = shunt_volt * calib_register / 2048 (ina 226)
current = shunt_volt * calib_register / 4096 (ina 219)

Fix calib_register value to 2048 for ina226 and 4096 for ina 219 in
order to avoid truncation error and provide best precision allowed
by shunt_voltage measurement. Make current scale value follow changes
of shunt_resistor from sysfs as calib_register value is now fixed.

Power_lsb value should also follow shunt_resistor changes as stated in
datasheet:
power_lsb = 25 * current_lsb (ina 226)
power_lsb = 20 * current_lsb (ina 219)

This is a part of the patchset: https://lkml.org/lkml/2017/11/22/394

Signed-off-by: Maciej Purski <m.purski@samsung.com>
Reviewed-by:  Stefan Brüns <stefan.bruens@rwth-aachen.de>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-01-08 16:03:42 +01:00
Venkat Prashanth B U c34812e490 Drivers: iio:adc: fix brace coding style issue in at91_adc.c
This is a patch to the at91_adc.c file that fixes up a brace
warning found by the checkpatch.pl tool

Signed-off-by: Venkat Prashanth B U <venkat.prashanth2498@gmail.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-01-08 16:03:42 +01:00
Andreas Klinger 1fe899e3ed iio: hx711: fix bug in reset functionality
Return value in hx711_reset() should indicate status of dout otherwise the
calling function is reporting an error as false positive

If there are two reads too close to each other, then the second one will
never succeed. This happens especially when using buffered mode with both
channels enabled.

When changing the channel on every trigger event the former 100 ms are not
enough for waiting until the device indicates normal mode.

Wait up to 1 second until the device turns into normal mode.

Signed-off-by: Andreas Klinger <ak@it-klinger.de>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-01-08 16:03:42 +01:00
Andreas Klinger d3bf60450d iio: hx711: add triggered buffer support
Add buffer to device data struct and add trigger function

Data format is quite simple:
      voltage - channel 0   32 Bit
      voltage - channel 1   32 Bit
      timestamp             64 Bit

Using both channels at the same time is working quite slow because of
changing the channel which needs a dummy read.

Signed-off-by: Andreas Klinger <ak@it-klinger.de>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-01-08 16:03:42 +01:00
Stefan Brüns 8bcf024f06 iio: adc: ina2xx: Do not udelay for several seconds
The conversion time can be up to 16 seconds (8 ms per channel, 2 channels,
1024 times averaging).

Signed-off-by: Stefan Brüns <stefan.bruens@rwth-aachen.de>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-01-08 16:03:42 +01:00
Stefan Brüns c68013f3a9 iio: adc: ina2xx: Remove unneeded dummy read to clear CNVR flag
Although the datasheet states the CNVR flag is cleared by reading the
BUS_VOLTAGE register, it is actually cleared by reading any of the
voltage/current/power registers.

The behaviour has been confirmed by TI support:
http://e2e.ti.com/support/amplifiers/current-shunt-monitors/f/931/p/647053/2378282

Signed-off-by: Stefan Brüns <stefan.bruens@rwth-aachen.de>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-01-08 16:03:42 +01:00
Stefan Brüns d456d61f53 iio: adc: ina2xx: Clarify size requirement for data buffer
The timestamp is inserted into the buffer after the sample data by
iio_push_to_buffers_with_timestamp, document the space requirement for
the timestamp.

Signed-off-by: Stefan Brüns <stefan.bruens@rwth-aachen.de>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-01-08 16:03:42 +01:00
Stefan Brüns 17b3453f5c iio: adc: ina2xx: Remove bogus cast for data argument
iio_push_to_buffers_with_timestamp expects a void pointer, so the cast
is both unnecessary and misleading.

Signed-off-by: Stefan Brüns <stefan.bruens@rwth-aachen.de>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-01-08 16:03:42 +01:00
Martin Blumenstingl ab569a4c55 iio: adc: meson-saradc: program the channel muxes during initialization
On some Meson8 devices the channel muxes are not programmed. This
results in garbage values when trying to read channels that are not set
up.
Fix this by initializing the channel 0 and 1 muxes in
MESON_SAR_ADC_CHAN_10_SW as well as the muxes for all other channels in
MESON_SAR_ADC_AUX_SW based on what the vendor driver does (which is
simply a 1:1 mapping of channel number and channel mux).
This only showed up on Meson8 devices, because for GXBB and newer BL30
is taking care of initializing the channel muxes.

This additionally fixes a typo in the
MESON_SAR_ADC_AUX_SW_MUX_SEL_CHAN_MASK macro because the old definition
assumed that the register fields were 2 bit wide, while they are
actually 3 bit wide.

Signed-off-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-01-08 16:03:42 +01:00
Martin Blumenstingl fda29dbac9 iio: adc: meson-saradc: fix the clock frequency on Meson8 and Meson8b
GX SoCs use a 1.2 MHz ADC clock, while the older SoCs use a 1.14 MHz
clock.

A comment in the driver from Amlogic's GPL kernel says that it's
running at 1.28 MHz. However, it's actually programming a divider of
20 + 1. With a XTAL clock of 24 MHz this results in a frequency of
1.14 MHz. (their calculation might be based on a 27 MHz XTAL clock,
but this is not what we have on the Meson8 and Meson8b SoCs).

The ADC was still working with the 1.2MHz clock. In my own tests I did
not see a difference between 1.2 and 1.14 MHz (regardless of the clock
frequency used, the ADC results were identical).

Signed-off-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-01-08 16:03:42 +01:00
Pravin Shedge ef6cad920d drivers: iio: gyro: remove duplicate includes
These duplicate includes have been found with scripts/checkincludes.pl but
they have been removed manually to avoid removing false positives.

Signed-off-by: Pravin Shedge <pravin.shedge4linux@gmail.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-01-08 16:03:42 +01:00
Andrew F. Davis f272f19cb6 iio: dac: mcp4725: Remove unneeded conversions to bool
Found with scripts/coccinelle/misc/boolconv.cocci.

Signed-off-by: Andrew F. Davis <afd@ti.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-01-08 16:03:41 +01:00
Benjamin Gaignard 6e93e26193 iio: stm32: Adopt SPDX identifier
Add SPDX identifier in stm32's files in IIO directory

Signed-off-by: Benjamin Gaignard <benjamin.gaignard@st.com>
Acked-by: Fabrice Gasnier <fabrice.gasnier@st.com>
Acked-by: Philippe Ombredanne <pombredanne@nexb.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-01-08 16:03:41 +01:00
Colin Ian King debbbbef06 iio: light: make a couple of config structures static
Structures st_uvis25_i2c_regmap_config and st_uvis25_spi_regmap_config are
local to the source and do not need to be in global scope, so make them
both static.

Cleans up sparse warnings:
warning: symbol 'st_uvis25_i2c_regmap_config' was not declared. Should
it be static?
warning: symbol 'st_uvis25_spi_regmap_config' was not declared. Should
it be static?

Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-01-08 16:03:41 +01:00
Matt Fornero 350f6c75f6 iio: buffer: Expose data available
Add a sysfs attribute that exposes buffer data available to userspace.
This attribute can be checked at runtime to determine the overall buffer
fill level (across all allocated buffers).

Signed-off-by: Matt Fornero <matt.fornero@mathworks.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-01-08 16:03:41 +01:00
Martin Kepplinger 80e3f0103e iio: mma8452: replace license description with SPDX specifier
This replaces the custom license information text with the appropriate
SPDX identifier. While the information here stays the same, it is easier
to read.

Signed-off-by: Martin Kepplinger <martink@posteo.de>
Acked-by: Peter Meerwald-Stadler <pmeerw@pmeerw.net>
Acked-by: Harinath Nampally <harinath922@gmail.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-01-08 16:03:41 +01:00
Arnd Bergmann a4493f227d iio: common: ssp_sensors: use ktime_get_real_ns() timestamps
getnstimeofday() suffers from the overflow in y2038 on 32-bit
architectures and requires a conversion into the nanosecond format that
we want here.

This changes ssp_parse_dataframe() to use ktime_get_real_ns() directly,
which does not have that problem.

An open question is what time base should be used here. Normally
timestamps should use ktime_get_ns() or ktime_get_boot_ns() to read
monotonic time instead of "real" time, which suffers from time jumps
due to settimeofday() calls or leap seconds.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-01-08 16:03:41 +01:00
Bartosz Golaszewski 1b39eacdbd iio: dummy_evgen: modify the return value check for irq_sim_init()
As discussed with Marc Zyngier: irq_sim_init() and its devres variant
should return the base of the allocated interrupt range on success
rather than 0. This will be modified later - first, change the way
users handle the return value of these routines.

Signed-off-by: Bartosz Golaszewski <brgl@bgdev.pl>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-01-08 16:03:41 +01:00
Greg Kroah-Hartman e8cd29b774 Merge Linus's staging merge point into staging-next
This resolves the merge issue pointed out by Stephen in
drivers/iio/adc/meson_saradc.c.

Reported-by: Stephen Rothwell <sfr@canb.auug.org.au>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-12-06 15:27:17 +01:00
Lukas Wunner 8d05ffd2b8 iio: Add macro to populate struct iio_map array
The GPIO core provides a handy GPIO_LOOKUP() macro to populate a struct
gpiod_lookup array without having to spell out attribute names (but
still avoid breakage when attributes within the struct are rearranged
or added).

The axp288_adc.c driver uses a similar macro to populate a struct
iio_map array.  Make it available to others.

Cc: Jacob Pan <jacob.jun.pan@linux.intel.com>
Signed-off-by: Lukas Wunner <lukas@wunner.de>
Acked-by: Chen-Yu Tsai <wens@csie.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2017-12-02 13:28:21 +00:00
Javier Martinez Canillas 798c3c9b4c iio: accel: bmc150: Add OF device ID table
The driver doesn't have a struct of_device_id table but supported devices
are registered via Device Trees. This is working on the assumption that a
I2C device registered via OF will always match a legacy I2C device ID and
that the MODALIAS reported will always be of the form i2c:<device>.

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

The I2C device ID table entries have the .driver_data field set, but they
are not used in the driver so weren't set in the OF device table entries.

Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2017-12-02 11:59:33 +00:00
Xingyu Chen 930df4d853 iio: adc: meson-saradc: remove irrelevant clock "sana"
The "sana" clock is not used at SAR ADC module in Amlogic Meson SoC,
it is irrelevant for the SAR ADC.

Signed-off-by: Xingyu Chen <xingyu.chen@amlogic.com>
Signed-off-by: Yixun Lan <yixun.lan@amlogic.com>
Reviewed-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2017-12-02 11:33:53 +00:00
Peter Meerwald-Stadler ad44a9f804 iio: health: max30102: Temperature should be in milli Celsius
As per ABI temperature should be in milli Celsius after scaling,
not Celsius

Note on stable cc.  This driver is breaking the standard IIO
ABI. (JC)

Signed-off-by: Peter Meerwald-Stadler <pmeerw@pmeerw.net>
Acked-by: Matt Ranostay <matt.ranostay@konsulko.com>
Cc: <Stable@vger.kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2017-12-02 11:15:14 +00:00
Randy Dunlap c175cb7cd9 iio: fix kernel-doc build errors
Fix build errors in kernel-doc notation. Symbols that end in '_'
have a special meaning, but adding a '*' makes them OK.

../drivers/iio/industrialio-core.c:635: ERROR: Unknown target name: "iio_val".
../drivers/iio/industrialio-core.c:642: ERROR: Unknown target name: "iio_val".

Signed-off-by: Randy Dunlap <rdunlap@infradead.org>
Cc: <Stable@vger.kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2017-12-02 11:15:14 +00:00
Martin Blumenstingl 96748823c4 iio: adc: meson-saradc: Meson8 and Meson8b do not have REG11 and REG13
The Meson GXBB and newer SoCs have a few more registers than the older
Meson8 and Meson8b SoCs.
Use a separate regmap config to limit the older SoCs to the DELTA_10
register.

Fixes: 6c76ed31cd ("iio: adc: meson-saradc: add Meson8b SoC compatibility")
Signed-off-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
Cc: <Stable@vger.kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2017-12-02 11:15:14 +00:00
Martin Blumenstingl d85eed9f57 iio: adc: meson-saradc: initialize the bandgap correctly on older SoCs
Meson8 and Meson8b do not have the MESON_SAR_ADC_REG11 register. The
bandgap setting for these SoCs is configured in the
MESON_SAR_ADC_DELTA_10 register instead.
Make the driver aware of this difference and use the correct bandgap
register depending on the SoC.
This has worked fine on Meson8 and Meson8b because the bootloader is
already initializing the bandgap setting.

Fixes: 6c76ed31cd ("iio: adc: meson-saradc: add Meson8b SoC compatibility")
Signed-off-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
Cc: <Stable@vger.kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2017-12-02 11:15:14 +00:00
Martin Blumenstingl 7a6b0420d2 iio: adc: meson-saradc: fix the bit_idx of the adc_en clock
Meson8 and Meson8b SoCs use the the SAR ADC gate clock provided by the
MESON_SAR_ADC_REG3 register within the SAR ADC register area.
According to the datasheet (and the existing MESON_SAR_ADC_REG3_CLK_EN
definition) the gate is on bit 30.
The fls() function returns the last set bit, which is "bit index + 1"
(fls(MESON_SAR_ADC_REG3_CLK_EN) returns 31). Fix this by switching to
__ffs() which returns the first set bit, which is bit 30 in our case.

This off by one error results in the ADC not being usable on devices
where the bootloader did not enable the clock.

Fixes: 3adbf34273 ("iio: adc: add a driver for the SAR ADC found in Amlogic Meson SoCs")
Signed-off-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
Cc: <Stable@vger.kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2017-12-02 11:15:13 +00:00
Andy Shevchenko e53111ad5d iio: proximity: sx9500: Assign interrupt from GpioIo()
The commit 0f0796509c

("iio: remove gpio interrupt probing from drivers that use a single interrupt")

removed custom IRQ assignment for the drivers which are enumerated via
ACPI or OF. Unfortunately, some ACPI tables have IRQ line defined as
GpioIo() resource and thus automatic IRQ allocation will fail.

Partially revert the commit 0f0796509c to restore original behaviour.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Acked-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2017-12-02 11:15:13 +00:00
Pan Bian 81b039ec36 iio: adc: cpcap: fix incorrect validation
Function platform_get_irq_byname() returns a negative error code on
failure, and a zero or positive number on success. However, in function
cpcap_adc_probe(), positive IRQ numbers are also taken as error cases.
Use "if (ddata->irq < 0)" instead of "if (!ddata->irq)" to validate the
return value of platform_get_irq_byname().

Signed-off-by: Pan Bian <bianpan2016@163.com>
Fixes: 25ec249632 ("iio: adc: cpcap: Add minimal support for CPCAP PMIC ADC")
Reviewed-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
Acked-by: Tony Lindgren <tony@atomide.com>
Cc: <Stable@vger.kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2017-12-02 11:15:13 +00:00
Colin Ian King 585ed27d06 iio: accel: st_accel: remove redundant pointer pdata
Pointer pdata is being assigned but it is never being used, hence
it is redundant and can be removed. Cleans up clang warning:

drivers/iio/accel/st_accel_core.c:952:3: warning: Value stored to 'pdata'
is never read

Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2017-12-02 10:41:38 +00:00
Luke Ross 4c42bef0d3 iio:accel:da280: Linx 820 Windows tablet has a da280 mapped via ACPI
This adds an ACPI table to the driver and the ACPI ID of the sensor
on the tablet.

Signed-off-by: Luke Ross <luke@lukeross.name>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2017-12-02 10:41:33 +00:00
Lorenzo Bianconi 3025c8688c iio: light: add support for UVIS25 sensor
add support for STMicroelectronics UVIS25 uv sensor
http://www.st.com/resource/en/datasheet/uvis25.pdf

- continuos mode support
- i2c support
- spi support
- trigger mode support
- system PM support

Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi83@gmail.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2017-12-02 10:41:25 +00:00
Joel Stanley edf7550a1f iio: adc: aspeed: Deassert reset in probe
The ASPEED SoC must deassert a reset in order to use the ADC peripheral.

The device tree bindings are updated to document the resets phandle, and
the example is updated to match what is expected for both the reset and
clock phandle. Note that the bindings should have always had the reset
controller, as the hardware is unusable without it.

Signed-off-by: Joel Stanley <joel@jms.id.au>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2017-12-02 10:41:15 +00:00
Peter Meerwald-Stadler 90579b69e9 iio: health: max30102: Add MAX30105 support
The Maxim MAX30105 part adds a third LED (green) and uses a multi-LED
measuring mode producing three measurements

Signed-off-by: Peter Meerwald-Stadler <pmeerw@pmeerw.net>
Acked-by: Matt Ranostay <matt.ranostay@konsulko.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2017-12-02 10:41:08 +00:00
Peter Meerwald-Stadler fef79edc17 iio: health: max30102: Prepare for copying varying number of measurements
Current code assumes always 2 measurements (6 bytes) have to be copied,
prepare for more flexibility

Signed-off-by: Peter Meerwald-Stadler <pmeerw@pmeerw.net>
Acked-by: Matt Ranostay <matt.ranostay@konsulko.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2017-12-02 10:41:05 +00:00
Peter Meerwald-Stadler 83e6415d56 iio: health: max30102: Move mode setting to buffer_postenable
Move the programming of the mode setting from init() to
buffer_postenable()

Split out a separate function to
only update the power/shutdown bit

This changes permits to more easily implement different
modes of measurements in further patches

Signed-off-by: Peter Meerwald-Stadler <pmeerw@pmeerw.net>
Acked-by: Matt Ranostay <matt.ranostay@konsulko.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2017-12-02 10:41:01 +00:00
Peter Meerwald-Stadler ad90e570e2 iio: health: max30102: Introduce indices for LED channels
Signed-off-by: Peter Meerwald-Stadler <pmeerw@pmeerw.net>
Acked-by: Matt Ranostay <matt.ranostay@konsulko.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2017-12-02 10:40:57 +00:00
Peter Meerwald-Stadler a9c47abbdd iio: health: max30102: Add power enable parameter to get_temp function
Chip must not be in shutdown for reading temperature, so briefly leave
shutdown if buffer is not already running

Signed-off-by: Peter Meerwald-Stadler <pmeerw@pmeerw.net>
Acked-by: Matt Ranostay <matt.ranostay@konsulko.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2017-12-02 10:40:55 +00:00
Peter Meerwald-Stadler 839a74cde7 iio: health: max30102: Introduce intensity channel macro
Signed-off-by: Peter Meerwald-Stalder <pmeerw@pmeerw.net>
Acked-by: Matt Ranostay <matt.ranostay@konsulko.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2017-12-02 10:40:50 +00:00
Peter Meerwald-Stadler 84b0ce05e4 iio: health: max30102: Add check for part ID
Signed-off-by: Peter Meerwald-Stadler <pmeerw@pmeerw.net>
Acked-by: Matt Ranostay <matt.ranostay@konsulko.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2017-12-02 10:40:46 +00:00
Peter Meerwald-Stadler d0b950c73d iio: health: max30102: Check retval of powermode function
Signed-off-by: Peter Meerwald-Stadler <pmeerw@pmeerw.net>
Acked-by: Matt Ranostay <matt.ranostay@konsulko.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2017-12-02 10:40:44 +00:00
Peter Meerwald-Stadler 7b0b0ec157 iio: health: max30102: Fix mode config values
Table 4 of the datasheet specifies the mode control, these are not
individual bits; add multi LED mode

Add multi-LED mode and fix MODE_MASK (3 bits wide, not 2)

Signed-off-by: Peter Meerwald-Stadler <pmeerw@pmeerw.net>
Acked-by: Matt Ranostay <matt.ranostay@konsulko.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2017-12-02 10:40:39 +00:00
Peter Meerwald-Stadler c31c946af8 iio: health: max30102: Remove inconsistent full stop in error message
Signed-off-by: Peter Meerwald-Stadler <pmeerw@pmeerw.net>
Acked-by: Matt Ranostay <matt.ranostay@konsulko.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2017-12-02 10:40:34 +00:00
Peter Meerwald-Stadler dd86dbf94f iio: health: max30102: Fix missing newline in dev_err
Signed-off-by: Peter Meerwald-Stadler <pmeerw@pmeerw.net>
Acked-by: Matt Ranostay <matt.ranostay@konsulko.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2017-12-02 10:40:31 +00:00
Fabrice Gasnier 3fb2e24ed7 iio: adc: stm32: add support for differential channels
STM32H7 ADC channels can be configured either as single ended or
differential with 'st,adc-channels' or 'st,adc-diff-channels'
(positive and negative input pair: <vinp vinn>, ...).

Differential channels have different offset and scale, from spec:
raw value = (full_scale / 2) * (1 + (vinp - vinn) / vref).
Add offset attribute.

Differential channels are selected by DIFSEL register. Negative
inputs must be added to pre-selected channels as well (PCSEL).

Signed-off-by: Fabrice Gasnier <fabrice.gasnier@st.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2017-12-02 10:40:28 +00:00
Fabrice Gasnier 0bae72aa8a iio: adc: stm32: remove const channel names definition
Remove const array that defines channels. Build channels definition
at probe time, when initializing channels (only for requested ones).
This will ease adding differential channels support.

Signed-off-by: Fabrice Gasnier <fabrice.gasnier@st.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2017-12-02 10:40:26 +00:00
Stefan Brüns ca6a2d86ac iio: adc: ina2xx: Allow setting Shunt Voltage PGA gain and Bus Voltage range
Reducing shunt and bus voltage range improves the accuracy, so allow
altering the default settings.

Both settings are exposed as gain values. While for the shunt voltage
this is straightforward, the bus range settings of 32V (default) and 16V
are mapped to gain values of 1 resp. 2, to provide a uniform API to
userspace.

As the gain settings are incorporated into the raw values by the sensor
itself, adjusting of the scale attributes is not necessary.

Signed-off-by: Stefan Brüns <stefan.bruens@rwth-aachen.de>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2017-12-02 10:40:20 +00:00
Stefan Brüns 2d8119d752 iio: adc: ina2xx: Use LSB specifier instead of divider in config
While the config uses the physical value corresponding to the LSB
for both the power and the bus voltage register, the shunt voltage is
specified as parts of 1 mV. Use the LSB physical value for all registers.

No functional change.

Signed-off-by: Stefan Brüns <stefan.bruens@rwth-aachen.de>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2017-12-02 10:40:17 +00:00
Stefan Brüns 2e64438487 iio: adc: ina2xx: Shift bus voltage register to mask flag bits
Lower bits of the INA219/220 bus voltage register are conversion
status flags, properly shift the value.

When reading via IIO buffer, the value is passed on unaltered,
shifting is the responsibility of the user.

Signed-off-by: Stefan Brüns <stefan.bruens@rwth-aachen.de>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2017-12-02 10:40:14 +00:00
Andy Shevchenko e36c8c161c iio: imu: inv_mpu6050: Remove duplicate NULL check
Since i2c_unregister_device() became NULL-aware we may remove duplicate
NULL check.

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>
Cc: linux-iio@vger.kernel.org
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2017-12-02 10:40:11 +00:00
Andy Shevchenko 9ed2484598 iio: magnetometer: ak8975: Add another ACPI ID
Add new ACPI ID for ak9911 as had been found on prototype board.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2017-12-02 10:40:02 +00:00
Andy Shevchenko b87935552e iio: proximity: sx9500: Add another ACPI ID
Add new ACPI ID for sx9500 as had been found on prototype board.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2017-12-02 10:40:00 +00:00
Harinath Nampally a654c062dc iio: accel: mma8452: Rename config structs for readability
Rename structs holding event configuration registers
to more appropriate names. This naming is consistent
with the event config register names given in the
mma845x and fxls8471 datasheets.

Signed-off-by: Harinath Nampally <harinath922@gmail.com>
Acked-by: Martin Kepplinger <martink@posteo.de>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2017-12-02 10:39:56 +00:00
Harinath Nampally cc54a660a6 iio: accel: mma8452: Rename a struct for code readibility
Rename time step look up struct to generic name
as the values in the look table are same for all
the other events like pulse, transient etc.

Signed-off-by: Harinath Nampally <harinath922@gmail.com>
Acked-by: Martin Kepplinger <martink@posteo.de>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2017-12-02 10:39:54 +00:00
Peter Meerwald-Stadler 8556f51498 iio: light: Add driver for IDT ZOPT2201 ambient light and UVB sensor
Driver for 20-bit ALS and UV B sensor with I2C interface exposing
the following API:
  in_uvindex_input
  in_illuminance_raw
  in_illuminance_scale
  in_illuminance_scale_available
  in_intensity_uv_raw
  in_intensity_uv_scale
  in_intensity_uv_scale_available
  integration_time
  integration_time_available

Signed-off-by: Peter Meerwald-Stadler <pmeerw@pmeerw.net>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2017-12-02 10:39:48 +00:00
Gustavo A. R. Silva 9d793c1a7f iio: core: Mark expected switch fall-through
In preparation to enabling -Wimplicit-fallthrough, mark switch cases
where we are expecting to fall through.

Addresses-Coverity-ID: 1397962
Signed-off-by: Gustavo A. R. Silva <garsilva@embeddedor.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2017-12-02 10:39:45 +00:00
Paolo Cretaro 5f045af0b5 iio: cros_ec: Remove unused variables
Fix gcc warnings about variable 'ec_device' being set but not used
in these files:
common/cros_ec_sensors/cros_ec_sensors.c:194:25
light/cros_ec_light_prox.c:184:25

Signed-off-by: Paolo Cretaro <paolocretaro@gmail.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2017-12-02 10:39:44 +00:00
Eugen Hristev 10c7a314c9 iio: adc: at91-sama5d2_adc: ack DRDY irq in direct mode
Need to acknowledge DRDY irq in direct mode/ software
triggered mode. Otherwise, on the next conversion, overrun
flag will be raised, which is not a correct state.
This doesn't affect the functionality, but will generate
possible incorrect overrun reports.

Signed-off-by: Eugen Hristev <eugen.hristev@microchip.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2017-12-02 10:39:44 +00:00
Eugen Hristev 073c662017 iio: adc: at91-sama5d2_adc: add support for DMA
Added support for DMA transfers. The implementation uses the user watermark
to decide whether DMA will be used or not. For watermark 1, DMA will not be
used. If watermark is bigger, DMA will be used.
Sysfs attributes are created to indicate whether the DMA is used,
with hwfifo_enabled, and the current DMA watermark is readable
in hwfifo_watermark. Minimum and maximum values are in hwfifo_watermark_min
and hwfifo_watermark_max.

Signed-off-by: Eugen Hristev <eugen.hristev@microchip.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2017-12-02 10:39:43 +00:00
Linus Walleij 9a0ebbc935 iio: adc/accel: Fix up module licenses
The module license checker complains about these two so just fix
it up. They are both GPLv2, both written by me or using code
I extracted while refactoring from the GPLv2 drivers.

Cc: Randy Dunlap <rdunlap@infradead.org>
Reported-by: Randy Dunlap <rdunlap@infradead.org>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2017-12-02 10:39:43 +00:00
Al Viro afc9a42b74 the rest of drivers/*: annotate ->poll() instances
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
2017-11-28 11:06:58 -05:00
Kees Cook e99e88a9d2 treewide: setup_timer() -> timer_setup()
This converts all remaining cases of the old setup_timer() API into using
timer_setup(), where the callback argument is the structure already
holding the struct timer_list. These should have no behavioral changes,
since they just change which pointer is passed into the callback with
the same available pointers after conversion. It handles the following
examples, in addition to some other variations.

Casting from unsigned long:

    void my_callback(unsigned long data)
    {
        struct something *ptr = (struct something *)data;
    ...
    }
    ...
    setup_timer(&ptr->my_timer, my_callback, ptr);

and forced object casts:

    void my_callback(struct something *ptr)
    {
    ...
    }
    ...
    setup_timer(&ptr->my_timer, my_callback, (unsigned long)ptr);

become:

    void my_callback(struct timer_list *t)
    {
        struct something *ptr = from_timer(ptr, t, my_timer);
    ...
    }
    ...
    timer_setup(&ptr->my_timer, my_callback, 0);

Direct function assignments:

    void my_callback(unsigned long data)
    {
        struct something *ptr = (struct something *)data;
    ...
    }
    ...
    ptr->my_timer.function = my_callback;

have a temporary cast added, along with converting the args:

    void my_callback(struct timer_list *t)
    {
        struct something *ptr = from_timer(ptr, t, my_timer);
    ...
    }
    ...
    ptr->my_timer.function = (TIMER_FUNC_TYPE)my_callback;

And finally, callbacks without a data assignment:

    void my_callback(unsigned long data)
    {
    ...
    }
    ...
    setup_timer(&ptr->my_timer, my_callback, 0);

have their argument renamed to verify they're unused during conversion:

    void my_callback(struct timer_list *unused)
    {
    ...
    }
    ...
    timer_setup(&ptr->my_timer, my_callback, 0);

The conversion is done with the following Coccinelle script:

spatch --very-quiet --all-includes --include-headers \
	-I ./arch/x86/include -I ./arch/x86/include/generated \
	-I ./include -I ./arch/x86/include/uapi \
	-I ./arch/x86/include/generated/uapi -I ./include/uapi \
	-I ./include/generated/uapi --include ./include/linux/kconfig.h \
	--dir . \
	--cocci-file ~/src/data/timer_setup.cocci

@fix_address_of@
expression e;
@@

 setup_timer(
-&(e)
+&e
 , ...)

// Update any raw setup_timer() usages that have a NULL callback, but
// would otherwise match change_timer_function_usage, since the latter
// will update all function assignments done in the face of a NULL
// function initialization in setup_timer().
@change_timer_function_usage_NULL@
expression _E;
identifier _timer;
type _cast_data;
@@

(
-setup_timer(&_E->_timer, NULL, _E);
+timer_setup(&_E->_timer, NULL, 0);
|
-setup_timer(&_E->_timer, NULL, (_cast_data)_E);
+timer_setup(&_E->_timer, NULL, 0);
|
-setup_timer(&_E._timer, NULL, &_E);
+timer_setup(&_E._timer, NULL, 0);
|
-setup_timer(&_E._timer, NULL, (_cast_data)&_E);
+timer_setup(&_E._timer, NULL, 0);
)

@change_timer_function_usage@
expression _E;
identifier _timer;
struct timer_list _stl;
identifier _callback;
type _cast_func, _cast_data;
@@

(
-setup_timer(&_E->_timer, _callback, _E);
+timer_setup(&_E->_timer, _callback, 0);
|
-setup_timer(&_E->_timer, &_callback, _E);
+timer_setup(&_E->_timer, _callback, 0);
|
-setup_timer(&_E->_timer, _callback, (_cast_data)_E);
+timer_setup(&_E->_timer, _callback, 0);
|
-setup_timer(&_E->_timer, &_callback, (_cast_data)_E);
+timer_setup(&_E->_timer, _callback, 0);
|
-setup_timer(&_E->_timer, (_cast_func)_callback, _E);
+timer_setup(&_E->_timer, _callback, 0);
|
-setup_timer(&_E->_timer, (_cast_func)&_callback, _E);
+timer_setup(&_E->_timer, _callback, 0);
|
-setup_timer(&_E->_timer, (_cast_func)_callback, (_cast_data)_E);
+timer_setup(&_E->_timer, _callback, 0);
|
-setup_timer(&_E->_timer, (_cast_func)&_callback, (_cast_data)_E);
+timer_setup(&_E->_timer, _callback, 0);
|
-setup_timer(&_E._timer, _callback, (_cast_data)_E);
+timer_setup(&_E._timer, _callback, 0);
|
-setup_timer(&_E._timer, _callback, (_cast_data)&_E);
+timer_setup(&_E._timer, _callback, 0);
|
-setup_timer(&_E._timer, &_callback, (_cast_data)_E);
+timer_setup(&_E._timer, _callback, 0);
|
-setup_timer(&_E._timer, &_callback, (_cast_data)&_E);
+timer_setup(&_E._timer, _callback, 0);
|
-setup_timer(&_E._timer, (_cast_func)_callback, (_cast_data)_E);
+timer_setup(&_E._timer, _callback, 0);
|
-setup_timer(&_E._timer, (_cast_func)_callback, (_cast_data)&_E);
+timer_setup(&_E._timer, _callback, 0);
|
-setup_timer(&_E._timer, (_cast_func)&_callback, (_cast_data)_E);
+timer_setup(&_E._timer, _callback, 0);
|
-setup_timer(&_E._timer, (_cast_func)&_callback, (_cast_data)&_E);
+timer_setup(&_E._timer, _callback, 0);
|
 _E->_timer@_stl.function = _callback;
|
 _E->_timer@_stl.function = &_callback;
|
 _E->_timer@_stl.function = (_cast_func)_callback;
|
 _E->_timer@_stl.function = (_cast_func)&_callback;
|
 _E._timer@_stl.function = _callback;
|
 _E._timer@_stl.function = &_callback;
|
 _E._timer@_stl.function = (_cast_func)_callback;
|
 _E._timer@_stl.function = (_cast_func)&_callback;
)

// callback(unsigned long arg)
@change_callback_handle_cast
 depends on change_timer_function_usage@
identifier change_timer_function_usage._callback;
identifier change_timer_function_usage._timer;
type _origtype;
identifier _origarg;
type _handletype;
identifier _handle;
@@

 void _callback(
-_origtype _origarg
+struct timer_list *t
 )
 {
(
	... when != _origarg
	_handletype *_handle =
-(_handletype *)_origarg;
+from_timer(_handle, t, _timer);
	... when != _origarg
|
	... when != _origarg
	_handletype *_handle =
-(void *)_origarg;
+from_timer(_handle, t, _timer);
	... when != _origarg
|
	... when != _origarg
	_handletype *_handle;
	... when != _handle
	_handle =
-(_handletype *)_origarg;
+from_timer(_handle, t, _timer);
	... when != _origarg
|
	... when != _origarg
	_handletype *_handle;
	... when != _handle
	_handle =
-(void *)_origarg;
+from_timer(_handle, t, _timer);
	... when != _origarg
)
 }

// callback(unsigned long arg) without existing variable
@change_callback_handle_cast_no_arg
 depends on change_timer_function_usage &&
                     !change_callback_handle_cast@
identifier change_timer_function_usage._callback;
identifier change_timer_function_usage._timer;
type _origtype;
identifier _origarg;
type _handletype;
@@

 void _callback(
-_origtype _origarg
+struct timer_list *t
 )
 {
+	_handletype *_origarg = from_timer(_origarg, t, _timer);
+
	... when != _origarg
-	(_handletype *)_origarg
+	_origarg
	... when != _origarg
 }

// Avoid already converted callbacks.
@match_callback_converted
 depends on change_timer_function_usage &&
            !change_callback_handle_cast &&
	    !change_callback_handle_cast_no_arg@
identifier change_timer_function_usage._callback;
identifier t;
@@

 void _callback(struct timer_list *t)
 { ... }

// callback(struct something *handle)
@change_callback_handle_arg
 depends on change_timer_function_usage &&
	    !match_callback_converted &&
            !change_callback_handle_cast &&
            !change_callback_handle_cast_no_arg@
identifier change_timer_function_usage._callback;
identifier change_timer_function_usage._timer;
type _handletype;
identifier _handle;
@@

 void _callback(
-_handletype *_handle
+struct timer_list *t
 )
 {
+	_handletype *_handle = from_timer(_handle, t, _timer);
	...
 }

// If change_callback_handle_arg ran on an empty function, remove
// the added handler.
@unchange_callback_handle_arg
 depends on change_timer_function_usage &&
	    change_callback_handle_arg@
identifier change_timer_function_usage._callback;
identifier change_timer_function_usage._timer;
type _handletype;
identifier _handle;
identifier t;
@@

 void _callback(struct timer_list *t)
 {
-	_handletype *_handle = from_timer(_handle, t, _timer);
 }

// We only want to refactor the setup_timer() data argument if we've found
// the matching callback. This undoes changes in change_timer_function_usage.
@unchange_timer_function_usage
 depends on change_timer_function_usage &&
            !change_callback_handle_cast &&
            !change_callback_handle_cast_no_arg &&
	    !change_callback_handle_arg@
expression change_timer_function_usage._E;
identifier change_timer_function_usage._timer;
identifier change_timer_function_usage._callback;
type change_timer_function_usage._cast_data;
@@

(
-timer_setup(&_E->_timer, _callback, 0);
+setup_timer(&_E->_timer, _callback, (_cast_data)_E);
|
-timer_setup(&_E._timer, _callback, 0);
+setup_timer(&_E._timer, _callback, (_cast_data)&_E);
)

// If we fixed a callback from a .function assignment, fix the
// assignment cast now.
@change_timer_function_assignment
 depends on change_timer_function_usage &&
            (change_callback_handle_cast ||
             change_callback_handle_cast_no_arg ||
             change_callback_handle_arg)@
expression change_timer_function_usage._E;
identifier change_timer_function_usage._timer;
identifier change_timer_function_usage._callback;
type _cast_func;
typedef TIMER_FUNC_TYPE;
@@

(
 _E->_timer.function =
-_callback
+(TIMER_FUNC_TYPE)_callback
 ;
|
 _E->_timer.function =
-&_callback
+(TIMER_FUNC_TYPE)_callback
 ;
|
 _E->_timer.function =
-(_cast_func)_callback;
+(TIMER_FUNC_TYPE)_callback
 ;
|
 _E->_timer.function =
-(_cast_func)&_callback
+(TIMER_FUNC_TYPE)_callback
 ;
|
 _E._timer.function =
-_callback
+(TIMER_FUNC_TYPE)_callback
 ;
|
 _E._timer.function =
-&_callback;
+(TIMER_FUNC_TYPE)_callback
 ;
|
 _E._timer.function =
-(_cast_func)_callback
+(TIMER_FUNC_TYPE)_callback
 ;
|
 _E._timer.function =
-(_cast_func)&_callback
+(TIMER_FUNC_TYPE)_callback
 ;
)

// Sometimes timer functions are called directly. Replace matched args.
@change_timer_function_calls
 depends on change_timer_function_usage &&
            (change_callback_handle_cast ||
             change_callback_handle_cast_no_arg ||
             change_callback_handle_arg)@
expression _E;
identifier change_timer_function_usage._timer;
identifier change_timer_function_usage._callback;
type _cast_data;
@@

 _callback(
(
-(_cast_data)_E
+&_E->_timer
|
-(_cast_data)&_E
+&_E._timer
|
-_E
+&_E->_timer
)
 )

// If a timer has been configured without a data argument, it can be
// converted without regard to the callback argument, since it is unused.
@match_timer_function_unused_data@
expression _E;
identifier _timer;
identifier _callback;
@@

(
-setup_timer(&_E->_timer, _callback, 0);
+timer_setup(&_E->_timer, _callback, 0);
|
-setup_timer(&_E->_timer, _callback, 0L);
+timer_setup(&_E->_timer, _callback, 0);
|
-setup_timer(&_E->_timer, _callback, 0UL);
+timer_setup(&_E->_timer, _callback, 0);
|
-setup_timer(&_E._timer, _callback, 0);
+timer_setup(&_E._timer, _callback, 0);
|
-setup_timer(&_E._timer, _callback, 0L);
+timer_setup(&_E._timer, _callback, 0);
|
-setup_timer(&_E._timer, _callback, 0UL);
+timer_setup(&_E._timer, _callback, 0);
|
-setup_timer(&_timer, _callback, 0);
+timer_setup(&_timer, _callback, 0);
|
-setup_timer(&_timer, _callback, 0L);
+timer_setup(&_timer, _callback, 0);
|
-setup_timer(&_timer, _callback, 0UL);
+timer_setup(&_timer, _callback, 0);
|
-setup_timer(_timer, _callback, 0);
+timer_setup(_timer, _callback, 0);
|
-setup_timer(_timer, _callback, 0L);
+timer_setup(_timer, _callback, 0);
|
-setup_timer(_timer, _callback, 0UL);
+timer_setup(_timer, _callback, 0);
)

@change_callback_unused_data
 depends on match_timer_function_unused_data@
identifier match_timer_function_unused_data._callback;
type _origtype;
identifier _origarg;
@@

 void _callback(
-_origtype _origarg
+struct timer_list *unused
 )
 {
	... when != _origarg
 }

Signed-off-by: Kees Cook <keescook@chromium.org>
2017-11-21 15:57:07 -08:00
Linus Torvalds abc36be236 A couple of configfs cleanups:
- proper use of the bool type (Thomas Meyer)
   - constification of struct config_item_type (Bhumika Goyal)
 -----BEGIN PGP SIGNATURE-----
 
 iQI/BAABCAApFiEEgdbnc3r/njty3Iq9D55TZVIEUYMFAloLSTALHGhjaEBsc3Qu
 ZGUACgkQD55TZVIEUYNxfhAAv3cunxiEPEAvs+1xuGd3cZYaxz7qinvIODPxIKoF
 kRWiuy5PUklRMnJ8seOgJ1p1QokX6Sk4cZ8HcctDJVByqODjOq4K5eaKVN1ZqJoz
 BUzO/gOqfs64r9yaFIlKfe8nFA+gpUftSeWyv3lThxAIJ1iSbue7OZ/A10tTOS1m
 RWp9FPepFv+nJMfWqeQU64BsoDQ4kgZ2NcEA+jFxNx5dlmIbLD49tk0lfddvZQXr
 j5WyAH73iugilLtNUGVOqSzHBY4kUvfCKUV7leirCegyMoGhFtA87m6Wzwbo6ZUI
 DwQLzWvuPaGv1P2PpNEHfKiNbfIEp75DRyyyf87DD3lc5ffAxQSm28mGuwcr7Rn5
 Ow/yWL6ERMzCLExoCzEkXYJISy7T5LIzYDgNggKMpeWxysAduF7Onx7KfW1bTuhK
 mHvY7iOXCjEvaIVaF8uMKE6zvuY1vCMRXaJ+kC9jcIE3gwhg+2hmQvrdJ2uAFXY+
 rkeF2Poj/JlblPU4IKWAjiPUbzB7Lv0gkypCB2pD4riaYIN5qCAgF8ULIGQp2hsO
 lYW1EEgp5FBop85oSO/HAGWeH9dFg0WaV7WqNRVv0AGXhKjgy+bVd7iYPpvs7mGw
 z9IqSQDORcG2ETLcFhZgiJpCk/itwqXBD+wgMOjJPP8lL+4kZ8FcuhtY9kc9WlJE
 Tew=
 =+tMO
 -----END PGP SIGNATURE-----

Merge tag 'configfs-for-4.15' of git://git.infradead.org/users/hch/configfs

Pull configfs updates from Christoph Hellwig:
 "A couple of configfs cleanups:

   - proper use of the bool type (Thomas Meyer)

   - constification of struct config_item_type (Bhumika Goyal)"

* tag 'configfs-for-4.15' of git://git.infradead.org/users/hch/configfs:
  RDMA/cma: make config_item_type const
  stm class: make config_item_type const
  ACPI: configfs: make config_item_type const
  nvmet: make config_item_type const
  usb: gadget: configfs: make config_item_type const
  PCI: endpoint: make config_item_type const
  iio: make function argument and some structures const
  usb: gadget: make config_item_type structures const
  dlm: make config_item_type const
  netconsole: make config_item_type const
  nullb: make config_item_type const
  ocfs2/cluster: make config_item_type const
  target: make config_item_type const
  configfs: make ci_type field, some pointers and function arguments const
  configfs: make config_item_type const
  configfs: Fix bool initialization/comparison
2017-11-14 14:44:04 -08:00
Linus Torvalds 449fcf3ab0 Staging/IIO patches for 4.15-rc1
Here is the "big" staging and IIO driver update for 4.15-rc1.
 
 Lots and lots of little changes, almost all minor code cleanups as the
 Outreachy application process happened during this development cycle.
 Also happened was a lot of IIO driver activity, and the typec USB code
 moving out of staging to drivers/usb (same commits are in the USB tree
 on a persistent branch to not cause merge issues.)
 
 Overall, it's a wash, I think we added a few hundred more lines than
 removed, but really only a few thousand were modified at all.
 
 All of these have been in linux-next for a while.  There might be a
 merge issue with Al's vfs tree in the pi433 driver (take his changes,
 they are always better), and the media tree with some of the odd atomisp
 cleanups (take the media tree's version).
 
 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
 -----BEGIN PGP SIGNATURE-----
 
 iG0EABECAC0WIQT0tgzFv3jCIUoxPcsxR9QN2y37KQUCWgnFrg8cZ3JlZ0Brcm9h
 aC5jb20ACgkQMUfUDdst+ymxbwCgtNlBkqD2JJYpLRKvI/C4w1vzZsEAnA2THRkt
 g3ioPBqmqC/2DSbldr2o
 =/ebw
 -----END PGP SIGNATURE-----

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

Pull staging and IIO updates from Greg KH:
 "Here is the "big" staging and IIO driver update for 4.15-rc1.

  Lots and lots of little changes, almost all minor code cleanups as the
  Outreachy application process happened during this development cycle.
  Also happened was a lot of IIO driver activity, and the typec USB code
  moving out of staging to drivers/usb (same commits are in the USB tree
  on a persistent branch to not cause merge issues.)

  Overall, it's a wash, I think we added a few hundred more lines than
  removed, but really only a few thousand were modified at all.

  All of these have been in linux-next for a while. There might be a
  merge issue with Al's vfs tree in the pi433 driver (take his changes,
  they are always better), and the media tree with some of the odd
  atomisp cleanups (take the media tree's version)"

* tag 'staging-4.15-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging: (507 commits)
  staging: lustre: add SPDX identifiers to all lustre files
  staging: greybus: Remove redundant license text
  staging: greybus: add SPDX identifiers to all greybus driver files
  staging: ccree: simplify ioread/iowrite
  staging: ccree: simplify registers access
  staging: ccree: simplify error handling logic
  staging: ccree: remove dead code
  staging: ccree: handle limiting of DMA masks
  staging: ccree: copy IV to DMAable memory
  staging: fbtft: remove redundant initialization of buf
  staging: sm750fb: Fix parameter mistake in poke32
  staging: wilc1000: Fix bssid buffer offset in Txq
  staging: fbtft: fb_ssd1331: fix mirrored display
  staging: android: Fix checkpatch.pl error
  staging: greybus: loopback: convert loopback to use generic async operations
  staging: greybus: operation: add private data with get/set accessors
  staging: greybus: loopback: Fix iteration count on async path
  staging: greybus: loopback: Hold per-connection mutex across operations
  staging: greybus/loopback: use ktime_get() for time intervals
  staging: fsl-dpaa2/eth: Extra headroom in RX buffers
  ...
2017-11-13 20:53:28 -08:00
Greg Kroah-Hartman b24413180f License cleanup: add SPDX GPL-2.0 license identifier to files with no license
Many source files in the tree are missing licensing information, which
makes it harder for compliance tools to determine the correct license.

By default all files without license information are under the default
license of the kernel, which is GPL version 2.

Update the files which contain no license information with the 'GPL-2.0'
SPDX license identifier.  The SPDX identifier is a legally binding
shorthand, which can be used instead of the full boiler plate text.

This patch is based on work done by Thomas Gleixner and Kate Stewart and
Philippe Ombredanne.

How this work was done:

Patches were generated and checked against linux-4.14-rc6 for a subset of
the use cases:
 - file had no licensing information it it.
 - file was a */uapi/* one with no licensing information in it,
 - file was a */uapi/* one with existing licensing information,

Further patches will be generated in subsequent months to fix up cases
where non-standard license headers were used, and references to license
had to be inferred by heuristics based on keywords.

The analysis to determine which SPDX License Identifier to be applied to
a file was done in a spreadsheet of side by side results from of the
output of two independent scanners (ScanCode & Windriver) producing SPDX
tag:value files created by Philippe Ombredanne.  Philippe prepared the
base worksheet, and did an initial spot review of a few 1000 files.

The 4.13 kernel was the starting point of the analysis with 60,537 files
assessed.  Kate Stewart did a file by file comparison of the scanner
results in the spreadsheet to determine which SPDX license identifier(s)
to be applied to the file. She confirmed any determination that was not
immediately clear with lawyers working with the Linux Foundation.

Criteria used to select files for SPDX license identifier tagging was:
 - Files considered eligible had to be source code files.
 - Make and config files were included as candidates if they contained >5
   lines of source
 - File already had some variant of a license header in it (even if <5
   lines).

All documentation files were explicitly excluded.

The following heuristics were used to determine which SPDX license
identifiers to apply.

 - when both scanners couldn't find any license traces, file was
   considered to have no license information in it, and the top level
   COPYING file license applied.

   For non */uapi/* files that summary was:

   SPDX license identifier                            # files
   ---------------------------------------------------|-------
   GPL-2.0                                              11139

   and resulted in the first patch in this series.

   If that file was a */uapi/* path one, it was "GPL-2.0 WITH
   Linux-syscall-note" otherwise it was "GPL-2.0".  Results of that was:

   SPDX license identifier                            # files
   ---------------------------------------------------|-------
   GPL-2.0 WITH Linux-syscall-note                        930

   and resulted in the second patch in this series.

 - if a file had some form of licensing information in it, and was one
   of the */uapi/* ones, it was denoted with the Linux-syscall-note if
   any GPL family license was found in the file or had no licensing in
   it (per prior point).  Results summary:

   SPDX license identifier                            # files
   ---------------------------------------------------|------
   GPL-2.0 WITH Linux-syscall-note                       270
   GPL-2.0+ WITH Linux-syscall-note                      169
   ((GPL-2.0 WITH Linux-syscall-note) OR BSD-2-Clause)    21
   ((GPL-2.0 WITH Linux-syscall-note) OR BSD-3-Clause)    17
   LGPL-2.1+ WITH Linux-syscall-note                      15
   GPL-1.0+ WITH Linux-syscall-note                       14
   ((GPL-2.0+ WITH Linux-syscall-note) OR BSD-3-Clause)    5
   LGPL-2.0+ WITH Linux-syscall-note                       4
   LGPL-2.1 WITH Linux-syscall-note                        3
   ((GPL-2.0 WITH Linux-syscall-note) OR MIT)              3
   ((GPL-2.0 WITH Linux-syscall-note) AND MIT)             1

   and that resulted in the third patch in this series.

 - when the two scanners agreed on the detected license(s), that became
   the concluded license(s).

 - when there was disagreement between the two scanners (one detected a
   license but the other didn't, or they both detected different
   licenses) a manual inspection of the file occurred.

 - In most cases a manual inspection of the information in the file
   resulted in a clear resolution of the license that should apply (and
   which scanner probably needed to revisit its heuristics).

 - When it was not immediately clear, the license identifier was
   confirmed with lawyers working with the Linux Foundation.

 - If there was any question as to the appropriate license identifier,
   the file was flagged for further research and to be revisited later
   in time.

In total, over 70 hours of logged manual review was done on the
spreadsheet to determine the SPDX license identifiers to apply to the
source files by Kate, Philippe, Thomas and, in some cases, confirmation
by lawyers working with the Linux Foundation.

Kate also obtained a third independent scan of the 4.13 code base from
FOSSology, and compared selected files where the other two scanners
disagreed against that SPDX file, to see if there was new insights.  The
Windriver scanner is based on an older version of FOSSology in part, so
they are related.

Thomas did random spot checks in about 500 files from the spreadsheets
for the uapi headers and agreed with SPDX license identifier in the
files he inspected. For the non-uapi files Thomas did random spot checks
in about 15000 files.

In initial set of patches against 4.14-rc6, 3 files were found to have
copy/paste license identifier errors, and have been fixed to reflect the
correct identifier.

Additionally Philippe spent 10 hours this week doing a detailed manual
inspection and review of the 12,461 patched files from the initial patch
version early this week with:
 - a full scancode scan run, collecting the matched texts, detected
   license ids and scores
 - reviewing anything where there was a license detected (about 500+
   files) to ensure that the applied SPDX license was correct
 - reviewing anything where there was no detection but the patch license
   was not GPL-2.0 WITH Linux-syscall-note to ensure that the applied
   SPDX license was correct

This produced a worksheet with 20 files needing minor correction.  This
worksheet was then exported into 3 different .csv files for the
different types of files to be modified.

These .csv files were then reviewed by Greg.  Thomas wrote a script to
parse the csv files and add the proper SPDX tag to the file, in the
format that the file expected.  This script was further refined by Greg
based on the output to detect more types of files automatically and to
distinguish between header and source .c files (which need different
comment types.)  Finally Greg ran the script using the .csv files to
generate the patches.

Reviewed-by: Kate Stewart <kstewart@linuxfoundation.org>
Reviewed-by: Philippe Ombredanne <pombredanne@nexb.com>
Reviewed-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-11-02 11:10:55 +01:00
Greg Kroah-Hartman 85078fd095 Third set of new device support, cleanups and features for IIO in the 4.15 cycle
New device support
 * ti-dac082s085 dac
   - new driver supporting 8, 10 and 12 bit TI DACs with 2 and 4 channels:
     DAC082S085, DAC102S085, DAC122S085, DAC104s085 and DAC124S085.
 
 Minor features and cleanps
 * adc12138
   - make array ch_to_mux static for small object code size reduction.
 * sun4i-gpadc
   - use of_device_get_match_data rather than opencoding it.
 * stm32 trigger
   - add tim15 tigger on STM32H7
   - check clock rate to avoid potential division by zero
 * tsl2x7x staging cleanups.
   - move *_thresh_period to being created by IIO core.
   - remove unused tsl2x7x_parse_result structure.
   - sort includes
   - drop a repeat iio_dev forward definition
   - fix some code alignment of defines.
   - use IIO_CONST_ATTR for constant string attribute
   - drop some unnecessary parentheses
   - fix various alignment with parenthese
   - rename power defines for readability reasons
   - fix a missaligned break statement
   - Tidy up function definitions so they fit on a single line.
 -----BEGIN PGP SIGNATURE-----
 
 iQJFBAABCAAvFiEEbilms4eEBlKRJoGxVIU0mcT0FogFAlnyJXQRHGppYzIzQGtl
 cm5lbC5vcmcACgkQVIU0mcT0FogSMw/9Hv7euztsUr7lq+6pN+lXZVBCTveIxqf8
 JSKoUt7unA0OqlZAyQv2oR2Vd6/d0Oy6WuAgpBg/mXEjBYC5/yy2NdXKLFvG0HVX
 5JdaKg+ZVTzGceWk75fEFbQ+6bzonXGwkWGMEqV+tb3MPQPD1ffP222pjj6Q8nqZ
 9c72WsScZhU5FxvJsyD31pAx0BxPUTKQKU/ShFF5o1jtQPo/rtoLKQDB4tysaJ9g
 SK5CKvoZMZScMffUnhGUTCOQEXUiew3jgSEHWOpl5JYAO/tTwDkR6EpLAbkbkNFr
 wvwPErfuxoY/PAXuJDQaBX3/wrGqd4UBj0w+w+l3CbkkX8xvmdfVVr+ri501QHUO
 pZYxdvQ5u+lBn6bkTjzf7A2IbT7Y1rdJJvTSIcRieFGmJ3nTOjrWNEo5QnxR5IME
 xR4qHgABqwFJ6dZSgofJ2yWH/t9zjz66guY1IkH3+yzeOjnSAGlrXY3+bJrCJpL8
 vgvNnTwHAWdKYx+1luPTN5vWqB/2ylWcgP2LK/cxslSP1l1jT+JmqmfQ9ydk8NgG
 CT4DuoH0ECSHmWpvPgv6Lu6wJ60hZH5y5u1O7gr2MndYOPGg3L0a7aFWUtzzHgGj
 9GVolsgFHoKGq2hr5FZ5fFJk88FRZP2U7Vus07r34XWuxZItn1aYqHqRTLgaa2hU
 Z9TMNvh4RS4=
 =IXO+
 -----END PGP SIGNATURE-----

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

Jonathan writes:

Third set of new device support, cleanups and features for IIO in the 4.15 cycle

New device support
* ti-dac082s085 dac
  - new driver supporting 8, 10 and 12 bit TI DACs with 2 and 4 channels:
    DAC082S085, DAC102S085, DAC122S085, DAC104s085 and DAC124S085.

Minor features and cleanps
* adc12138
  - make array ch_to_mux static for small object code size reduction.
* sun4i-gpadc
  - use of_device_get_match_data rather than opencoding it.
* stm32 trigger
  - add tim15 tigger on STM32H7
  - check clock rate to avoid potential division by zero
* tsl2x7x staging cleanups.
  - move *_thresh_period to being created by IIO core.
  - remove unused tsl2x7x_parse_result structure.
  - sort includes
  - drop a repeat iio_dev forward definition
  - fix some code alignment of defines.
  - use IIO_CONST_ATTR for constant string attribute
  - drop some unnecessary parentheses
  - fix various alignment with parenthese
  - rename power defines for readability reasons
  - fix a missaligned break statement
  - Tidy up function definitions so they fit on a single line.
2017-10-27 11:13:08 +02:00
Greg Kroah-Hartman 7706abf5a0 Merge 4.14-rc6 into staging-next
We want the IIO and staging driver fixes in here as well.

Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-10-23 14:29:43 +02:00
Lukas Wunner f98677cf31 iio: dac: ti-dac082s085: Read chip spec from device table
The two properties unique to each supported chip, resolution and number
of channels, are currently gleaned from the chip's name.
E.g. dac102s085 is a dual channel 10-bit DAC.
        ^^^
This was deemed unmaintainable by the subsystem maintainer once the
driver is extended to support further chips, hence it was requested
to add an explicit table for chip-specific information and use an
enum to reference into it.

This adds 17 LoC without any immediate gain, so make the change in a
separate commit which can be reverted if we determine in 10 years that
it was unnecessary.

Signed-off-by: Lukas Wunner <lukas@wunner.de>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2017-10-21 20:36:45 +01:00
Lukas Wunner 61011264c1 iio: dac: Add Texas Instruments 8/10/12-bit 2/4-channel DAC driver
The DACrrcS085 (rr = 08/10/12, c = 2/4) family of SPI DACs was
inherited by TI when they acquired National Semiconductor in 2011.
This driver was developed for and tested with the DAC082S085 built into
the Revolution Pi by KUNBUS, but should work with any of the other
chips as they share the same programming interface.

There is also a family of I2C DACs with just a single channel called
DACrr1C08x (rr = 08/10/12, x = 1/5).  Their programming interface is
very similar and it should be possible to extend the driver for these
chips with moderate effort.  Alternatively they could be integrated into
ad5446.c.  (The AD5301/AD5311/AD5321 use different power-down modes but
otherwise appear to be comparable.)

Furthermore there is a family of 8-channel DACs called DACrr8S085
(rr = 08/10/12) as well as two 16-bit DACs called DAC161Sxxx
(xxx = 055/997).  These are more complicated devices with support for
daisy-chaining and the ability to power down each channel separately.
They could either be handled by a separate driver or integrated into the
present driver with a larger effort.

Cc: Mathias Duckeck <m.duckeck@kunbus.de>
Signed-off-by: Lukas Wunner <lukas@wunner.de>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2017-10-21 20:35:43 +01:00
Corentin Labbe 0d87a4aa37 iio: adc: sun4i-gpadc: use of_device_get_match_data
The usage of of_device_get_match_data reduce the code size a bit.
Furthermore, it prevents an improbable dereference when
of_match_device() return NULL.

Signed-off-by: Corentin Labbe <clabbe.montjoie@gmail.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2017-10-21 18:48:00 +01:00
Colin Ian King 59dba8facb iio: adc: adc12138: make array ch_to_mux static, makes object code smaller
Don't populate const array ch_to_mux on the stack, instead
make it static. Makes the object code smaller by over 200 bytes:

Before:
   text	   data	    bss	    dec	    hex	filename
  12663	   1648	    128	  14439	   3867	drivers/iio/adc/ti-adc12138.o

After
   text	   data	    bss	    dec	    hex	filename
  12353	   1744	    128	  14225	   3791	drivers/iio/adc/ti-adc12138.o

(gcc version 7.2.0 x86_64)

Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2017-10-21 17:56:09 +01:00
Fabrice Gasnier f66f18e99a iio: adc: stm32: add check on clock rate
Add check on STM32 ADC clock rate to report an explicit error.
This may avoid division by 0 later in stm32-adc driver.

Signed-off-by: Fabrice Gasnier <fabrice.gasnier@st.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2017-10-21 17:52:20 +01:00
Fabrice Gasnier 3a06990428 iio: adc: stm32: add tim15 trigger
Add TIM15_TRGO trigger that is now supported on STM32H7.

Signed-off-by: Fabrice Gasnier <fabrice.gasnier@st.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2017-10-21 17:49:57 +01:00
Bhumika Goyal 612a462acb iio: make function argument and some structures const
Make the argument of the functions iio_sw{d/t}_group_init_type_name const
as they are only passed to the function config_group_init_type_name having
the argument as const.

Make the config_item_type structures const as they are either passed to
the functions having the argument as const or they are
stored in the const "ci_type" field of a config_item structure.

Signed-off-by: Bhumika Goyal <bhumirks@gmail.com>
Acked-by: Jonathan Cameron <Jonathan.Cameron@Huawei.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
2017-10-19 16:15:24 +02:00
Gwendal Grignou 11b86c7004 platform/chrome: Add cros_ec_accel_legacy driver
Add driver to support older EC firmware that only support deprecated
ec command. Rely on ACPI memory map register to access sensor
information.
Present same interface as the regular cros_ec sensor stack:
- one iio device per accelerometer
- use HTML5 axis definition
- use iio abi units
- accept calibration calls, but do nothing
Chrome can use the same code than regular cros_ec sensor stack to
calculate orientation and lid angle.

Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
Signed-off-by: Thierry Escande <thierry.escande@collabora.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2017-10-14 20:34:01 +01:00
Eugen Hristev ca4c302398 iio: adc: at91-sama5d2_adc: fix probe error on missing trigger property
This fix allows platforms to probe correctly even if the
trigger edge property is missing. The hardware trigger
will no longer be registered in the sybsystem
Preserves backwards compatibility with the support that
was in the driver before the hardware trigger.

https://storage.kernelci.org/mainline/master/v4.14-rc2-255-g74d83ec2b734/arm/sama5_defconfig/lab-free-electrons/boot-at91-sama5d2_xplained.txt

Signed-off-by: Eugen Hristev <eugen.hristev@microchip.com>
Fixes: 5e1a1da0f ("iio: adc: at91-sama5d2_adc: add hw trigger and buffer support")
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2017-10-14 19:52:07 +01:00
Srinivas Pandruvada ad7532cefd iio: hid-sensor-trigger: Don't touch sensors unless user space requests
One of the user complained that on his system Thinkpad Yoga S1, with
commit f1664eaace ("iio: hid-sensor-trigger: Fix the race with user
space powering up sensors") causes the system to resume immediately
on suspend (S3 operation). On this system the sensor hub is on USB
and is a wake up device from S3. So if any sensor sends data on
motion, the system will wake up. This can be a legitimate use case
to wake up device motion, but that needs proper user space support
to set right thresholds.

In fact the above commit didn't cause this regression, but any operation
which cause sensors to wake up would have caused the same issue. So if
user reads the raw sensor data, same issue occurs, with or without this
commit. Only difference is that the above commit by default will trigger
a power up and power down of sensors as part of runtime pm enable
(runtime enable will cause a runtime resume callback followed by
runtime_suspend callback). Previously user has to do some action on
sensors.

On investigation it was observed that the current driver correctly
changing the state of all sensors to power off but then also some sensor
will still send some data. Only option is to never power up any sensor.

Only good option is to:
- Using sysfs interface disable USB as a wakeup device (This will not
need any driver change)

Since some user don't care about sensors. So for those users this change
brings back old functionality. As long as they don't cause any operation
to power up sensors (like raw read or start iio-sensor-proxy service),
the sensors will not be to touched. This is done by delaying run time
enable till user space does some operation with sensors.

Link: https://bugzilla.kernel.org/show_bug.cgi?id=196853
Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2017-10-14 19:29:50 +01:00
Peter Meerwald-Stadler 79e6418866 iio: proximity: Add rfd77402 driver
Driver for RF Digital RFD77402 VCSEL (vertical-cavity surface-emitting
laser) Time-of-Flight (ToF) sensor to measure distance up to 2 m with
millimeter precision

Signed-off-by: Peter Meerwald-Stadler <pmeerw@pmeerw.net>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2017-10-14 18:28:51 +01:00
Lorenzo Bianconi fea4d48661 iio: accel: add support to LIS3DHH
add support to STMicroelectronics LIS3DHH accel sensor

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

Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@st.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2017-10-10 20:40:54 +01:00
Lorenzo Bianconi 7d24517267 iio: common: st_sensors: check odr address value in st_sensors_set_odr()
Do not try to configure sample frequency if the sensor do not export
odr register address in register map. That change will be used to
properly support LIS3DHH accel sensor.

Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@st.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2017-10-10 20:39:28 +01:00
Lorenzo Bianconi a542f9a04d iio: st_sensors: split open-drain parameters for irq1 and irq2
Define st_sensor_int_drdy structure in st_sensor_data_ready_irq in order
to contain irq line parameters of the device.
Moreover separate data-ready open-drain configuration parameters for INT1
and INT2 pins in st_sensor_data_ready_irq data structure.
That change will be used to properly support LIS3DHH accel sensor.

Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@st.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2017-10-10 20:38:39 +01:00
Lorenzo Bianconi 6f66700461 iio: pressure: st_pressure: add SPI-3wire support to st_pressure framework
Add SPI Serial Interface Mode (SIM) register information
to STM pressure framework

Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@st.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2017-10-10 20:37:20 +01:00
Lorenzo Bianconi 9915c19056 iio: magnetometer: st_magn: add SPI-3wire support to LIS3MDL
Add SPI Serial Interface Mode (SIM) register information to
LIS3MDL magn sensor

Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@st.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2017-10-10 20:36:33 +01:00
Lorenzo Bianconi 281dbadb5f iio: gyro: st_gyro: add SPI-3wire support to st_gyro framework
Add SPI Serial Interface Mode (SIM) register information
to STM gyroscope framework

Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@st.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2017-10-10 20:32:28 +01:00
Lorenzo Bianconi f94124f9fb iio: accel: add support to LIS2DW12
add support to STMicroelectronics LIS2DW12 accelerometer in
st_accel framework

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

Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@st.com>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2017-10-09 21:59:48 +01:00
Lorenzo Bianconi 2e8325f489 iio: st_sensors: do not always write enable_axis register
New devices (e.g. LIS2DW12) enable all axis by default and do not export
that capability in register map. Check if the enable_axis register
address has been declared in st_sensor_settings map in order to verify if
the driver needs to enable all sensor axis

Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@st.com>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2017-10-09 21:58:47 +01:00
Lorenzo Bianconi 75d4c6d2e1 iio: st_sensors: decouple irq1 configuration parameters from the irq2 ones
Separate data-ready configuration parameters for INT1 and INT2 pins in
st_sensor_data_ready_irq data structure. That change will be use to
properly support LIS2DW12 accel sensor.

Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@st.com>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2017-10-09 21:04:22 +01:00
Lorenzo Bianconi e72a060151 iio: st_sensors: add register mask for status register
Introduce register mask for data-ready status register since
pressure sensors (e.g. LPS22HB) export just two channels
(BIT(0) and BIT(1)) and BIT(2) is marked reserved while in
st_sensors_new_samples_available() value read from status register
is masked using 0x7.
Moreover do not mask status register using active_scan_mask since
now status value is properly masked and if the result is not zero the
interrupt has to be consumed by the driver. This fix an issue on LPS25H
and LPS331AP where channel definition is swapped respect to status
register.
Furthermore that change allows to properly support new devices
(e.g LIS2DW12) that report just ZYXDA (data-ready) field in status register
to figure out if the interrupt has been generated by the device.

Fixes: 97865fe413 (iio: st_sensors: verify interrupt event to status)
Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@st.com>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2017-10-09 21:01:45 +01:00
Lukas Wunner c1375d671a iio: adc: mcp320x: Add support for mcp3550/1/3
These ADCs are marketed as single-channel 22 bit delta-sigma ADCs, but
in reality their resolution is 21 bit with an overrange or underrange
of 12% beyond Vref.  In other words, "full scale" means +/- 2^20.

This driver does not explicitly signal back to the user when an
overrange or underrange occurs, but the user can detect it by comparing
the raw value to +/- 2^20 (or the scaled value to Vref).

The chips feature an extended temperature range and high accuracy,
low noise characteristics, but their conversion times are slow with
up to 80 ms +/- 2% (on the MCP3550-50).

Hence, unlike the other ADCs supported by the driver, conversion does
not take place in realtime upon lowering CS.  Instead, CS is asserted
for 8 usec to start the conversion.  After waiting for the duration of
the conversion, the result can be fetched.  While waiting, control of
the bus is ceased so it may be used by a different device.

After the result has been fetched and 10 us have passed, the chip goes
into shutdown and an additional power-up delay of 144 clock periods is
then required to wake the analog circuitry upon the next conversion
(footnote below table 4-1, page 16 in the spec).

Optionally, the chips can be used in so-called "continuous conversion
mode":  Conversions then take place continuously and the last result may
be fetched at any time without observing a delay.  The mode is enabled
by permanently driving CS low, e.g. by wiring it to ground.  The driver
only supports "single conversion mode" for now but should be adaptable
to "continuous conversion mode" with moderate effort.

The chips clock out a 3 byte word, unlike the other ADCs supported by
the driver which all have a lower resolution than 16 bit and thus make
do with 2 bytes.  Calculate the word length on probe by rounding up the
resolution to full bytes.  Crucially, if the clock idles low, the
transfer is preceded by a useless Data Ready bit which increases its
length from 24 bit to 25 bit = 4 bytes (section 5.5 in the spec).
Autosense this based on the SPI slave's configuration.

Cc: Mathias Duckeck <m.duckeck@kunbus.de>
Signed-off-by: Lukas Wunner <lukas@wunner.de>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2017-10-09 21:01:36 +01:00
Stefan Brüns 103f3afe91 iio: adc: ina2xx: Adhere to documented ABI, use Ohm instead of uOhm
According to the ABI documentation, the shunt resistor value should be
specificied in Ohm. As this is also used/documented for the MAX9611,
use the same for the INA2xx driver.

This poses an ABI break for anyone actually altering the shunt value
through the sysfs interface, it does not alter the default value nor
a value set from the devicetree.

Minor change: Fix comment, 1mA is 10^-3A.

Signed-off-by: Stefan Brüns <stefan.bruens@rwth-aachen.de>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2017-10-09 20:51:01 +01:00
Lorenzo Bianconi 92617c158a iio: imu: st_lsm6dsx: add FIFO ops data structure
Introduce FIFO ops data structure to contain FIFO related parameters
in order to properly support more devices in st_lsm6dsx driver

Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@st.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2017-10-09 20:51:01 +01:00
Lorenzo Bianconi 7ca3ac9e9e iio: imu: st_lsm6dsx: move decimator info in st_lsm6dsx_sensor_settings
Move FIFO decimator info in st_lsm6dsx_sensor_settings list since
decimator registers are exported in register map just in
lsm6ds3/lsm6ds3h/lsm6dsl/lsm6dsm sensors and not in other compliant
devices

Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@st.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2017-10-09 20:51:01 +01:00
Lorenzo Bianconi ff81a933c1 iio: imu: st_lsm6dsx: split fifo mode and fifo odr configuration
Separate fifo mode and max fifo sample rate configuration.
That change will be necessary to reuse st_lsm6dsx_set_fifo_mode()
routine and to support more devices in st_lsm6dsx driver

Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@st.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2017-10-09 20:50:57 +01:00
Lorenzo Bianconi 8f2a88a2b2 iio: imu: st_lsm6dsx: convert max_fifo_size in FIFO sample size
Express max fifo depth in ST_LSM6DSX_SAMPLE_SIZE instead of in bytes.
That change will be necessary to properly support more devices
in st_lsm6dsx driver

Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@st.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2017-10-09 20:50:52 +01:00
Geert Uytterhoeven fb942f8ce6 iio: adc: rcar-gyroadc: Use of_device_get_match_data() helper
Use the of_device_get_match_data() helper instead of open coding.
Note that the rcar-gyroadc driver is used with DT only, so there's
always a valid match.

Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Reviewed-by: Simon Horman <horms+renesas@verge.net.au>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2017-10-09 20:50:49 +01:00
Geert Uytterhoeven af5d716a90 iio: adc: rcar-gyroadc: Enable compile-testing on non-ARM
The rcar-gyroadc driver compiles fine on other platforms, hence increase
compile coverage.

Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Reviewed-by: Simon Horman <horms+renesas@verge.net.au>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2017-10-09 20:50:46 +01:00
Geert Uytterhoeven 2a35734564 iio: adc: rcar-gyroadc: Cast pointer to uintptr_t to fix warning on 64-bit
On 64-bit:

    drivers/iio/adc/rcar-gyroadc.c: In function 'rcar_gyroadc_parse_subdevs':
    drivers/iio/adc/rcar-gyroadc.c:352:15: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
       childmode = (unsigned int)of_id->data;
		   ^

Cast the pointer to uintptr_t instead of unsigned int to fix this.

Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Reviewed-by: Simon Horman <horms+renesas@verge.net.au>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2017-10-09 20:50:43 +01:00
Bartosz Golaszewski ca48139856 iio: dummy: evgen: use irq_sim
Switch to using the recently added interrupt simulator for dummy irqs.

Signed-off-by: Bartosz Golaszewski <brgl@bgdev.pl>
Reviewed-by: Lars-Peter Clausen <lars@metafoo.de>
Tested-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2017-10-09 20:50:34 +01:00
Stefan Brüns 3525d7cfb7 iio: light: vl6180: Correct ALS scale for non-default gain/integration time
The reported scale was only correct for the default settings of 100 ms
integration time and gain 1.

This aligns the reported scale with the behaviour of any other IIO driver
and the documented ABI, but may require userspace changes if someone uses
non-default settings.

Signed-off-by: Stefan Brüns <stefan.bruens@rwth-aachen.de>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2017-10-09 20:50:21 +01:00
Stefan Brüns e794bf6751 iio: light: vl6180: Cleanup als_gain lookup, avoid register readback
Instead of manually iterating the array of allowed gain values, use
find_closest. Storing the current gain setting avoids accessing the
hardware on each query.

Signed-off-by: Stefan Brüns <stefan.bruens@rwth-aachen.de>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2017-10-09 20:50:15 +01:00
Stefan Brüns df698c0402 iio: light: vl6180: Avoid readback of integration time register
Instead of reading the value from the register on each query, store the
set value.

Signed-off-by: Stefan Brüns <stefan.bruens@rwth-aachen.de>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2017-10-09 20:50:10 +01:00
Stefan Brüns 1e2ed3d0d2 iio: light: vl6180: Move range check to integration time setter, cleanup
This improves code uniformity (range checks for als_gain are also done
in the setter). Also unmangle rounding and calculation of register value.

The calculated integration time it_ms is required in the next patch of
the series.

Signed-off-by: Stefan Brüns <stefan.bruens@rwth-aachen.de>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2017-10-09 20:50:08 +01:00
Michał Mirosław 1540d0106b iio: accel: kxcjk1013: add support for KXTF9
KXTF9 has mostly compatible register layout to KXCJK accelerometer.
There is no motion direction interrupt support, but there is tap
direction detection instead (not implemented in this patch).

Signed-off-by: Michał Mirosław <mirq-linux@rere.qmqm.pl>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2017-10-09 20:50:06 +01:00
Michał Mirosław d2ff1956ba iio: accel: kxcjk1013: make sampling_frequency_avail per-type
Make sampling_frequency_avail per-type - like sampling_frequency is.

Signed-off-by: Michał Mirosław <mirq-linux@rere.qmqm.pl>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2017-10-09 20:50:03 +01:00
Michał Mirosław 81fa8cb9f8 iio: accel: kxcjk1013: make sysfs/sampling_frequency_avail dynamic
In preparation for KXTF9 support, make sampling_frequency_avail
attribute dynamic.

Signed-off-by: Michał Mirosław <mirq-linux@rere.qmqm.pl>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2017-10-09 20:50:01 +01:00
Michał Mirosław d8408e98f5 iio: accel: kxcjk1013: extract report_motion_event() from interrupt handler
Extract reporting of motion event direction from interrupt handler,
as it is not supported by KXTF9.

Signed-off-by: Michał Mirosław <mirq-linux@rere.qmqm.pl>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2017-10-09 20:49:58 +01:00
Michał Mirosław f74e440c81 iio: accel: kxcjk1013: fix INT_CTRL/INT_SRC1 bit names
Fix INT_CTRL1 bit names to match register name and add names
for INT_SRC1 bits.

Signed-off-by: Michał Mirosław <mirq-linux@rere.qmqm.pl>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2017-10-09 20:49:55 +01:00
Michał Mirosław 7469ac69db iio: accel: kxcjk1003: refactor ODR setting
Refactor ODR/WUF setting code in preparation of KXTF9 support.

Signed-off-by: Michał Mirosław <mirq-linux@rere.qmqm.pl>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2017-10-09 20:49:51 +01:00
Harinath Nampally 4febd9f184 iio: accel: mma8452: Rename read/write event value callbacks to generic function name.
'mma8452_read_thresh' and 'mma8452_write_thresh' functions
does more than just read/write threshold values.
They also handle  IIO_EV_INFO_HIGH_PASS_FILTER_3DB and
IIO_EV_INFO_PERIOD therefore renaming to generic names.

Improves code readability, no impact on functionality.

Signed-off-by: Harinath Nampally <harinath922@gmail.com>
Acked-by: Martin Kepplinger <martink@posteo.de>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2017-10-09 20:49:49 +01:00
Quentin Schulz 3b455cdc49 iio: adc: sun4i-gpadc-iio: do not fail probing when no thermal DT node
Before this patch, forgetting to put a thermal-zones DT node would
result in the driver failing to probe.

It should be perfectly acceptable to have the driver probe even if no
thermal-zones DT is found. However, it shouldn't want to fail if the
thermal registering fail for any other reason (waiting for other drivers
for example) so check on ENODEV only.

Signed-off-by: Quentin Schulz <quentin.schulz@free-electrons.com>
Acked-by: Maxime Ripard <maxime.ripard@free-electrons.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2017-10-09 20:49:47 +01:00
Quentin Schulz b0a242894f iio: adc: sun4i-gpadc-iio: register in the thermal after registering in pm
This driver has a get_temp function used by the thermal framework that
uses pm functions.

However, the driver isn't registered in pm before it is registered in
thermal framework, resulting in the pm_resume not being called and thus
the IP not enabled.

When the IP is disabled, the raw temp value is always 0. With the
devices currently supported, it isn't a problem since with their
respective formula, they return a really cold SoC temperature which
isn't a problem for the thermal framework. But for future SoC that have
a different formula, it could return a critically hot temperature,
forcing the thermal framework to shutdown the board.

Signed-off-by: Quentin Schulz <quentin.schulz@free-electrons.com>
Acked-by: Maxime Ripard <maxime.ripard@free-electrons.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2017-10-09 20:49:42 +01:00
Ismail H. Kose d632a2bd8f iio: dac: ds4422/ds4424 dac driver
This patch provides an iio device driver for DS4422/DS4424 chips that support
two/four channel 7-bit Sink/Source Current DAC.

Signed-off-by: Ismail H. Kose <Ismail.Kose@maximintegrated.com>
Signed-off-by: Ismail H. Kose <ihkose@gmail.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2017-10-09 20:49:39 +01:00
Greg Kroah-Hartman 1236d6bb6e Merge 4.14-rc4 into staging-next
We want the staging/iio fixes in here as well to handle merge issues.

Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-10-09 09:02:35 +02:00
Randy Dunlap 5151b4afb4 iio: adc: dln2-adc: fix build error
The dln2-adc driver uses interface(s) that are controlled by the
IIO_TRIGGERED_BUFFER Kconfig symbol, so the driver needs to select
that symbol to prevent the build error.

drivers/iio/adc/dln2-adc.o: In function `dln2_adc_probe':
dln2-adc.c:(.text+0x528): undefined reference to `devm_iio_triggered_buffer_setup'

Signed-off-by: Randy Dunlap <rdunlap@infradead.org>
Reported-by: kbuild test robot <fengguang.wu@intel.com>
Cc: Jonathan Cameron <jic23@kernel.org>
Cc: linux-iio@vger.kernel.org
Cc: Jack Andersen <jackoalan@gmail.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2017-10-08 11:42:00 +01:00
Lars-Peter Clausen be94a6f6d4 iio: dummy: events: Add missing break
Add missing break in iio_simple_dummy_write_event_config() for the voltage
threshold event enable attribute. Without this writing to the
in_voltage0_thresh_rising_en always returns -EINVAL even though the change
was correctly applied.

Fixes: 3e34e650db ("iio: dummy: Demonstrate the usage of new channel types")
Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Cc: <Stable@vger.kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2017-10-01 11:17:18 +01:00
Jonathan Cameron f4052efe31 iio:stm32-lp-timer and ep93xx: drop assign iio_info.driver_module and iio_trigger_ops.owner
The equivalent of both of these are now done via macro magic when
the relevant register calls are made.  The actual structure
elements have gone away.

Reported-by: Stephen Rothwell <sfr@canb.auug.org.au>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-09-26 09:38:57 +02:00
Geert Uytterhoeven f61dfff2f5 iio: pressure: zpa2326: Remove always-true check which confuses gcc
With gcc 4.1.2:

    drivers/iio/pressure/zpa2326.c: In function ‘zpa2326_wait_oneshot_completion’:
    drivers/iio/pressure/zpa2326.c:868: warning: ‘ret’ may be used uninitialized in this function

When testing for "timeout < 0", timeout is already guaranteed to be
strict negative, so the branch is always taken, and ret is thus always
initialized.  But (some version of) gcc is not smart enough to notice.

Remove the check to fix this.
As there is no other code in between assigning the error codes and
returning them, the error codes can be returned immediately, and the
intermediate variable can be dropped.
Drop the "else" to please checkpatch.

Fixes: e7215fe4d5 ("iio: pressure: zpa2326: report interrupted case as failure")
Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2017-09-25 21:39:00 +01:00
Matt Ranostay eb35279dd7 iio: proximity: as3935: noise detection + threshold changes
Most applications are too noisy to allow the default noise and
watchdog settings, and thus need to be configurable via DT
properties.

Also default settings to POR defaults on a reset, and register
distuber interrupts as noise since it prevents proper usage.

Cc: devicetree@vger.kernel.org
Signed-off-by: Matt Ranostay <matt.ranostay@konsulko.com>
Acked-by: Rob Herring <robh@kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2017-09-25 19:49:21 +01:00
Greg Kroah-Hartman 069f0e0c06 Round one of new device support, features and cleanup for IIO in the 4.15 cycle.
Note there is a misc driver drop in here given we have support
 in IIO and the feeling is no one will care.
 
 A large part of this series is a boiler plate removal series avoiding
 the need to explicitly provide THIS_MODULE in various locations.
 It's very dull but touches all drivers.
 
 New device support
 * ad5446
   - add ids to support compatible parts DAC081S101, DAC101S101,
     DAC121S101.
   - add the dac7512 id and drop the misc driver as feeling is no
     one is using it (was introduced for a board that is long obsolete)
 * mt6577
   - add bindings for mt2712 which is fully compatible with other
     supported parts.
 * st_pressure
   - add support for LPS33HW and LPS35HW with bindings (ids mostly).
 
 New features
 * ccs811
   - Add support for the data ready trigger.
 * mma8452
   - remove artifical restriction on supporting multiple event types
     at the same time.
 * tcs3472
   - support out of threshold events
 
 Core and tree wide cleanup
 * Use macro magic to remove the need to provide THIS_MODULE as part of
   struct iio_info or struct iio_trigger_ops.  This is similar to
   work done in a number of other subsystems (e.g. i2c, spi).
 
   All drivers are fixed and then the fields in these structures are
   removed.
 
   This will cause build failures for out of tree drivers and any
   new drivers that cross with this work going into the kernel.
 
   Note mostly done with a coccinelle patch, included in the series
   on the mailing list but not merged as the fields no longer exist
   in the structures so the any hold outs will cause a build failure.
 
 Cleanups
 * ads1015
   - avoid writing config register when it doesn't change.
   - add 10% to conversion wait time as it seems it is sometimes
     a little small.
 * ade7753
   - replace use of core mlock with a local lock.  This is part of a
     long term effort to make the use of mlock opaque and single
     purpose.
 * ade7759
   - expand the use of buf_lock to cover previous mlock cases.  This
     is a slightly nicer solution to the same issue as in ade7753.
 * cros_ec
   - drop an unused variable
 * inv_mpu6050
   - add a missing break in a switch for consistency - not actual
     bug,
   - make some local arrays static to save on object code size.
 * max5481
   - drop manual setting of the spi module owner as handled by the
     spi core.
 * max5487
   - drop manual setting of the spi module owner as handled by the
     spi core.
 * max9611
   - drop explicit setting of the i2c module owner as handled by
     the i2c core.
 * mcp320x
   - speed up reads on single channel devices,
   - drop unused of_device_id data elements,
   - document the struct mcp320x,
   - improve binding docs to reflect restrictions on spi setup and
     to make it explicit that the reference regulator is needed.
 * mma8452
   - symbolic to octal permissions,
   - unsigned to unsigned int.
 * st_lsm6dsx
   - avoid setting odr values multiple times,
   - drop config of LIR as it is only ever set to the existing
     defaults,
   - drop rounding configuration as it only ever matches the defaults.
 * ti-ads8688
   - drop manual setting of the spi module owner as handled by the
     spi core.
 * tsl2x7x
   - constify the i2c_device_id,
   - cleanup limit checks to avoid static checker warnings (and generally
     have nicer code).
 -----BEGIN PGP SIGNATURE-----
 
 iQJFBAABCAAvFiEEbilms4eEBlKRJoGxVIU0mcT0FogFAlnH4XkRHGppYzIzQGtl
 cm5lbC5vcmcACgkQVIU0mcT0Fogkaw//e3z+4TQT2Hn+550lBYUV8pBR5emDiSe3
 0QTG+ZS7Kh+fPYENLCXtW9ttZicmUSqkTQFvlMTjAxHyj9XzL7+BXS9UlNgVLsqX
 pn9KprPj31lrXpJOXMSgcdiqWMZLtCvprAJgnwfZt1GevS3WbCMmnnoaBuJV61jp
 w0VD+forukTGF7b0OMGB0d5mwtYS0bJYqXRRMPD+2bNeM4hqt5YM3+wHSqP35t3l
 MoaqKlbx7ZtKDF4zIa59nKNP7Ky7IByWogLZRlJ/vD/uKrACckPT22+KT8rX2TwA
 NpZb1Oy/KZBTl5D9iRjZADq4NaRJENFXJiG6GkjoGjrQhUqHaCinHWpLioqLGlRq
 qCPL2nRjqm4Qr7E8sxlwR1Ajlg0utBMY7Oflym/XJMMLF/ZE6HSrzyrxuVMG2EjV
 T7SVIncbfg6kyr/r4kKsAT3BUMV+TdO4sXm+JgphZBUqZLp0nFHnmjP7Rm2j2uWq
 +yLrSuF25RijrRj3sp28zg9dFWlRwRvZvcAx8kEGm1kMjMWr+Q10xTK9o/5LlFEw
 57sUm6qgmigPK8sahDtcdLIwaCPVvAYvJ0e4Mfw5UsPSlZmHmM1mLwjpwiXBZ5ig
 oxnJmTXsn5RcOGiW/mg0VCH26NkBx7H0fsRqQeq9wkxHLrm75vXroIn7YqRIg+Ad
 /Itu6x6fOIg=
 =ik5C
 -----END PGP SIGNATURE-----

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

Jonathan writes:

Round one of new device support, features and cleanup for IIO in the 4.15 cycle.

Note there is a misc driver drop in here given we have support
in IIO and the feeling is no one will care.

A large part of this series is a boiler plate removal series avoiding
the need to explicitly provide THIS_MODULE in various locations.
It's very dull but touches all drivers.

New device support
* ad5446
  - add ids to support compatible parts DAC081S101, DAC101S101,
    DAC121S101.
  - add the dac7512 id and drop the misc driver as feeling is no
    one is using it (was introduced for a board that is long obsolete)
* mt6577
  - add bindings for mt2712 which is fully compatible with other
    supported parts.
* st_pressure
  - add support for LPS33HW and LPS35HW with bindings (ids mostly).

New features
* ccs811
  - Add support for the data ready trigger.
* mma8452
  - remove artifical restriction on supporting multiple event types
    at the same time.
* tcs3472
  - support out of threshold events

Core and tree wide cleanup
* Use macro magic to remove the need to provide THIS_MODULE as part of
  struct iio_info or struct iio_trigger_ops.  This is similar to
  work done in a number of other subsystems (e.g. i2c, spi).

  All drivers are fixed and then the fields in these structures are
  removed.

  This will cause build failures for out of tree drivers and any
  new drivers that cross with this work going into the kernel.

  Note mostly done with a coccinelle patch, included in the series
  on the mailing list but not merged as the fields no longer exist
  in the structures so the any hold outs will cause a build failure.

Cleanups
* ads1015
  - avoid writing config register when it doesn't change.
  - add 10% to conversion wait time as it seems it is sometimes
    a little small.
* ade7753
  - replace use of core mlock with a local lock.  This is part of a
    long term effort to make the use of mlock opaque and single
    purpose.
* ade7759
  - expand the use of buf_lock to cover previous mlock cases.  This
    is a slightly nicer solution to the same issue as in ade7753.
* cros_ec
  - drop an unused variable
* inv_mpu6050
  - add a missing break in a switch for consistency - not actual
    bug,
  - make some local arrays static to save on object code size.
* max5481
  - drop manual setting of the spi module owner as handled by the
    spi core.
* max5487
  - drop manual setting of the spi module owner as handled by the
    spi core.
* max9611
  - drop explicit setting of the i2c module owner as handled by
    the i2c core.
* mcp320x
  - speed up reads on single channel devices,
  - drop unused of_device_id data elements,
  - document the struct mcp320x,
  - improve binding docs to reflect restrictions on spi setup and
    to make it explicit that the reference regulator is needed.
* mma8452
  - symbolic to octal permissions,
  - unsigned to unsigned int.
* st_lsm6dsx
  - avoid setting odr values multiple times,
  - drop config of LIR as it is only ever set to the existing
    defaults,
  - drop rounding configuration as it only ever matches the defaults.
* ti-ads8688
  - drop manual setting of the spi module owner as handled by the
    spi core.
* tsl2x7x
  - constify the i2c_device_id,
  - cleanup limit checks to avoid static checker warnings (and generally
    have nicer code).
2017-09-25 12:56:37 +02:00
Greg Kroah-Hartman b2e312061c First round of IIO fixes for the 4.14 cycle
Note this includes fixes from recent merge window.  As such the tree
 is based on top of a prior staging/staging-next tree.
 
 * iio core
   - return and error for a failed read_reg debugfs call rather than
     eating the error.
 * ad7192
   - Use the dedicated reset function in the ad_sigma_delta library
     instead of an spi transfer with the data on the stack which
     could cause problems with DMA.
 * ad7793
   - Implement a dedicate reset function in the ad_sigma_delta library
     and use it to correctly reset this part.
 * bme280
   - ctrl_reg write must occur after any register writes
   for updates to take effect.
 * mcp320x
   - negative voltage readout was broken.
   - Fix an oops on module unload due to spi_set_drvdata not being called
     in probe.
 * st_magn
   - Fix the data ready line configuration for the lis3mdl. It is not
     configurable so the st_magn core was assuming it didn't exist
     and so wasn't consuming interrupts resulting in an unhandled
     interrupt.
 * stm32-adc
   - off by one error on max channels checking.
 * stm32-timer
   - preset should not be buffered - reorganising register writes avoids
   this.
   - fix a corner case in which write preset goes wrong when a timer is
   used first as a trigger then as a counter with preset. Odd case but
   you never know.
 * ti-ads1015
   - Fix setting of comparator polarity by fixing bitfield definition.
 * twl4030
   - Error path handling fix to cleanup in event of regulator
     registration failure.
   - Disable the vusb3v1 regulator correctly in error handling
   - Don't paper over a regulator enable failure.
 -----BEGIN PGP SIGNATURE-----
 
 iQJFBAABCAAvFiEEbilms4eEBlKRJoGxVIU0mcT0FogFAlnH2PkRHGppYzIzQGtl
 cm5lbC5vcmcACgkQVIU0mcT0FoiNFw//XKT/CRq7R8Dg5vy4FT7NRw/SpSVH9u8M
 JsIISyAoh0jfOFJFkVv2Ll+Zs+SkbXJOPMUreaFJMnftSCkBdteT9D5kz5cYiUkO
 sFn58YEEqKCqQVJBEi0yM00HMxbpNKiNHXzo9WC8ZiUVRJqSigq1coznSqaZngRd
 yf4a9Z33jiH/NXalqy5Vb4CSn76UWpvvYJ11tuNxXqOldkyU4sm8bvsPWnBg1qG3
 YIuVZs83Rv1HW0t6ktYf3WwC2rBhKEM8st2fUCLkU+4+foDuqQBiFdWJzTcxe6Ru
 8za+q3ngOo7rRkLS8cSTsh8hbfKwIV0e3rQvsN3zqodqjPilw9uH3eybMYzLK/0I
 j9o12jaD1Ow7zQfiQnNnyJqDLddEt+f6GcrI/iYQPlTIQIhqDii4YInDyCrF4xbr
 i/8saOr5n4PsdHRovTUl2rrgiX+Jix6OmNLEtUdp1HWrc0XwbZ5L/1g6pXFL98QZ
 Kq8MwjNu+6x+66Hga/1fll19hZ/VMYGqxFtoP+6S28TS1bO9dXm6XNl5/U5Nh5mN
 J255UFCdFkBmJO9nP7tmbDscMCAbhc6AOHKxjUebuoNnyhyV+20W9S/gpzTIilnO
 Gv9D0z29zITc8Hpfhl2YKC6F00BuRAdPFJo05rSE/KoWX3bkPCiXFTfQ+aPwB72h
 bYT4oJeUoQg=
 =CcjQ
 -----END PGP SIGNATURE-----

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

Jonathan writes:

First round of IIO fixes for the 4.14 cycle

Note this includes fixes from recent merge window.  As such the tree
is based on top of a prior staging/staging-next tree.

* iio core
  - return and error for a failed read_reg debugfs call rather than
    eating the error.
* ad7192
  - Use the dedicated reset function in the ad_sigma_delta library
    instead of an spi transfer with the data on the stack which
    could cause problems with DMA.
* ad7793
  - Implement a dedicate reset function in the ad_sigma_delta library
    and use it to correctly reset this part.
* bme280
  - ctrl_reg write must occur after any register writes
  for updates to take effect.
* mcp320x
  - negative voltage readout was broken.
  - Fix an oops on module unload due to spi_set_drvdata not being called
    in probe.
* st_magn
  - Fix the data ready line configuration for the lis3mdl. It is not
    configurable so the st_magn core was assuming it didn't exist
    and so wasn't consuming interrupts resulting in an unhandled
    interrupt.
* stm32-adc
  - off by one error on max channels checking.
* stm32-timer
  - preset should not be buffered - reorganising register writes avoids
  this.
  - fix a corner case in which write preset goes wrong when a timer is
  used first as a trigger then as a counter with preset. Odd case but
  you never know.
* ti-ads1015
  - Fix setting of comparator polarity by fixing bitfield definition.
* twl4030
  - Error path handling fix to cleanup in event of regulator
    registration failure.
  - Disable the vusb3v1 regulator correctly in error handling
  - Don't paper over a regulator enable failure.
2017-09-25 10:58:22 +02:00
Matt Fornero 3d62c78a6e iio: core: Return error for failed read_reg
If an IIO device returns an error code for a read access via debugfs, it
is currently ignored by the IIO core (other than emitting an error
message). Instead, return this error code to user space, so upper layers
can detect it correctly.

Signed-off-by: Matt Fornero <matt.fornero@mathworks.com>
Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Cc: <Stable@vger.kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2017-09-24 16:58:32 +01:00
Dragos Bogdan 7ee3b7ebcb iio: ad7793: Fix the serial interface reset
The serial interface can be reset by writing 32 consecutive 1s to the device.
'ret' was initialized correctly but its value was overwritten when
ad7793_check_platform_data() was called. Since a dedicated reset function
is present now, it should be used instead.

Fixes: 2edb769d24 ("iio:ad7793: Add support for the ad7798 and ad7799")
Signed-off-by: Dragos Bogdan <dragos.bogdan@analog.com>
Acked-by: Lars-Peter Clausen <lars@metafoo.de>
Cc: <Stable@vger.kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2017-09-24 16:58:29 +01:00
Dragos Bogdan 7fc10de8d4 iio: ad_sigma_delta: Implement a dedicated reset function
Since most of the SD ADCs have the option of reseting the serial
interface by sending a number of SCLKs with CS = 0 and DIN = 1,
a dedicated function that can do this is usefull.

Needed for the patch:  iio: ad7793: Fix the serial interface reset
Signed-off-by: Dragos Bogdan <dragos.bogdan@analog.com>
Acked-by: Lars-Peter Clausen <lars@metafoo.de>
Cc: <Stable@vger.kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2017-09-24 16:58:21 +01:00
Colin Parker 4b1f0c31f9 IIO: BME280: Updates to Humidity readings need ctrl_reg write!
The ctrl_reg register needs to be written after any write to
the humidity registers. The value written to the ctrl_reg register
does not necessarily need to change, but a write operation must
occur.

The regmap_update_bits functions will not write to a register
if the register value matches the value to be written. This saves
unnecessary bus operations.  The change in this patch forces a bus
write during the chip_config operation by switching to
regmap_write_bits.

This will fix issues where the Humidity Sensor Oversampling bits
are not updated after initialization.

Signed-off-by: Colin Parker <colin.parker@aclima.io>
Acked-by: Andreas Klinger <ak@it-klinger.de>
Cc: <Stable@vger.kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2017-09-24 16:58:14 +01:00
Lukas Wunner e6f4794371 iio: adc: mcp320x: Fix readout of negative voltages
Commit f686a36b4b ("iio: adc: mcp320x: Add support for mcp3301")
returns a signed voltage from mcp320x_adc_conversion() but neglects that
the caller interprets a negative return value as failure.  Only mcp3301
(and the upcoming mcp3550/1/3) is affected as the other chips are
incapable of measuring negative voltages.

Fix and while at it, add mcp3301 to the list of supported chips at the
top of the file.

Fixes: f686a36b4b ("iio: adc: mcp320x: Add support for mcp3301")
Cc: Andrea Galbusera <gizero@gmail.com>
Signed-off-by: Lukas Wunner <lukas@wunner.de>
Cc: <Stable@vger.kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2017-09-24 16:58:10 +01:00
Lukas Wunner 0964e40947 iio: adc: mcp320x: Fix oops on module unload
The driver calls spi_get_drvdata() in its ->remove hook even though it
has never called spi_set_drvdata().  Stack trace for posterity:

Unable to handle kernel NULL pointer dereference at virtual address 00000220
Internal error: Oops: 5 [#1] SMP ARM
[<8072f564>] (mutex_lock) from [<7f1400d0>] (iio_device_unregister+0x24/0x7c [industrialio])
[<7f1400d0>] (iio_device_unregister [industrialio]) from [<7f15e020>] (mcp320x_remove+0x20/0x30 [mcp320x])
[<7f15e020>] (mcp320x_remove [mcp320x]) from [<8055a8cc>] (spi_drv_remove+0x2c/0x44)
[<8055a8cc>] (spi_drv_remove) from [<805087bc>] (__device_release_driver+0x98/0x134)
[<805087bc>] (__device_release_driver) from [<80509180>] (driver_detach+0xdc/0xe0)
[<80509180>] (driver_detach) from [<8050823c>] (bus_remove_driver+0x5c/0xb0)
[<8050823c>] (bus_remove_driver) from [<80509ab0>] (driver_unregister+0x38/0x58)
[<80509ab0>] (driver_unregister) from [<7f15e69c>] (mcp320x_driver_exit+0x14/0x1c [mcp320x])
[<7f15e69c>] (mcp320x_driver_exit [mcp320x]) from [<801a78d0>] (SyS_delete_module+0x184/0x1d0)
[<801a78d0>] (SyS_delete_module) from [<80108100>] (ret_fast_syscall+0x0/0x1c)

Fixes: f5ce4a7a92 ("iio: adc: add driver for MCP3204/08 12-bit ADC")
Cc: Oskar Andero <oskar.andero@gmail.com>
Signed-off-by: Lukas Wunner <lukas@wunner.de>
Cc: <Stable@vger.kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2017-09-24 16:58:03 +01:00
Lorenzo Bianconi a678684740 iio: imu: st_lsm6dsx: remove rounding configuration
Remove rounding configuration since it is enabled by default for the
FIFO output registers

Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@st.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2017-09-24 16:50:24 +01:00
Lorenzo Bianconi ac2561518b iio: imu: st_lsm6dsx: remove LIR configuration
Remove Latched Interrupt configuration since it is enabled by default
for FIFO watermark interrupt

Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@st.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2017-09-24 16:49:15 +01:00
Zhiyong Tao 4e74767e50 iio: adc: mt2712: Add compatible node for mt2712.
This commit adds mt2712 compatible node.

Signed-off-by: Zhiyong Tao <zhiyong.tao@mediatek.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2017-09-24 16:45:38 +01:00
Lorenzo Bianconi 5e3c3e3382 iio: imu: st_lsm6dsx: set sensor->odr value just in st_lsm6dsx_write_raw()
Update odr value in st_lsm6dsx_sensor data structure just in
st_lsm6dsx_write_raw() in order to avoid to set the same value
multiple times

Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@st.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2017-09-24 16:24:35 +01:00
Harinath Nampally f8b7b30fb4 iio: accel: mma8452: Fix code style warning for unsigned int declarations
Replace 'unsigned' with 'unsigned int'
to improve code readability.

Issue found by checkpatch.

Signed-off-by: Harinath Nampally <harinath922@gmail.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2017-09-24 14:11:47 +01:00
Harinath Nampally cd327b0047 iio: accel: mma8452: Fix code style warning
Replace symbolic permissions with octal permissions
to improve code readability.

Issue found by checkpatch.

Signed-off-by: Harinath Nampally <harinath922@gmail.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2017-09-24 14:11:24 +01:00
Fabrice Gasnier 4fb840c95f iio: adc: stm32: fix bad error check on max_channels
Fix a bad error check when counting 'st,adc-channels' array elements.
This is seen when all channels are in use simultaneously.

Fixes: 64ad7f643 ("iio: adc: stm32: introduce compatible data cfg")
Signed-off-by: Fabrice Gasnier <fabrice.gasnier@st.com>
Cc: <Stable@vger.kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2017-09-24 14:07:28 +01:00
Fabrice Gasnier b7a9776c1f iio: trigger: stm32-timer: fix a corner case to write preset
Balance timer start routine that sets ARPE: clear it in stop routine.
This fixes a corner case, when timer is used successively as trigger
(with sampling_frequency start/stop routines), then as a counter
(with preset).

Fixes: 93fbe91b55 ("iio: Add STM32 timer trigger driver")
Signed-off-by: Fabrice Gasnier <fabrice.gasnier@st.com>
Cc: <Stable@vger.kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2017-09-24 13:09:57 +01:00
Fabrice Gasnier 0a56eabc4e iio: trigger: stm32-timer: preset shouldn't be buffered
Currently, setting preset value (ARR) will update directly 'Auto reload
value' only on 1st write access. But then, ARPE is set. This makes
ARR a shadow register. Preset value should be updated upon each
write request: ensure ARPE is 0. This fixes successive writes to
preset attribute.

Fixes: 4adec7da05 ("iio: stm32 trigger: Add quadrature encoder device")
Signed-off-by: Fabrice Gasnier <fabrice.gasnier@st.com>
Cc: <Stable@vger.kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2017-09-24 13:08:48 +01:00
Christophe JAILLET 53063846af iio: adc: twl4030: Return an error if we can not enable the vusb3v1 regulator in 'twl4030_madc_probe()'
If we can not enable the regulator, go through the error handling path
instead of silently continuing.

Fixes: 7cc97d77ee ("iio: adc: twl4030: Fix ADC[3:6] readings")
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2017-09-24 13:04:07 +01:00
Christophe JAILLET 7f70be6e40 iio: adc: twl4030: Disable the vusb3v1 rugulator in the error handling path of 'twl4030_madc_probe()'
Commit 7cc97d77ee has introduced a call to 'regulator_disable()' in the
.remove function.
So we should also have such a call in the .probe function in case of
error after a successful 'regulator_enable()' call.

Add a new label for that and use it.

Fixes: 7cc97d77ee ("iio: adc: twl4030: Fix ADC[3:6] readings")
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Cc: <Stable@vger.kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2017-09-24 12:59:53 +01:00
Christophe JAILLET 245a396a9b iio: adc: twl4030: Fix an error handling path in 'twl4030_madc_probe()'
If 'devm_regulator_get()' fails, we should go through the existing error
handling path instead of returning directly, as done is all the other
error handling paths in this function.

Fixes: 7cc97d77ee ("iio: adc: twl4030: Fix ADC[3:6] readings")
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Cc: <Stable@vger.kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2017-09-24 12:57:32 +01:00
Paolo Cretaro 11d36e6a8e iio: cros_ec: Remove unused variable
Fix gcc warning:
cros_ec_baro.c:130:25: warning: variable ‘ec_device’ set but not used

Signed-off-by: Paolo Cretaro <paolocretaro@gmail.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2017-09-24 12:34:57 +01:00
Lukas Wunner 9c84c9101b iio: adc: mcp320x: Document struct mcp320x
Signed-off-by: Lukas Wunner <lukas@wunner.de>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2017-09-24 12:34:56 +01:00
Lukas Wunner 35ed9fbfd0 iio: adc: mcp320x: Drop unnecessary of_device_id attributes
The driver sets a .data pointer for each .compatible string but never
calls of_device_get_match_data().  Instead, ADC properties are looked up
with spi_get_device_id().  The .data pointer is therefore unnecessary,
so drop it.

Signed-off-by: Lukas Wunner <lukas@wunner.de>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2017-09-24 12:34:55 +01:00
Lukas Wunner ea9103186d iio: adc: mcp320x: Speed up readout of single-channel ADCs
Single-channel converters such as mcp3001, mcp3201, mcp3301 and the
upcoming mcp3550/1/3 lack a MOSI pin, so there's no need to call
mcp320x_channel_to_tx_data() for them.

Moreover, instead of calling spi_read() for these converters, which
generates an spi_message and spi_transfer on the stack on every readout,
it's more efficient to use the spi_message and spi_transfer[] included
in struct mcp320x (as we do for multi-channel ADCs), but initialize the
spi_message only with the receive transfer.

Signed-off-by: Lukas Wunner <lukas@wunner.de>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2017-09-24 12:34:54 +01:00
Narcisa Ana Maria Vasile f1f065d7ac iio: chemical: ccs811: Add support for data ready trigger
Add data ready trigger for hardware interrupts that signal
new, available measurement samples.

Cc: Daniel Baluta <daniel.baluta@gmail.com>
Cc: Alison Schofield <amsfield22@gmail.com>
Signed-off-by: Narcisa Ana Maria Vasile <narcisaanamaria12@gmail.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2017-09-24 12:34:36 +01:00
Harinath Nampally 605f72de13 iio: accel: mma8452: improvements to handle multiple events
This driver supports multiple devices like mma8653,
    mma8652, mma8452, mma8453 and fxls8471. Almost all
    these devices have more than one event.

    Current driver design hardcodes the event specific
    information, so only one event can be supported by this
    driver at any given time.
    Also current design doesn't have the flexibility to
    add more events.

    This patch improves by detaching the event related
    information from chip_info struct,and based on channel
    type and event direction the corresponding event
    configuration registers are picked dynamically.
    Hence both transient and freefall events can be
    handled in read/write callbacks.

    Changes are thoroughly tested on fxls8471 device on imx6UL
    Eval board using iio_event_monitor user space program.

    After this fix both Freefall and Transient events are
    handled by the driver without any conflicts.

Signed-off-by: Harinath Nampally <harinath922@gmail.com>
Reviewed-by: Martin Kepplinger <martink@posteo.de>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2017-09-13 17:49:58 +01:00
Lukas Wunner 49b3f87496 drivers: misc: ti_dac7512: Remove duplicate driver
The Texas Instruments DAC7512 has the exact same pinout, programming
interface and power-down modes as the Texas Instruments DAC121S101 and
Analog Devices AD5320, which are already supported by the IIO driver
ad5446.c.  Remove the duplicate misc driver.

This requires user space to migrate to the standardized IIO sysfs ABI.
(In other words, it needs to change a filename.)

The IIO driver supports the chip's features more fully, e.g. the ability
to power down the output or choose one of the available powerdown modes.

There is an oddity with the misc driver in that it initializes the SPI
slave to SPI_MODE_0, in contradiction to the datasheet which specifies
that data is latched in on the falling edge, implying that SPI_MODE_1
or SPI_MODE_2 must be used.  Another oddity is that Kconfig and the
MODULE_DESCRIPTION() claim the chip has 16-bit resolution although it
actually has 12-bit.

Datasheets:
http://www.ti.com/lit/ds/symlink/dac7512.pdf
http://www.ti.com/lit/ds/symlink/dac121s101.pdf
http://www.analog.com/media/en/technical-documentation/data-sheets/AD5320.pdf

Signed-off-by: Lukas Wunner <lukas@wunner.de>
Acked-by: Daniel Mack <daniel@zonque.org>
Acked-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2017-09-13 17:49:57 +01:00
Lukas Wunner 9cad3b9854 iio: dac: ad5446: Add IDs of compatible Texas Instruments chips
The Texas Instruments DAC081S101, DAC101S101 and DAC121S101 have the
exact same pinout, programming interface and power-down modes as the
AD5300, AD5310 and AD5320, respectively, and their datasheets declare
them "a direct replacement" for the Analog Devices chips.  This may
not be immediately obvious to a casual observer, so add them to the
supported modalias strings.

Datasheets:
http://www.ti.com/lit/ds/symlink/dac081s101.pdf
http://www.ti.com/lit/ds/symlink/dac101s101.pdf
http://www.ti.com/lit/ds/symlink/dac121s101.pdf
http://www.analog.com/media/en/technical-documentation/data-sheets/AD5300.pdf
http://www.analog.com/media/en/technical-documentation/data-sheets/AD5310.pdf
http://www.analog.com/media/en/technical-documentation/data-sheets/AD5320.pdf

Signed-off-by: Lukas Wunner <lukas@wunner.de>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2017-09-13 17:49:57 +01:00
Linus Torvalds 968c61f7da - New Drivers
- RK805 Power Management IC (PMIC)
    - ROHM BD9571MWV-M MFD Power Management IC (PMIC)
    - Texas Instruments TPS68470 Power Management IC (PMIC) & LEDs
 
  - New Device Support
    - Add support for HiSilicon Hi6421v530 to hi6421-pmic-core
    - Add support for X-Powers AXP806 to axp20x
    - Add support for X-Powers AXP813 to axp20x
    - Add support for Intel Sunrise Point LPSS to intel-lpss-pci
 
  - New Functionality
    - Amend API to provide register layout; atmel-smc
 
 - Fix-ups
    - DT re-work; omap, nokia
    - Header file location change {I2C => MFD}; dm355evm_msp, tps65010
    - Fix chip ID formatting issue(s); rk808
    - Optionally register touchscreen devices; da9052-core
    - Documentation improvements; twl-core
    - Constification; rtsx_pcr, ab8500-core, da9055-i2c, da9052-spi
    - Drop unnecessary static declaration; max8925-i2c
    - Kconfig changes (missing deps and remove module support)
    - Slim down oversized licence statement; hi6421-pmic-core
    - Use managed resources (devm_*); lp87565
    - Supply proper error checking/handling; t7l66xb
 
  - Bug Fixes
    - Fix counter duplication issue; da9052-core
    - Fix potential NULL deference issue; max8998
    - Leave SPI-NOR write-protection bit alone; lpc_ich
    - Ensure device is put into reset during suspend; intel-lpss
    - Correct register offset variable size; omap-usb-tll
 -----BEGIN PGP SIGNATURE-----
 
 iQIcBAABCAAGBQJZsP0YAAoJEFGvii+H/HdhrJUP/RB6BTCDMf3WCi5e6PN8IFST
 JspCcf4bwKVc5lDvORQglVRfBhKY/uSr7F9xlfXtHx8V60ZNo1VOQcyJBTKIz+IJ
 +FQQgM3lEMKIn3QCcu9lKSRomJx55YDnF5SrZ8FzkC8pGLrCYEru5HfqFqOTfPqq
 OH2wZSqiX4H/jYdfVzp3bgqXkDff/nSEGTeFankFkv4wRvLGRxlpVuqkRJcvEJA3
 d8N9MoBBxkZAtAn2j1H5cHyPx5NrBEM2gkXpDfdd+kJNnFzjL72xsXd6rp+N6rcm
 d20eL+1fyJVyvGhGiDOhFwqRAZEqvjPSI4k5kQdRk8IdioGgbmaI74eUbv+rGAKp
 P9QdR7n1ctYyVgwnawIwKTPMzdZo5+9kdagCtu8IBVT02zQqVSDKZM7dAYo2rJuF
 yw24jONcwHFrKA25n1pLJmMbJGHq83kqqw3q5kl17nyArvOOcyspCTODIL9iskhZ
 L0IoIMwQYEj/pnI+iuXl9bJ30v2FIJxyCzUR2u7OJnrH7G27rsoOL0WDqxbp3Dp9
 7tD+6OzMiyIEDxtcd74kjg7g9p5HCmcY3FiDWirmQuZIR3abSET4ap+cTYPdFqVZ
 widS5Pi4PP40ZFN6+4lbBHLlh6MgpHpig9M03kFAr1SyZnH8nf4TnCsFV+wYPyTb
 LR3cKpFeTY8IyFWaLoSg
 =TKIm
 -----END PGP SIGNATURE-----

Merge tag 'mfd-next-4.14' of git://git.kernel.org/pub/scm/linux/kernel/git/lee/mfd

Pull MFD updates from Lee Jones:
 "New Drivers
   - RK805 Power Management IC (PMIC)
   - ROHM BD9571MWV-M MFD Power Management IC (PMIC)
   - Texas Instruments TPS68470 Power Management IC (PMIC) & LEDs

  New Device Support:
   - Add support for HiSilicon Hi6421v530 to hi6421-pmic-core
   - Add support for X-Powers AXP806 to axp20x
   - Add support for X-Powers AXP813 to axp20x
   - Add support for Intel Sunrise Point LPSS to intel-lpss-pci

  New Functionality:
   - Amend API to provide register layout; atmel-smc

  Fix-ups:
   - DT re-work; omap, nokia
   - Header file location change {I2C => MFD}; dm355evm_msp, tps65010
   - Fix chip ID formatting issue(s); rk808
   - Optionally register touchscreen devices; da9052-core
   - Documentation improvements; twl-core
   - Constification; rtsx_pcr, ab8500-core, da9055-i2c, da9052-spi
   - Drop unnecessary static declaration; max8925-i2c
   - Kconfig changes (missing deps and remove module support)
   - Slim down oversized licence statement; hi6421-pmic-core
   - Use managed resources (devm_*); lp87565
   - Supply proper error checking/handling; t7l66xb

  Bug Fixes:
   - Fix counter duplication issue; da9052-core
   - Fix potential NULL deference issue; max8998
   - Leave SPI-NOR write-protection bit alone; lpc_ich
   - Ensure device is put into reset during suspend; intel-lpss
   - Correct register offset variable size; omap-usb-tll"

* tag 'mfd-next-4.14' of git://git.kernel.org/pub/scm/linux/kernel/git/lee/mfd: (61 commits)
  mfd: intel_soc_pmic: Differentiate between Bay and Cherry Trail CRC variants
  mfd: intel_soc_pmic: Export separate mfd-cell configs for BYT and CHT
  dt-bindings: mfd: Add bindings for ZII RAVE devices
  mfd: omap-usb-tll: Fix register offsets
  mfd: da9052: Constify spi_device_id
  mfd: intel-lpss: Put I2C and SPI controllers into reset state on suspend
  mfd: da9055: Constify i2c_device_id
  mfd: intel-lpss: Add missing PCI ID for Intel Sunrise Point LPSS devices
  mfd: t7l66xb: Handle return value of clk_prepare_enable
  mfd: Add ROHM BD9571MWV-M PMIC DT bindings
  mfd: intel_soc_pmic_chtwc: Turn Kconfig option into a bool
  mfd: lp87565: Convert to use devm_mfd_add_devices()
  mfd: Add support for TPS68470 device
  mfd: lpc_ich: Do not touch SPI-NOR write protection bit on Haswell/Broadwell
  mfd: syscon: atmel-smc: Add helper to retrieve register layout
  mfd: axp20x: Use correct platform device ID for many PEK
  dt-bindings: mfd: axp20x: Introduce bindings for AXP813
  mfd: axp20x: Add support for AXP813 PMIC
  dt-bindings: mfd: axp20x: Add AXP806 to supported list of chips
  mfd: Add ROHM BD9571MWV-M MFD PMIC driver
  ...
2017-09-07 13:51:13 -07:00
Linus Torvalds b42a362e6d Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jikos/hid
Pull HID update from Jiri Kosina:

 - Wacom driver fixes/updates (device name generation improvements,
   touch ring status support) from Jason Gerecke

 - T100 touchpad support from Hans de Goede

 - support for batteries driven by HID input reports, from Dmitry
   Torokhov

 - Arnd pointed out that driver_lock semaphore is superfluous, as driver
   core already provides all the necessary concurency protection.
   Removal patch from Binoy Jayan

 - logical minimum numbering improvements in sensor-hub driver, from
   Srinivas Pandruvada

 - support for Microsoft Win8 Wireless Radio Controls extensions from
   João Paulo Rechi Vita

 - assorted small fixes and device ID additions

* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jikos/hid: (28 commits)
  HID: prodikeys: constify snd_rawmidi_ops structures
  HID: sensor: constify platform_device_id
  HID: input: throttle battery uevents
  HID: usbmouse: constify usb_device_id and fix space before '[' error
  HID: usbkbd: constify usb_device_id and fix space before '[' error.
  HID: hid-sensor-hub: Force logical minimum to 1 for power and report state
  HID: wacom: Do not completely map WACOM_HID_WD_TOUCHRINGSTATUS usage
  HID: asus: Add T100CHI bluetooth keyboard dock touchpad support
  HID: ntrig: constify attribute_group structures.
  HID: logitech-hidpp: constify attribute_group structures.
  HID: sensor: constify attribute_group structures.
  HID: multitouch: constify attribute_group structures.
  HID: multitouch: use proper symbolic constant for 0xff310076 application
  HID: multitouch: Support Asus T304UA media keys
  HID: multitouch: Support HID_GD_WIRELESS_RADIO_CTLS
  HID: input: optionally use device id in battery name
  HID: input: map digitizer battery usage
  HID: Remove the semaphore driver_lock
  HID: wacom: add USB_HID dependency
  HID: add ALWAYS_POLL quirk for Logitech 0xc077
  ...
2017-09-05 11:54:41 -07:00
Lee Jones 3f979bf8f5 Merge branches 'ib-mfd-arm-i2c-4.14', 'ib-mfd-arm-usb-video-4.14', 'ib-mfd-hwmon-4.14', 'ib-mfd-iio-pwm-4.14', 'ib-mfd-input-rtc-4.14', 'ib-mfd-many-4.14' and 'ib-mfd-pinctrl-regulator-4.14' into ibs-for-mfd-merged 2017-09-05 08:45:36 +01:00
Fabrice Gasnier f0b638a7f6 iio: adc: stm32: add support for lptimer triggers
STM32 ADC supports hardware triggers like STM32 Low-Power Timer.
For instance, STM32H7 ADC may be triggered by instances 1, 2 or 3.
Add hardware triggered mode so Low-Power Timer Trigger driver can
validate device.

Signed-off-by: Fabrice Gasnier <fabrice.gasnier@st.com>
Acked-by: Jonathan Cameron <jic23@kernel.org>
Signed-off-by: Lee Jones <lee.jones@linaro.org>
2017-09-04 14:49:34 +01:00
Fabrice Gasnier d8958824cf iio: counter: Add support for STM32 LPTimer
Add support for STM32 Low-Power Timer, that can be used as counter
or quadrature encoder.

Signed-off-by: Fabrice Gasnier <fabrice.gasnier@st.com>
Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Signed-off-by: Lee Jones <lee.jones@linaro.org>
2017-09-04 14:49:30 +01:00
Fabrice Gasnier b01ced2b50 iio: trigger: Add STM32 LPTimer trigger driver
Add support for LPTIMx_OUT triggers that can be found on some STM32
devices. These triggers can be used then by ADC or DAC.
Typical usage is to configure LPTimer as PWM output (via pwm-stm32-lp)
and have synchronised analog conversions with these triggers.

Signed-off-by: Fabrice Gasnier <fabrice.gasnier@st.com>
Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Signed-off-by: Lee Jones <lee.jones@linaro.org>
2017-09-04 14:49:23 +01:00
Wolfram Sang a205425658 mfd: twl: Move header file out of I2C realm
include/linux/i2c is not for client devices. Move the header file to a
more appropriate location.

Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Acked-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
Acked-by: Mark Brown <broonie@kernel.org>
Acked-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
Acked-by: Jonathan Cameron <jic23@kernel.org>
Acked-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Acked-by: Kishon Vijay Abraham I <kishon@ti.com>
Acked-by: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>
Acked-by: Thierry Reding <thierry.reding@gmail.com>
Acked-by: Tony Lindgren <tony@atomide.com>
Acked-by: Daniel Thompson <daniel.thompson@linaro.org>
Acked-by: Linus Walleij <linus.walleij@linaro.org>
Acked-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Lee Jones <lee.jones@linaro.org>
2017-09-04 14:41:02 +01:00
Lorenzo Bianconi b954d77aa9 iio: pressure: add support to LPS33HW and LPS35HW
add support to STMicroelectronics LPS33HW and LPS35HW pressure sensors
to st_pressure framework

http://www.st.com/resource/en/datasheet/lps33hw.pdf
http://www.st.com/resource/en/datasheet/lps35hw.pdf
Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@st.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2017-09-03 18:10:33 +01:00
Colin Ian King 2711e642ba iio: imu: inv_mpu6050: make arrays hz and d static
Don't populate the arrays on the stack, instead make them static.
Makes the object code smaller by 135 bytes:

Before:
   text	   data	    bss	    dec	    hex	filename
  15135	   4240	    128	  19503	   4c2f	inv_mpu_core.o

After:
   text	   data	    bss	    dec	    hex	filename
  14840	   4400	    128	  19368	   4ba8	inv_mpu_core.o

Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2017-09-03 18:10:32 +01:00
Ladislav Michl fe895ac88b iio: adc: ti-ads1015: add 10% to conversion wait time
As user's guide "ADS1015EVM, ADS1115EVM, ADS1015EVM-PDK, ADS1115EVM-PDK
User Guide (Rev. B)" (http://www.ti.com/lit/ug/sbau157b/sbau157b.pdf)
states at page 16:
"Note that both the ADS1115 and ADS1015 have internal clocks with a ±10%
accuracy. If performing FFT tests, frequencies may appear to be incorrect
as a result of this tolerance range.", add those 10% to converion wait
time.

Cc: Daniel Baluta <daniel.baluta@gmail.com>
Cc: Jonathan Cameron <jic23@kernel.org>
Signed-off-by: Ladislav Michl <ladis@linux-mips.org>
Reviewed-by: Akinobu Mita <akinobu.mita@gmail.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2017-09-03 18:10:31 +01:00
Ladislav Michl d1c11dc27e iio: adc: ti-ads1015: write config register only on change
There is no point writing ADS1015_CFG_REG when configuration
didn't change. Avoid that.

Cc: Daniel Baluta <daniel.baluta@gmail.com>
Cc: Jonathan Cameron <jic23@kernel.org>
Signed-off-by: Ladislav Michl <ladis@linux-mips.org>
Reviewed-by: Akinobu Mita <akinobu.mita@gmail.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2017-09-03 18:10:31 +01:00
Gustavo A. R. Silva 4e57562b48 iio: imu: inv_mpu6050: fix missing break in switch
Add missing break statement to prevent the code for case
IIO_CHAN_INFO_CALIBBIAS falling through to the default case.

Also, add a break to the default case for the switch within
case IIO_CHAN_INFO_CALIBBIAS.

Addresses-Coverity-ID: 1357377
Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2017-09-03 18:10:30 +01:00
Gustavo A. R. Silva dd92d5ea20 iio: multiplexer: add NULL check on devm_kzalloc() and devm_kmemdup() return values
Check return values from call to devm_kzalloc() and devm_kmemup()
in order to prevent a NULL pointer dereference.

This issue was detected using Coccinelle and the following semantic patch:

@@
expression x;
identifier fld;
@@

* x = devm_kzalloc(...);
   ... when != x == NULL
   x->fld

Fixes: 7ba9df54b0 ("iio: multiplexer: new iio category and iio-mux driver")
Signed-off-by: Gustavo A. R. Silva <garsilva@embeddedor.com>
Acked-by: Peter Rosin <peda@axentia.se>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2017-09-03 18:10:29 +01:00
Akinobu Mita 9d2f715d59 iio: light: tcs3472: support out-of-threshold events
The TCS3472 device provides interrupt signal for out-of-threshold events
with persistence filter.

This change adds interrupt support for the threshold events and enables
to configure the period of time by persistence filter.

Cc: Peter Meerwald <pmeerw@pmeerw.net>
Cc: Jonathan Cameron <jic23@kernel.org>
Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2017-09-03 18:10:29 +01:00
Jonathan Cameron 7090992708 iio:potentiometer:max5487: Drop explicit setting of module owner
The SPI core has handled this for some time.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Reviewed-by: Lars-Peter Clausen <lars@metafoo.de>
2017-09-03 18:10:27 +01:00
Jonathan Cameron 6ec7ffd6e9 iio:potentiometer:max5481 drop explicit setting of the owner module.
This has been handled by the spi core for some time.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Reviewed-by: Lars-Peter Clausen <lars@metafoo.de>
2017-09-03 18:10:26 +01:00
Jonathan Cameron aacbd095b4 iio:adc:ti-ads8688: Drop manual setting of the driver owner field.
This has been handled by the spi core for some time now.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Cc: Sean Nyekjaer <sean.nyekjaer@prevas.dk>
Reviewed-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2017-09-03 18:10:25 +01:00
Jonathan Cameron a8375d704d iio:adc:max9611: Drop explicit setting of the i2c module owner.
This has been handled by the i2c core for some time.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Reviewed-by: Lars-Peter Clausen <lars@metafoo.de>
2017-09-03 18:10:25 +01:00
Jonathan Cameron 873f389433 iio: multiplexer: drop the manual assignment of THIS_MODULE
This is now done through some macro magic by the core.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Acked-by: Peter Rosin <peda@axentia.se>
2017-09-03 18:10:24 +01:00
Lorenzo Bianconi c65e3d6ef4 iio: magnetometer: st_magn: fix drdy line configuration for LIS3MDL
Data-ready line in LIS3MDL is routed to drdy pin and it is not possible
to select a different INT pin. st_sensors_set_dataready_irq() assumes
that if drdy int address is not exported in register map, irq trigger
is not supported by the sensor and hw_irq_trigger is always false.
Based on this configuration st_sensors_irq_thread does not consume
generated interrupt causing an unhandled irq.
Fix this taking into account status register address in
st_sensors_set_dataready_irq()

Fixes: 90efe05562 (iio: st_sensors: harden interrupt handling)
Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@st.com>
Cc: <Stable@vger.kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2017-09-03 17:39:39 +01:00
Akinobu Mita 3af75db12e iio: adc: ti-ads1015: fix comparator polarity setting
The comparator polarity field in config register is not correctly
initialized as per the interrupt trigger setting.  Because the bitfield
definision is wrong and bit shifting is missed.

Fixes: d9f39babd8 ("iio: adc: ti-ads1015: add threshold event support")
Cc: Daniel Baluta <daniel.baluta@gmail.com>
Cc: Jonathan Cameron <jic23@kernel.org>
Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2017-09-03 17:09:32 +01:00
Greg Kroah-Hartman 8439a69e72 Merge 4.13-rc7 into staging-next
We want the staging and iio fixes in here to handle the merge issues.

Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-08-28 15:26:48 +02:00
Jonathan Cameron 38ebbf689e iio:triggers: drop assign iio_info.driver_module and iio_trigger_ops.owner
The equivalent of both of these are now done via macro magic when
the relevant register calls are made.  The actual structure
elements will shortly go away.

Note that stm32-timer-trigger has expanded rather beyond triggers
(to include encoder input counting for example) and hence has an
iio_info structure.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Reviewed-by: Lars-Peter Clausen <lars@metafoo.de>
2017-08-22 22:14:52 +01:00
Jonathan Cameron 5e42916ad9 iio:temperature: drop assignment of iio_info.driver_module
The equivalent of this is now done via macro magic when
the relevant register call is made.  The actual structure
elements will shortly go away.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Reviewed-by: Lars-Peter Clausen <lars@metafoo.de>
2017-08-22 22:14:52 +01:00
Jonathan Cameron a62e256b14 iio:proximity: drop assign iio_info.driver_module and iio_trigger_ops.owner
The equivalent of both of these are now done via macro magic when
the relevant register calls are made.  The actual structure
elements will shortly go away.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Reviewed-by: Lars-Peter Clausen <lars@metafoo.de>
2017-08-22 22:14:51 +01:00
Jonathan Cameron 6a15fef2cb iio:pressure: drop assign iio_info.driver_module and iio_trigger_ops.owner
The equivalent of both of these are now done via macro magic when
the relevant register calls are made.  The actual structure
elements will shortly go away.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Reviewed-by: Lars-Peter Clausen <lars@metafoo.de>
2017-08-22 21:35:27 +01:00
Jonathan Cameron c64fdf0fe9 iio:potentiostat:lmp91000 drop assign iio_info.driver_module and iio_trigger_ops.owner
The equivalent of both of these are now done via macro magic when
the relevant register calls are made.  The actual structure
elements will shortly go away.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Reviewed-by: Lars-Peter Clausen <lars@metafoo.de>
2017-08-22 21:34:48 +01:00
Jonathan Cameron 6d9d020da5 iio:dpot: drop assign iio_info.driver_module
The equivalent of this is now done via macro magic when
the relevant register call is made.  The actual structure
elements will shortly go away.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Reviewed-by: Lars-Peter Clausen <lars@metafoo.de>
2017-08-22 21:34:10 +01:00
Jonathan Cameron 1b449a7258 iio:orientation: drop assign iio_info.driver_module
The equivalent of this is now done via macro magic when
the relevant register call is made.  The actual structure
elements will shortly go away.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Reviewed-by: Lars-Peter Clausen <lars@metafoo.de>
2017-08-22 21:33:36 +01:00
Jonathan Cameron 7f307262af iio:magnetometer: drop assign iio_info.driver_module and iio_trigger_ops.owner
The equivalent of both of these are now done via macro magic when
the relevant register calls are made.  The actual structure
elements will shortly go away.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Reviewed-by: Lars-Peter Clausen <lars@metafoo.de>
2017-08-22 21:32:52 +01:00
Jonathan Cameron 4166b47c2b iio:light: drop assign iio_info.driver_module and iio_trigger_ops.owner
The equivalent of both of these are now done via macro magic when
the relevant register calls are made.  The actual structure
elements will shortly go away.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Reviewed-by: Lars-Peter Clausen <lars@metafoo.de>
2017-08-22 21:31:57 +01:00
Jonathan Cameron 79978a9bd0 iio:imu: drop assign iio_info.driver_module and iio_trigger_ops.owner
The equivalent of both of these are now done via macro magic when
the relevant register calls are made.  The actual structure
elements will shortly go away.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Reviewed-by: Lars-Peter Clausen <lars@metafoo.de>
2017-08-22 21:31:01 +01:00
Jonathan Cameron 13a8c6c2a1 iio:humidity: drop assign iio_info.driver_module and iio_trigger_ops.owner
The equivalent of both of these are now done via macro magic when
the relevant register calls are made.  The actual structure
elements will shortly go away.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Reviewed-by: Lars-Peter Clausen <lars@metafoo.de>
2017-08-22 21:30:20 +01:00
Jonathan Cameron 73bba67096 iio:health: drop assign iio_info.driver_module and iio_trigger_ops.owner
The equivalent of both of these are now done via macro magic when
the relevant register calls are made.  The actual structure
elements will shortly go away.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Reviewed-by: Lars-Peter Clausen <lars@metafoo.de>
2017-08-22 21:29:44 +01:00
Jonathan Cameron 227e8ef81d iio:gyro: drop assign iio_info.driver_module and iio_trigger_ops.owner
The equivalent of both of these are now done via macro magic when
the relevant register calls are made.  The actual structure
elements will shortly go away.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Reviewed-by: Lars-Peter Clausen <lars@metafoo.de>
2017-08-22 21:28:56 +01:00
Jonathan Cameron 3b3ec60341 iio:frequency: drop assign iio_info.driver_module
The equivalent is now done via macro magic when
the relevant register call is made.  The actual structure
element will shortly go away.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Reviewed-by: Lars-Peter Clausen <lars@metafoo.de>
2017-08-22 21:28:20 +01:00
Jonathan Cameron 4403a39829 iio:dummy: drop assignment of iio_info.driver_module
The equivalent is now done via macro magic when
the relevant register call is made.  The actual structure
element will shortly go away.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Reviewed-by: Lars-Peter Clausen <lars@metafoo.de>
2017-08-22 21:27:45 +01:00
Jonathan Cameron ea9e3f3588 iio:dac: drop assignment of iio_info.driver_module
The equivalent of this is now done via macro magic when
the relevant register call is made.  The actual structure
element will shortly go away.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Reviewed-by: Lars-Peter Clausen <lars@metafoo.de>
2017-08-22 21:26:54 +01:00
Jonathan Cameron d5b531a8bc iio:counter:104-quad-8 drop assign iio_info.driver_module
The equivalent is now done via macro magic when
the relevant register calls are made.  The actual structure
elements will shortly go away.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Reviewed-by: Lars-Peter Clausen <lars@metafoo.de>
2017-08-22 21:26:11 +01:00
Jonathan Cameron d177f6af48 iio:common: drop assign iio_info.driver_module and iio_trigger_ops.owner
The equivalent of both of these are now done via macro magic when
the relevant register calls are made.  The actual structure
elements will shortly go away.

Clearly this set jumps across multiple areas, but inherently it
can't be grouped like the other sets in this series so I've done
all the stuff in the common directory together.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Reviewed-by: Lars-Peter Clausen <lars@metafoo.de>
2017-08-22 21:25:33 +01:00