platform/kernel/linux-starfive.git
2 years agoiio: accel: mma7455: Make mma7455_core_remove() return void
Uwe Kleine-König [Wed, 13 Oct 2021 20:32:13 +0000 (22:32 +0200)]
iio: accel: mma7455: Make mma7455_core_remove() return void

Up to now mma7455_core_remove() returns zero unconditionally. Make it
return void instead which makes it easier to see in the callers that
there is no error to handle.

Also the return value of i2c and spi remove callbacks is ignored anyway.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Reviewed-by: Alexandru Ardelean <ardeleanalex@gmail.com>
Link: https://lore.kernel.org/r/20211013203223.2694577-6-u.kleine-koenig@pengutronix.de
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2 years agoiio: accel: kxsd9: Make kxsd9_common_remove() return void
Uwe Kleine-König [Wed, 13 Oct 2021 20:32:12 +0000 (22:32 +0200)]
iio: accel: kxsd9: Make kxsd9_common_remove() return void

Up to now kxsd9_common_remove() returns zero unconditionally. Make it
return void instead which makes it easier to see in the callers that
there is no error to handle.

Also the return value of i2c and spi remove callbacks is ignored anyway.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Reviewed-by: Alexandru Ardelean <ardeleanalex@gmail.com>
Link: https://lore.kernel.org/r/20211013203223.2694577-5-u.kleine-koenig@pengutronix.de
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2 years agoiio: accel: bmi088: Make bmi088_accel_core_remove() return void
Uwe Kleine-König [Wed, 13 Oct 2021 20:32:11 +0000 (22:32 +0200)]
iio: accel: bmi088: Make bmi088_accel_core_remove() return void

Up to now bmi088_accel_core_remove() returns zero unconditionally. Make
it return void instead which makes it easier to see in the callers that
there is no error to handle.

Also the return value of spi remove callbacks is ignored anyway.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Reviewed-by: Alexandru Ardelean <ardeleanalex@gmail.com>
Link: https://lore.kernel.org/r/20211013203223.2694577-4-u.kleine-koenig@pengutronix.de
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2 years agoiio: accel: bmc150: Make bmc150_accel_core_remove() return void
Uwe Kleine-König [Wed, 13 Oct 2021 20:32:10 +0000 (22:32 +0200)]
iio: accel: bmc150: Make bmc150_accel_core_remove() return void

Up to now bmc150_accel_core_remove() returns zero unconditionally. Make
it return void instead which makes it easier to see in the callers that
there is no error to handle.

Also the return value of i2c and spi remove callbacks is ignored anyway.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Reviewed-by: Alexandru Ardelean <ardeleanalex@gmail.com>
Link: https://lore.kernel.org/r/20211013203223.2694577-3-u.kleine-koenig@pengutronix.de
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2 years agoiio: accel: bma400: Make bma400_remove() return void
Uwe Kleine-König [Wed, 13 Oct 2021 20:32:09 +0000 (22:32 +0200)]
iio: accel: bma400: Make bma400_remove() return void

When an i2c or spi driver's remove function returns a non-zero error
code nothing happens apart from emitting a generic error message. Make
this error message more device specific and return zero instead in the
remove callbacks. As the return value of bma400_remove() is unused then,
change the function to not yield a return value.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Reviewed-by: Alexandru Ardelean <ardeleanalex@gmail.com>
Link: https://lore.kernel.org/r/20211013203223.2694577-2-u.kleine-koenig@pengutronix.de
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2 years agodrivers:iio:dac:ad5766.c: Add trigger buffer
Mihail Chindris [Thu, 7 Oct 2021 08:00:37 +0000 (08:00 +0000)]
drivers:iio:dac:ad5766.c: Add trigger buffer

This chip is able to generate waveform and using an
with the output trigger buffer will be easy to generate one.

Signed-off-by: Mihail Chindris <mihail.chindris@analog.com>
Reviewed-by: Alexandru Ardelean <ardeleanalex@gmail.com>
Link: https://lore.kernel.org/r/20211007080035.2531-7-mihail.chindris@analog.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2 years agoiio: triggered-buffer: extend support to configure output buffers
Alexandru Ardelean [Thu, 7 Oct 2021 08:00:32 +0000 (08:00 +0000)]
iio: triggered-buffer: extend support to configure output buffers

Now that output (kfifo) buffers are supported, we need to extend the
{devm_}iio_triggered_buffer_setup_ext() parameter list to take a direction
parameter.

This allows us to attach an output triggered buffer to a DAC device.
Unfortunately it's a bit difficult to add another macro to avoid changing 5
drivers where {devm_}iio_triggered_buffer_setup_ext() is used.
Well, it's doable, but may not be worth the trouble vs just updating all
these 5 drivers.

Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
Signed-off-by: Mihail Chindris <mihail.chindris@analog.com>
Link: https://lore.kernel.org/r/20211007080035.2531-4-mihail.chindris@analog.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2 years agoiio: kfifo-buffer: Add output buffer support
Lars-Peter Clausen [Thu, 7 Oct 2021 08:00:31 +0000 (08:00 +0000)]
iio: kfifo-buffer: Add output buffer support

Add output buffer support to the kfifo buffer implementation.

The implementation is straight forward and mostly just wraps the kfifo
API to provide the required operations.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
Signed-off-by: Mihail Chindris <mihail.chindris@analog.com>
Link: https://lore.kernel.org/r/20211007080035.2531-3-mihail.chindris@analog.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2 years agoiio: Add output buffer support
Mihail Chindris [Thu, 7 Oct 2021 08:00:30 +0000 (08:00 +0000)]
iio: Add output buffer support

Currently IIO only supports buffer mode for capture devices like ADCs. Add
support for buffered mode for output devices like DACs.

The output buffer implementation is analogous to the input buffer
implementation. Instead of using read() to get data from the buffer write()
is used to copy data into the buffer.

poll() with POLLOUT will wakeup if there is space available.

Drivers can remove data from a buffer using iio_pop_from_buffer(), the
function can e.g. called from a trigger handler to write the data to
hardware.

A buffer can only be either a output buffer or an input, but not both. So,
for a device that has an ADC and DAC path, this will mean 2 IIO buffers
(one for each direction).

The direction of the buffer is decided by the new direction field of the
iio_buffer struct and should be set after allocating and before registering
it.

Co-developed-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Co-developed-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
Signed-off-by: Mihail Chindris <mihail.chindris@analog.com>
Link: https://lore.kernel.org/r/20211007080035.2531-2-mihail.chindris@analog.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2 years agoiio: documentation: Document scd4x calibration use
Roan van Dijk [Fri, 8 Oct 2021 10:17:06 +0000 (12:17 +0200)]
iio: documentation: Document scd4x calibration use

Add entries from Documentation/ABI/testing/sysfs-bus-iio-scd30
to Documentation/ABI/testing/sysfs-bus-iio. The attributes of the scd4x
and scd30 are common.

Remove Documentation/ABI/testing/sysfs-bus-iio-scd30.

Signed-off-by: Roan van Dijk <roan@protonic.nl>
Link: https://lore.kernel.org/r/20211008101706.755942-5-roan@protonic.nl
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2 years agodrivers: iio: chemical: Add support for Sensirion SCD4x CO2 sensor
Roan van Dijk [Fri, 8 Oct 2021 10:17:05 +0000 (12:17 +0200)]
drivers: iio: chemical: Add support for Sensirion SCD4x CO2 sensor

This is a driver for the SCD4x CO2 sensor from Sensirion. The sensor is
able to measure CO2 concentration, temperature and relative humdity.
The sensor uses a photoacoustic principle for measuring CO2 concentration.
An I2C interface is supported by this driver in order to communicate with
the sensor.

Signed-off-by: Roan van Dijk <roan@protonic.nl>
Link: https://lore.kernel.org/r/20211008101706.755942-4-roan@protonic.nl
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2 years agoMAINTAINERS: Add myself as maintainer of the scd4x driver
Roan van Dijk [Fri, 8 Oct 2021 10:17:04 +0000 (12:17 +0200)]
MAINTAINERS: Add myself as maintainer of the scd4x driver

Signed-off-by: Roan van Dijk <roan@protonic.nl>
Link: https://lore.kernel.org/r/20211008101706.755942-3-roan@protonic.nl
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2 years agodt-bindings: iio: chemical: sensirion,scd4x: Add yaml description
Roan van Dijk [Fri, 8 Oct 2021 10:17:03 +0000 (12:17 +0200)]
dt-bindings: iio: chemical: sensirion,scd4x: Add yaml description

Add documentation for the SCD4x carbon dioxide sensor from Sensirion.

Reviewed-by: Rob Herring <robh@kernel.org>
Signed-off-by: Roan van Dijk <roan@protonic.nl>
Link: https://lore.kernel.org/r/20211008101706.755942-2-roan@protonic.nl
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2 years agoiio: light: noa1305: Make use of the helper function dev_err_probe()
Cai Huoqing [Tue, 28 Sep 2021 01:41:55 +0000 (09:41 +0800)]
iio: light: noa1305: Make use of the helper function dev_err_probe()

When possible use dev_err_probe help to properly deal with the
PROBE_DEFER error, the benefit is that DEFER issue will be logged
in the devices_deferred debugfs file.
Using dev_err_probe() can reduce code size, and the error value
gets printed.

Signed-off-by: Cai Huoqing <caihuoqing@baidu.com>
Link: https://lore.kernel.org/r/20210928014156.1491-4-caihuoqing@baidu.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2 years agoiio: light: cm36651: Make use of the helper function dev_err_probe()
Cai Huoqing [Tue, 28 Sep 2021 01:41:53 +0000 (09:41 +0800)]
iio: light: cm36651: Make use of the helper function dev_err_probe()

When possible use dev_err_probe help to properly deal with the
PROBE_DEFER error, the benefit is that DEFER issue will be logged
in the devices_deferred debugfs file.
Using dev_err_probe() can reduce code size, and the error value
gets printed.

Signed-off-by: Cai Huoqing <caihuoqing@baidu.com>
Link: https://lore.kernel.org/r/20210928014156.1491-2-caihuoqing@baidu.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2 years agoiio: health: afe4404: Make use of the helper function dev_err_probe()
Cai Huoqing [Tue, 28 Sep 2021 01:44:02 +0000 (09:44 +0800)]
iio: health: afe4404: Make use of the helper function dev_err_probe()

When possible use dev_err_probe help to properly deal with the
PROBE_DEFER error, the benefit is that DEFER issue will be logged
in the devices_deferred debugfs file.
Using dev_err_probe() can reduce code size, and the error value
gets printed.

Signed-off-by: Cai Huoqing <caihuoqing@baidu.com>
Link: https://lore.kernel.org/r/20210928014403.1563-2-caihuoqing@baidu.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2 years agoiio: health: afe4403: Make use of the helper function dev_err_probe()
Cai Huoqing [Tue, 28 Sep 2021 01:44:01 +0000 (09:44 +0800)]
iio: health: afe4403: Make use of the helper function dev_err_probe()

When possible use dev_err_probe help to properly deal with the
PROBE_DEFER error, the benefit is that DEFER issue will be logged
in the devices_deferred debugfs file.
Using dev_err_probe() can reduce code size, and the error value
gets printed.

Signed-off-by: Cai Huoqing <caihuoqing@baidu.com>
Link: https://lore.kernel.org/r/20210928014403.1563-1-caihuoqing@baidu.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2 years agoiio: st_lsm9ds0: Make use of the helper function dev_err_probe()
Cai Huoqing [Tue, 28 Sep 2021 01:40:54 +0000 (09:40 +0800)]
iio: st_lsm9ds0: Make use of the helper function dev_err_probe()

When possible use dev_err_probe help to properly deal with the
PROBE_DEFER error, the benefit is that DEFER issue will be logged
in the devices_deferred debugfs file.
Using dev_err_probe() can reduce code size, and the error value
gets printed.

Signed-off-by: Cai Huoqing <caihuoqing@baidu.com>
Link: https://lore.kernel.org/r/20210928014055.1431-2-caihuoqing@baidu.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2 years agoiio: st_sensors: Make use of the helper function dev_err_probe()
Cai Huoqing [Tue, 28 Sep 2021 01:40:53 +0000 (09:40 +0800)]
iio: st_sensors: Make use of the helper function dev_err_probe()

When possible use dev_err_probe help to properly deal with the
PROBE_DEFER error, the benefit is that DEFER issue will be logged
in the devices_deferred debugfs file.
Using dev_err_probe() can reduce code size, and the error value
gets printed.

Signed-off-by: Cai Huoqing <caihuoqing@baidu.com>
Link: https://lore.kernel.org/r/20210928014055.1431-1-caihuoqing@baidu.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2 years agoiio: dac: ti-dac7311: Make use of the helper function dev_err_probe()
Cai Huoqing [Tue, 28 Sep 2021 01:39:01 +0000 (09:39 +0800)]
iio: dac: ti-dac7311: Make use of the helper function dev_err_probe()

When possible use dev_err_probe help to properly deal with the
PROBE_DEFER error, the benefit is that DEFER issue will be logged
in the devices_deferred debugfs file.
Using dev_err_probe() can reduce code size, and the error value
gets printed.

Signed-off-by: Cai Huoqing <caihuoqing@baidu.com>
Link: https://lore.kernel.org/r/20210928013902.1341-8-caihuoqing@baidu.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2 years agoiio: dac: stm32-dac: Make use of the helper function dev_err_probe()
Cai Huoqing [Tue, 28 Sep 2021 01:39:00 +0000 (09:39 +0800)]
iio: dac: stm32-dac: Make use of the helper function dev_err_probe()

When possible use dev_err_probe help to properly deal with the
PROBE_DEFER error, the benefit is that DEFER issue will be logged
in the devices_deferred debugfs file.
Using dev_err_probe() can reduce code size, and the error value
gets printed.

Signed-off-by: Cai Huoqing <caihuoqing@baidu.com>
Link: https://lore.kernel.org/r/20210928013902.1341-7-caihuoqing@baidu.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2 years agoiio: dac: mcp4922: Make use of the helper function dev_err_probe()
Cai Huoqing [Tue, 28 Sep 2021 01:38:59 +0000 (09:38 +0800)]
iio: dac: mcp4922: Make use of the helper function dev_err_probe()

When possible use dev_err_probe help to properly deal with the
PROBE_DEFER error, the benefit is that DEFER issue will be logged
in the devices_deferred debugfs file.
Using dev_err_probe() can reduce code size, and the error value
gets printed.

Signed-off-by: Cai Huoqing <caihuoqing@baidu.com>
Link: https://lore.kernel.org/r/20210928013902.1341-6-caihuoqing@baidu.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2 years agoiio: dac: max5821: Make use of the helper function dev_err_probe()
Cai Huoqing [Tue, 28 Sep 2021 01:38:58 +0000 (09:38 +0800)]
iio: dac: max5821: Make use of the helper function dev_err_probe()

When possible use dev_err_probe help to properly deal with the
PROBE_DEFER error, the benefit is that DEFER issue will be logged
in the devices_deferred debugfs file.
Using dev_err_probe() can reduce code size, and the error value
gets printed.

Signed-off-by: Cai Huoqing <caihuoqing@baidu.com>
Link: https://lore.kernel.org/r/20210928013902.1341-5-caihuoqing@baidu.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2 years agoiio: dac: ds4424: Make use of the helper function dev_err_probe()
Cai Huoqing [Tue, 28 Sep 2021 01:38:57 +0000 (09:38 +0800)]
iio: dac: ds4424: Make use of the helper function dev_err_probe()

When possible use dev_err_probe help to properly deal with the
PROBE_DEFER error, the benefit is that DEFER issue will be logged
in the devices_deferred debugfs file.
Using dev_err_probe() can reduce code size, and the error value
gets printed.

Signed-off-by: Cai Huoqing <caihuoqing@baidu.com>
Link: https://lore.kernel.org/r/20210928013902.1341-4-caihuoqing@baidu.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2 years agoiio: dac: ltc1660: Make use of the helper function dev_err_probe()
Cai Huoqing [Tue, 28 Sep 2021 01:38:56 +0000 (09:38 +0800)]
iio: dac: ltc1660: Make use of the helper function dev_err_probe()

When possible use dev_err_probe help to properly deal with the
PROBE_DEFER error, the benefit is that DEFER issue will be logged
in the devices_deferred debugfs file.
Using dev_err_probe() can reduce code size, and the error value
gets printed.

Signed-off-by: Cai Huoqing <caihuoqing@baidu.com>
Reviewed-by: Marcus Folkesson <marcus.folkesson@gmail.com>
Link: https://lore.kernel.org/r/20210928013902.1341-3-caihuoqing@baidu.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2 years agoiio: dac: lpc18xx_dac: Make use of the helper function dev_err_probe()
Cai Huoqing [Tue, 28 Sep 2021 01:38:55 +0000 (09:38 +0800)]
iio: dac: lpc18xx_dac: Make use of the helper function dev_err_probe()

When possible use dev_err_probe help to properly deal with the
PROBE_DEFER error, the benefit is that DEFER issue will be logged
in the devices_deferred debugfs file.
Using dev_err_probe() can reduce code size, and the error value
gets printed.

Signed-off-by: Cai Huoqing <caihuoqing@baidu.com>
Link: https://lore.kernel.org/r/20210928013902.1341-2-caihuoqing@baidu.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2 years agoiio: dac: ad8801: Make use of the helper function dev_err_probe()
Cai Huoqing [Tue, 28 Sep 2021 01:38:54 +0000 (09:38 +0800)]
iio: dac: ad8801: Make use of the helper function dev_err_probe()

When possible use dev_err_probe help to properly deal with the
PROBE_DEFER error, the benefit is that DEFER issue will be logged
in the devices_deferred debugfs file.
Using dev_err_probe() can reduce code size, and the error value
gets printed.

Signed-off-by: Cai Huoqing <caihuoqing@baidu.com>
Link: https://lore.kernel.org/r/20210928013902.1341-1-caihuoqing@baidu.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2 years agodt-bindings: iio: ad779x: Add binding document
Florian Boor [Thu, 30 Sep 2021 10:42:49 +0000 (12:42 +0200)]
dt-bindings: iio: ad779x: Add binding document

New binding documentation for AD799x series of I²C ADC ICs.

Signed-off-by: Florian Boor <florian.boor@kernelconcepts.de>
Reviewed-by: Rob Herring <robh@kernel.org>
Link: https://lore.kernel.org/r/20210930104249.2924336-2-florian.boor@kernelconcepts.de
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2 years agoiio: adc: ad799x: Implement selecting external reference voltage input on AD7991...
Florian Boor [Thu, 30 Sep 2021 10:42:48 +0000 (12:42 +0200)]
iio: adc: ad799x: Implement selecting external reference voltage input on AD7991, AD7995 and AD7999.

Make use of the AD7991_REF_SEL bit and support using the external
reference voltage if 'vref-supply' is present. Use VCC voltage supply
as reference if no extra reference is supplied.

Signed-off-by: Florian Boor <florian.boor@kernelconcepts.de>
Link: https://lore.kernel.org/r/20210930104249.2924336-1-florian.boor@kernelconcepts.de
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2 years agoiio: adc: max1027: fix error code in max1027_wait_eoc()
Dan Carpenter [Mon, 4 Oct 2021 13:44:54 +0000 (16:44 +0300)]
iio: adc: max1027: fix error code in max1027_wait_eoc()

Return -ETIMEDOUT on timeout instead of success.

Fixes: 1f7b4048b31b ("iio: adc: max1027: Use the EOC IRQ when populated for single reads")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Reviewed-by: Miquel Raynal <miquel.raynal@bootlin.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2 years agoiio: imu: adis16400: Fix buffer alignment requirements.
Jonathan Cameron [Sun, 13 Jun 2021 15:10:39 +0000 (16:10 +0100)]
iio: imu: adis16400: Fix buffer alignment requirements.

iio_push_to_buffers_with_timestamp() requires that the buffer
is 8 byte alignment to ensure an inserted timestamp is naturally aligned.

This requirement was not met here when burst mode is in use beause
of a leading u16. Use the new iio_push_to_buffers_with_ts_unaligned()
function that has more relaxed requirements.

It is somewhat complex to access that actual data length, but a
safe bound can be found by using scan_bytes - sizeof(timestamp) so that
is used in this path.

More efficient approaches exist, but this ensure correctness at the
cost of using a bounce buffer.

Fixes: 5075e0720d93 ("iio: imu: adis: generalize burst mode support")
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Reviewed-by: Nuno Sá <nuno.sa@analog.com>
Link: https://lore.kernel.org/r/20210613151039.569883-5-jic23@kernel.org
2 years agoiio: gyro: mpu3050: Fix alignment and size issues with buffers.
Jonathan Cameron [Sun, 13 Jun 2021 15:10:38 +0000 (16:10 +0100)]
iio: gyro: mpu3050: Fix alignment and size issues with buffers.

Fix a set of closely related issues.
1. When using fifo_values() there was not enough space for the timestamp to
   be inserted by iio_push_to_buffers_with_timestamp()
2. fifo_values() did not meet the alignment requirement of
   iio_push_to_buffers_with_timestamp()
3. hw_values did not meet the alignment requirement either.

1 and 2 fixed by using new iio_push_to_buffers_with_ts_unaligned() which has
no alignment or space padding requirements.
3 fixed by introducing a structure that makes the space and alignment
requirements explicit.

Fixes: 3904b28efb2c ("iio: gyro: Add driver for the MPU-3050 gyroscope")
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Link: https://lore.kernel.org/r/20210613151039.569883-4-jic23@kernel.org
2 years agoiio: adc: ti-adc108s102: Fix alignment of buffer pushed to iio buffers.
Jonathan Cameron [Sun, 13 Jun 2021 15:10:37 +0000 (16:10 +0100)]
iio: adc: ti-adc108s102: Fix alignment of buffer pushed to iio buffers.

Use the newly introduce iio_push_to_buffers_with_ts_unaligned() function
to ensure a bounce buffer is used to provide the required alignment and
space padding needed by the IIO core which requires the timestamp
is naturally aligned.  There will be a performance cost to this change
but it will ensure the driver works on platforms that do not support
unaligned 8 byte assignments, and with consumer drivers that may
assume natural alignment of the timestamp.

Issue found as part of an audit of all calls to
iio_push_to_buffers_with_timestamp()

Fixes: 7e87d11c9bda ("iio: adc: Add support for TI ADC108S102 and ADC128S102")
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Cc: Jan Kiszka <jan.kiszka@siemens.com>
Link: https://lore.kernel.org/r/20210613151039.569883-3-jic23@kernel.org
2 years agoiio: core: Introduce iio_push_to_buffers_with_ts_unaligned()
Jonathan Cameron [Sun, 13 Jun 2021 15:10:36 +0000 (16:10 +0100)]
iio: core: Introduce iio_push_to_buffers_with_ts_unaligned()

Whilst it is almost always possible to arrange for scan data to be
read directly into a buffer that is suitable for passing to
iio_push_to_buffers_with_timestamp(), there are a few places where
leading data needs to be skipped over.

For these cases introduce a function that will allocate an appropriate
sized and aligned bounce buffer (if not already allocated) and copy
the unaligned data into that before calling
iio_push_to_buffers_with_timestamp() on the bounce buffer.
We tie the lifespace of this buffer to that of the iio_dev.dev
which should ensure no memory leaks occur.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Reviewed-by: Nuno Sá <nuno.sa@analog.com>
Link: https://lore.kernel.org/r/20210613151039.569883-2-jic23@kernel.org
2 years agoiio: chemical: SENSEAIR_SUNRISE_CO2 depends on I2C
Randy Dunlap [Sat, 2 Oct 2021 23:28:03 +0000 (16:28 -0700)]
iio: chemical: SENSEAIR_SUNRISE_CO2 depends on I2C

Fix kconfig symbol dependency warning:

WARNING: unmet direct dependencies detected for REGMAP_I2C
  Depends on [n]: I2C [=n]
  Selected by [y]:
  - SENSEAIR_SUNRISE_CO2 [=y] && IIO [=y]

Fixes: c397894e24f1 ("iio: chemical: Add Senseair Sunrise 006-0-007 drive")
Signed-off-by: Randy Dunlap <rdunlap@infradead.org>
Cc: Jacopo Mondi <jacopo@jmondi.org>
Cc: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Cc: linux-iio@vger.kernel.org
Link: https://lore.kernel.org/r/20211002232803.5108-1-rdunlap@infradead.org
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2 years agoiio: adc: aspeed: Fix spelling mistake "battey" -> "battery"
Colin Ian King [Fri, 1 Oct 2021 12:00:18 +0000 (13:00 +0100)]
iio: adc: aspeed: Fix spelling mistake "battey" -> "battery"

There is a spelling mistake in a dev_warn message. Fix it.

Signed-off-by: Colin Ian King <colin.king@canonical.com>
Link: https://lore.kernel.org/r/20211001120018.17570-1-colin.king@canonical.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2 years agoiio: adc: ad7291: convert probe to device-managed only
Alexandru Ardelean [Sun, 26 Sep 2021 19:43:15 +0000 (22:43 +0300)]
iio: adc: ad7291: convert probe to device-managed only

This is a simple conversion for to device-managed with using
devm_request_threaded_irq(), disabling the regulator via a
devm_add_action_or_reset() hook and finally using
devm_iio_device_register().

The i2c_set_clientdata() call is removed as it becomes redundant after this
change.

Signed-off-by: Alexandru Ardelean <aardelean@deviqon.com>
Link: https://lore.kernel.org/r/20210926194315.7742-1-aardelean@deviqon.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2 years agoiio: adc: Kconfig: add COMPILE_TEST dep for berlin2-adc
Alexandru Ardelean [Sun, 26 Sep 2021 19:26:42 +0000 (22:26 +0300)]
iio: adc: Kconfig: add COMPILE_TEST dep for berlin2-adc

Otherwise most build checks will omit this driver from a compile-test due
to it's dependency only on the BERLIN_ARCH symbol.

Signed-off-by: Alexandru Ardelean <aardelean@deviqon.com>
Link: https://lore.kernel.org/r/20210926192642.4051329-2-aardelean@deviqon.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2 years agoiio: adc: berlin2-adc: convert probe to device-managed only
Alexandru Ardelean [Sun, 26 Sep 2021 19:26:41 +0000 (22:26 +0300)]
iio: adc: berlin2-adc: convert probe to device-managed only

This driver requires only a devm_add_action_or_reset() hook for the
power-down of the device, and then devm_iio_device_register() can be used
directly.

Signed-off-by: Alexandru Ardelean <aardelean@deviqon.com>
Link: https://lore.kernel.org/r/20210926192642.4051329-1-aardelean@deviqon.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2 years agoiio: adc: rn5t618-adc: use devm_iio_map_array_register() function
Alexandru Ardelean [Sun, 26 Sep 2021 16:28:59 +0000 (19:28 +0300)]
iio: adc: rn5t618-adc: use devm_iio_map_array_register() function

This driver already hooks a similar unwind callback via
devm_add_action_or_reset().

They pretty much do the same thing, so this change converts it to the
devm_iio_map_array_register().

Signed-off-by: Alexandru Ardelean <aardelean@deviqon.com>
Reviewed-by: Andreas Kemnade <andreas@kemnade.info>
Link: https://lore.kernel.org/r/20210926162859.3567685-1-aardelean@deviqon.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2 years agoiio: adc: max1363: convert probe to full device-managed
Alexandru Ardelean [Sun, 26 Sep 2021 16:21:10 +0000 (19:21 +0300)]
iio: adc: max1363: convert probe to full device-managed

For this conversion, the 2 regulators (being enabled) require each a
devm_add_action_or_reset() hook registration.

For the other functions, there are device-managed variants.

Signed-off-by: Alexandru Ardelean <aardelean@deviqon.com>
Link: https://lore.kernel.org/r/20210926162110.3536436-1-aardelean@deviqon.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2 years agoiio: adc: nau7802: convert probe to full device-managed
Alexandru Ardelean [Sun, 26 Sep 2021 15:49:32 +0000 (18:49 +0300)]
iio: adc: nau7802: convert probe to full device-managed

This is a trivial conversion to device-managed functions.
The mutex_destroy() calls are redundant, as the data will be free'd anyway.

And the IRQ and IIO register functions both have device-managed
equivalents.

Signed-off-by: Alexandru Ardelean <aardelean@deviqon.com>
Reviewed-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Link: https://lore.kernel.org/r/20210926154932.3287590-1-aardelean@deviqon.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2 years agoiio: adis16460: make use of the new unmasked_drdy flag
Nuno Sá [Fri, 3 Sep 2021 14:14:22 +0000 (16:14 +0200)]
iio: adis16460: make use of the new unmasked_drdy flag

The library can now handle enabling/disabling IRQs for devices that
cannot unmask the data ready pin. Hence there's no need to provide an
'enable_irq' callback anymore.

The library will also automatically request the IRQ with 'IRQF_NO_AUTOEN'
so that we can also remove that from the driver.

Signed-off-by: Nuno Sá <nuno.sa@analog.com>
Link: https://lore.kernel.org/r/20210903141423.517028-5-nuno.sa@analog.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2 years agoiio: adis16475: make use of the new unmasked_drdy flag
Nuno Sá [Fri, 3 Sep 2021 14:14:21 +0000 (16:14 +0200)]
iio: adis16475: make use of the new unmasked_drdy flag

The library can now handle enabling/disabling IRQs for devices that
cannot unmask the data ready pin. Hence there's no need to provide an
'enable_irq' callback anymore.

The library will also automatically request the IRQ with 'IRQF_NO_AUTOEN'
so that we can also remove that from the driver.

Signed-off-by: Nuno Sá <nuno.sa@analog.com>
Link: https://lore.kernel.org/r/20210903141423.517028-4-nuno.sa@analog.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2 years agoiio: adis: handle devices that cannot unmask the drdy pin
Nuno Sá [Fri, 3 Sep 2021 14:14:20 +0000 (16:14 +0200)]
iio: adis: handle devices that cannot unmask the drdy pin

Some devices can't mask/unmask the data ready pin and in those cases
each driver was just calling '{dis}enable_irq()' to control the trigger
state. This change, moves that handling into the library by introducing
a new boolean in the data structure that tells the library that the
device cannot unmask the pin.

On top of controlling the trigger state, we can also use this flag to
automatically request the IRQ with 'IRQF_NO_AUTOEN' in case it is set.
So far, all users of the library want to start operation with IRQs/DRDY
pin disabled so it should be fairly safe to do this inside the library.

Signed-off-by: Nuno Sá <nuno.sa@analog.com>
Link: https://lore.kernel.org/r/20210903141423.517028-3-nuno.sa@analog.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2 years agoiio: adis: do not disabe IRQs in 'adis_init()'
Nuno Sá [Fri, 3 Sep 2021 14:14:19 +0000 (16:14 +0200)]
iio: adis: do not disabe IRQs in 'adis_init()'

With commit ecb010d441088 ("iio: imu: adis: Refactor adis_initial_startup")
we are doing a HW or SW reset to the device which means that we'll get
the default state of the data ready pin (which is enabled). Hence there's
no point in disabling the IRQ in the init function. Moreover, this
function is intended to initialize internal data structures and not
really do anything on the device.

As a result of this, some devices were left with the data ready pin enabled
after probe which was not the desired behavior. Thus, we move the call to
'adis_enable_irq()' to the initial startup function where it makes more
sense for it to be.

Note that for devices that cannot mask/unmask the pin, it makes no sense
to call the function at this point since the IRQ should not have been
yet requested. This will be improved in a follow up change.

Fixes: ecb010d441088 ("iio: imu: adis: Refactor adis_initial_startup")
Signed-off-by: Nuno Sá <nuno.sa@analog.com>
Link: https://lore.kernel.org/r/20210903141423.517028-2-nuno.sa@analog.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2 years agoiio: adc: da9150-gpadc: convert probe to full-device managed
Alexandru Ardelean [Fri, 3 Sep 2021 07:29:17 +0000 (10:29 +0300)]
iio: adc: da9150-gpadc: convert probe to full-device managed

This change converts the probe of this driver to use device-managed
functions only, which means that the remove hook can be removed.
The remove hook has only 2 calls to iio_device_unregister() and
iio_map_array_unregister(). Both these can now be done via devm register
functions, now that there's also a devm_iio_map_array_register() function.

The platform_set_drvdata() can also be removed now.

This change also removes the error print for when the iio_device_register()
call fails. This isn't required now.

Signed-off-by: Alexandru Ardelean <aardelean@deviqon.com>
Link: https://lore.kernel.org/r/20210903072917.45769-6-aardelean@deviqon.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2 years agoiio: adc: lp8788_adc: convert probe to full-device managed
Alexandru Ardelean [Fri, 3 Sep 2021 07:29:16 +0000 (10:29 +0300)]
iio: adc: lp8788_adc: convert probe to full-device managed

This change converts the probe of this driver to use device-managed
functions only, which means that the remove hook can be removed.
The remove hook has only 2 calls to iio_device_unregister() and
iio_map_array_unregister(). Both these can now be done via devm register
functions, now that there's also a devm_iio_map_array_register() function.

The platform_set_drvdata() can also be removed now.

This change also removes the error print for when the iio_device_register()
call fails. This isn't required now.

Signed-off-by: Alexandru Ardelean <aardelean@deviqon.com>
Link: https://lore.kernel.org/r/20210903072917.45769-5-aardelean@deviqon.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2 years agoiio: adc: axp288_adc: convert probe to full device-managed
Alexandru Ardelean [Fri, 3 Sep 2021 07:29:15 +0000 (10:29 +0300)]
iio: adc: axp288_adc: convert probe to full device-managed

This change converts the probe of this driver to use device-managed
functions only, which means that the remove hook can be removed.
The remove hook has only 2 calls to iio_device_unregister() and
iio_map_array_unregister(). Both these can now be done via devm register
functions, now that there's also a devm_iio_map_array_register() function.

The platform_set_drvdata() can also be removed now.

This change also removes the error print for when the iio_device_register()
call fails. This isn't required now.

Signed-off-by: Alexandru Ardelean <aardelean@deviqon.com>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Link: https://lore.kernel.org/r/20210903072917.45769-4-aardelean@deviqon.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2 years agoiio: adc: intel_mrfld_adc: convert probe to full device-managed
Alexandru Ardelean [Fri, 3 Sep 2021 07:29:14 +0000 (10:29 +0300)]
iio: adc: intel_mrfld_adc: convert probe to full device-managed

The only call in the remove hook is the iio_map_array_unregister() call.
Since we have a devm_iio_map_array_register() function now, we can use that
and remove the remove hook entirely.
The IIO device was registered with the devm_iio_device_register() prior to
this change.

Also, the platform_set_drvdata() can be removed now, since it was used only
in the remove hook.

Signed-off-by: Alexandru Ardelean <aardelean@deviqon.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://lore.kernel.org/r/20210903072917.45769-3-aardelean@deviqon.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2 years agoiio: inkern: introduce devm_iio_map_array_register() short-hand function
Alexandru Ardelean [Fri, 3 Sep 2021 07:29:13 +0000 (10:29 +0300)]
iio: inkern: introduce devm_iio_map_array_register() short-hand function

This change introduces a device-managed variant to the
iio_map_array_register() function. It's a simple implementation of calling
iio_map_array_register() and registering a callback to
iio_map_array_unregister() with the devm_add_action_or_reset().

The function uses an explicit 'dev' parameter to bind the unwinding to. It
could have been implemented to implicitly use the parent of the IIO device,
however it shouldn't be too expensive to callers to just specify to which
device object to bind this unwind call.
It would make the API a bit more flexible.

Signed-off-by: Alexandru Ardelean <aardelean@deviqon.com>
Link: https://lore.kernel.org/r/20210903072917.45769-2-aardelean@deviqon.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2 years agoiio: adc: fsl-imx25-gcq: initialize regulators as needed
Alexandru Ardelean [Fri, 25 Jun 2021 07:43:25 +0000 (10:43 +0300)]
iio: adc: fsl-imx25-gcq: initialize regulators as needed

The driver tries to initialize all possible regulators from the DT, then
match the external regulators with each channel and then release all unused
regulators.

We can change the logic a bit to initialize regulators only when at least
one channel needs them.

This change creates a mx25_gcq_ext_regulator_setup() function that is
called only for the external regulators. If there's already a reference to
an external regulator, the function will just exit early with no error.

This way, the driver doesn't need to keep any track of these regulators
during init.

Signed-off-by: Alexandru Ardelean <aardelean@deviqon.com>
Link: https://lore.kernel.org/r/20210625074325.9237-1-aardelean@deviqon.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2 years agoiio: imu: st_lsm6dsx: move max_fifo_size in st_lsm6dsx_fifo_ops
Lorenzo Bianconi [Sun, 26 Sep 2021 14:02:30 +0000 (16:02 +0200)]
iio: imu: st_lsm6dsx: move max_fifo_size in st_lsm6dsx_fifo_ops

Move max_fifo_size in st_lsm6dsx_fifo_ops in order to have all
FIFO configuration parameters in st_lsm6dsx_fifo_ops structure.
This patch does not introduce any logic change, just small code
rearrangement.

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Link: https://lore.kernel.org/r/3262ad9d9d1497e19ea1bab208c495c2b9a98994.1632664866.git.lorenzo@kernel.org
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2 years agoiio: adc: max1027: Don't reject external triggers when there is no IRQ
Miquel Raynal [Tue, 21 Sep 2021 11:54:08 +0000 (13:54 +0200)]
iio: adc: max1027: Don't reject external triggers when there is no IRQ

External triggers do not necessarily need the EOC interrupt to be
populated to work properly. The end of conversion status may either come
from an interrupt or from a sufficient enough extra delay. IRQs are not
mandatory so move the triggered buffer setup out of the IRQ condition
and add the logic to wait enough time for all the requested conversions
to be in the device's FIFO.

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/r/20210921115408.66711-17-miquel.raynal@bootlin.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2 years agoiio: adc: max1027: Allow all kind of triggers to be used
Miquel Raynal [Tue, 21 Sep 2021 11:54:07 +0000 (13:54 +0200)]
iio: adc: max1027: Allow all kind of triggers to be used

There is no reason to limit this driver to its internal trigger. The
only difference being, when using an external trigger, the sample
conversion must be manually started.

Drop the ->validate_trigger() hook in order to allow other triggers to
be bound.

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/r/20210921115408.66711-16-miquel.raynal@bootlin.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2 years agoiio: adc: max1027: Use the EOC IRQ when populated for single reads
Miquel Raynal [Tue, 21 Sep 2021 11:54:06 +0000 (13:54 +0200)]
iio: adc: max1027: Use the EOC IRQ when populated for single reads

So far the End-Of-Conversion interrupt was only used in conjunction with
the internal trigger to process the data. Let's extend the use of this
interrupt handler to support regular single-shot conversions as well.

Doing so requires writing our own hard IRQ handler. This handler has to
check if buffers are enabled or not:

*** Buffers disabled condition ***

  This means the user requested a single conversion and the sample is
  ready to be retrieved.

    -> This implies adding the relevant completion boilerplate.

*** Buffers enabled condition ***

  Triggers are used. So far there is only support for the internal
  trigger but this trigger might soon be attached to another device as
  well so it is the core duty to decide which handler to call in order
  to process the data. The core will decide to either:

  * Call the internal trigger handler which will extract the data that
    is already present in the ADC FIFOs

  or

  * Call the trigger handler of another driver when using this trigger
    with another device, even though this call will be slightly delayed
    by the fact that the max1027 IRQ is a data-ready interrupt rather
    than a real trigger:

  -> The new handler will manually inform the core about the trigger
     having transitioned by directly calling iio_trigger_poll() (which
     iio_trigger_generic_data_rdy_poll() initially did).

In order for the handler to be "source" agnostic, we also need to change
the private pointer and provide the IIO device instead of the trigger
object.

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/r/20210921115408.66711-15-miquel.raynal@bootlin.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2 years agoiio: adc: max1027: Stop requesting a threaded IRQ
Miquel Raynal [Tue, 21 Sep 2021 11:54:05 +0000 (13:54 +0200)]
iio: adc: max1027: Stop requesting a threaded IRQ

The threaded handler is not populated, this means there is nothing
running in process context so let's switch to the regular
devm_request_irq() call instead.

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/r/20210921115408.66711-14-miquel.raynal@bootlin.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2 years agoiio: adc: max1027: Introduce an end of conversion helper
Miquel Raynal [Tue, 21 Sep 2021 11:54:04 +0000 (13:54 +0200)]
iio: adc: max1027: Introduce an end of conversion helper

For now this helper only waits for the maximum duration of a single
conversion.

In practice, a "temperature measurement" will take twice this
time because it will also carry another analog conversion but as here we
will only care about the temperature conversion which happens first, we
can still only wait for a single sample and get the right data.

This helper will soon be improved to properly handle the end of
conversion interrupt as well as a higher number of samples.

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/r/20210921115408.66711-13-miquel.raynal@bootlin.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2 years agoiio: adc: max1027: Separate the IRQ handler from the read logic
Miquel Raynal [Tue, 21 Sep 2021 11:54:03 +0000 (13:54 +0200)]
iio: adc: max1027: Separate the IRQ handler from the read logic

Create a max1027_read_scan() helper which will make clearer the future IRQ
handler updates (no functional change).

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/r/20210921115408.66711-12-miquel.raynal@bootlin.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2 years agoiio: adc: max1027: Prevent single channel accesses during buffer reads
Miquel Raynal [Tue, 21 Sep 2021 11:54:02 +0000 (13:54 +0200)]
iio: adc: max1027: Prevent single channel accesses during buffer reads

When hardware buffers are enabled (the cnvst pin being the trigger), one
should not mess with the device state by requesting a single channel
read.

There is already a iio_buffer_enabled() check in *_read_single_value()
to merely prevent this situation but the check is inconsistent since
buffers can be enabled after the if clause anyway. Instead, use the core
mutex by calling iio_device_claim/release_direct_mode().

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/r/20210921115408.66711-11-miquel.raynal@bootlin.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2 years agoiio: adc: max1027: Create a helper to configure the channels to scan
Miquel Raynal [Tue, 21 Sep 2021 11:54:01 +0000 (13:54 +0200)]
iio: adc: max1027: Create a helper to configure the channels to scan

These bits are meant to be reused for triggered buffers setup.

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/r/20210921115408.66711-10-miquel.raynal@bootlin.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2 years agoiio: adc: max1027: Ensure a default cnvst trigger configuration
Miquel Raynal [Tue, 21 Sep 2021 11:54:00 +0000 (13:54 +0200)]
iio: adc: max1027: Ensure a default cnvst trigger configuration

We don't expect the (hardware) cnvst trigger to be enabled at boot time,
this is a user choice made in sysfs and there is a dedicated callback to
enable/disable this trigger. Hence, we can just ensure it is disabled in
the probe at initialization time and then assume that whenever a
->read_raw() call happens, the trigger has been disabled and conversions
will start on register write.

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/r/20210921115408.66711-9-miquel.raynal@bootlin.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2 years agoiio: adc: max1027: Simplify the _set_trigger_state() helper
Miquel Raynal [Tue, 21 Sep 2021 11:53:59 +0000 (13:53 +0200)]
iio: adc: max1027: Simplify the _set_trigger_state() helper

The call to max1027_enable_trigger() is the same in both cases thanks to
the 'state' variable, so factorize a little bit to simplify the code and
explain why we call this helper.

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/r/20210921115408.66711-8-miquel.raynal@bootlin.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2 years agoiio: adc: max1027: Create a helper to enable/disable the cnvst trigger
Miquel Raynal [Tue, 21 Sep 2021 11:53:58 +0000 (13:53 +0200)]
iio: adc: max1027: Create a helper to enable/disable the cnvst trigger

There are two ways to physically trigger a conversion:
- A falling edge on the cnvst pin
- A write operation on the conversion register

Let's create a helper for this.

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Reviewed-by: Nuno Sá <nuno.sa@analog.com>
Link: https://lore.kernel.org/r/20210921115408.66711-7-miquel.raynal@bootlin.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2 years agoiio: adc: max1027: Rename a helper
Miquel Raynal [Tue, 21 Sep 2021 11:53:57 +0000 (13:53 +0200)]
iio: adc: max1027: Rename a helper

Make it clear that the *_set_trigger_state() hook is responsible for
cnvst based conversions by renaming the helper. This may avoid
confusions with software trigger support that is going to be
introduced.

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Reviewed-by: Nuno Sá <nuno.sa@analog.com>
Link: https://lore.kernel.org/r/20210921115408.66711-6-miquel.raynal@bootlin.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2 years agoiio: adc: max1027: Minimize the number of converted channels
Miquel Raynal [Tue, 21 Sep 2021 11:53:56 +0000 (13:53 +0200)]
iio: adc: max1027: Minimize the number of converted channels

Provide a list of ->available_scan_masks which match the device's
capabilities. Basically, these devices are able to scan from 0 to N, N
being the highest voltage channel requested by the user. The temperature
can be included or not, but cannot be retrieved alone.

The consequence is, instead of reading and pushing to the IIO buffers
all channels each time, the "minimum" number of channels will be scanned
and pushed based on the ->active_scan_mask.

For example, if the user wants channels 1, 4 and 5, all channels from
0 to 5 will be scanned and pushed to the IIO buffers. The core will then
filter out the unneeded samples based on the ->active_scan_mask that has
been selected and only channels 1, 4 and 5 will be available to the user
in the shared buffer.

Provide a comment in the code explaining this logic.

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/r/20210921115408.66711-5-miquel.raynal@bootlin.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2 years agoiio: adc: max1027: Drop useless debug messages
Miquel Raynal [Tue, 21 Sep 2021 11:53:55 +0000 (13:53 +0200)]
iio: adc: max1027: Drop useless debug messages

These two debug messages bring absolutely no value, let's drop them.

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/r/20210921115408.66711-4-miquel.raynal@bootlin.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2 years agoiio: adc: max1027: Drop extra warning message
Miquel Raynal [Tue, 21 Sep 2021 11:53:54 +0000 (13:53 +0200)]
iio: adc: max1027: Drop extra warning message

Memory allocation errors automatically trigger the right logs, no need
to have our own.

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Reviewed-by: Nuno Sá <nuno.sa@analog.com>
Link: https://lore.kernel.org/r/20210921115408.66711-3-miquel.raynal@bootlin.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2 years agoiio: adc: max1027: Fix style
Miquel Raynal [Tue, 21 Sep 2021 11:53:53 +0000 (13:53 +0200)]
iio: adc: max1027: Fix style

Follow checkpatch.pl's main advices before hacking into the driver, mainly:
WARNING: Prefer 'unsigned int' to bare use of 'unsigned'
WARNING: Prefer 'unsigned int *' to bare use of 'unsigned *'
CHECK: Comparison to NULL could be written "!foo"
CHECK: Alignment should match open parenthesis

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/r/20210921115408.66711-2-miquel.raynal@bootlin.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2 years agoMAINTAINERS: Add the driver info of the NXP IMX8QXP
Cai Huoqing [Sat, 25 Sep 2021 02:05:47 +0000 (10:05 +0800)]
MAINTAINERS: Add the driver info of the NXP IMX8QXP

The NXP i.MX 8QuadXPlus SOC has a new ADC IP. After adding
the driver support for it, I add the driver info of the
NXP IMX8QXP ADC to MAINTAINERS file.

Signed-off-by: Cai Huoqing <caihuoqing@baidu.com>
Link: https://lore.kernel.org/r/20210925020555.129-4-caihuoqing@baidu.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2 years agodt-bindings: iio: adc: Add binding documentation for NXP IMX8QXP ADC
Cai Huoqing [Sat, 25 Sep 2021 02:05:46 +0000 (10:05 +0800)]
dt-bindings: iio: adc: Add binding documentation for NXP IMX8QXP ADC

The NXP i.MX 8QuadXPlus SOC a new ADC IP, so add
binding documentation for NXP IMX8QXP ADC.

Reviewed-by: Rob Herring <robh@kernel.org>
Signed-off-by: Cai Huoqing <caihuoqing@baidu.com>
Link: https://lore.kernel.org/r/20210925020555.129-3-caihuoqing@baidu.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2 years agoiio: imx8qxp-adc: Add driver support for NXP IMX8QXP ADC
Cai Huoqing [Sat, 25 Sep 2021 02:05:45 +0000 (10:05 +0800)]
iio: imx8qxp-adc: Add driver support for NXP IMX8QXP ADC

The NXP i.MX 8QuadXPlus SOC has a new ADC IP, so add
driver support for this ADC.

Signed-off-by: Cai Huoqing <caihuoqing@baidu.com>
Reviewed-by: Fabio Estevam <festevam@gmail.com>
Link: https://lore.kernel.org/r/20210925020555.129-2-caihuoqing@baidu.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2 years agoiio: accel: fxls8962af: add wake on event
Sean Nyekjaer [Mon, 20 Sep 2021 11:42:21 +0000 (13:42 +0200)]
iio: accel: fxls8962af: add wake on event

This adds ways for the SoC to wake from accelerometer wake events.

In the suspend function we skip disabling the sensor if wakeup-source
and events are activated.

If buffered reads are enabled they will be deactivated before suspend.
As the onboard buffer is only holding up to 32 12-bit X/Y/Z data
triplets.

Signed-off-by: Sean Nyekjaer <sean@geanix.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Link: https://lore.kernel.org/r/20210920114221.1595543-2-sean@geanix.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2 years agoiio: accel: fxls8962af: add threshold event handling
Sean Nyekjaer [Mon, 20 Sep 2021 11:42:20 +0000 (13:42 +0200)]
iio: accel: fxls8962af: add threshold event handling

Add event channels that control the creation of motion events.

Signed-off-by: Sean Nyekjaer <sean@geanix.com>
Link: https://lore.kernel.org/r/20210920114221.1595543-1-sean@geanix.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2 years agoiio: adc: aspeed: Get and set trimming data.
Billy Tsai [Wed, 22 Sep 2021 08:15:20 +0000 (16:15 +0800)]
iio: adc: aspeed: Get and set trimming data.

The ADC controller has a trimming register for fine-tune the reference
voltage. The trimming value comes from the OTP register which will be
written during chip production. This patch will read this OTP value and
configure it to the ADC register when the ADC controller probes and using
dts property "aspeed,trim-data-valid" to determine whether to execute this
flow.

Signed-off-by: Billy Tsai <billy_tsai@aspeedtech.com>
Link: https://lore.kernel.org/r/20210922081520.30580-12-billy_tsai@aspeedtech.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2 years agoiio: adc: aspeed: Support battery sensing.
Billy Tsai [Wed, 22 Sep 2021 08:15:19 +0000 (16:15 +0800)]
iio: adc: aspeed: Support battery sensing.

In ast2600, ADC integrate dividing circuit at last input channel for
battery sensing. This patch use the dts property "battery-sensing" to
enable this feature makes the last channel of each adc can tolerance
higher voltage than reference voltage. The offset interface of ch7 will
be separated when enabling the battery sensing mode.

Signed-off-by: Billy Tsai <billy_tsai@aspeedtech.com>
Link: https://lore.kernel.org/r/20210922081520.30580-11-billy_tsai@aspeedtech.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2 years agoiio: adc: aspeed: Add compensation phase.
Billy Tsai [Wed, 22 Sep 2021 08:15:18 +0000 (16:15 +0800)]
iio: adc: aspeed: Add compensation phase.

This patch adds a compensation phase to improve the accuracy of ADC
measurement. This is the built-in function through input half of the
reference voltage to get the ADC offset.

Signed-off-by: Billy Tsai <billy_tsai@aspeedtech.com>
Link: https://lore.kernel.org/r/20210922081520.30580-10-billy_tsai@aspeedtech.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2 years agoiio: adc: aspeed: Add func to set sampling rate.
Billy Tsai [Wed, 22 Sep 2021 08:15:17 +0000 (16:15 +0800)]
iio: adc: aspeed: Add func to set sampling rate.

Add the function to set the sampling rate and keep the sampling period
for a driver used to wait the fresh value.
In addition, since the ADC clock is required when initializing the ADC
device, move clk_prepare_enable ahead of the initialization phase.

Signed-off-by: Billy Tsai <billy_tsai@aspeedtech.com>
Link: https://lore.kernel.org/r/20210922081520.30580-9-billy_tsai@aspeedtech.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2 years agoiio: adc: aspeed: Fix the calculate error of clock.
Billy Tsai [Wed, 22 Sep 2021 08:15:16 +0000 (16:15 +0800)]
iio: adc: aspeed: Fix the calculate error of clock.

The ADC clock formula is
ast2400/2500:
ADC clock period = PCLK * 2 * (ADC0C[31:17] + 1) * (ADC0C[9:0] + 1)
ast2600:
ADC clock period = PCLK * 2 * (ADC0C[15:0] + 1)
They all have one fixed divided 2 and the legacy driver didn't handle it.
This patch register the fixed factory clock device as the parent of ADC
clock scaler to fix this issue.

Signed-off-by: Billy Tsai <billy_tsai@aspeedtech.com>
Link: https://lore.kernel.org/r/20210922081520.30580-8-billy_tsai@aspeedtech.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2 years agoiio: adc: aspeed: Support ast2600 adc.
Billy Tsai [Wed, 22 Sep 2021 08:15:15 +0000 (16:15 +0800)]
iio: adc: aspeed: Support ast2600 adc.

Make driver to support ast2600 adc device.
- Use shared reset controller
- Complete the vref configure function
- Add the model data for ast2600 adc

Signed-off-by: Billy Tsai <billy_tsai@aspeedtech.com>
Link: https://lore.kernel.org/r/20210922081520.30580-7-billy_tsai@aspeedtech.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2 years agoiio: adc: aspeed: Use devm_add_action_or_reset.
Billy Tsai [Wed, 22 Sep 2021 08:15:14 +0000 (16:15 +0800)]
iio: adc: aspeed: Use devm_add_action_or_reset.

This patch use devm_add_action_or_reset to handle the error in probe
phase.

Signed-off-by: Billy Tsai <billy_tsai@aspeedtech.com>
Link: https://lore.kernel.org/r/20210922081520.30580-6-billy_tsai@aspeedtech.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2 years agoiio: adc: aspeed: Use model_data to set clk scaler.
Billy Tsai [Wed, 22 Sep 2021 08:15:13 +0000 (16:15 +0800)]
iio: adc: aspeed: Use model_data to set clk scaler.

This patch uses need_prescaler and scaler_bit_width to set the ADC clock
scaler.

Reported-by: kernel test robot <lkp@intel.com>
Signed-off-by: Billy Tsai <billy_tsai@aspeedtech.com>
Link: https://lore.kernel.org/r/20210922081520.30580-5-billy_tsai@aspeedtech.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2 years agoiio: adc: aspeed: Add vref config function
Billy Tsai [Wed, 22 Sep 2021 08:15:12 +0000 (16:15 +0800)]
iio: adc: aspeed: Add vref config function

Add the function to check the vref_fixed_mv and set the value to driver
data.

Signed-off-by: Billy Tsai <billy_tsai@aspeedtech.com>
Link: https://lore.kernel.org/r/20210922081520.30580-4-billy_tsai@aspeedtech.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2 years agoiio: adc: aspeed: Restructure the model data
Billy Tsai [Wed, 22 Sep 2021 08:15:11 +0000 (16:15 +0800)]
iio: adc: aspeed: Restructure the model data

This patch refactors the model data structure to distinguish the
function form different versions of aspeed ADC.
- Rename the vref_voltage to vref_fixed_mv and add vref_mv driver data
When driver probe will check vref_fixed_mv value and store it to vref_mv
which isn't const value.
- Add num_channels
Make num_channles of iio device can be changed by different model_data
- Add need_prescaler flag and scaler_bit_width
The need_prescaler flag is used to tell the driver the clock divider needs
another Prescaler and the scaler_bit_width to set the clock divider
bitfield width.

Signed-off-by: Billy Tsai <billy_tsai@aspeedtech.com>
Link: https://lore.kernel.org/r/20210922081520.30580-3-billy_tsai@aspeedtech.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2 years agoiio: adc: aspeed: Keep model data to driver data.
Billy Tsai [Wed, 22 Sep 2021 08:15:10 +0000 (16:15 +0800)]
iio: adc: aspeed: Keep model data to driver data.

Keep the model data pointer to driver data for reducing the usage of
of_device_get_match_data().

Signed-off-by: Billy Tsai <billy_tsai@aspeedtech.com>
Link: https://lore.kernel.org/r/20210922081520.30580-2-billy_tsai@aspeedtech.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2 years agoiio: ABI: Document in_concentration_co2_scale
Jacopo Mondi [Mon, 20 Sep 2021 13:54:13 +0000 (15:54 +0200)]
iio: ABI: Document in_concentration_co2_scale

Document the 'in_concentration_co2_scale' standard IIO attribute.

Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
Link: https://lore.kernel.org/r/20210920135413.140310-5-jacopo+renesas@jmondi.org
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2 years agoiio: chemical: Add Senseair Sunrise 006-0-007 driver
Jacopo Mondi [Mon, 20 Sep 2021 13:54:12 +0000 (15:54 +0200)]
iio: chemical: Add Senseair Sunrise 006-0-007 driver

Add support for the Senseair Sunrise 006-0-0007 driver through the
IIO subsystem.

Datasheet: https://rmtplusstoragesenseair.blob.core.windows.net/docs/Dev/publicerat/TDE5531.pdf
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
Link: https://lore.kernel.org/r/20210920135413.140310-4-jacopo+renesas@jmondi.org
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2 years agoiio: ABI: docs: Document Senseair Sunrise ABI
Jacopo Mondi [Mon, 20 Sep 2021 13:54:11 +0000 (15:54 +0200)]
iio: ABI: docs: Document Senseair Sunrise ABI

Add documentation for the sysfs attributes of the sunrise_co2 driver.

Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
Link: https://lore.kernel.org/r/20210920135413.140310-3-jacopo+renesas@jmondi.org
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2 years agodt-bindings: iio: chemical: Document senseair,sunrise CO2 sensor
Jacopo Mondi [Mon, 20 Sep 2021 13:54:10 +0000 (15:54 +0200)]
dt-bindings: iio: chemical: Document senseair,sunrise CO2 sensor

Add documentation for the Senseair Sunrise 006-0-0007 CO2 NDIR sensor.

Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Rob Herring <robh@kernel.org>
Link: https://lore.kernel.org/r/20210920135413.140310-2-jacopo+renesas@jmondi.org
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2 years agodt-bindings: iio: magnetometer: asahi-kasei,ak8975 add vid reg
David Heidelberg [Mon, 13 Sep 2021 18:19:49 +0000 (20:19 +0200)]
dt-bindings: iio: magnetometer: asahi-kasei,ak8975 add vid reg

Driver and device-tree also use vid-supply regulator.

Fixes: 7e000fbff7a0 ("dt-bindings: iio: magnetometer: ak8975: convert format to yaml, add maintainer")
Signed-off-by: David Heidelberg <david@ixit.cz>
Acked-by: Rob Herring <robh@kernel.org>
Link: https://lore.kernel.org/r/20210913181949.83179-1-david@ixit.cz
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2 years agodt-bindings: iio: kionix,kxcjk1013: driver support interrupts
David Heidelberg [Sun, 19 Sep 2021 20:36:56 +0000 (22:36 +0200)]
dt-bindings: iio: kionix,kxcjk1013: driver support interrupts

Device has interrupts support, which description was missing in the bindings.

Signed-off-by: David Heidelberg <david@ixit.cz>
Acked-by: Rob Herring <robh@kernel.org>
Link: https://lore.kernel.org/r/20210919203656.119742-1-david@ixit.cz
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2 years agoiio: adc: exynos: describe drivers in KConfig
Krzysztof Kozlowski [Fri, 24 Sep 2021 13:35:15 +0000 (15:35 +0200)]
iio: adc: exynos: describe drivers in KConfig

Describe better which driver applies to which SoC, to make configuring
kernel for Samsung SoC easier.

Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
Link: https://lore.kernel.org/r/20210924133515.112357-1-krzysztof.kozlowski@canonical.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2 years agoiio: adc: rockchip_saradc: Make use of the helper function devm_platform_ioremap_reso...
Cai Huoqing [Wed, 8 Sep 2021 10:56:30 +0000 (18:56 +0800)]
iio: adc: rockchip_saradc: Make use of the helper function devm_platform_ioremap_resource()

Use the devm_platform_ioremap_resource() helper instead of
calling platform_get_resource() and devm_ioremap_resource()
separately

Signed-off-by: Cai Huoqing <caihuoqing@baidu.com>
Link: https://lore.kernel.org/r/20210908105631.1474-1-caihuoqing@baidu.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2 years agoiio: dac: stm32-dac: Make use of the helper function devm_platform_ioremap_resource()
Cai Huoqing [Wed, 8 Sep 2021 10:56:38 +0000 (18:56 +0800)]
iio: dac: stm32-dac: Make use of the helper function devm_platform_ioremap_resource()

Use the devm_platform_ioremap_resource() helper instead of
calling platform_get_resource() and devm_ioremap_resource()
separately

Signed-off-by: Cai Huoqing <caihuoqing@baidu.com>
Link: https://lore.kernel.org/r/20210908105638.1525-1-caihuoqing@baidu.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2 years agoiio: accel: mma7660: Mark acpi match table as maybe unused
Daniel Palmer [Sun, 19 Sep 2021 07:26:16 +0000 (16:26 +0900)]
iio: accel: mma7660: Mark acpi match table as maybe unused

When building kernels without ACPI support the table is declared
but is not used because ACPI_PTR() turns it into a NULL.

Add the __maybe_unused attribute to stop the compiler whining.

Signed-off-by: Daniel Palmer <daniel@0x0f.com>
Link: https://lore.kernel.org/r/20210919072616.3849723-1-daniel@0x0f.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2 years agoiio: light: max44000: use device-managed functions in probe
Alexandru Ardelean [Mon, 13 Sep 2021 12:00:02 +0000 (15:00 +0300)]
iio: light: max44000: use device-managed functions in probe

This is a simple conversion. Both iio_device_register() and
iio_triggered_buffer_setup() functions have device-managed variants.

Signed-off-by: Alexandru Ardelean <aardelean@deviqon.com>
Link: https://lore.kernel.org/r/20210913120002.306280-1-aardelean@deviqon.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2 years agoiio: gyro: adis16080: use devm_iio_device_register() in probe
Alexandru Ardelean [Mon, 13 Sep 2021 11:53:08 +0000 (14:53 +0300)]
iio: gyro: adis16080: use devm_iio_device_register() in probe

There is nothing else that needs to be done for this driver. The remove
hook calls only the iio_device_unregister() hook.

So this driver can use devm_iio_device_register() directly.

Signed-off-by: Alexandru Ardelean <aardelean@deviqon.com>
Link: https://lore.kernel.org/r/20210913115308.301877-1-aardelean@deviqon.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2 years agoiio: dac: ad5064: convert probe to full device-managed
Alexandru Ardelean [Mon, 13 Sep 2021 11:52:37 +0000 (14:52 +0300)]
iio: dac: ad5064: convert probe to full device-managed

This change converts the probe of the AD5064 driver to use only
device-managed functions.

The regulator_bulk_disable() is passed on a devm_add_action_or_reset() hook
and the devm_iio_device_register() can be used to register the IIO device.

The driver has both I2C and SPI hooks inside, so all these can be removed.

Signed-off-by: Alexandru Ardelean <aardelean@deviqon.com>
Link: https://lore.kernel.org/r/20210913115237.301310-1-aardelean@deviqon.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2 years agostaging: iio: ad9832: convert probe to device-managed
Alexandru Ardelean [Mon, 13 Sep 2021 11:52:09 +0000 (14:52 +0300)]
staging: iio: ad9832: convert probe to device-managed

This change does a conversion of the driver to use device-managed init
functions. The 2 regulators and the clock inits are converted to use
devm_add_action_or_reset() callbacks for de-initializing them when the
driver unloads.

And finally the devm_iio_device_register() function can be use to register
the device.

The remove hook can finally be removed and the spi_set_drvdata() call can
also be removed as the private data is no longer used.

Signed-off-by: Alexandru Ardelean <aardelean@deviqon.com>
Link: https://lore.kernel.org/r/20210913115209.300665-1-aardelean@deviqon.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2 years agoiio: dac: ad7303: convert probe to full device-managed
Alexandru Ardelean [Mon, 13 Sep 2021 11:51:21 +0000 (14:51 +0300)]
iio: dac: ad7303: convert probe to full device-managed

For this conversion, the regulators need to have some cleanup hooks
registered with devm_add_action_or_reset() and then the
devm_io_device_register() call can be used.

Signed-off-by: Alexandru Ardelean <aardelean@deviqon.com>
Link: https://lore.kernel.org/r/20210913115121.300082-1-aardelean@deviqon.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>