Commit graph

5116 commits

Author SHA1 Message Date
Andy Shevchenko
38934daf7b iio: magnetometer: st_magn: Provide default platform data
Provide default platform data for magnetometer in case it supports DRDY.

One case is LSM9DS0 IMU, on which it is the case. Since accelerometer
is using INT1, default magnetometer to INT2.

While at it, update description of the drdy_int_pin field.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://lore.kernel.org/r/20210414195454.84183-3-andriy.shevchenko@linux.intel.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-05-17 13:54:22 +01:00
Andy Shevchenko
dffdd75678 iio: gyro: st_gyro: Move platform data from header to C file
Platform data is solely used by one file. Don't share it with others.

While at it, drop unneeded anymore __maybe_unused and fix kernel doc
to avoid warning:

  st_gyro_core.c:366: error: Cannot parse struct or union!

by converting to a simple comment. It is described at the declaration.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://lore.kernel.org/r/20210414195454.84183-2-andriy.shevchenko@linux.intel.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-05-17 13:54:22 +01:00
Andy Shevchenko
3b91452032 iio: accel: st_accel: Move platform data from header to C file
Platform data is solely used by one file. Don't share it with others.

While at it, drop unneeded anymore __maybe_unused and fix kernel doc
to avoid warning:

  st_accel_core.c:1079: error: Cannot parse struct or union!

by converting to a simple comment. It is described at the declaration.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://lore.kernel.org/r/20210414195454.84183-1-andriy.shevchenko@linux.intel.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-05-17 13:54:21 +01:00
Jonathan Cameron
62a486c46d iio: core: move @clock_id from struct iio_dev to struct iio_dev_opaque
There is already an acessor function used to access it, making this
move straight forward.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Reviewed-by: Alexandru Ardelean <ardeleanalex@gmail.com>
Link: https://lore.kernel.org/r/20210426174911.397061-10-jic23@kernel.org
2021-05-17 13:54:21 +01:00
Jonathan Cameron
8b1c82cb84 iio: core: move @flags from struct iio_dev to struct iio_dev_opaque
No reason any driver should ever need access to this field, so hide it.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Reviewed-by: Alexandru Ardelean <ardeleanalex@gmail.com>
Link: https://lore.kernel.org/r/20210426174911.397061-9-jic23@kernel.org
2021-05-17 13:54:21 +01:00
Jonathan Cameron
396f723485 iio: core: move @chrdev from struct iio_dev to struct iio_dev_opaque
No reason for this to be exposed to the drivers, so lets move it to the
opaque structure.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Reviewed-by: Alexandru Ardelean <ardeleanalex@gmail.com>
Link: https://lore.kernel.org/r/20210426174911.397061-8-jic23@kernel.org
2021-05-17 13:54:17 +01:00
Jonathan Cameron
b804e2b76a iio: core: move @info_exist_lock to struct iio_dev_opaque
This lock is only of interest to the IIO core, so make it only
visible there.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Reviewed-by: Alexandru Ardelean <ardeleanalex@gmail.com>
Link: https://lore.kernel.org/r/20210426174911.397061-7-jic23@kernel.org
2021-05-17 13:49:13 +01:00
Jonathan Cameron
62f4f36cdf iio: core: move @scan_index_timestamp to struct iio_dev_opaque
No reason for this cached value to be exposed to drivers so move it
to the opaque structure.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Reviewed-by: Alexandru Ardelean <ardeleanalex@gmail.com>
Link: https://lore.kernel.org/r/20210426174911.397061-6-jic23@kernel.org
2021-05-17 13:49:13 +01:00
Jonathan Cameron
3028e0c2af iio: core: move @trig_readonly from struct iio_dev to struct iio_dev_opaque
This is only set via the iio_trig_set_immutable() call and later used
by the IIO core so there is no benefit in drivers being able to access
it.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Reviewed-by: Alexandru Ardelean <ardeleanalex@gmail.com>
Link: https://lore.kernel.org/r/20210426174911.397061-5-jic23@kernel.org
2021-05-17 13:49:13 +01:00
Jonathan Cameron
6eaf9f6a27 iio: core: move @driver_module from struct iio_dev to struct iio_dev_opaque
Continuing move to hide internal elements from drivers, move this structure
element over.  It's only accessed from iio core files so this one was
straight forward and no accessor functions are needed.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Reviewed-by: Alexandru Ardelean <ardeleanalex@gmail.com>
Link: https://lore.kernel.org/r/20210426174911.397061-4-jic23@kernel.org
2021-05-17 13:49:13 +01:00
Jonathan Cameron
15ea2878bf iio: core: move @id from struct iio_dev to struct iio_dev_opaque
Continuing from Alexandru Ardelean's introduction of the split between
driver modifiable fields and those that should only be set by the core.

This could have been done in two steps to make the actual move after
introducing iio_device_id() but there seemed limited point to that
given how mechanical the majority of the patch is.

Includes fixup from Alex for missing mxs-lradc-adc conversion.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Reviewed-by: Alexandru Ardelean <ardeleanalex@gmail.com>
Link: https://lore.kernel.org/r/20210426174911.397061-2-jic23@kernel.org
2021-05-17 13:49:13 +01:00
Jonathan Cameron
e6cc8f2b76 iio: common: scmi_sensors: Drop duplicate setting of iio_dev.dev.parent
This is already set to the same value in devm_iio_device_alloc()

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Cc: Jyoti Bhayana <jbhayana@google.com>
Reviewed-by: Alexandru Ardelean <ardeleanalex@gmail.com>
Link: https://lore.kernel.org/r/20210426170251.351957-9-jic23@kernel.org
2021-05-17 13:49:12 +01:00
Jonathan Cameron
63027b3418 iio: position: hid-sensor-custom-intel-hinge: Drop duplicate parent setting.
iio_dev.dev.parent is already set to the same value in
devm_iio_device_alloc()

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Cc: Ye Xiang <xiang.ye@intel.com>
Reviewed-by: Alexandru Ardelean <ardeleanalex@gmail.com>
Link: https://lore.kernel.org/r/20210426170251.351957-8-jic23@kernel.org
2021-05-17 13:49:12 +01:00
Jonathan Cameron
932bf4710e iio: humidity: hdc2010: Drop duplicate setting of iio_dev.dev.parent
Already set to same value in devm_iio_device_alloc()

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Cc: Eugene Zaikonnikov <ez@norphonic.com>
Reviewed-by: Alexandru Ardelean <ardeleanalex@gmail.com>
Link: https://lore.kernel.org/r/20210426170251.351957-7-jic23@kernel.org
2021-05-17 13:49:12 +01:00
Jonathan Cameron
9eb04878e4 iio: adc: ti-ads131e08: Drop duplicate setting of iio_dev.dev.parent
Already set to same value in devm_iio_device_alloc()

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Cc: Tomislav Denis <tomislav.denis@avl.com>
Reviewed-by: Alexandru Ardelean <ardeleanalex@gmail.com>
Link: https://lore.kernel.org/r/20210426170251.351957-6-jic23@kernel.org
2021-05-17 13:49:12 +01:00
Jonathan Cameron
85493b9ae8 iio: adc: mt6360: Drop duplicate setting of iio_dev.dev.parent
Already set to the same value in devm_iio_device_alloc()

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Cc: Gene Chen <gene_chen@richtek.com>
Reviewed-by: Alexandru Ardelean <ardeleanalex@gmail.com>
Link: https://lore.kernel.org/r/20210426170251.351957-5-jic23@kernel.org
2021-05-17 13:49:12 +01:00
Jonathan Cameron
806e657b0f iio: adc: mp2629: Drop duplicate setting iio_dev.dev.parent
This is already set to the same value in devm_iio_device_alloc()

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Cc: Saravanan Sekar <sravanhome@gmail.com>
Reviewed-by: Alexandru Ardelean <ardeleanalex@gmail.com>
Link: https://lore.kernel.org/r/20210426170251.351957-4-jic23@kernel.org
2021-05-17 13:49:12 +01:00
Jonathan Cameron
e42523c11f iio: dac: ad5766: Drop duplicate setting of iio_dev.dev.parent and of_node
This is set to the same value in devm_iio_device_alloc() so no need to do
it again.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Cc: Cristian Pop <cristian.pop@analog.com>
Reviewed-by: Alexandru Ardelean <ardeleanalex@gmail.com>
Link: https://lore.kernel.org/r/20210426170251.351957-3-jic23@kernel.org
2021-05-17 13:49:12 +01:00
Jonathan Cameron
cb25d770cf iio: accel: bmi088: Drop manual assignment of iio_dev.dev.parent
The core already set this to the same value in devm_iio_device_alloc()

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Cc: Mike Looijmans <mike.looijmans@topic.nl>
Reviewed-by: Alexandru Ardelean <ardeleanalex@gmail.com>
Link: https://lore.kernel.org/r/20210426170251.351957-2-jic23@kernel.org
2021-05-17 13:49:12 +01:00
Oleksij Rempel
9374e8f5a3 iio: adc: add ADC driver for the TI TSC2046 controller
Basically the TI TSC2046 touchscreen controller is 8 channel ADC optimized for
the touchscreen use case. By implementing it as an IIO ADC device, we can
make use of resistive-adc-touch and iio-hwmon drivers.

Polled readings are currently not implemented to keep this patch small, so
iio-hwmon will not work out of the box for now.

So far, this driver was tested with a custom version of resistive-adc-touch driver,
since it needs to be extended to make use of Z1 and Z2 channels. The X/Y
are working without additional changes.

Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Link: https://lore.kernel.org/r/20210428073208.19570-4-o.rempel@pengutronix.de
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-05-17 13:49:11 +01:00
Jonathan Cameron
fb6da706ff iio: adc: stm32-adc: Fix docs wrongly marked as kernel-doc
W=1 highlights these two cases that are obviously not in kernel-doc
format.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Cc: Fabrice Gasnier <fabrice.gasnier@foss.st.com>
Reviewed-by: Fabrice Gasnier <fabrice.gasnier@foss.st.com>
2021-05-17 13:49:11 +01:00
Tomasz Duszynski
b2e171f5a5 iio: sps30: add support for serial interface
Sensor has support for both i2c and serial communication interfaces.
Both offer very similar set of features. Minor differences don't impact
overall functionality like doing measurements, etc.

Support for i2c have already been added, this patch adds support
for the latter ie. serial interface.

Signed-off-by: Tomasz Duszynski <tomasz.duszynski@octakon.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-05-17 13:49:10 +01:00
Tomasz Duszynski
8f3f130852 iio: sps30: separate core and interface specific code
Move code responsible for handling i2c communication to a separate file.
Rationale for this change is preparation for adding support for serial
communication.

Signed-off-by: Tomasz Duszynski <tomasz.duszynski@octakon.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-05-17 13:49:10 +01:00
Nuno Sa
b27e1970aa iio: adis16400: do not directly change spi 'max_speed_hz'
With commit 3ba10e37371d ("iio: adis: add burst_max_speed_hz variable"), we
just need to define 'burst_max_speed_hz' and the adis core will take
care of setting up the spi transfers for burst mode. Hence, we fix
a potential race with the spi core where we could be left witn an
invalid 'max_speed_hz'.

Reviewed-by: Alexandru Ardelean <ardeleanalex@gmail.com>
Fixes: 5eda3550a3 ("staging:iio:adis16400: Preallocate transfer message")
Signed-off-by: Nuno Sa <nuno.sa@analog.com>
Link: https://lore.kernel.org/r/20210427085454.30616-7-nuno.sa@analog.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-05-17 13:49:10 +01:00
Nuno Sa
256e69ab96 iio: adis16475: do not directly change spi 'max_speed_hz'
With commit 3ba10e37371d ("iio: adis: add burst_max_speed_hz variable"), we
just need to define 'burst_max_speed_hz' and the adis core will take
care of setting up the spi transfers for burst mode. Hence, we fix
a potential race with the spi core where we could be left with an
invalid 'max_speed_hz'.

Reviewed-by: Alexandru Ardelean <ardeleanalex@gmail.com>
Fixes: fff7352bf7 ("iio: imu: Add support for adis16475")
Signed-off-by: Nuno Sa <nuno.sa@analog.com>
Link: https://lore.kernel.org/r/20210427085454.30616-6-nuno.sa@analog.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-05-17 13:49:09 +01:00
Nuno Sa
dbf20809d6 iio: adis: add burst_max_speed_hz variable
Typically, in burst mode, the device cannot operate at it's full spi
speed. Hence, the spi transfers for burst mode have to take this into
account. With this change we avoid a potential race with the spi core as
drivers were 'hacking' the device 'max_speed_hz' directly in the
trigger handler.

Reviewed-by: Alexandru Ardelean <ardeleanalex@gmail.com>
Signed-off-by: Nuno Sa <nuno.sa@analog.com>
Link: https://lore.kernel.org/r/20210427085454.30616-5-nuno.sa@analog.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-05-17 13:49:09 +01:00
Nuno Sa
669da56a7e iio: adis_buffer: don't push data to buffers on failure
There's no point in pushing data to IIO buffers in case 'spi_sync()'
fails.

Reviewed-by: Alexandru Ardelean <ardeleanalex@gmail.com>
Signed-off-by: Nuno Sa <nuno.sa@analog.com>
Link: https://lore.kernel.org/r/20210427085454.30616-4-nuno.sa@analog.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-05-17 13:49:09 +01:00
Nuno Sa
0ae157081c iio: adis_buffer: update device page after changing it
It makes more sense to update the device page as soon as we we
successfully changed it. Moreover, a follow up patch will handle
'spi_sync' error path which would leave 'current_page' in a inconsistent
state.

Signed-off-by: Nuno Sa <nuno.sa@analog.com>
Reviewed-by: Alexandru Ardelean <ardeleanalex@gmail.com>
Link: https://lore.kernel.org/r/20210427085454.30616-3-nuno.sa@analog.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-05-17 13:49:09 +01:00
Nuno Sa
00a72db718 iio: adis16475: do not return ints in irq handlers
On an IRQ handler we should not return normal error codes as 'irqreturn_t'
is expected.

This is done by jumping to the 'check_burst32' label where we return
'IRQ_HANDLED'. Note that it is fine to do the burst32 check in this
error path. If we have proper settings to apply burst32, we might just
do the setup now so that the next sample already uses it.

Fixes: fff7352bf7 ("iio: imu: Add support for adis16475")
Reviewed-by: Alexandru Ardelean <ardeleanalex@gmail.com>
Signed-off-by: Nuno Sa <nuno.sa@analog.com>
Link: https://lore.kernel.org/r/20210427085454.30616-2-nuno.sa@analog.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-05-17 13:49:09 +01:00
Tomas Melin
9cc9806e22 iio: accel: Add driver for Murata SCA3300 accelerometer
Add initial support for Murata SCA3300 3-axis industrial
accelerometer with digital SPI interface. This device also
provides a temperature measurement.

Datasheet: https://www.murata.com/en-global/products/sensor/accel/sca3300
Signed-off-by: Tomas Melin <tomas.melin@vaisala.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Link: https://lore.kernel.org/r/20210426081041.59807-3-tomas.melin@vaisala.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-05-17 13:49:09 +01:00
Jonathan Cameron
7bf50a968a iio:adc:ad7476: Handle the different regulators used by various parts.
Not all of the parts supported by this driver use single supply.
Hence we add chip_info fields to say what additional supplies exist
and in the case of vref, ensure that is used for the reference voltage
rather than vcc.

One corner case is the ad7091r which has an internal reference that
can be over-driven by an external reference connected on the vref pin.
To handle that force_ext_vref is introduced and set if an optional
vref regulator is present.

Tested using really simple QEMU model and some fixed regulators.

The devm_add_action_or_reset() callback is changed to take the
regulator as it's parameter so we can use one callback for all the
different regulators without having to store pointers to them in
the iio_priv() structure.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Cc: Michael Hennerich <michael.hennerich@analog.com>
Reported-by: kernel test robot <lkp@intel.com>
Reviewed-by: Lars-Peter Clausen <lars@metafoo.de>
Link: https://lore.kernel.org/r/20210425163154.73209-2-jic23@kernel.org
2021-05-17 13:49:08 +01:00
Jonathan Cameron
6e5566e72d iio:accel:stk8312: Add lowercase i2c device id
These are never upper case.  Chances are that all users of this driver
were using the ACPI binding but just in case keep the uppercase version
but mark it deprecated.

Whilst here tidy up some spacing.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Link: https://lore.kernel.org/r/20210401144226.225928-1-jic23@kernel.org
2021-05-17 13:49:08 +01:00
Yicong Yang
7349e8a36c iio: inkern: simplify some devm functions
Use devm_add_action_or_reset() instead of devres_alloc() and
devres_add(), which works the same. This will simplify the
code. There is no functional changes.

Signed-off-by: Yicong Yang <yangyicong@hisilicon.com>
Reviewed-by: Lars-Peter Clausen <lars@metafoo.de>
Reviewed-by: Nuno Sa <nuno.sa@analog.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Link: https://lore.kernel.org/r/1617881896-3164-8-git-send-email-yangyicong@hisilicon.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-05-17 13:49:07 +01:00
Yicong Yang
171a70afbd iio: trigger: simplify __devm_iio_trigger_register
Use devm_add_action_or_reset() instead of devres_alloc() and
devres_add(), which works the same. This will simplify the
code. There is no functional changes.

Signed-off-by: Yicong Yang <yangyicong@hisilicon.com>
Reviewed-by: Lars-Peter Clausen <lars@metafoo.de>
Reviewed-by: Nuno Sa <nuno.sa@analog.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Link: https://lore.kernel.org/r/1617881896-3164-7-git-send-email-yangyicong@hisilicon.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-05-17 13:49:07 +01:00
Yicong Yang
cf5724e915 iio: core: simplify some devm functions
Use devm_add_action_or_reset() instead of devres_alloc() and
devres_add(), which works the same. This will simplify the
code. There is no functional changes.

Signed-off-by: Yicong Yang <yangyicong@hisilicon.com>
Reviewed-by: Lars-Peter Clausen <lars@metafoo.de>
Reviewed-by: Nuno Sa <nuno.sa@analog.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Link: https://lore.kernel.org/r/1617881896-3164-6-git-send-email-yangyicong@hisilicon.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-05-17 13:49:07 +01:00
Yicong Yang
8e39d4723a iio: triggered-buffer: simplify devm_iio_triggered_buffer_setup_ext()
Use devm_add_action_or_reset() instead of devres_alloc() and
devres_add(), which works the same. This will simplify the
code. There is no functional changes.

Signed-off-by: Yicong Yang <yangyicong@hisilicon.com>
Reviewed-by: Lars-Peter Clausen <lars@metafoo.de>
Reviewed-by: Nuno Sa <nuno.sa@analog.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Link: https://lore.kernel.org/r/1617881896-3164-5-git-send-email-yangyicong@hisilicon.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-05-17 13:49:07 +01:00
Yicong Yang
bfc1807acf iio: hw_consumer: simplify devm_iio_hw_consumer_alloc()
Use devm_add_action_or_reset() instead of devres_alloc() and
devres_add(), which works the same. This will simplify the
code. There is no functional changes.

Signed-off-by: Yicong Yang <yangyicong@hisilicon.com>
Reviewed-by: Lars-Peter Clausen <lars@metafoo.de>
Reviewed-by: Nuno Sa <nuno.sa@analog.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Link: https://lore.kernel.org/r/1617881896-3164-4-git-send-email-yangyicong@hisilicon.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-05-17 13:49:06 +01:00
Yicong Yang
2c6a958789 iio: buffer-dmaengine: simplify __devm_iio_dmaengine_buffer_free()
Use devm_add_action_or_reset() instead of devres_alloc() and
devres_add(), which works the same. This will simplify the
code. There is no functional changes.

Signed-off-by: Yicong Yang <yangyicong@hisilicon.com>
Reviewed-by: Lars-Peter Clausen <lars@metafoo.de>
Reviewed-by: Nuno Sa <nuno.sa@analog.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Link: https://lore.kernel.org/r/1617881896-3164-3-git-send-email-yangyicong@hisilicon.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-05-17 13:49:06 +01:00
Yicong Yang
4e023c4dcf iio: adc: adi-axi-adc: simplify devm_adi_axi_adc_conv_register()
Use devm_add_action_or_reset() instead of devres_alloc() and
devres_add(), which works the same. This will simplify the
code. There is no functional changes.

Signed-off-by: Yicong Yang <yangyicong@hisilicon.com>
Reviewed-by: Alexandru Ardelean <ardeleanalex@gmail.com>
Reviewed-by: Lars-Peter Clausen <lars@metafoo.de>
Reviewed-by: Nuno Sa <nuno.sa@analog.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Link: https://lore.kernel.org/r/1617881896-3164-2-git-send-email-yangyicong@hisilicon.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-05-17 13:49:06 +01:00
Joe Sandom
2335f0d7c7 iio: light: Added AMS tsl2591 driver implementation
Driver implementation for AMS/TAOS tsl2591 ambient light sensor.

This driver supports configuration via device tree and sysfs.
Supported channels for raw infrared light intensity,
raw combined light intensity and illuminance in lux.
The driver additionally supports iio events on lower and
upper thresholds.

This is a very-high sensitivity light-to-digital converter that
transforms light intensity into a digital signal.

Datasheet: https://ams.com/tsl25911#tab/documents
Signed-off-by: Joe Sandom <joe.g.sandom@gmail.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Link: https://lore.kernel.org/r/20210421221330.17007-1-joe.g.sandom@gmail.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-05-17 13:49:06 +01:00
Nuno Sa
00f6742b5f iio: adis_buffer: check return value on page change
On the trigger handler, we might need to change the device page. Hence,
we should check the return value from 'spi_write()' and act accordingly.

Signed-off-by: Nuno Sa <nuno.sa@analog.com>
Reviewed-by: Alexandru Ardelean <ardeleanalex@gmail.com>
Link: https://lore.kernel.org/r/20210422101911.135630-5-nuno.sa@analog.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-05-17 13:49:06 +01:00
Nuno Sa
ab3df79782 iio: adis16400: do not return ints in irq handlers
On an IRQ handler we should not return normal error codes as 'irqreturn_t'
is expected.

Not necessary to apply to stable as the original check cannot fail and
as such the bug cannot actually occur.

Fixes: 5eda3550a3 ("staging:iio:adis16400: Preallocate transfer message")
Reviewed-by: Alexandru Ardelean <ardeleanalex@gmail.com>
Signed-off-by: Nuno Sa <nuno.sa@analog.com>
Link: https://lore.kernel.org/r/20210422101911.135630-3-nuno.sa@analog.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-05-17 13:49:06 +01:00
Nuno Sa
d877539ad8 iio: adis_buffer: do not return ints in irq handlers
On an IRQ handler we should not return normal error codes as 'irqreturn_t'
is expected.

Not necessarily stable material as the old check cannot fail, so it's a bug
we can not hit.

Fixes: ccd2b52f4a ("staging:iio: Add common ADIS library")
Reviewed-by: Alexandru Ardelean <ardeleanalex@gmail.com>
Signed-off-by: Nuno Sa <nuno.sa@analog.com>
Link: https://lore.kernel.org/r/20210422101911.135630-2-nuno.sa@analog.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-05-17 13:49:06 +01:00
Andy Shevchenko
494186662e iio: adc: ad7298: Enable on Intel Galileo Gen 1
Enable ADC on Intel Galileo Gen 1 board.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://lore.kernel.org/r/20210412131835.70212-1-andriy.shevchenko@linux.intel.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-05-17 13:49:05 +01:00
Tian Tao
8bad605065 iio: trigger: stm32-timer: Convert sysfs sprintf/snprintf family to sysfs_emit
Fix the following coccicheck warning:
drivers/iio/trigger/stm32-timer-trigger.c:299:8-16: WARNING:
use scnprintf or sprintf

Signed-off-by: Tian Tao <tiantao6@hisilicon.com>
Link: https://lore.kernel.org/r/1618216751-1678-4-git-send-email-tiantao6@hisilicon.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-05-17 13:49:05 +01:00
Tian Tao
c79859bd77 iio: light: Convert sysfs sprintf/snprintf family to sysfs_emit
Fix the following coccicheck warning:
drivers/iio/light/veml6030.c:131:8-16: WARNING:
use scnprintf or sprintf

Signed-off-by: Tian Tao <tiantao6@hisilicon.com>
Link: https://lore.kernel.org/r/1618216751-1678-3-git-send-email-tiantao6@hisilicon.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-05-17 13:49:05 +01:00
Tian Tao
643adb9af7 iio:chemical:sps30: Convert sysfs sprintf/snprintf family to sysfs_emit
Fix the following coccicheck warning:
./drivers/iio/chemical/sps30.c:414:8-16: WARNING:
use scnprintf or sprintf

Signed-off-by: Tian Tao <tiantao6@hisilicon.com>
Link: https://lore.kernel.org/r/1618216751-1678-2-git-send-email-tiantao6@hisilicon.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-05-17 13:49:05 +01:00
Puranjay Mohan
df041e737a iio: temperature: add driver support for ti tmp117
TMP117 is a Digital temperature sensor with integrated Non-Volatile memory.
Add support for tmp117 driver in iio subsystem.

Datasheet: https://www.ti.com/lit/gpn/tmp117
Signed-off-by: Puranjay Mohan <puranjay12@gmail.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Reviewed-by: Lars-Peter Clausen <lars@metafoo.de>
Link: https://lore.kernel.org/r/20210407182147.77221-3-puranjay12@gmail.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-05-17 13:49:05 +01:00
Krzysztof Kozlowski
3cdea6e9a8 iio: adc: exynos: drop unneeded variable assignment
The initialization of 'ret' variable in probe function is shortly after
overwritten.  This initialization is simply not used.

Addresses-Coverity: Unused value
Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
Reviewed-by: Alim Akhtar <alim.akhtar@samsung.com>
Link: https://lore.kernel.org/r/20210410164728.8096-1-krzysztof.kozlowski@canonical.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-05-17 13:49:04 +01:00
Alexandru Ardelean
b0f27fca5a iio: adc: ad7192: handle regulator voltage error first
This change fixes a corner-case, where for a zero regulator value, the
driver would exit early, initializing the driver only partially.
The driver would be in an unknown state.

This change reworks the code to check regulator_voltage() return value
for negative (error) first, and return early. This is the more common
idiom.

Also, this change is removing the 'voltage_uv' variable and using the 'ret'
value directly. The only place where 'voltage_uv' is being used is to
compute the internal reference voltage, and the type of this variable is
'int' (same are for 'ret'). Using only 'ret' avoids having to assign it on
the error path.

Fixes: ab0afa65bb ("staging: iio: adc: ad7192: fail probe on get_voltage")
Cc: Alexandru Tachici <alexandru.tachici@analog.com>
Signed-off-by: Alexandru Ardelean <aardelean@deviqon.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Cc: <Stable@vger.kernel.org>
2021-05-13 16:36:49 +01:00
Jonathan Cameron
e32fe6d90f iio: adc: ad7192: Avoid disabling a clock that was never enabled.
Found by inspection.

If the internal clock source is being used, the driver doesn't
call clk_prepare_enable() and as such we should not call
clk_disable_unprepare()

Use the same condition to protect the disable path as is used
on the enable one.  Note this will all get simplified when
the driver moves over to a full devm_ flow, but that would make
backporting the fix harder.

Fix obviously predates move out of staging, but backporting will
become more complex (and is unlikely to happen), hence that patch
is given in the fixes tag.

Alexandru's sign off is here because he added this patch into
a larger series that Jonathan then applied.

Fixes: b581f748cc ("staging: iio: adc: ad7192: move out of staging")
Cc: Alexandru Tachici <alexandru.tachici@analog.com>
Reviewed-by: Alexandru Ardelean <ardeleanalex@gmail.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Signed-off-by: Alexandru Ardelean <aardelean@deviqon.com>
Cc: <Stable@vger.kernel.org>
2021-05-13 16:34:21 +01:00
Jonathan Cameron
f2a772c512 iio: adc: ad7124: Fix potential overflow due to non sequential channel numbers
Channel numbering must start at 0 and then not have any holes, or
it is possible to overflow the available storage.  Note this bug was
introduced as part of a fix to ensure we didn't rely on the ordering
of child nodes.  So we need to support arbitrary ordering but they all
need to be there somewhere.

Note I hit this when using qemu to test the rest of this series.
Arguably this isn't the best fix, but it is probably the most minimal
option for backporting etc.

Alexandru's sign-off is here because he carried this patch in a larger
set that Jonathan then applied.

Fixes: d7857e4ee1 ("iio: adc: ad7124: Fix DT channel configuration")
Reviewed-by: Alexandru Ardelean <ardeleanalex@gmail.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Signed-off-by: Alexandru Ardelean <aardelean@deviqon.com>
Cc: <Stable@vger.kernel.org>
2021-05-13 16:32:55 +01:00
Jonathan Cameron
4573472315 iio: adc: ad7124: Fix missbalanced regulator enable / disable on error.
If the devm_regulator_get() call succeeded but not the regulator_enable()
then regulator_disable() would be called on a regulator that was not
enabled.

Fix this by moving regulator enabling / disabling over to
devm_ management via devm_add_action_or_reset.

Alexandru's sign-off here because he pulled Jonathan's patch into
a larger set which Jonathan then applied.

Fixes: b3af341bbd ("iio: adc: Add ad7124 support")
Reviewed-by: Alexandru Ardelean <ardeleanalex@gmail.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Signed-off-by: Alexandru Ardelean <aardelean@deviqon.com>
Cc: <Stable@vger.kernel.org>
2021-05-13 16:32:39 +01:00
Colin Ian King
af0e1871d7 iio: tsl2583: Fix division by a zero lux_val
The lux_val returned from tsl2583_get_lux can potentially be zero,
so check for this to avoid a division by zero and an overflowed
gain_trim_val.

Fixes clang scan-build warning:

drivers/iio/light/tsl2583.c:345:40: warning: Either the
condition 'lux_val<0' is redundant or there is division
by zero at line 345. [zerodivcond]

Fixes: ac4f6eee8f ("staging: iio: TAOS tsl258x: Device driver")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
Cc: <Stable@vger.kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-05-10 14:01:48 +01:00
Alexandru Ardelean
af0670b0bf iio: core: return ENODEV if ioctl is unknown
When the ioctl() mechanism was introduced in IIO core to centralize the
registration of all ioctls in one place via commit 8dedcc3eee ("iio:
core: centralize ioctl() calls to the main chardev"), the return code was
changed from ENODEV to EINVAL, when the ioctl code isn't known.

This was done by accident.

This change reverts back to the old behavior, where if the ioctl() code
isn't known, ENODEV is returned (vs EINVAL).

This was brought into perspective by this patch:
  https://lore.kernel.org/linux-iio/20210428150815.136150-1-paul@crapouillou.net/

Fixes: 8dedcc3eee ("iio: core: centralize ioctl() calls to the main chardev")
Signed-off-by: Alexandru Ardelean <aardelean@deviqon.com>
Reviewed-by: Nuno Sá <nuno.sa@analog.com>
Tested-by: Paul Cercueil <paul@crapouillou.net>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-05-10 14:01:48 +01:00
Tomasz Duszynski
901f84de0e iio: core: fix ioctl handlers removal
Currently ioctl handlers are removed twice. For the first time during
iio_device_unregister() then later on inside
iio_device_unregister_eventset() and iio_buffers_free_sysfs_and_mask().
Double free leads to kernel panic.

Fix this by not touching ioctl handlers list directly but rather
letting code responsible for registration call the matching cleanup
routine itself.

Fixes: 8dedcc3eee ("iio: core: centralize ioctl() calls to the main chardev")
Signed-off-by: Tomasz Duszynski <tomasz.duszynski@octakon.com>
Acked-by: Alexandru Ardelean <ardeleanalex@gmail.com>
Cc: <Stable@vger.kernel.org>
Link: https://lore.kernel.org/r/20210423080244.2790-1-tomasz.duszynski@octakon.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-05-10 14:01:48 +01:00
Dmitry Osipenko
f73c730774 iio: gyro: mpu3050: Fix reported temperature value
The raw temperature value is a 16-bit signed integer. The sign casting
is missing in the code, which results in a wrong temperature reported
by userspace tools, fix it.

Cc: stable@vger.kernel.org
Fixes: 3904b28efb ("iio: gyro: Add driver for the MPU-3050 gyroscope")
Datasheet: https://www.cdiweb.com/datasheets/invensense/mpu-3000a.pdf
Tested-by: Maxim Schwalm <maxim.schwalm@gmail.com> # Asus TF700T
Tested-by: Svyatoslav Ryhel <clamor95@gmail.com> # Asus TF201
Reported-by: Svyatoslav Ryhel <clamor95@gmail.com>
Reviewed-by: Andy Shevchenko <Andy.Shevchenko@gmail.com>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
Acked-by: Jean-Baptiste Maneyrol <jmaneyrol@invensense.com>
Link: https://lore.kernel.org/r/20210423020959.5023-1-digetx@gmail.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-05-10 14:01:48 +01:00
Alexandru Ardelean
7061803522 iio: hid-sensors: select IIO_TRIGGERED_BUFFER under HID_SENSOR_IIO_TRIGGER
During commit 067fda1c06 ("iio: hid-sensors: move triggered buffer
setup into hid_sensor_setup_trigger"), the
iio_triggered_buffer_{setup,cleanup}() functions got moved under the
hid-sensor-trigger module.

The above change works fine, if any of the sensors get built. However, when
only the common hid-sensor-trigger module gets built (and none of the
drivers), then the IIO_TRIGGERED_BUFFER symbol isn't selected/enforced.

Previously, each driver would enforce/select the IIO_TRIGGERED_BUFFER
symbol. With this change the HID_SENSOR_IIO_TRIGGER (for the
hid-sensor-trigger module) will enforce that IIO_TRIGGERED_BUFFER gets
selected.

All HID sensor drivers select the HID_SENSOR_IIO_TRIGGER symbol. So, this
change removes the IIO_TRIGGERED_BUFFER enforcement from each driver.

Fixes: 067fda1c06 ("iio: hid-sensors: move triggered buffer setup into hid_sensor_setup_trigger")
Reported-by: Thomas Deutschmann <whissi@gentoo.org>
Cc: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Signed-off-by: Alexandru Ardelean <aardelean@deviqon.com>
Acked-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Link: https://lore.kernel.org/r/20210414084955.260117-1-aardelean@deviqon.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-05-10 14:01:48 +01:00
Dinghao Liu
a2fa9242e8 iio: proximity: pulsedlight: Fix rumtime PM imbalance on error
When lidar_write_control() fails, a pairing PM usage counter
decrement is needed to keep the counter balanced.

Fixes: 4ac4e086fd ("iio: pulsedlight-lidar-lite: add runtime PM")
Signed-off-by: Dinghao Liu <dinghao.liu@zju.edu.cn>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Link: https://lore.kernel.org/r/20210412053204.4889-1-dinghao.liu@zju.edu.cn
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-05-10 14:01:48 +01:00
Dinghao Liu
8edb79af88 iio: light: gp2ap002: Fix rumtime PM imbalance on error
When devm_request_threaded_irq() fails, we should decrease the
runtime PM counter to keep the counter balanced. But when
iio_device_register() fails, we need not to decrease it because
we have already decreased it before.

Signed-off-by: Dinghao Liu <dinghao.liu@zju.edu.cn>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Fixes: 97d642e230 ("iio: light: Add a driver for Sharp GP2AP002x00F")
Link: https://lore.kernel.org/r/20210407034927.16882-1-dinghao.liu@zju.edu.cn
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-05-10 14:01:48 +01:00
Linus Torvalds
4a0225c3d2 spi: Updates for v5.13
The only core work for SPI this time around is the completion of the
 conversion to the new style method for specifying transfer delays,
 meaning we can cope with what most controllers support more directly
 using conversions in the core rather than open coding in drivers.
 Otherwise it's a good stack of cleanups and fixes plus a few new
 drivers.
 
 The conversion to new style transfer delay will cause an issue with a
 newly added staging driver which has a straightforward resolution in
 -next.
 
  - Completion of the conversion to new style transfer delay
    configuration.
  - Introduction and use of module_parport_driver() helper, merged here
    as there's no parport tree.
  - Support for Altera SoCs on DFL buses, NXP i.MX8DL, HiSilicon Kunpeng,
    MediaTek MT8195,
 -----BEGIN PGP SIGNATURE-----
 
 iQEzBAABCgAdFiEEreZoqmdXGLWf4p/qJNaLcl1Uh9AFAmCG0FYACgkQJNaLcl1U
 h9BXlAf/ZQaU8Nq4NY2jgjzjUoplF4qSFvCZ05CXqfYftaAOp06AmoOwNuNTz2gU
 Fkxouuw3D0hNmaeVusF1PaRjIvJCu+RO68EDrzTJlcFytyC8CxWSDE4Yw6ytOBUM
 OWZdVXsuw0CUk3VRJl2ycCooeTyKaCksfkVucocZAoyexcfQrFpxkOCUbA8hVM43
 Hghzb8HWAZUerrfwreSwfvyVMralR3rqqbZFKgSgT/sRM3zpaR4sctIkNgKKEbFE
 eRPRfBIWWZdJtjQ+uifFAc3jJHeZlmNXuQq3C+ETd2vQDFlymTxj+U3u74ieZxrm
 c6V4u4R3+Qx9qONV/q0LV6E4sBSvdw==
 =cBUy
 -----END PGP SIGNATURE-----

Merge tag 'spi-v5.13' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi

Pull spi updates from Mark Brown:
 "The only core work for SPI this time around is the completion of the
  conversion to the new style method for specifying transfer delays,
  meaning we can cope with what most controllers support more directly
  using conversions in the core rather than open coding in drivers.

  Otherwise it's a good stack of cleanups and fixes plus a few new
  drivers.

  Summary:

   - Completion of the conversion to new style transfer delay
     configuration

   - Introduction and use of module_parport_driver() helper, merged here
     as there's no parport tree

   - Support for Altera SoCs on DFL buses, NXP i.MX8DL, HiSilicon
     Kunpeng, MediaTek MT8195"

* tag 'spi-v5.13' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi: (113 commits)
  spi: Rename enable1 to activate in spi_set_cs()
  spi: Convert Freescale QSPI binding to json schema
  spi: stm32-qspi: fix debug format string
  spi: tools: make a symbolic link to the header file spi.h
  spi: fsi: add a missing of_node_put
  spi: Make error handling of gpiod_count() call cleaner
  spidev: Add Micron SPI NOR Authenta device compatible
  spi: brcm,spi-bcm-qspi: convert to the json-schema
  spi: altera: Add DFL bus driver for Altera API Controller
  spi: altera: separate core code from platform code
  spi: stm32-qspi: Fix compilation warning in ARM64
  spi: Handle SPI device setup callback failure.
  spi: sync up initial chipselect state
  spi: stm32-qspi: Add dirmap support
  spi: stm32-qspi: Trigger DMA only if more than 4 bytes to transfer
  spi: stm32-qspi: fix pm_runtime usage_count counter
  spi: spi-zynqmp-gqspi: return -ENOMEM if dma_map_single fails
  spi: spi-zynqmp-gqspi: fix use-after-free in zynqmp_qspi_exec_op
  spi: spi-zynqmp-gqspi: Resolved slab-out-of-bounds bug
  spi: spi-zynqmp-gqspi: fix hang issue when suspend/resume
  ...
2021-04-26 16:32:11 -07:00
Linus Torvalds
d8f9176b4e ACPI updates for 5.13-rc1
- Update ACPICA code in the kernel to upstream revision 20210331
    including the following changes:
 
    * Add parsing for IVRS IVHD 40h and device entry F0h (Alexander
      Monakov).
 
    * Add new CEDT table for CXL 2.0 and iASL support for it (Ben
      Widawsky, Bob Moore).
 
    * NFIT: add Location Cookie field (Bob Moore).
 
    * HMAT: add new fields/flags (Bob Moore).
 
    * Add new flags in SRAT (Bob Moore).
 
    * PMTT: add new fields/structures (Bob Moore).
 
    * Add CSI2Bus resource template (Bob Moore).
 
    * iASL: Decode subtable type field for VIOT (Bob Moore).
 
    * Fix various typos and spelling mistakes (Colin Ian King).
 
    * Add new predefined objects _BPC, _BPS, and _BPT (Erik Kaneda).
 
    * Add USB4 capabilities UUID (Erik Kaneda).
 
    * Add CXL ACPI device ID and _CBR object (Erik Kaneda).
 
    * MADT: add Multiprocessor Wakeup Structure (Erik Kaneda).
 
    * PCCT: add support for subtable type 5 (Erik Kaneda).
 
    * PPTT: add new version of subtable type 1 (Erik Kaneda).
 
    * Add SDEV secure access components (Erik Kaneda).
 
    * Add support for PHAT table (Erik Kaneda).
 
    * iASL: Add definitions for the VIOT table (Jean-Philippe Brucker).
 
    * acpisrc: Add missing conversion for VIOT support (Jean-Philippe
      Brucker).
 
    * IORT: Updates for revision E.b (Shameer Kolothum).
 
  - Rearrange message printing in ACPI-related code to avoid using the
    ACPICA's internal message printing macros outside ACPICA and do
    some related code cleanups (Rafael Wysocki).
 
  - Modify the device enumeration code to turn off all of the unused
    ACPI power resources at the end (Rafael Wysocki).
 
  - Change the ACPI power resources handling code to turn off unused
    ACPI power resources without checking their status which should
    not be necessary by the spec (Rafael Wysocki).
 
  - Add empty stubs for CPPC-related functions to be used when
    CONFIG_ACPI_CPPC_LIB is not set (Rafael Wysocki).
 
  - Simplify device enumeration code (Rafael Wysocki).
 
  - Change device enumeration code to use match_string() for string
    matching (Andy Shevchenko).
 
  - Modify irqresource_disabled() to retain the resouce flags that
    have been set already (Angela Czubak).
 
  - Add native backlight whitelist entry for GA401/GA502/GA503 (Luke
    Jones).
 
  - Modify the ACPI backlight driver to let the native backlight
    handling take over on hardware-reduced systems (Hans de Goede).
 
  - Introduce acpi_dev_get() and switch over the ACPI core code to
    using it (Andy Shevchenko).
 
  - Use kobj_attribute as callback argument instead of a local struct
    type in the CPPC linrary code (Nathan Chancellor).
 
  - Drop unneeded initializatio of a static variable from the ACPI
    processor driver (Tian Tao).
 
  - Drop unnecessary local variable assignment from the ACPI APEI
    code (Colin Ian King).
 
  - Document for_each_acpi_dev_match() macro (Andy Shevchenko).
 
  - Address assorted coding style issues in multiple places (Xiaofei
    Tan).
 
  - Capitalize TLAs in a few comments (Andy Shevchenko).
 
  - Correct assorted typos in comments (Tom Saeger).
 -----BEGIN PGP SIGNATURE-----
 
 iQJGBAABCAAwFiEE4fcc61cGeeHD/fCwgsRv/nhiVHEFAmCHAL8SHHJqd0Byand5
 c29ja2kubmV0AAoJEILEb/54YlRxZroQAIdFsRUTKmm8st9sdfEtF3QHLS3/EV2x
 1GlkL+3yE/WuEFXNd0mAv0MTcV2sNMKGd5oz74zLkciPC2dNR4168Ni6DhGSoELM
 0ZMOAu9E12Nyq7/1FdWalLQprtR8OuLVwgC2VckK+f//4vzpZ+6PtGMwAwtImSHK
 m3WRPimVbgOVJ1UWZjsfIm7kLBD4o4oCx0pdeEl77q0oQKmMdcByUh2YnjwKzFnP
 9zqV+SCi3HL4w67HO/uMe7x8isNyWONYXVqOvOkgXi7PeoX9v0XiWSCJ0KnAvbI1
 PZokJT8pTrKnFyL3zJS6pU/ZHj7ikFiTc+MfyyPcYRJZ5nBvRjqHKoPOtZ9yfU6n
 jgt/u3REhqwnHy0ikS8HsP+PWnAJF1Re3sNVvIMnX6XxTIndHCXZEoeldfeC23S9
 PmzGA0//iPngiYaOVM5BxIjRi2nRBHlVvzSIACICXDcszA81RHePFIzfjUgW3elp
 v6kAhkrXYajqrDb7NuvY4MTuuBo8w3q2xWJGu5VlDkNOblM0AExRhXmvp1RW0kL7
 +mi5X6xBFEB9M6hEoWKnleaZTXTlFYBreKsMPEEP7N7a5+UZRPedcjX1PflCkOB3
 uL5p/+x3br1fkDyK0P7wFf3VqiBXuwFajEdCmyHnizpD6m0oWC6pv9PUGYUCneJ1
 JGH5X/3Uu33D
 =5fuB
 -----END PGP SIGNATURE-----

Merge tag 'acpi-5.13-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm

Pull ACPI updates from Rafael Wysocki:
 "These update the ACPICA code in the kernel to the most recent upstream
  revision including (but not limited to) new material introduced in the
  6.4 version of the spec, update message printing in the ACPI-related
  code, address a few issues and clean up code in a number of places.

  Specifics:

   - Update ACPICA code in the kernel to upstream revision 20210331
     including the following changes:

      * Add parsing for IVRS IVHD 40h and device entry F0h (Alexander
        Monakov).

      * Add new CEDT table for CXL 2.0 and iASL support for it (Ben
        Widawsky, Bob Moore).

      * NFIT: add Location Cookie field (Bob Moore).

      * HMAT: add new fields/flags (Bob Moore).

      * Add new flags in SRAT (Bob Moore).

      * PMTT: add new fields/structures (Bob Moore).

      * Add CSI2Bus resource template (Bob Moore).

      * iASL: Decode subtable type field for VIOT (Bob Moore).

      * Fix various typos and spelling mistakes (Colin Ian King).

      * Add new predefined objects _BPC, _BPS, and _BPT (Erik Kaneda).

      * Add USB4 capabilities UUID (Erik Kaneda).

      * Add CXL ACPI device ID and _CBR object (Erik Kaneda).

      * MADT: add Multiprocessor Wakeup Structure (Erik Kaneda).

      * PCCT: add support for subtable type 5 (Erik Kaneda).

      * PPTT: add new version of subtable type 1 (Erik Kaneda).

      * Add SDEV secure access components (Erik Kaneda).

      * Add support for PHAT table (Erik Kaneda).

      * iASL: Add definitions for the VIOT table (Jean-Philippe
        Brucker).

      * acpisrc: Add missing conversion for VIOT support (Jean-Philippe
        Brucker).

      * IORT: Updates for revision E.b (Shameer Kolothum).

   - Rearrange message printing in ACPI-related code to avoid using the
     ACPICA's internal message printing macros outside ACPICA and do
     some related code cleanups (Rafael Wysocki).

   - Modify the device enumeration code to turn off all of the unused
     ACPI power resources at the end (Rafael Wysocki).

   - Change the ACPI power resources handling code to turn off unused
     ACPI power resources without checking their status which should not
     be necessary by the spec (Rafael Wysocki).

   - Add empty stubs for CPPC-related functions to be used when
     CONFIG_ACPI_CPPC_LIB is not set (Rafael Wysocki).

   - Simplify device enumeration code (Rafael Wysocki).

   - Change device enumeration code to use match_string() for string
     matching (Andy Shevchenko).

   - Modify irqresource_disabled() to retain the resouce flags that have
     been set already (Angela Czubak).

   - Add native backlight whitelist entry for GA401/GA502/GA503 (Luke
     Jones).

   - Modify the ACPI backlight driver to let the native backlight
     handling take over on hardware-reduced systems (Hans de Goede).

   - Introduce acpi_dev_get() and switch over the ACPI core code to
     using it (Andy Shevchenko).

   - Use kobj_attribute as callback argument instead of a local struct
     type in the CPPC linrary code (Nathan Chancellor).

   - Drop unneeded initializatio of a static variable from the ACPI
     processor driver (Tian Tao).

   - Drop unnecessary local variable assignment from the ACPI APEI code
     (Colin Ian King).

   - Document for_each_acpi_dev_match() macro (Andy Shevchenko).

   - Address assorted coding style issues in multiple places (Xiaofei
     Tan).

   - Capitalize TLAs in a few comments (Andy Shevchenko).

   - Correct assorted typos in comments (Tom Saeger)"

* tag 'acpi-5.13-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm: (68 commits)
  ACPI: video: use native backlight for GA401/GA502/GA503
  ACPI: APEI: remove redundant assignment to variable rc
  ACPI: utils: Capitalize abbreviations in the comments
  ACPI: utils: Document for_each_acpi_dev_match() macro
  ACPI: bus: Introduce acpi_dev_get() and reuse it in ACPI code
  ACPI: scan: Utilize match_string() API
  resource: Prevent irqresource_disabled() from erasing flags
  ACPI: CPPC: Replace cppc_attr with kobj_attribute
  ACPI: scan: Call acpi_get_object_info() from acpi_set_pnp_ids()
  ACPI: scan: Drop sta argument from acpi_init_device_object()
  ACPI: scan: Drop sta argument from acpi_add_single_object()
  ACPI: scan: Rearrange checks in acpi_bus_check_add()
  ACPI: scan: Fold acpi_bus_type_and_status() into its caller
  ACPI: video: Check LCD flag on ACPI-reduced-hardware devices
  ACPI: utils: Add acpi_reduced_hardware() helper
  ACPI: dock: fix some coding style issues
  ACPI: sysfs: fix some coding style issues
  ACPI: PM: add a missed blank line after declarations
  ACPI: custom_method: fix a coding style issue
  ACPI: CPPC: fix some coding style issues
  ...
2021-04-26 15:03:23 -07:00
Linus Torvalds
37f00ab4a0 ARM: SoC drivers for v5.13
Updates for SoC specific drivers include a few subsystems that
 have their own maintainers but send them through the soc tree:
 
 TEE/OP-TEE:
  -  Add tracepoints around calls to secure world
 
 Memory controller drivers:
  - Minor fixes for Renesas, Exynos, Mediatek and Tegra platforms
  - Add debug statistics to Tegra20 memory controller
  - Update Tegra bindings and convert to dtschema
 
 ARM SCMI Firmware:
  - Support for modular SCMI protocols and vendor specific extensions
  - New SCMI IIO driver
  - Per-cpu DVFS
 
 The other driver changes are all from the platform maintainers
 directly and reflect the drivers that don't fit into any other
 subsystem as well as treewide changes for a particular platform.
 
 SoCFPGA:
  - Various cleanups contributed by Krzysztof Kozlowski
 
 Mediatek:
  - add MT8183 support to mutex driver
  - MMSYS: use per SoC array to describe the possible routing
  - add MMSYS support for MT8183 and MT8167
  - add support for PMIC wrapper with integrated arbiter
  - add support for MT8192/MT6873
 
 Tegra:
  - Bug fixes to PMC and clock drivers
 
 NXP/i.MX:
  - Update SCU power domain driver to keep console domain power on.
  - Add missing ADC1 power domain to SCU power domain driver.
  - Update comments for single global power domain in SCU power domain
    driver.
  - Add i.MX51/i.MX53 unique id support to i.MX SoC driver.
 
 NXP/FSL SoC driver updates for v5.13
  - Add ACPI support for RCPM driver
  - Use generic io{read,write} for QE drivers after performance optimized
    for PowerPC
  - Fix QBMAN probe to cleanup HW states correctly for kexec
  - Various cleanup and style fix for QBMAN/QE/GUTS drivers
 
 OMAP:
  - Preparation to use devicetree for genpd
  - ti-sysc needs iorange check improved when the interconnect target module
    has no control registers listed
  - ti-sysc needs to probe l4_wkup and l4_cfg interconnects first to avoid
    issues with missing resources and unnecessary deferred probe
  - ti-sysc debug option can now detect more devices
  - ti-sysc now warns if an old incomplete devicetree data is found as we
    now rely on it being complete for am3 and 4
  - soc init code needs to check for prcm and prm nodes for omap4/5 and dra7
  - omap-prm driver needs to enable autoidle retention support for omap4
  - omap5 clocks are missing gpmc and ocmc clock registers
  - pci-dra7xx now needs to use builtin_platform_driver instead of using
    builtin_platform_driver_probe for deferred probe to work
 
 Raspberry Pi:
  - Fix-up all RPi firmware drivers so as for unbind to happen in an
    orderly fashion
  - Support for RPi's PoE hat PWM bus
 
 Qualcomm
  - Improved detection for SCM calling conventions
  - Support for OEM specific wifi firmware path
  - Added drivers for SC7280/SM8350: RPMH, LLCC< AOSS QMP
 
 Signed-off-by: Arnd Bergmann <arnd@arndb.de>
 -----BEGIN PGP SIGNATURE-----
 
 iQIzBAABCgAdFiEEo6/YBQwIrVS28WGKmmx57+YAGNkFAmCC2JwACgkQmmx57+YA
 GNkgRg//cBtq2NyDbjiNABxFSkmGCfcc0w0C2wjVzr4cfg6BLTbuvvlpZxI912pu
 P1G2sbsdfQJ8sSeIyZos+PilWK0zHrqlaGZfKI19US45dMjpteDBgsPd7wNZwBjQ
 jbops3YLjztZK1HpY4dIdvMnfxt7yRqhBWaTbPuCwQ35c5KsOM8NHB3cP3BUINWK
 x1uuBCv9svppzwdDiPxneV93WKEzabOUo+WBMPyh5vnyvmW17Iif4BA/VKQxzymm
 mWUi8HHpKBpvntJOKwAD2hnLAdpR3SwX20SLOpyLhnJMotbzNUEqq3LdRxDNPdHk
 ry+rarJ78JGlYfpcfegf2bLf5ITNMfOyRGkjtzeYpcZIXPjufOg9DA9YtAy37k0u
 L0T/9gQ+tQ01WGMca77OyUtIqJKdblZrQMfuH/yGlR99bqFQMV7rNc7GNlX1MXp/
 zw4aOYrRWGtGEeAjx5JJWcYydvMSJpCrqxTz3YhgeJECHB2iA6YkV3NROR4TLW//
 tfxaKqxR/KmSqE6hoVOAuuQ0BLXNlql/+4EE6MKsAOBiKPJclvmJg4CyuY8G21ev
 9Su0zJnXMzai7gNu32v1pizGj26+AOhxCEgAG0mGgk2jlQSn24CKgm5e7kCUewcF
 j/1XksNPT95v/K8MsLpXe5xGvF3jhA1BlFfvjJNZOrcZywBXRxg=
 =iidq
 -----END PGP SIGNATURE-----

Merge tag 'arm-drivers-5.13' of git://git.kernel.org/pub/scm/linux/kernel/git/soc/soc

Pull ARM SoC driver updates from Arnd Bergmann:
 "Updates for SoC specific drivers include a few subsystems that have
  their own maintainers but send them through the soc tree:

  TEE/OP-TEE:
   - Add tracepoints around calls to secure world

  Memory controller drivers:
   - Minor fixes for Renesas, Exynos, Mediatek and Tegra platforms
   - Add debug statistics to Tegra20 memory controller
   - Update Tegra bindings and convert to dtschema

  ARM SCMI Firmware:
   - Support for modular SCMI protocols and vendor specific extensions
   - New SCMI IIO driver
   - Per-cpu DVFS

  The other driver changes are all from the platform maintainers
  directly and reflect the drivers that don't fit into any other
  subsystem as well as treewide changes for a particular platform.

  SoCFPGA:
   - Various cleanups contributed by Krzysztof Kozlowski

  Mediatek:
   - add MT8183 support to mutex driver
   - MMSYS: use per SoC array to describe the possible routing
   - add MMSYS support for MT8183 and MT8167
   - add support for PMIC wrapper with integrated arbiter
   - add support for MT8192/MT6873

  Tegra:
   - Bug fixes to PMC and clock drivers

  NXP/i.MX:
   - Update SCU power domain driver to keep console domain power on.
   - Add missing ADC1 power domain to SCU power domain driver.
   - Update comments for single global power domain in SCU power domain
     driver.
   - Add i.MX51/i.MX53 unique id support to i.MX SoC driver.

  NXP/FSL SoC driver updates for v5.13
   - Add ACPI support for RCPM driver
   - Use generic io{read,write} for QE drivers after performance
     optimized for PowerPC
   - Fix QBMAN probe to cleanup HW states correctly for kexec
   - Various cleanup and style fix for QBMAN/QE/GUTS drivers

  OMAP:
   - Preparation to use devicetree for genpd
   - ti-sysc needs iorange check improved when the interconnect target
     module has no control registers listed
   - ti-sysc needs to probe l4_wkup and l4_cfg interconnects first to
     avoid issues with missing resources and unnecessary deferred probe
   - ti-sysc debug option can now detect more devices
   - ti-sysc now warns if an old incomplete devicetree data is found as
     we now rely on it being complete for am3 and 4
   - soc init code needs to check for prcm and prm nodes for omap4/5 and
     dra7
   - omap-prm driver needs to enable autoidle retention support for
     omap4
   - omap5 clocks are missing gpmc and ocmc clock registers
   - pci-dra7xx now needs to use builtin_platform_driver instead of
     using builtin_platform_driver_probe for deferred probe to work

  Raspberry Pi:
   - Fix-up all RPi firmware drivers so as for unbind to happen in an
     orderly fashion
   - Support for RPi's PoE hat PWM bus

  Qualcomm
   - Improved detection for SCM calling conventions
   - Support for OEM specific wifi firmware path
   - Added drivers for SC7280/SM8350: RPMH, LLCC< AOSS QMP"

* tag 'arm-drivers-5.13' of git://git.kernel.org/pub/scm/linux/kernel/git/soc/soc: (165 commits)
  soc: aspeed: fix a ternary sign expansion bug
  memory: mtk-smi: Add device-link between smi-larb and smi-common
  memory: samsung: exynos5422-dmc: handle clk_set_parent() failure
  memory: renesas-rpc-if: fix possible NULL pointer dereference of resource
  clk: socfpga: fix iomem pointer cast on 64-bit
  soc: aspeed: Adapt to new LPC device tree layout
  pinctrl: aspeed-g5: Adapt to new LPC device tree layout
  ipmi: kcs: aspeed: Adapt to new LPC DTS layout
  ARM: dts: Remove LPC BMC and Host partitions
  dt-bindings: aspeed-lpc: Remove LPC partitioning
  soc: fsl: enable acpi support in RCPM driver
  soc: qcom: mdt_loader: Detect truncated read of segments
  soc: qcom: mdt_loader: Validate that p_filesz < p_memsz
  soc: qcom: pdr: Fix error return code in pdr_register_listener
  firmware: qcom_scm: Fix kernel-doc function names to match
  firmware: qcom_scm: Suppress sysfs bind attributes
  firmware: qcom_scm: Workaround lack of "is available" call on SC7180
  firmware: qcom_scm: Reduce locking section for __get_convention()
  firmware: qcom_scm: Make __qcom_scm_is_call_available() return bool
  Revert "soc: fsl: qe: introduce qe_io{read,write}* wrappers"
  ...
2021-04-26 12:11:52 -07:00
Rafael J. Wysocki
ab497507c0 Merge branch 'acpi-messages'
* acpi-messages:
  hwmon: acpi_power_meter: Get rid of ACPICA message printing
  IIO: acpi-als: Get rid of ACPICA message printing
  ACPI: utils: Introduce acpi_evaluation_failure_warn()
  ACPI: Drop unused ACPI_*_COMPONENT definitions and update documentation
  ACPI: sysfs: Get rid of ACPICA message printing
2021-04-26 17:03:22 +02:00
Lars-Peter Clausen
e09fe91353 iio: inv_mpu6050: Fully validate gyro and accel scale writes
When setting the gyro or accelerometer scale the inv_mpu6050 driver ignores
the integer part of the value. As a result e.g. all of 0.13309, 1.13309,
12345.13309, ... are accepted as a valid gyro scale and 0.13309 is the
scale that gets set in all those cases.

Make sure to check that the integer part of the scale value is 0 and reject
it otherwise.

Fixes: 09a642b785 ("Invensense MPU6050 Device Driver.")
Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Acked-by: Jean-Baptiste Maneyrol <jmaneyrol@invensense.com>
Link: https://lore.kernel.org/r/20210405114441.24167-1-lars@metafoo.de
Cc: <Stable@vger.kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-04-07 08:36:40 +01:00
Gwendal Grignou
fc948409cc iio: sx9310: Fix write_.._debounce()
Check input to be sure it matches Semtech sx9310 specification and
can fit into debounce register.
Compare argument writen to thresh_.._period with read from same
sysfs attribute:

Before:                   Afer:
write   |  read           write   |  read
-1      |     8           -1 fails: -EINVAL
0       |     8           0       |     0
1       |     0           1       |     0
2..15   |  2^log2(N)      2..15   |  2^log2(N)
16      |     0           >= 16 fails: -EINVAL

Fixes: 1b6872015f ("iio: sx9310: Support setting debounce values")
Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
Cc: stable@vger.kernel.org
Reviewed-by: Stephen Boyd <swboyd@chromium.org>
Link: https://lore.kernel.org/r/20210331182222.219533-1-gwendal@chromium.org
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-04-07 08:36:40 +01:00
Gwendal Grignou
6f0078ae70 iio: sx9310: Fix access to variable DT array
With the current code, we want to read 4 entries from DT array
"semtech,combined-sensors". If there are less, we silently fail as
of_property_read_u32_array() returns -EOVERFLOW.

First count the number of entries and if between 1 and 4, collect the
content of the array.

Fixes: 5b19ca2c78 ("iio: sx9310: Set various settings from DT")
Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Link: https://lore.kernel.org/r/20210326184603.251683-2-gwendal@chromium.org
Cc: <stable@vger.kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-04-07 08:36:40 +01:00
Alexandru Ardelean
194eafc9c1 iio: adc: Kconfig: make AD9467 depend on ADI_AXI_ADC symbol
Because a dependency on HAS_IOMEM and OF was added for the ADI AXI ADC
driver, this makes the AD9467 driver have some build/dependency issues
when OF is disabled (typically on ACPI archs like x86).

This is because the selection of the AD9467 enforces the ADI_AXI_ADC symbol
which is blocked by the OF (and potentially HAS_IOMEM) being disabled.

To fix this, we make the AD9467 driver depend on the ADI_AXI_ADC symbol.
The AD9467 driver cannot operate on it's own. It requires the ADI AXI ADC
driver to stream data (or some similar IIO interface).

So, the fix here is to make the AD9467 symbol depend on the ADI_AXI_ADC
symbol. At some point this could become it's own subgroup of high-speed
ADCs.

Fixes: be24c65e9f ("iio: adc: adi-axi-adc: add proper Kconfig dependencies")
Reported-by: Randy Dunlap <rdunlap@infradead.org>
Signed-off-by: Alexandru Ardelean <aardelean@deviqon.com>
Acked-by: Randy Dunlap <rdunlap@infradead.org>
Link: https://lore.kernel.org/r/20210324182746.9337-1-aardelean@deviqon.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-04-07 08:36:40 +01:00
Linus Walleij
bb354aeb36 iio: magnetometer: yas530: Include right header
To get access to the big endian byte order parsing helpers
drivers need to include <asm/unaligned.h> and nothing else.

Reported-by: kernel test robot <lkp@intel.com>
Suggested-by: Harvey Harrison <harvey.harrison@gmail.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Cc: <Stable@vger.kernel.org>
Link: https://lore.kernel.org/r/20210215153032.47962-1-linus.walleij@linaro.org
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-04-07 08:36:40 +01:00
Linus Walleij
e64837bf9e iio: magnetometer: yas530: Fix return value on error path
There was a missed return variable assignment in the
default errorpath of the switch statement in yas5xx_probe().
Fix it.

Reported-by: kernel test robot <lkp@intel.com>
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Suggested-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Link: https://lore.kernel.org/r/20210215153023.47899-1-linus.walleij@linaro.org
Cc: <Stable@vger.kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-04-07 08:36:40 +01:00
Jonathan Cameron
032aec339c iio:cdc:ad7150: Fix use of uninitialized ret
This doesn't appear to generate a warning on all versions of GCC, but
0-day reported it and the report looks valid.

Reported-by: kbuild test robot <lkp@intel.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-04-07 08:36:39 +01:00
Gustavo A. R. Silva
c10f8109f7 iio: hrtimer-trigger: Fix potential integer overflow in iio_hrtimer_store_sampling_frequency
Add suffix ULL to constant 1000 in order to avoid a potential integer
overflow and give the compiler complete information about the proper
arithmetic to use. Notice that this constant is being used in a context
that expects an expression of type unsigned long long, but it's
currently evaluated using 32-bit arithmetic.

Addresses-Coverity-ID: 1503062 ("Unintentional integer overflow")
Fixes: dafcf4ed83 ("iio: hrtimer: Allow sub Hz granularity")
Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
Link: https://lore.kernel.org/r/20210329205817.GA188755@embeddedor
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-04-07 08:36:39 +01:00
Jonathan Cameron
4d84487d96 iio:adc: Fix trivial typo
"an" should be "and".

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Link: https://lore.kernel.org/r/20210401150810.227168-1-jic23@kernel.org
2021-04-07 08:36:39 +01:00
Jonathan Cameron
6baee4bd63 iio:adc:ad7476: Fix remove handling
This driver was in an odd half way state between devm based cleanup
and manual cleanup (most of which was missing).
I would guess something went wrong with a rebase or similar.
Anyhow, this basically finishes the job as a precursor to improving
the regulator handling.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Fixes: 4bb2b8f94a ("iio: adc: ad7476: implement devm_add_action_or_reset")
Cc: Michael Hennerich <michael.hennerich@analog.com>
Reviewed-by: Alexandru Ardelean <ardeleanalex@gmail.com>
Cc: <Stable@vger.kernel.org>
Link: https://lore.kernel.org/r/20210401171759.318140-2-jic23@kernel.org
2021-04-07 08:36:39 +01:00
Jonathan Cameron
eaa17fa7d8 iio:adc:ad_sigma_delta: Use IRQF_NO_AUTOEN rather than request and disable
These devices are not able to mask the signal used as a data ready
interrupt.  As such they previously requested the irq then immediately
disabled it.  Now we can avoid the potential of a spurious interrupt
by avoiding the irq being auto enabled in the first place.

I'm not sure how this code could have been called with the irq already
disabled, so I believe the conditional would always have been true and
have removed it.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Cc: Lars-Peter Clausen <lars@metafoo.de>
Cc: Alexandru Ardelean <ardeleanalex@gmail.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Reviewed-by: Lars-Peter Clausen <lars@metafoo.de>
Link: https://lore.kernel.org/r/20210402184544.488862-8-jic23@kernel.org
2021-04-07 08:36:39 +01:00
Jonathan Cameron
30f6a542b7 iio:imu:adis: Use IRQF_NO_AUTOEN instead of irq request then disable
This is a bit involved as the adis library code already has some
sanity checking of the flags of the requested irq that we need
to ensure is happy to pass through the IRQF_NO_AUTOEN flag untouched.

Using this flag avoids us autoenabling the irq in the adis16460 and
adis16475 drivers which cover parts that don't have any means of
masking the interrupt on the device end.

Note, compile tested only!

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Cc: Alexandru Ardelean <ardeleanalex@gmail.com>
Reviewed-by: Nuno Sa <nuno.sa@analog.com>
Reviewed-by: Barry Song <song.bao.hua@hisilicon.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Reviewed-by: Lars-Peter Clausen <lars@metafoo.de>
Link: https://lore.kernel.org/r/20210402184544.488862-7-jic23@kernel.org
2021-04-07 08:36:39 +01:00
Jonathan Cameron
dbb8f20d83 iio:chemical:scd30: Use IRQF_NO_AUTOEN to avoid irq request then disable
This new flag cleanly avoids the need for a dance where we request the
interrupt only to immediately disabling it by ensuring it is not
auto-enabled in the first place.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Cc: Tomasz Duszynski <tomasz.duszynski@octakon.com>
Reviewed-by: Barry Song <song.bao.hua@hisilicon.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Reviewed-by: Lars-Peter Clausen <lars@metafoo.de>
Link: https://lore.kernel.org/r/20210402184544.488862-6-jic23@kernel.org
2021-04-07 08:36:39 +01:00
Jonathan Cameron
ff2293ea9c iio:adc:sun4i-gpadc: Use new IRQF_NO_AUTOEN flag instead of request then disable
This new flag ensures a requested irq is not autoenabled, thus removing
the need for the disable_irq() that follows and closing off any chance
of spurious interrupts.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Cc: Maxime Ripard <maxime.ripard@bootlin.com>
Reviewed-by: Barry Song <song.bao.hua@hisilicon.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Reviewed-by: Lars-Peter Clausen <lars@metafoo.de>
Link: https://lore.kernel.org/r/20210402184544.488862-5-jic23@kernel.org
2021-04-07 08:36:39 +01:00
Jonathan Cameron
aef3ef1659 iio:adc:nau7802: Use IRQF_NO_AUTOEN instead of request then disable
Whilst a race during interrupt enabling is probably not a problem,
it is better to not enable the interrupt at all.  The new
IRQF_NO_AUTOEN flag allows us to do that.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Cc: Alexandre Belloni <alexandre.belloni@bootlin.com>
Reviewed-by: Barry Song <song.bao.hua@hisilicon.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Reviewed-by: Lars-Peter Clausen <lars@metafoo.de>
Link: https://lore.kernel.org/r/20210402184544.488862-4-jic23@kernel.org
2021-04-07 08:36:39 +01:00
Jonathan Cameron
42004ceb34 iio:adc:exynos-adc: Use new IRQF_NO_AUTOEN flag rather than separate irq_disable()
Disabling an irq before the driver has actually atempted to request it
may work, but is definitely not as clean as just requesting it as
normal but with the auto enable disabled.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Cc: Krzysztof Kozlowski <krzk@kernel.org>
Reviewed-by: Barry Song <song.bao.hua@hisilicon.com>
Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Reviewed-by: Lars-Peter Clausen <lars@metafoo.de>
Link: https://lore.kernel.org/r/20210402184544.488862-3-jic23@kernel.org
2021-04-07 08:36:39 +01:00
Jonathan Cameron
0be49bdedc iio:adc:ad7766: Use new IRQF_NO_AUTOEN to reduce boilerplate
As iio_poll_trigger() is safe against spurious interrupts when the
trigger is not enabled, this is not a fix despite looking like
a race.  It is nice to simplify the code however so the interrupt
is never enabled in the first place.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Cc: Lars-Peter Clausen <lars@metafoo.de>
Reviewed-by: Barry Song <song.bao.hua@hisilicon.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Reviewed-by: Lars-Peter Clausen <lars@metafoo.de>
Link: https://lore.kernel.org/r/20210402184544.488862-2-jic23@kernel.org
2021-04-07 08:36:39 +01:00
Alexandru Ardelean
ca3e7d524c iio: buffer: use sysfs_attr_init() on allocated attrs
When dynamically allocating sysfs attributes, it's a good idea to call
sysfs_attr_init() on them to initialize lock_class_keys.
This change does that.

The lock_class_keys are set when the CONFIG_DEBUG_LOCK_ALLOC symbol is
enabled. Which is [likely] one reason why I did not see this during
development.

I also am not able to see this even with CONFIG_DEBUG_LOCK_ALLOC enabled,
so this may [likely] be reproduce-able on some system configurations.

This was reported via:
  https://lore.kernel.org/linux-iio/CA+U=DsrsvGgXEF30-vXuXS_k=-mjSjiBwEEzwKb1hJVn1P98OA@mail.gmail.com/T/#u

Fixes: 15097c7a1a ("iio: buffer: wrap all buffer attributes into iio_dev_attr")
Reported-by: Marek Szyprowski <m.szyprowski@samsung.com>
Signed-off-by: Alexandru Ardelean <aardelean@deviqon.com>
Link: https://lore.kernel.org/r/20210402174226.630346-1-aardelean@deviqon.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-04-07 08:36:38 +01:00
Andy Shevchenko
af3bac44b1 iio: trigger: Fix strange (ladder-type) indentation
In some cases indentation looks a bit weird with starting from = sign
and being in a ladder-type style. Unify it across the module.

While at it, add blank line after definition block where it needed,

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://lore.kernel.org/r/20210402174911.44408-2-andriy.shevchenko@linux.intel.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-04-07 08:36:38 +01:00
Andy Shevchenko
ebb9493c07 iio: trigger: Replace explicit casting and wrong specifier with proper one
By unknown reason device name is set with an index casted from int
to unsigned long while at the same time with "%ld" specifier. Both parts
seems wrong to me, thus replace replace explicit casting and wrong specifier
with proper one, i.e. "%d".

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://lore.kernel.org/r/20210402174911.44408-1-andriy.shevchenko@linux.intel.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-04-07 08:36:38 +01:00
Mugilraj Dhavachelvan
bb142d4433 iio: adc: stm32-dfsdm: drop __func__ while using Dynamic debug
Dropped __func__ while using dev_dbg() and pr_debug()
If the function name is desired, it can be configured using
dynamic debug.

Signed-off-by: Mugilraj Dhavachelvan <dmugil2000@gmail.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Link: https://lore.kernel.org/r/20210401154343.41527-1-dmugil2000@gmail.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-04-07 08:36:38 +01:00
Jonathan Cameron
7604c2f9ea iio:adc: Drop false comment about lack of timestamp control
The timestamp control has been a function implemented in the core of
IIO for a long time, so this comment is incorrect and has clearly been
cut and paste into all these drivers.

The remainder of the comment added nothing and was confusing so dropped
that as well.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Cc: Lars-Peter Clausen <lars@metafoo.de>
Cc: Michael Hennerich <Michael.Hennerich@analog.com>
Reviewed-by: Alexandru Ardelean <ardeleanalex@gmail.com>
Link: https://lore.kernel.org/r/20210401145410.226917-1-jic23@kernel.org
2021-04-07 08:36:38 +01:00
Jonathan Cameron
646d67b5c5 iio:cdc:ad7150: Move driver out of staging.
This capacitance to digital converter (CDC) driver is compliant with
the IIO ABI.  Note, not all features supported (e.g. window event modes)
but the driver should be in a useful functional state.

The cleanup was done against QEMU emulation of the device rather than
actual hardware.   Whilst this was a bit of an experiment, it made it
easy to confirm that the driver remained in a consistent working state
through the various refactors.  If it worked in the first place, it
should still be working after this cleanup.

Given some IIO drivers require expensive hardware setups, (not particularly
true with this one) the use of QEMU may provide a viable way forward
for providing testing during code changes where previously we'd had
to rely on sharp eyes and crossed fingers.

Note, no explicit MAINTAINERS entry as it will be covered by the
generic catch-alls for ADI and IIO drivers which are sufficient.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Reviewed-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
Link: https://lore.kernel.org/r/20210314181511.531414-25-jic23@kernel.org
2021-04-07 08:36:37 +01:00
Jonathan Cameron
45b77828b0 iio:event: Add timeout event info type
For adaptive threshold events, the current value is compared with a
(typically) low pass filtered version of the same signal that slowly
tracks large scale changes.  However, sometimes a step change can
result in a large lag before the low pass filtered version begins
to track the signal again.  Timeouts can be used to made an
instantaneous 'correction'.  Documentation of this attribute
is added in a later patch.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Reviewed-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
Link: https://lore.kernel.org/r/20210314181511.531414-11-jic23@kernel.org
2021-04-07 08:36:36 +01:00
Lars-Peter Clausen
a71654af0a iio: inv_mpu6050: Make interrupt optional
The inv_mpu6050 driver requires an interrupt for buffered capture. But non
buffered reading for measurements works just fine without an interrupt
connected.

Make the interrupt optional to support this case.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Acked-by: Jean-Baptiste Maneyrol <jmaneyrol@invensense.com>
Link: https://lore.kernel.org/r/20210325131046.13383-2-lars@metafoo.de
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-04-07 08:36:35 +01:00
Lars-Peter Clausen
0d41da0374 iio: inv_mpu6050: Remove superfluous indio_dev->modes assignment
The inv_mpu6050 driver manually assigns the indio_dev->modes property. But
this is not necessary since it will be setup in iio_trigger_buffer_setup().

Remove the manual assignment.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Acked-by: Linus Walleij <linus.walleij@linaro.org>
Acked-by: Jean-Baptiste Maneyrol <jmaneyrol@invensense.com>
Link: https://lore.kernel.org/r/20210325131046.13383-1-lars@metafoo.de
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-04-07 08:36:35 +01:00
Alexandru Ardelean
4c822244bf iio: buffer: return 0 for buffer getfd ioctl handler
As Lars pointed out, we could either return the FD vs memcpy-ing it to the
userspace data object.

However, this comment exposed a bug. We should return 0 or negative from
these ioctl() handlers. Because an ioctl() handler can also return
IIO_IOCTL_UNHANDLED (which is positive 1), which means that the ioctl()
handler doesn't support this ioctl number. Positive 1 could also be a valid
FD number in some corner cases.

The reason we did this is to be able to differentiate between an error
code and an unsupported ioctl number; for unsupported ioctl numbers, the
main loop should keep going.

Maybe we should change this to a higher negative number, to avoid such
cases when/if we add more ioctl() handlers.

Cc: Lars-Peter Clausen <lars@metafoo.de>
Fixes: f73f7f4da5 ("iio: buffer: add ioctl() to support opening extra buffers for IIO device")
Signed-off-by: Alexandru Ardelean <aardelean@deviqon.com>
Link: https://lore.kernel.org/r/20210322084135.17536-1-aardelean@deviqon.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-04-07 08:36:35 +01:00
Linus Walleij
b3b64e2c15 iio: Fix iio_read_channel_processed_scale()
The code was checking if (ret) from the processed
channel readout, not smart, we need to check if (ret < 0)
as this will likely be something like IIO_VAL_INT.

Fixes: 635ef601b2 ("iio: Provide iio_read_channel_processed_scale() API")
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Link: https://lore.kernel.org/r/20210323122705.1326362-1-linus.walleij@linaro.org
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-04-07 08:35:51 +01:00
Cristian Marussi
25cbdd4609 iio/scmi: Port driver to the new scmi_sensor_proto_ops interface
Port the scmi iio driver to the new SCMI sensor interface based on
protocol handles and common devm_get_ops().

Link: https://lore.kernel.org/r/20210316124903.35011-26-cristian.marussi@arm.com
Link: https://lore.kernel.org/r/20210330134711.1962-1-cristian.marussi@arm.com
Acked-by: Jyoti Bhayana <jbhayana@google.com>
Acked-by: Jonathan Cameron <jic23@kernel.org>
Tested-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: Cristian Marussi <cristian.marussi@arm.com>
Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>
2021-03-30 16:34:55 +01:00
Lucas Stankus
3e55bb6f2a iio: adc: ad7923: register device with devm_iio_device_register
Registers the device using the devm variant.
This is the final step of converting the ad7923 to only use devm routines,
meaning that the ad7923_remove() function is no longer needed to release
resources on device detach.

Signed-off-by: Lucas Stankus <lucas.p.stankus@gmail.com>
Reviewed-by: Alexandru Ardelean <ardeleanalex@gmail.com>
Link: https://lore.kernel.org/r/b0146465d52f4e259f5f95c83c71e72f065093da.1616966903.git.lucas.p.stankus@gmail.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-03-29 13:25:01 +01:00
Lucas Stankus
075dff3367 iio: adc: ad7923: use device-managed function for triggered buffer
Converts the iio_triggered_buffer_setup() call to its device-managed
counterpart.
With this, the error handling routine in the ad7923_probe() function
becomes unnecessary as well as the iio_triggered_buffer_cleanup() call.

Signed-off-by: Lucas Stankus <lucas.p.stankus@gmail.com>
Reviewed-by: Alexandru Ardelean <ardeleanalex@gmail.com>
Link: https://lore.kernel.org/r/fe46a45caaa788f333d78367968272de728f4a6e.1616966903.git.lucas.p.stankus@gmail.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-03-29 12:17:41 +01:00
Lucas Stankus
44fc4de9bd iio: adc: ad7923: use devm_add_action_or_reset for regulator disable
Adds a device-managed action to handle disabling the driver's regulator on
device detach.
This slightly simplifies deinitialization and enables further conversion of
the driver to device-managed routines without breaking the init order.

Signed-off-by: Lucas Stankus <lucas.p.stankus@gmail.com>
Reviewed-by: Alexandru Ardelean <ardeleanalex@gmail.com>
Link: https://lore.kernel.org/r/49a7c0436ca1186313dbccf3d810d0cf38cb5b37.1616966903.git.lucas.p.stankus@gmail.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-03-29 12:17:41 +01:00
Bhaskar Chowdhury
abfdfd1443 iio: dac: Rudimentary typo fix
s/concurent/concurrent/

Signed-off-by: Bhaskar Chowdhury <unixbhaskar@gmail.com>
Acked-by: Randy Dunlap <rdunlap@infradead.org>
Link: https://lore.kernel.org/r/20210323012215.451075-1-unixbhaskar@gmail.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-03-29 11:28:24 +01:00
Linus Walleij
454c219f5d iio: imu: inv_mpu6050: Use as standalone trigger
It may happen that the MPU6050 is the only hardware
trigger available on your system such as this:

> lsiio
Device 003: hscdtd008a
Device 001: mpu6050
Device 002: gp2ap002
Device 000: ab8500-gpadc
Trigger 000: mpu6050-dev1

And when you want to use it to read periodically from
your magnetometer like this:

> iio_generic_buffer -a -c 100 -n hscdtd008a -t mpu6050-dev1

Then the following happens:

[  209.951334] Internal error: Oops: 5 [#1] SMP ARM
(...)
[  209.981969] Hardware name: ST-Ericsson Ux5x0 platform (Device Tree Support)
[  209.988925] PC is at inv_scan_query_mpu6050+0x8/0xb8
[  209.993914] LR is at inv_mpu6050_set_enable+0x40/0x194

This is because since we are not using any channels from the
same device, the indio_dev->active_scan_mask is NULL.

Just checking for that and bailing out is however not enough:
we have to enable some kind of FIFO for the readout to work.
So enable the temperature as a dummy FIFO and all works
fine.

Not suitable for backporting to stable.  It is an odd corner case
and does not represent a regression.

Fixes: 09a642b785 ("Invensense MPU6050 Device Driver.")
Cc: Jean-Baptiste Maneyrol <jmaneyrol@invensense.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Acked-by: Jean-Baptiste Maneyrol <jmaneyrol@invensense.com>
Link: https://lore.kernel.org/r/20210322132408.1003443-1-linus.walleij@linaro.org
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-03-29 11:18:45 +01:00
Jonathan Cameron
4e102429f3 iio:accel:adis16201: Fix wrong axis assignment that prevents loading
Whilst running some basic tests as part of writing up the dt-bindings for
this driver (to follow), it became clear it doesn't actually load
currently.

iio iio:device1: tried to double register : in_incli_x_index
adis16201 spi0.0: Failed to create buffer sysfs interfaces
adis16201: probe of spi0.0 failed with error -16

Looks like a cut and paste / update bug.  Fixes tag obviously not accurate
but we don't want to bother carry thing back to before the driver moved
out of staging.

Fixes: 591298e54c ("Staging: iio: accel: adis16201: Move adis16201 driver out of staging")
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Cc: <Stable@vger.kernel.org>
Cc: Himanshu Jha <himanshujha199640@gmail.com>
Cc: Nuno Sá <nuno.sa@analog.com>
Reviewed-by: Alexandru Ardelean <ardeleanalex@gmail.com>
Link: https://lore.kernel.org/r/20210321182956.844652-1-jic23@kernel.org
2021-03-29 11:14:41 +01:00
Lars-Peter Clausen
f46ac00978 iio: dac: Convert powerdown read callbacks to sysfs_emit()
Update DAC drivers powerdown attribute show callback to use the new
sysfs_emit() function.

sysfs_emit() is preferred over raw s*printf() for sysfs attributes since it
knows about the sysfs buffer specifics and has some built-in sanity checks.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Link: https://lore.kernel.org/r/20210320071405.9347-5-lars@metafoo.de
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-03-29 11:12:30 +01:00
Lars-Peter Clausen
6b92ba0a30 iio: __iio_format_value(): Convert to sysfs_emit_at()
sysfs_emit() is preferred over raw s*printf() for sysfs attributes since it
knows about the sysfs buffer specifics and has some built-in sanity checks.

Convert __iio_format_value() and related functions to use this new
interface.

This conversion involves changing the signature of __iio_format_value() so
that it similar to sysfs_emit_at() and takes the buffers start address and
an offset where to write within the buffer.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Link: https://lore.kernel.org/r/20210320071405.9347-4-lars@metafoo.de
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-03-29 11:12:30 +01:00
Lars-Peter Clausen
0207483b22 iio: iio_enum_available_read(): Convert to sysfs_emit_at()
sysfs_emit() is preferred over raw s*printf() for sysfs attributes since it
knows about the sysfs buffer specifics and has some built-in sanity checks.

Convert the iio_enum_available_read() function to use sysfs_emit_at()
instead of scnprintf().

The conversion is straight forward, the only difference is that
sysfs_emit_at() takes the buffers start address and an offset as parameters
and already knows about the buffer's size limit.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Link: https://lore.kernel.org/r/20210320071405.9347-3-lars@metafoo.de
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-03-29 11:12:30 +01:00
Lars-Peter Clausen
83ca56b663 iio: core: Use sysfs_emit() (trivial bits)
sysfs_emit() is preferred over raw s*printf() for sysfs attributes since it
knows about the sysfs buffer specifics and has some built-in sanity checks.

This patch converts the places in the iio core that follow the pattern of

   return s*printf(...)

to

   return sysfs_emit(...)

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Link: https://lore.kernel.org/r/20210320071405.9347-2-lars@metafoo.de
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-03-29 11:12:30 +01:00
Greg Kroah-Hartman
9c15db92a8 1st set of IIO/counter device support, features and cleanup in the 5.13 cycle
Big set in here from Alexandru Ardelean enabling multiple buffer support.
 This includes providing a new directory per buffer that combines
 what was previously in buffer/ and scan_elements/. Old interfaces still
 in place for compatiblity.
 
 Note immuatable branch for scmi patches to allow for some significant
 rework going on in that subsystem.  Merge required updating to reflect
 some changes in IIO.
 
 Late rebase to fix some wrong fixes tags due to some earlier rebases
 made necessary by messing up the immutable branch.
 
 IIO New Device Support
 * adi,ad5686
   - Add info to support AD5673R and AD5677R
 * bosch,bmi088
   - New driver supporting this accelerometer + gyroscope
 * cros_ec_mkbp
   - New driver for this proximity sensor that exposes a 'front'
     sensor. Very simple switch like device, but driver allows it
     to share interface with more sophisticated proximity sensors.
 * iio_scmi
   - New driver to support ARM SCMI protocol to expose underlying
     accelerometers and gyroscopes via this firmware interface.
 * st,st_magn
   - Add ID for IISMDC magnetometer.
 * ti,ads131e0
   - New driver supporting ads131e04, ads131e06 and ads131e08 24 bit ADCs
 
 Counter New Device Support
 * IRQ or GPIO based counter
   - New driver for a conceptually simple counter that uses interrupts
     to perform the count.
 
 Features
 * core
   - Dual buffer supprt including:
      Various helpers to centralize handling of bufferer related elements.
      Document existing and new IOCTLs
      Register the IIO chrdev only if it can actually be used for anything.
      Rework attribute group creation in the core (lots of patches)
      Merge buffer/ and scan_elements/ entries into one list + maintain
      backwards compatible set.
      Introduce the internal logic and IOCTL to allow multiple buffers
      + access to an anon FD per buffer to actually read from it.
      Tidy up tools/iio/iio_generic_buffer and switch to new interfaces.
      Update ABI docs.
      A few follow up fixes, unsuprising as this was a huge bit of rework.
   - Move common case setting of trig->parent to the core.
   - Provide an iio_read_channel_processed_scale() to avoid loss of
     precision from iio_read_channel_processed() then applying integer
     scale. Use it in ntc_thermistor driver in hwmon.
   - Allow drivers to specify labels from elsewhere than DT. Use it for
     bmc150 and kxcjk-1013 labels related to position on 2 in one tablets.
   - Document label usage for proximity and accelerometer sensors.
   - Some local variable renames for consistency
 tools
   - Add -a parameter to iio_event_monitor to allow autoenabling of events.
 * acpi_als
   - Add trigger support for devices that don't support notification method.
 * adi,ad7124
   - Allow more than 8 channels.  This is a complex little device, but is
     capable of supporting up to 16 channels if the share certain
     configuration settings.
 * hrtimer-trigger
   - Support sampling frequency below 1Hz.
 * mediatek,mt8195-auxadc
   - Add compatible to binding docs (always also includes mt8173)
 * st,stm32-adc
   - Enable timetamps when not using DMA.
 * vishay,vcnl3020
   - Sampling frequency control.
 
 Cleanup and minor fixes:
 * treewide
   - Use some getter and setter functions instead of opencoding.
   - Set of fixes for pointless casts in various drivers.
   - Avoid wrong kernel-doc marking on comment blocks.
   - Fix various other minor kernel-doc issues shown by W=1
 * core
   - Use a signed temporary for IIO_VAL_FRACTIONAL_LOG2 to avoid odd casts.
   - Fix IIO_VAL_FRACTIONAL_LOG2 for values between -1.0 and 0.0
   - Add unit tests for iio_format_value()
 * docs
   - Fix formatting/typos in iio_configfs.rst and buffers.rst
   - Add documentation of index in buffers.rst
   - Fix scan element description
   - Avoid some issues with HTML generation from ABI docs by moving
     duplicated defintions to more generic files.
   - Drop reference to long dead mailing list.
 * 104-quad
   - Remove left over deprecated IIO counter ABI.
 * adi,adi-axi-adc
   - Fix wrong bit of docs.
 * adi,ad5791
   - Typos
 * adi,ad9834
    - Switch to device managed functions in probe.
 * adi,adis*
   - Add and use helpers for locking to reduced duplication.
 * adi,adis16480
   - Fix calculation of sampling frequency when using pulse per second input.
 * adi,adis16475
   - Calculate the IMU scaled internal sampling rate and runtime depending
     on sysfs based configuration rather than getting from DT. Drop now
     unnecessary property from DT bindings doc.
 * cros_ec
    - Fix result of a series of recent changes that means extended buffer
      attributes turn up in the wrong place. Too complex to revert the
      various patches unfortunately so this is a bit messy.
 * fsl,mma3452
   - Indentation cleanup.
 * hid-sensors
   - Size of storage needs to increase for some parts when using quaternions.
   - Move the get sensistivity attribute to hid-sensors-common to reduce
     duplication.  Enable it for more device types.
   - Correctly handle relative sensitivity if reported that way including
     documenting the new ABI.
 * maxim,max517
   - Use device managed functions in probe.
 * mediatek,mt6360-adc
   - Use asm/unaligned.h instead of directly including
     unaligned/be_byteshift.h
 * novuton,npcm-adc
   - Local lock instead of missusing mlock.
 * semtech,sx9500
   - Typos
 * st,sensor
   - typo fix
 * st,spear-adc
   - Local lock instead of missusing mlock.
 * st,stm32-adc
   - Long standing HAS_IOMEM dependency fix.
 * st,stm32-counter
   - Remove left over deprecated IIO counter ABI.
 * ti,palmas-adc
   - Local lock instead of missusing mlock.
 * ti,tmp007
   - Switch to device managed functions in probe.
 
 Other
 * MAINTAINERS
   - Move Peter Meerwald-Stadler to Credits at his request
 -----BEGIN PGP SIGNATURE-----
 
 iQJFBAABCAAvFiEEbilms4eEBlKRJoGxVIU0mcT0FogFAmBdtl4RHGppYzIzQGtl
 cm5lbC5vcmcACgkQVIU0mcT0FogEhxAAuTWrEwun8rE5fQkQIlEkKYwZqEgUln4Q
 tLKhrqeyfGcY/A1aX/HTpnn0TOtaOkUqRzLWsAW0thZih1u7yEL6Vc55KKh5WGL7
 CvcvLWAkorsTjbtusgrBgFmjuoAMjW892Q+bbh1CJ/0qlezhFE9jrmJfmH2klI/p
 nIoJsdyCE98+4oIdcOCxwJe7nTDDHP8BCF7WnKtHCLtn3T9Dzttises3T6HfKxlg
 cdu3cy2N+pQpakYpv96tvjBGI9Ho3FX8R+dILUxJpVwCcLUjf8b1CFcgboJwxou2
 tgPNwWToxd9OTYJa7EOsDaFPZD46NRProkUBGKgA58XPkhqSvLcSdvGokFPgKnPW
 NorymGaUOC2qolH91nuFaWrd6c6hIf5NeWtGDo1GHJdcSgu21C0OdaU3K72EGhsB
 YLnl0Wp8Bthwn7KS0Ck4TqUPN3D3Q9NCEz7sAUzqc3QBzm4U+dXVzCwRehI7hPdw
 YlORAzbV1o7Z0skhAAth+NAYUUB6GywGZLaUi5oXWoJSYhNvI1K1uiHVVStVINWl
 L7uor5FXTr4/czjrutWQbw7GQ0cfCODH6B1cbS9vNaDQ6wO9XGSaWgc3mK9Lgsqc
 Y1ekYvXNSxKJw42FWvr4ylkeF7BV6h0oBFB4DLlZppYi1pKZb8oPsED8UpBrFnG1
 uPqjNX9Tsqw=
 =jeRJ
 -----END PGP SIGNATURE-----

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

Jonathan writes:

1st set of IIO/counter device support, features and cleanup in the 5.13 cycle

Big set in here from Alexandru Ardelean enabling multiple buffer support.
This includes providing a new directory per buffer that combines
what was previously in buffer/ and scan_elements/. Old interfaces still
in place for compatiblity.

Note immuatable branch for scmi patches to allow for some significant
rework going on in that subsystem.  Merge required updating to reflect
some changes in IIO.

Late rebase to fix some wrong fixes tags due to some earlier rebases
made necessary by messing up the immutable branch.

IIO New Device Support
* adi,ad5686
  - Add info to support AD5673R and AD5677R
* bosch,bmi088
  - New driver supporting this accelerometer + gyroscope
* cros_ec_mkbp
  - New driver for this proximity sensor that exposes a 'front'
    sensor. Very simple switch like device, but driver allows it
    to share interface with more sophisticated proximity sensors.
* iio_scmi
  - New driver to support ARM SCMI protocol to expose underlying
    accelerometers and gyroscopes via this firmware interface.
* st,st_magn
  - Add ID for IISMDC magnetometer.
* ti,ads131e0
  - New driver supporting ads131e04, ads131e06 and ads131e08 24 bit ADCs

Counter New Device Support
* IRQ or GPIO based counter
  - New driver for a conceptually simple counter that uses interrupts
    to perform the count.

Features
* core
  - Dual buffer supprt including:
     Various helpers to centralize handling of bufferer related elements.
     Document existing and new IOCTLs
     Register the IIO chrdev only if it can actually be used for anything.
     Rework attribute group creation in the core (lots of patches)
     Merge buffer/ and scan_elements/ entries into one list + maintain
     backwards compatible set.
     Introduce the internal logic and IOCTL to allow multiple buffers
     + access to an anon FD per buffer to actually read from it.
     Tidy up tools/iio/iio_generic_buffer and switch to new interfaces.
     Update ABI docs.
     A few follow up fixes, unsuprising as this was a huge bit of rework.
  - Move common case setting of trig->parent to the core.
  - Provide an iio_read_channel_processed_scale() to avoid loss of
    precision from iio_read_channel_processed() then applying integer
    scale. Use it in ntc_thermistor driver in hwmon.
  - Allow drivers to specify labels from elsewhere than DT. Use it for
    bmc150 and kxcjk-1013 labels related to position on 2 in one tablets.
  - Document label usage for proximity and accelerometer sensors.
  - Some local variable renames for consistency
tools
  - Add -a parameter to iio_event_monitor to allow autoenabling of events.
* acpi_als
  - Add trigger support for devices that don't support notification method.
* adi,ad7124
  - Allow more than 8 channels.  This is a complex little device, but is
    capable of supporting up to 16 channels if the share certain
    configuration settings.
* hrtimer-trigger
  - Support sampling frequency below 1Hz.
* mediatek,mt8195-auxadc
  - Add compatible to binding docs (always also includes mt8173)
* st,stm32-adc
  - Enable timetamps when not using DMA.
* vishay,vcnl3020
  - Sampling frequency control.

Cleanup and minor fixes:
* treewide
  - Use some getter and setter functions instead of opencoding.
  - Set of fixes for pointless casts in various drivers.
  - Avoid wrong kernel-doc marking on comment blocks.
  - Fix various other minor kernel-doc issues shown by W=1
* core
  - Use a signed temporary for IIO_VAL_FRACTIONAL_LOG2 to avoid odd casts.
  - Fix IIO_VAL_FRACTIONAL_LOG2 for values between -1.0 and 0.0
  - Add unit tests for iio_format_value()
* docs
  - Fix formatting/typos in iio_configfs.rst and buffers.rst
  - Add documentation of index in buffers.rst
  - Fix scan element description
  - Avoid some issues with HTML generation from ABI docs by moving
    duplicated defintions to more generic files.
  - Drop reference to long dead mailing list.
* 104-quad
  - Remove left over deprecated IIO counter ABI.
* adi,adi-axi-adc
  - Fix wrong bit of docs.
* adi,ad5791
  - Typos
* adi,ad9834
   - Switch to device managed functions in probe.
* adi,adis*
  - Add and use helpers for locking to reduced duplication.
* adi,adis16480
  - Fix calculation of sampling frequency when using pulse per second input.
* adi,adis16475
  - Calculate the IMU scaled internal sampling rate and runtime depending
    on sysfs based configuration rather than getting from DT. Drop now
    unnecessary property from DT bindings doc.
* cros_ec
   - Fix result of a series of recent changes that means extended buffer
     attributes turn up in the wrong place. Too complex to revert the
     various patches unfortunately so this is a bit messy.
* fsl,mma3452
  - Indentation cleanup.
* hid-sensors
  - Size of storage needs to increase for some parts when using quaternions.
  - Move the get sensistivity attribute to hid-sensors-common to reduce
    duplication.  Enable it for more device types.
  - Correctly handle relative sensitivity if reported that way including
    documenting the new ABI.
* maxim,max517
  - Use device managed functions in probe.
* mediatek,mt6360-adc
  - Use asm/unaligned.h instead of directly including
    unaligned/be_byteshift.h
* novuton,npcm-adc
  - Local lock instead of missusing mlock.
* semtech,sx9500
  - Typos
* st,sensor
  - typo fix
* st,spear-adc
  - Local lock instead of missusing mlock.
* st,stm32-adc
  - Long standing HAS_IOMEM dependency fix.
* st,stm32-counter
  - Remove left over deprecated IIO counter ABI.
* ti,palmas-adc
  - Local lock instead of missusing mlock.
* ti,tmp007
  - Switch to device managed functions in probe.

Other
* MAINTAINERS
  - Move Peter Meerwald-Stadler to Credits at his request

* tag 'iio-for-5.13a' of https://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio: (119 commits)
  iio: acpi_als: Add trigger support
  iio: acpi_als: Add local variable dev in probe
  iio: acpi_als: Add timestamp channel
  iio: adc: ad7292: Modify the bool initialization assignment
  iio: cros: unify hw fifo attributes without API changes
  iio: kfifo: add devm_iio_triggered_buffer_setup_ext variant
  iio: event_monitor: Enable events before monitoring
  dt-bindings: iio: adc: Add compatible for Mediatek MT8195
  iio:magnetometer: Add Support for ST IIS2MDC
  dt-bindings: iio: st,st-sensors add IIS2MDC.
  staging: iio: ad9832: kernel-doc fixes
  iio:dac:max517.c: Use devm_iio_device_register()
  iio:cros_ec_sensors: Fix a wrong function name in kernel doc.
  iio: buffer: kfifo_buf: kernel-doc, typo in function name.
  iio: accel: sca3000: kernel-doc fixes. Missing - and wrong function names.
  iio: adc: adi-axi-adc: Drop false marking for kernel-doc
  iio: adc: cpcap-adc: kernel-doc fix - that should be _ in structure name
  iio: dac: ad5504: fix wrong part number in kernel-doc structure name.
  iio: dac: ad5770r: kernel-doc fix case of letter R wrong in structure name
  iio: adc: ti-adc084s021: kernel-doc fixes, missing function names
  ...
2021-03-26 12:09:47 +01:00
Jonathan Cameron
1b33dfa5d5 Merge remote-tracking branch 'local/ib-iio-scmi-5.12-rc2-take3' into togreg
Updated to use devm_iio_kfifo_buffer_setup() in place of now
removed devm_iio_kfifo_allocate()

Take3 branch because first 2 versions including wrong version of
patch.
2021-03-26 10:23:46 +00:00
Gwendal Grignou
24b84444eb iio: acpi_als: Add trigger support
As some firmware does not notify on illuminance changes, add a
trigger to be able to query light via software (sysfs-trigger or
hrtrigger).
Add a hardware trigger set as the default trigger to maintain backward
compatibility.

Check iio_info reports the sensor as buffer capable:
  iio:device0: acpi-als (buffer capable)

To test, check we can get data on demand on an Intel based chromebook:

  IIO_DEV="iio:device0"
  echo 1 > iio_sysfs_trigger/add_trigger
  cat trigger2/name > ${IIO_DEV}/trigger/current_trigger
  for i in ${IIO_DEV}/scan_elements/*_en ${IIO_DEV}/buffer/enable ; do
    echo 1 > $i
  done
  od -x /dev/${IIO_DEV} &
  echo 1 > trigger2/trigger_now

Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Link: https://lore.kernel.org/r/20210317074012.2336454-4-gwendal@chromium.org
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-03-25 19:13:52 +00:00
Gwendal Grignou
ddaf14dab7 iio: acpi_als: Add local variable dev in probe
Use dev = &device->dev in probe routine for clarity.

Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Link: https://lore.kernel.org/r/20210317074012.2336454-3-gwendal@chromium.org
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-03-25 19:13:52 +00:00
Gwendal Grignou
dbd7e992a5 iio: acpi_als: Add timestamp channel
Add timestamp channel in list of channel, to allow retrieving timestamps
when events are produced.

Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Link: https://lore.kernel.org/r/20210317074012.2336454-2-gwendal@chromium.org
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-03-25 19:13:52 +00:00
Guoqing Chi
707182b4ff iio: adc: ad7292: Modify the bool initialization assignment
A bool initializer is best assigned to false rather than 0.

Signed-off-by: Guoqing Chi <chiguoqing@yulong.com>
Reviewed-by: Marcelo Schmitt <marcelo.schmitt1@gmail.com>
Link: https://lore.kernel.org/r/20210319062706.5135-1-chi962464zy@163.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-03-25 19:13:52 +00:00
Gwendal Grignou
80346b2b55 iio: cros: unify hw fifo attributes without API changes
Commit 2e2366c2d1 ("iio: cros_ec: unify hw fifo attributes into the core file")
should be reverted as it set buffer extended attributes at
the wrong place. However, to revert it will requires to revert more
commits:
commit 165aea80e2 ("iio: cros_ec: use devm_iio_triggered_buffer_setup_ext()")
commit 21232b4456 ("iio: buffer: remove iio_buffer_set_attrs() helper")).
and we would still have conflict with more recent development.
commit ee708e6baa ("iio: buffer: introduce support for attaching more IIO buffers")

Instead, this commit reverts the first 2 commits without re-adding
iio_buffer_set_attrs() and set the buffer extended attributes at the
right place:

1. Instead of adding has_fw_fifo, deduct it from the configuration:
- EC must support FIFO (EC_FEATURE_MOTION_SENSE_FIFO) set.
- sensors send data a regular interval (accelerometer, gyro,
  magnetomer, barometer, light sensor).
- "Legacy accelerometer" is only present on EC without FIFO, so we don't
need to set buffer attributes.

2. devm_iio_triggered_buffer_setup_ext() does not need to be called when
EC does not support FIFO, as there is no FIFO to manage.

3. Use devm_iio_triggered_buffer_setup_ext() when EC has a FIFO to
specify the buffer extended attributes.

Fixes: 2e2366c2d1 ("iio: cros_ec: unify hw fifo attributes into the core file")
Fixes: 165aea80e2 ("iio: cros_ec: use devm_iio_triggered_buffer_setup_ext()")
Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
Reviewed-by: Alexandru Ardelean <ardeleanalex@gmail.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Link: https://lore.kernel.org/r/20210318184857.2679181-1-gwendal@chromium.org
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-03-25 19:13:52 +00:00
Alexandru Ardelean
0a21526bc1 iio: kfifo: add devm_iio_triggered_buffer_setup_ext variant
This is similar to the {devm_}iio_triggered_buffer_setup_ext variants added
via commit 5164c78898 ("iio: triggered-buffer: add
{devm_}iio_triggered_buffer_setup_ext variants").

These can be used to pass extra buffer attributes to the buffer object.
This is a bit of temporary mechanism (hopefully) so that drivers that want
to allocate a kfifo buffer with extra buffer attributes, don't need to
include 'buffer_impl.h' directly. This can also become an API function (in
it's own right, unfortunately), but it may be a little less bad vs drivers
having to include 'buffer_impl.h'.

So, far the drivers that want to pass buffer attributes, all have to do
with some HW FIFO attributes, so there may be a chance of unifying them
into IIO core somehow (as some standard API). But, until that happens, we
just need to let them register their HW FIFO attributes directly (without
having to let them include 'buffer_impl.h' directly).

Signed-off-by: Alexandru Ardelean <aardelean@deviqon.com>
Link: https://lore.kernel.org/r/20210311091042.22417-1-aardelean@deviqon.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-03-25 19:13:52 +00:00
LI Qingwu
c71cfe5576 iio:magnetometer: Add Support for ST IIS2MDC
Add support for ST magnetometer IIS2MDC,
an I2C/SPI interface 3-axis magnetometer.
The patch was tested on the instrument with IIS2MDC via I2C interface.

Signed-off-by: LI Qingwu <Qing-wu.Li@leica-geosystems.com.cn>
Link: https://lore.kernel.org/r/20210317063902.19300-3-Qing-wu.Li@leica-geosystems.com.cn
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-03-25 19:13:52 +00:00
Mugilraj Dhavachelvan
2662e81745 iio:dac:max517.c: Use devm_iio_device_register()
Use devm_iio_device_register() to avoid remove function and
drop explicit call to iio_device_unregister().

Signed-off-by: Mugilraj Dhavachelvan <dmugil2000@gmail.com>
Reviewed-by: Lars-Peter Clausen <lars@metafoo.de>
Link: https://lore.kernel.org/r/20210314175709.34301-1-dmugil2000@gmail.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-03-25 19:13:52 +00:00
Jonathan Cameron
85ece36406 iio:cros_ec_sensors: Fix a wrong function name in kernel doc.
cros_ec_sensors_read_data_unsafe() had wrong function name in kernel-doc
This shows up with W=1 builds.

No fixes tag because I don't want to waste time on this being
backported.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Cc: Guenter Roeck <groeck@chromium.org>
Cc: Douglas Anderson <dianders@chromium.org>
Cc: Gwendal Grignou <gwendal@chromium.org>
Cc: Enric Balletbo i Serra <enric.balletbo@collabora.com>
Acked-by: Enric Balletbo i Serra <enric.balletbo@collabora.com>
Link: https://lore.kernel.org/r/20210313145341.116088-1-jic23@kernel.org
2021-03-25 19:13:52 +00:00
Jonathan Cameron
831aaea663 iio: buffer: kfifo_buf: kernel-doc, typo in function name.
Should have been _kfifo_ and was _fifo_

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Acked-by: Alexandru Ardelean <ardeleanalex@gmail.com>
Reviewed-by: Lars-Peter Clausen <lars@metafoo.de>
Link: https://lore.kernel.org/r/20210314164655.408461-9-jic23@kernel.org
2021-03-25 19:13:51 +00:00
Jonathan Cameron
d7f1c0c313 iio: accel: sca3000: kernel-doc fixes. Missing - and wrong function names.
All extremely obvious so nothing to add to patch title.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Reviewed-by: Alexandru Ardelean <ardeleanalex@gmail.com>
Reviewed-by: Lars-Peter Clausen <lars@metafoo.de>
Link: https://lore.kernel.org/r/20210314164655.408461-8-jic23@kernel.org
2021-03-25 19:13:51 +00:00
Jonathan Cameron
63abed2a1e iio: adc: adi-axi-adc: Drop false marking for kernel-doc
This comment block isn't in kernel-doc format so drop the /** marking.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Reviewed-by: Alexandru Ardelean <ardeleanalex@gmail.com>
Reviewed-by: Lars-Peter Clausen <lars@metafoo.de>
Cc: Nuno Sá <nuno.sa@analog.com>
Link: https://lore.kernel.org/r/20210314164655.408461-7-jic23@kernel.org
2021-03-25 19:13:51 +00:00
Jonathan Cameron
a80aeec087 iio: adc: cpcap-adc: kernel-doc fix - that should be _ in structure name
Fixes a W=1 warning.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Reviewed-by: Tony Lindgren <tony@atomide.com>
Reviewed-by: Lars-Peter Clausen <lars@metafoo.de>
Link: https://lore.kernel.org/r/20210314164655.408461-6-jic23@kernel.org
2021-03-25 19:13:51 +00:00
Jonathan Cameron
92e212e597 iio: dac: ad5504: fix wrong part number in kernel-doc structure name.
Probably a bit of cut and paste where someone forgot to change the
part number.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Reviewed-by: Lars-Peter Clausen <lars@metafoo.de>
Link: https://lore.kernel.org/r/20210314164655.408461-5-jic23@kernel.org
2021-03-25 19:13:51 +00:00
Jonathan Cameron
e0549f3432 iio: dac: ad5770r: kernel-doc fix case of letter R wrong in structure name
Nothing useful to add beyond this causing a warning with W=1

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Reviewed-by: Lars-Peter Clausen <lars@metafoo.de>
Acked-by: Alexandru Ardelean <ardeleanalex@gmail.com>
Link: https://lore.kernel.org/r/20210314164655.408461-4-jic23@kernel.org
2021-03-25 19:13:51 +00:00
Jonathan Cameron
b863ff9419 iio: adc: ti-adc084s021: kernel-doc fixes, missing function names
The documentation in this driver was nearly kernel-doc and was marked
as such. Unfortunately the format was wrong and function names were
missing. This patch puts them in with minor edits to keep the resulting
line short.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Reviewed-by: Lars-Peter Clausen <lars@metafoo.de>
Cc: Gwendal Grignou <gwendal@chromium.org>
Cc: Mårten Lindahl <martenli@axis.com>
Link: https://lore.kernel.org/r/20210314164655.408461-3-jic23@kernel.org
2021-03-25 19:13:51 +00:00
Jonathan Cameron
44f14695bd iio: pressure: zpa2326: kernel-doc fixes
Two comment blocks had wrong naming for function/structures that they
referred to.  Results in warnings when doing a W=1 build.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Reviewed-by: Alexandru Ardelean <ardeleanalex@gmail.com>
Reviewed-by: Lars-Peter Clausen <lars@metafoo.de>
Link: https://lore.kernel.org/r/20210314164655.408461-2-jic23@kernel.org
2021-03-25 19:13:51 +00:00
Alexandru Ardelean
70da641531 iio: temperature: tmp007: use device-managed functions in probe
This change converts the driver to use device-managed functions in the
probe function. The power-down call is handled now via a
devm_add_action_or_reset() hook, and then devm_iio_device_register() can be
used to register the IIO device.

The final aim here would be for IIO to export only the device-managed
functions of it's API. That's a long way to go and this a small step in
that direction.

Signed-off-by: Alexandru Ardelean <aardelean@deviqon.com>
Link: https://lore.kernel.org/r/20210310093800.45822-1-aardelean@deviqon.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-03-25 19:13:51 +00:00
Alexandru Ardelean
218bc53dc7 iio: buffer: fix use-after-free for attached_buffers array
Thanks to Lars for finding this.
The free of the 'attached_buffers' array should be done as late as
possible. This change moves it to iio_buffers_put(), which looks like
the best place for it, since it takes place right before the IIO device
data is free'd.
The free of this array will be handled by calling iio_device_free().
The iio_buffers_put() function is renamed to iio_device_detach_buffers()
since the role of this function changes a bit.

It looks like this issue was ocurring on the error path of
iio_buffers_alloc_sysfs_and_mask() and in
iio_buffers_free_sysfs_and_mask()

Added a comment in the doc-header of iio_device_attach_buffer() to
mention how this will be free'd in case anyone is reading the code
and becoming confused about it.

Fixes: ee708e6baa ("iio: buffer: introduce support for attaching more IIO buffers")
Reported-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Alexandru Ardelean <ardeleanalex@gmail.com>
Link: https://lore.kernel.org/r/20210307185444.32924-1-ardeleanalex@gmail.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-03-25 19:13:51 +00:00
Linus Walleij
635ef601b2 iio: Provide iio_read_channel_processed_scale() API
Since the old iio_read_channel_processed() would
lose precision if we fall back to reading raw and
scaling, we introduce a new API that will pass in
a scale factor when reading a processed channel:
iio_read_channel_processed_scale().

Refactor iio_read_channel_processed() as a special
case with scale factor 1.

Cc: Peter Rosin <peda@axentia.se>
Cc: Chris Lesiak <chris.lesiak@licor.com>
Cc: Jonathan Cameron <jic23@kernel.org>
Cc: linux-iio@vger.kernel.org
Link: https://lore.kernel.org/linux-iio/20201224011607.1059534-1-linus.walleij@linaro.org/
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Link: https://lore.kernel.org/r/20210308100219.2732156-1-linus.walleij@linaro.org
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-03-25 19:13:51 +00:00
Gwendal Grignou
86073fa2b5 iio: xilinx-xadc: Remove code to set trigger parent
iio_trigger_set_drvdata() sets the trigger device parent to first
argument of viio_trigger_alloc(), no need to do it again in the driver
code.

In xadc_alloc_trigger, given dev is indio_dev->dev.parent, and we call
devm_iio_trigger_alloc wit dev as argument,  we do not have to set
data->trig->dev.parent to indio_dev->dev.parent anymore.

Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Link: https://lore.kernel.org/r/20210309193620.2176163-9-gwendal@chromium.org
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-03-25 19:13:51 +00:00
Gwendal Grignou
86e52a25f3 iio: as3935: Remove code to set trigger parent
iio_trigger_set_drvdata() sets the trigger device parent to first
argument of viio_trigger_alloc(), no need to do it again in the driver
code.

Given we call devm_iio_trigger_alloc() and devm_iio_device_alloc() with
dev as parent, we do not have to set data->trig->dev.parent to
indio_dev->dev.parent anymore.

Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Reviewed-by: Matt Ranostay <matt.ranostay@konsulko.com>
Link: https://lore.kernel.org/r/20210309193620.2176163-8-gwendal@chromium.org
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-03-25 19:13:50 +00:00
Gwendal Grignou
e3c9b034e7 iio: chemical: atlas: Remove code to set trigger parent
iio_trigger_set_drvdata() sets the trigger device parent to first
argument of viio_trigger_alloc(), no need to do it again in the driver
code.

Given we call devm_iio_trigger_alloc() and devm_iio_device_alloc() with
&client->dev as parent, we do not have to set data->trig->dev.parent to
indio_dev->dev.parent anymore.

Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Reviewed-by: Matt Ranostay <matt.ranostay@konsulko.com>
Link: https://lore.kernel.org/r/20210309193620.2176163-7-gwendal@chromium.org
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-03-25 19:13:50 +00:00
Gwendal Grignou
4d03166656 iio: lmp91000: Remove code to set trigger parent
iio_trigger_set_drvdata() sets the trigger device parent to first
argument of viio_trigger_alloc(), no need to do it again in the driver
code.

Given data->dev is dev, and we call devm_iio_trigger_alloc with
dev instead of data->dev, we do not have to set data->trig->dev.parent to
dev anymore.

Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Reviewed-by: Matt Ranostay <matt.ranostay@konsulko.com>
Link: https://lore.kernel.org/r/20210309193620.2176163-6-gwendal@chromium.org
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-03-25 19:13:50 +00:00
Gwendal Grignou
cd21413947 iio: gp2ap020a00f: Remove code to set trigger parent
iio_trigger_set_drvdata() sets the trigger device parent to first
argument of viio_trigger_alloc(), no need to do it again in the driver
code.

Given data->client is client, and we call devm_iio_trigger_alloc() with
&client->dev, we do not have to set data->trig->dev.parent to
&data->client->dev anymore.

Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Link: https://lore.kernel.org/r/20210309193620.2176163-5-gwendal@chromium.org
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-03-25 19:13:50 +00:00
Gwendal Grignou
5c68f05305 iio: adis_trigger: Remove code to set trigger parent
iio_trigger_set_drvdata() sets the trigger device parent to first
argument of viio_trigger_alloc(), no need to do it again in the driver
code.
Remove adis_trigger_setup() to match other drivers where setting the
trigger is usually done in the probe() routine.

Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Reviewed-by: Nuno Sa <nuno.sa@analog.com>
Link: https://lore.kernel.org/r/20210309193620.2176163-4-gwendal@chromium.org
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-03-25 19:13:50 +00:00
Gwendal Grignou
8a22522016 iio: fix devm_iio_trigger_alloc with parent.cocci
Use cocci semantic patch:
@@
expression trigger, P;
@@
   trigger = devm_iio_trigger_alloc(P, ...);
   ...
-  trigger->dev.parent = P;

To remove trigger->dev.parent, since it is set by default.

Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Link: https://lore.kernel.org/r/20210309193620.2176163-3-gwendal@chromium.org
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-03-25 19:13:50 +00:00
Gwendal Grignou
995071d36b iio: set default trig->dev.parent
When allocated with [devm_]iio_trigger_alloc(), set trig device parent to
the device the trigger is allocated for by default.

It can always be reassigned in the probe routine.

Change iio_trigger_alloc() API to add the device pointer to be coherent
with devm_iio_trigger_alloc, using similar interface to
iio_device_alloc().

Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Link: https://lore.kernel.org/r/20210309193620.2176163-2-gwendal@chromium.org
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-03-25 19:13:50 +00:00
Alexandru Tachici
7b8d045e49 iio: adc: ad7124: allow more than 8 channels
Currently AD7124-8 driver cannot use more than 8 IIO channels
because it was assigning the channel configurations bijectively
to channels specified in the device-tree. This is not possible
to do when using more than 8 channels as AD7124-8 has only 8
configuration registers.

To allow the user to use all channels at once the driver
will keep in memory configurations for all channels but
will program only 8 of them at a time on the device.
If multiple channels have the same configuration, only
one configuration register will be used. If there
are more configurations than available registers only
the last 8 used configurations will be allowed to exist
on the device in a LRU fashion.

Signed-off-by: Alexandru Tachici <alexandru.tachici@analog.com>
Reported-by: kernel test robot <lkp@intel.com>
Link: https://lore.kernel.org/r/20210311091154.47785-2-alexandru.tachici@analog.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-03-25 19:13:50 +00:00
Andy Shevchenko
941f66765a iio: light: gp2ap002: Drop unneeded explicit casting
The unnecessary explicit casting is being used. Drop it for good.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://lore.kernel.org/r/20210312134903.4296-1-andriy.shevchenko@linux.intel.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-03-25 19:13:50 +00:00
Andy Shevchenko
9e301ea77d iio: imu: st_lsm6dsx: Drop unneeded explicit castings
In a few places the unnecessary explicit castings are being used.
Drop them for good.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://lore.kernel.org/r/20210312134743.4055-1-andriy.shevchenko@linux.intel.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-03-25 19:13:50 +00:00
Andy Shevchenko
897cd10a96 iio: imu: fxos8700: Drop unneeded explicit castings
In a few places the unnecessary explicit castings are being used.
Drop them for good.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://lore.kernel.org/r/20210312134538.3759-1-andriy.shevchenko@linux.intel.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-03-25 19:13:50 +00:00
Andy Shevchenko
d612eb13ba iio: chemical: bmp680: Drop unneeded explicit castings
In few places the unnecessary explicit castings are being used.
Drop them for good.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://lore.kernel.org/r/20210312134349.3472-1-andriy.shevchenko@linux.intel.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-03-25 19:13:50 +00:00
Stephen Boyd
7792225b7b iio: proximity: Add a ChromeOS EC MKBP proximity driver
Add support for a ChromeOS EC proximity driver that exposes a "front"
proximity sensor via the IIO subsystem. The EC decides when front
proximity is near and sets an MKBP switch 'EC_MKBP_FRONT_PROXIMITY' to
notify the kernel of proximity. Similarly, when proximity detects
something far away it sets the switch bit to 0. For now this driver
exposes a single sensor, but it could be expanded in the future via more
MKBP bits if desired.

Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Cc: Benson Leung <bleung@chromium.org>
Cc: Guenter Roeck <groeck@chromium.org>
Cc: Douglas Anderson <dianders@chromium.org>
Cc: Gwendal Grignou <gwendal@chromium.org>
Reviewed-by: Enric Balletbo i Serra <enric.balletbo@collabora.com>
Signed-off-by: Stephen Boyd <swboyd@chromium.org>
Reviewed-by: Gwendal Grignou <gwendal@chromium.org>
Link: https://lore.kernel.org/r/20210211024601.1963379-4-swboyd@chromium.org
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-03-25 19:13:50 +00:00
Gwendal Grignou
b9d453a53d iio: Remove kernel-doc keyword in file header comment
Remove kernel-doc keyword from function header comment.
It fixes issues spotted by scripts/kernel-doc like:
drivers/iio/<driver>.c:3: info: Scanning doc for function <component name>
drivers/iio/<driver>.c:X: warning: expecting prototype for <component name>.
  Prototype was for <function>() instead

To reproduce the errors:
scripts/kernel-doc -v -none $(find drivers/iio/ -name \*.c \
-exec head -2 {} \+ | grep -B2 -e '\*\*' | grep '==' | cut -d ' ' -f 2)

After, confirm these errors are gone with:
scripts/kernel-doc -v -none $(git show --name-only  | grep -e "^driver")

Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
Link: https://lore.kernel.org/r/20210309234314.2208256-1-gwendal@chromium.org
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-03-25 19:13:49 +00:00
Alexandru Ardelean
bbc1308de7 iio: kfifo: mask flags without zero-check in devm_iio_kfifo_buffer_setup()
As pointed by Lars, this doesn't require a zero-check. Also, while looking
at this a little closer at it (again), the masking can be done later, as
there is a zero-check for 'mode_flags' anyway, which returns -EINVAL. And
we only need the 'mode_flags' later in the logic.

This change is more of a tweak.

Fixes: e36db6a069 ("iio: kfifo: add devm_iio_kfifo_buffer_setup() helper")
Cc: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Alexandru Ardelean <ardeleanalex@gmail.com>
Link: https://lore.kernel.org/r/20210306162834.7339-1-ardeleanalex@gmail.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-03-25 19:13:49 +00:00
Gwendal Grignou
dafcf4ed83 iio: hrtimer: Allow sub Hz granularity
Allow setting frequency below 1Hz or sub 1Hz precision.
Useful for slow sensors like ALS.

Test frequency is set properly:
modprobe iio-trig-hrtimer && \
mkdir /sys/kernel/config/iio/triggers/hrtimer/t1 && \
cd /sys/bus/iio/devices/triggerX ;
for i in 1 .1 .01 .001 ; do
  echo $i > sampling_frequency
  cat sampling_frequency
done

Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Link: https://lore.kernel.org/r/20210226014733.2108544-1-gwendal@chromium.org
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-03-25 19:13:49 +00:00
Sean Nyekjaer
9013b1d970 iio: accel: mma8452: fix indentation
Improve readability by fixing indentation.

Signed-off-by: Sean Nyekjaer <sean@geanix.com>
Link: https://lore.kernel.org/r/20210301080029.1974797-1-sean@geanix.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-03-25 19:13:49 +00:00
Ivan Mikhaylov
6a878e70e8 iio: proximity: vcnl3020: add proximity rate
Add the proximity rate optional option and handling of it for
vishay vcnl3020.

Signed-off-by: Ivan Mikhaylov <i.mikhaylov@yadro.com>
Link: https://lore.kernel.org/r/20210225201444.12983-2-i.mikhaylov@yadro.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-03-25 19:13:49 +00:00
Sergiu Cuciurean
08dfc6f8aa iio: adc: npcm_adc: Replace indio_dev->mlock with own device lock
As part of the general cleanup of indio_dev->mlock, this change replaces
it with a local lock on the device's state structure.

This is part of a bigger cleanup.
Link: https://lore.kernel.org/linux-iio/CA+U=Dsoo6YABe5ODLp+eFNPGFDjk5ZeQEceGkqjxXcVEhLWubw@mail.gmail.com/

Signed-off-by: Sergiu Cuciurean <sergiu.cuciurean@analog.com>
Signed-off-by: Mircea Caprioru <mircea.caprioru@analog.com>
Link: https://lore.kernel.org/r/20200928131333.36646-3-mircea.caprioru@analog.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-03-25 19:13:49 +00:00
Sergiu Cuciurean
3a27d11fbf iio: adc: palmas_gpadc: Replace indio_dev->mlock with own device lock
As part of the general cleanup of indio_dev->mlock, this change replaces
it with a local lock on the device's state structure.

This is part of a bigger cleanup.
Link: https://lore.kernel.org/linux-iio/CA+U=Dsoo6YABe5ODLp+eFNPGFDjk5ZeQEceGkqjxXcVEhLWubw@mail.gmail.com/

Signed-off-by: Sergiu Cuciurean <sergiu.cuciurean@analog.com>
Signed-off-by: Mircea Caprioru <mircea.caprioru@analog.com>
Link: https://lore.kernel.org/r/20200928131333.36646-2-mircea.caprioru@analog.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-03-25 19:13:49 +00:00
Sergiu Cuciurean
31e2d42a86 iio: adc: spear_adc: Replace indio_dev->mlock with own device lock
As part of the general cleanup of indio_dev->mlock, this change replaces
it with a local lock on the device's state structure.

This is part of a bigger cleanup.
Link: https://lore.kernel.org/linux-iio/CA+U=Dsoo6YABe5ODLp+eFNPGFDjk5ZeQEceGkqjxXcVEhLWubw@mail.gmail.com/

Signed-off-by: Sergiu Cuciurean <sergiu.cuciurean@analog.com>
Signed-off-by: Mircea Caprioru <mircea.caprioru@analog.com>
Link: https://lore.kernel.org/r/20200928131333.36646-1-mircea.caprioru@analog.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-03-25 19:13:49 +00:00
Greg Kroah-Hartman
12ec5408d2 First set of IIO and counter fixes for the 5.12 cycle
adi,ad7949
 * Fix a wrong bitmask that could lead to an undefined bit being included.
 adi,adi-axi-adc
 * Add missing Kconfig dependencies
 adi,adis16400
 * Wrong error code handling in adis16400 that could lead to failed probe.
 hid-sensor-humidity, temperature
 * Fix alignment and space for timestamp channel.
 hid-sensor-prox
 * Fix an issue with handling of exponent on the channel scaling.
 invensense,mpu3050
 * Fix a hole in error handling.
 qcom,spi-vadc
 * Correct scaling
 st,ab8500-adc
 * Fix wrong scaling (by factor of 1000)
 st,stm32-adc
 * Add missing HAS_IOMEM dependency
 st,stm32-timer-cnt
 * Report count when running off internal clock
 * Fix issue with not checking ceiling before trying to write to hardware
 * Ensure driver doesn't have stashed state which doesn't match hardware by
   rereading from hardware in a slow path.
 -----BEGIN PGP SIGNATURE-----
 
 iQJFBAABCAAvFiEEbilms4eEBlKRJoGxVIU0mcT0FogFAmBOGa4RHGppYzIzQGtl
 cm5lbC5vcmcACgkQVIU0mcT0FojkDw//YDGkDIUEsx/je8xBjLevNvMd1+6Hc2TA
 eKxzQ8ihwJtc8o2ShHuqYdUXvZJIJjtzu9BA/kuEUGE1EmjPZztWGT3mJFwUuA82
 Woy9G/NStX6Cy/3z9rMEusGqIKysSWfvIVnEX3zLoyGUpskJYn6QDqifcFBLTyDa
 uXPSQ0x2sB0wufGxhAMXGAzUClqzcGIFp/VZSaLTYqT1P30WgQ5N2D/epYdVTQHD
 WbYn+HHP8+74sz2ozj/g5mCG/pE0FB9PyjoCqFz1kRdIm/4K/EGfsBRu4rjVhcNz
 NEsM+B+54MUcQv0vzop8Ip6J5XEy6zHNIlXT5B0ckxuU46s8vQnAZhtA03jXgWOT
 JbnonjMMJv/04q3dMbkYxvFpy4mBFlYmsQu+8JUfXMYlCPTHVHbkZhWE36Q7zT63
 wMX/yIMYTuNGozBrQkQeymrQpaa8zUlVjwPzkAmMt+w0Bh3mR5XXyxh7EncmevdG
 ZR8Znd7g0WidaEnXeuFy2sEJwljIGBiUbO2UurWD5EBsFshu9ZC7n9+gS1gaICva
 dEh2JmdYAq9cB2Enqw7jq8WyIsAmc++M3XXz6prgq1g0tcm/5od7AqeU7AiqPQVX
 Gxd0YyL4ihGBMcrZLJcB1HxBGv27w7fQzwfxW2e1fa8bPNepUajsyXpRj/iz9vRR
 x+IiixCgKbw=
 =L5Yl
 -----END PGP SIGNATURE-----

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

Jonathan writes:

First set of IIO and counter fixes for the 5.12 cycle

adi,ad7949
* Fix a wrong bitmask that could lead to an undefined bit being included.
adi,adi-axi-adc
* Add missing Kconfig dependencies
adi,adis16400
* Wrong error code handling in adis16400 that could lead to failed probe.
hid-sensor-humidity, temperature
* Fix alignment and space for timestamp channel.
hid-sensor-prox
* Fix an issue with handling of exponent on the channel scaling.
invensense,mpu3050
* Fix a hole in error handling.
qcom,spi-vadc
* Correct scaling
st,ab8500-adc
* Fix wrong scaling (by factor of 1000)
st,stm32-adc
* Add missing HAS_IOMEM dependency
st,stm32-timer-cnt
* Report count when running off internal clock
* Fix issue with not checking ceiling before trying to write to hardware
* Ensure driver doesn't have stashed state which doesn't match hardware by
  rereading from hardware in a slow path.

* tag 'iio-fixes-for-5.12a' of https://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio:
  iio: gyro: mpu3050: Fix error handling in mpu3050_trigger_handler
  iio: hid-sensor-temperature: Fix issues of timestamp channel
  iio: hid-sensor-humidity: Fix alignment issue of timestamp channel
  counter: stm32-timer-cnt: fix ceiling miss-alignment with reload register
  counter: stm32-timer-cnt: fix ceiling write max value
  counter: stm32-timer-cnt: Report count function when SLAVE_MODE_DISABLED
  iio: adc: ab8500-gpadc: Fix off by 10 to 3
  iio:adc:stm32-adc: Add HAS_IOMEM dependency
  iio: adis16400: Fix an error code in adis16400_initial_setup()
  iio: adc: adi-axi-adc: add proper Kconfig dependencies
  iio: adc: ad7949: fix wrong ADC result due to incorrect bit mask
  iio: hid-sensor-prox: Fix scale not correct issue
  iio:adc:qcom-spmi-vadc: add default scale to LR_MUX2_BAT_ID channel
2021-03-15 16:34:39 +01:00
Jyoti Bhayana
f774117c96 iio/scmi: Adding support for IIO SCMI Based Sensors
This change provides ARM SCMI Protocol based IIO device.
This driver provides support for Accelerometer and Gyroscope using
SCMI Sensor Protocol extensions added in the SCMIv3.0 ARM specification

Reported-by: kernel test robot <lkp@intel.com>
Signed-off-by: Jyoti Bhayana <jbhayana@google.com>
Link: https://lore.kernel.org/r/20210212172235.507028-2-jbhayana@google.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Link: https://lore.kernel.org/r/20210309231259.78050-2-jbhayana@google.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-03-13 16:43:04 +00:00
Linus Walleij
b923561fab iio: adc: mt6360: Include right header
To get access to the big endian byte order parsing helpers
drivers need to include <asm/unaligned.h> and nothing else.

Cc: Gene Chen <gene_chen@richtek.com>
Suggested-by: Harvey Harrison <harvey.harrison@gmail.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Link: https://lore.kernel.org/r/20210215153447.48457-1-linus.walleij@linaro.org
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-03-11 20:47:13 +00:00
Nuno Sa
15aacc980d iio: adis: add helpers for locking
Add some helpers to lock and unlock the device. As this is such a simple
change, we update all the users that were using the lock already in this
patch.

Signed-off-by: Nuno Sa <nuno.sa@analog.com>
Link: https://lore.kernel.org/r/20210218114039.216091-5-nuno.sa@analog.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-03-11 20:47:12 +00:00
Nuno Sa
39c024b51b iio: adis16475: improve sync scale mode handling
With this patch, we don't force users to define the IMU scaled internal
sampling rate once in the devicetree. Now it's dynamically calculated
at runtime depending on the desired output rate given by users.

Calculating the sync_scale dynamically gives us better chances of
achieving a perfect/integer value for DEC_RATE (thus giving more
flexibility). The math is:
 1. lcm of the input clock and the desired output rate.
 2. get the highest multiple of the previous result lower than the adis
    max rate.
 3. The last result becomes the IMU sample rate. Use that to calculate
    SYNC_SCALE and DEC_RATE (to get the user output rate).

Signed-off-by: Nuno Sa <nuno.sa@analog.com>
Link: https://lore.kernel.org/r/20210218114039.216091-3-nuno.sa@analog.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-03-11 20:47:12 +00:00
Nuno Sa
0463e60f08 iio: adis16480: fix pps mode sampling frequency math
When using PPS mode, the input clock needs to be scaled so that we have
an IMU sample rate between (optimally) 4000 and 4250. After this, we can
use the decimation filter to lower the sampling rate in order to get what
the user wants. Optimally, the user sample rate is a multiple of both the
IMU sample rate and the input clock. Hence, calculating the sync_scale
dynamically gives us better chances of achieving a perfect/integer value
for DEC_RATE. The math here is:
 1. lcm of the input clock and the desired output rate.
 2. get the highest multiple of the previous result lower than the adis
    max rate.
 3. The last result becomes the IMU sample rate. Use that to calculate
    SYNC_SCALE and DEC_RATE (to get the user output rate).

Fixes: 326e235755 ("iio: imu: adis16480: Add support for external clock")

Signed-off-by: Nuno Sa <nuno.sa@analog.com>
Link: https://lore.kernel.org/r/20210218114039.216091-2-nuno.sa@analog.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-03-11 20:47:11 +00:00
Mircea Caprioru
477bd010c2 iio: dac: ad5686: Add support for AD5673R/AD5677R
The AD5673R/AD5677R are low power, 16-channel, 12-/16-bit buffered voltage
output digital-to-analog converters (DACs). They include a 2.5 V internal
reference (enabled by default).

These devices are very similar to AD5674R/AD5679R, except that they
have an i2c interface.

Signed-off-by: Mircea Caprioru <mircea.caprioru@analog.com>
Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
Link: https://lore.kernel.org/r/20210217074102.23148-1-alexandru.ardelean@analog.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-03-11 20:47:10 +00:00
Ye Xiang
84dbc231a6 iio: hid-sensor-als: Add relative hysteresis support
Hid sensor als use relative hysteresis, this patch adds the support.

Signed-off-by: Ye Xiang <xiang.ye@intel.com>
Link: https://lore.kernel.org/r/20210207070048.23935-3-xiang.ye@intel.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-03-11 20:47:09 +00:00
Ye Xiang
1c71a2863a iio: Add relative sensitivity support
Some hid sensors may use relative sensitivity such as als sensor.
This patch adds relative sensitivity checking for all hid sensors.

Signed-off-by: Ye Xiang <xiang.ye@intel.com>
Acked-by: Jiri Kosina <jkosina@suse.cz>
Link: https://lore.kernel.org/r/20210207070048.23935-2-xiang.ye@intel.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-03-11 20:47:09 +00:00
Ye Xiang
4efd13c3c2 hid-sensors: Add more data fields for sensitivity checking
Before, when reading/writing the hysteresis of als, incli-3d, press, and
rotation sensor, we will get invalid argument error.

This patch add more sensitivity data fields for these sensors, so that
these sensors can get sensitivity index and return correct hysteresis
value.

Signed-off-by: Ye Xiang <xiang.ye@intel.com>
Link: https://lore.kernel.org/r/20210201054921.18214-3-xiang.ye@intel.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-03-11 20:47:09 +00:00
Ye Xiang
0e41fd515f iio: hid-sensors: Move get sensitivity attribute to hid-sensor-common
No functional change has been made with this patch. The main intent here
is to reduce code repetition of getting sensitivity attribute.

In the current implementation, sensor_hub_input_get_attribute_info() is
called from multiple drivers to get attribute info for sensitivity
field. Moving this to common place will avoid code repetition.

Signed-off-by: Ye Xiang <xiang.ye@intel.com>
Acked-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Link: https://lore.kernel.org/r/20210201054921.18214-2-xiang.ye@intel.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-03-11 20:47:09 +00:00
Julia Lawall
b624fd14a9 iio: use getter/setter functions
Use getter and setter functions, for a variety of data types.

Signed-off-by: Julia Lawall <Julia.Lawall@inria.fr>
Link: https://lore.kernel.org/r/20210209211315.1261791-1-Julia.Lawall@inria.fr
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-03-11 20:47:07 +00:00
Alexandru Ardelean
0d596bb2ad iio: core: rename 'dev' -> 'indio_dev' in iio_device_alloc()
The 'dev' variable name usually refers to 'struct device' types. However in
iio_device_alloc() this was used for the 'struct iio_dev' type, which was
sometimes causing minor confusions.

This change renames the variable to 'indio_dev', which is the usual name
used around IIO for 'struct iio_dev' type objects.
It makes grepping a bit easier as well.

Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
Link: https://lore.kernel.org/r/20210215104043.91251-22-alexandru.ardelean@analog.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-03-11 20:47:06 +00:00
Alexandru Ardelean
f73f7f4da5 iio: buffer: add ioctl() to support opening extra buffers for IIO device
With this change, an ioctl() call is added to open a character device for a
buffer. The ioctl() number is 'i' 0x91, which follows the
IIO_GET_EVENT_FD_IOCTL ioctl.

The ioctl() will return an FD for the requested buffer index. The indexes
are the same from the /sys/iio/devices/iio:deviceX/bufferY (i.e. the Y
variable).

Since there doesn't seem to be a sane way to return the FD for buffer0 to
be the same FD for the /dev/iio:deviceX, this ioctl() will return another
FD for buffer0 (or the first buffer). This duplicate FD will be able to
access the same buffer object (for buffer0) as accessing directly the
/dev/iio:deviceX chardev.

Also, there is no IIO_BUFFER_GET_BUFFER_COUNT ioctl() implemented, as the
index for each buffer (and the count) can be deduced from the
'/sys/bus/iio/devices/iio:deviceX/bufferY' folders (i.e the number of
bufferY folders).

Used following C code to test this:
-------------------------------------------------------------------

 #include <stdio.h>
 #include <stdlib.h>
 #include <unistd.h>
 #include <sys/ioctl.h>
 #include <fcntl.h"
 #include <errno.h>

 #define IIO_BUFFER_GET_FD_IOCTL      _IOWR('i', 0x91, int)

int main(int argc, char *argv[])
{
        int fd;
        int fd1;
        int ret;

        if ((fd = open("/dev/iio:device0", O_RDWR))<0) {
                fprintf(stderr, "Error open() %d errno %d\n",fd, errno);
                return -1;
        }

        fprintf(stderr, "Using FD %d\n", fd);

        fd1 = atoi(argv[1]);

        ret = ioctl(fd, IIO_BUFFER_GET_FD_IOCTL, &fd1);
        if (ret < 0) {
                fprintf(stderr, "Error for buffer %d ioctl() %d errno %d\n", fd1, ret, errno);
                close(fd);
                return -1;
        }

        fprintf(stderr, "Got FD %d\n", fd1);

        close(fd1);
        close(fd);

        return 0;
}
-------------------------------------------------------------------

Results are:
-------------------------------------------------------------------
 # ./test 0
 Using FD 3
 Got FD 4

 # ./test 1
 Using FD 3
 Got FD 4

 # ./test 2
 Using FD 3
 Got FD 4

 # ./test 3
 Using FD 3
 Got FD 4

 # ls /sys/bus/iio/devices/iio\:device0
 buffer  buffer0  buffer1  buffer2  buffer3  dev
 in_voltage_sampling_frequency  in_voltage_scale
 in_voltage_scale_available
 name  of_node  power  scan_elements  subsystem  uevent
-------------------------------------------------------------------

iio:device0 has some fake kfifo buffers attached to an IIO device.

Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
Link: https://lore.kernel.org/r/20210215104043.91251-21-alexandru.ardelean@analog.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-03-11 20:47:05 +00:00
Alexandru Ardelean
ee708e6baa iio: buffer: introduce support for attaching more IIO buffers
With this change, calling iio_device_attach_buffer() will actually attach
more buffers.
Right now this doesn't do any validation of whether a buffer is attached
twice; maybe that can be added later (if needed). Attaching a buffer more
than once should yield noticeably bad results.

The first buffer is the legacy buffer, so a reference is kept to it.

At this point, accessing the data for the extra buffers (that are added
after the first one) isn't possible yet.

The iio_device_attach_buffer() is also changed to return an error code,
which for now is -ENOMEM if the array could not be realloc-ed for more
buffers.
To adapt to this new change iio_device_attach_buffer() is called last in
all place where it's called. The realloc failure is a bit difficult to
handle during un-managed calls when unwinding, so it's better to have this
as the last error in the setup_buffer calls.

At this point, no driver should call iio_device_attach_buffer() directly,
it should call one of the {devm_}iio_triggered_buffer_setup() or
devm_iio_kfifo_buffer_setup() or devm_iio_dmaengine_buffer_setup()
functions. This makes iio_device_attach_buffer() a bit easier to handle.

Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
Link: https://lore.kernel.org/r/20210215104043.91251-20-alexandru.ardelean@analog.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-03-11 20:47:05 +00:00
Alexandru Ardelean
738f6ba118 iio: dummy: iio_simple_dummy_buffer: use triggered buffer core calls
The iio_simple_dummy_configure_buffer() function is essentially a
re-implementation of the iio_triggered_buffer_setup() function.

This change makes use of the iio_triggered_buffer_setup() function. The
reason is so that we don't have to modify the iio_device_attach_buffer()
function in this driver as well.

One minor drawback is that the pollfunc name may not be 100% identical
with the one in the original code, but since it's an example, it should be
a big problem.

This change does a minor re-arranging of the included iio headers, as a
minor tidy-up.

Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
Link: https://lore.kernel.org/r/20210215104043.91251-19-alexandru.ardelean@analog.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-03-11 20:47:05 +00:00
Alexandru Ardelean
0224af85a7 iio: buffer: move __iio_buffer_free_sysfs_and_mask() before alloc
The __iio_buffer_free_sysfs_and_mask() function will be used in
iio_buffer_alloc_sysfs_and_mask() when multiple buffers will be attached to
the IIO device.
This will need to be used to cleanup resources on each buffer, when the
buffers cleanup unwind will occur on the error path.

The move is done in this patch to make the patch that adds multiple buffers
per IIO device a bit cleaner.

Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
Link: https://lore.kernel.org/r/20210215104043.91251-18-alexandru.ardelean@analog.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-03-11 20:47:04 +00:00
Alexandru Ardelean
be24dcb113 iio: core: wrap iio device & buffer into struct for character devices
In order to keep backwards compatibility with the current chardev
mechanism, and in order to add support for multiple buffers per IIO device,
we need to pass both the IIO device & IIO buffer to the chardev.

This is particularly needed for the iio_buffer_read_outer() function, where
we need to pass another buffer object than 'indio_dev->buffer'.

Since we'll also open some chardevs via anon inodes, we can pass extra
buffers in that function by assigning another object to the
iio_dev_buffer_pair object.

Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
Link: https://lore.kernel.org/r/20210215104043.91251-17-alexandru.ardelean@analog.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-03-11 20:47:04 +00:00
Alexandru Ardelean
4991f3ea2a iio: buffer: dmaengine: obtain buffer object from attribute
The reference to the IIO buffer object is stored on the attribute object.
So we need to unwind it to obtain it.

Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
Link: https://lore.kernel.org/r/20210215104043.91251-16-alexandru.ardelean@analog.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-03-11 20:47:04 +00:00
Alexandru Ardelean
15097c7a1a iio: buffer: wrap all buffer attributes into iio_dev_attr
This change wraps all buffer attributes into iio_dev_attr objects, and
assigns a reference to the IIO buffer they belong to.

With the addition of multiple IIO buffers per one IIO device, we need a way
to know which IIO buffer is being enabled/disabled/controlled.

We know that all buffer attributes are device_attributes. So we can wrap
them with a iio_dev_attr types. In the iio_dev_attr type, we can also hold
a reference to an IIO buffer.
So, we end up being able to allocate wrapped attributes for all buffer
attributes (even the one from other drivers).

The neat part with this mechanism, is that we don't need to add any extra
cleanup, because these attributes are being added to a dynamic list that
will get cleaned up via iio_free_chan_devattr_list().

With this change, the 'buffer->scan_el_dev_attr_list' list is being renamed
to 'buffer->buffer_attr_list', effectively merging (or finalizing the
merge) of the buffer/ & scan_elements/ attributes internally.

Accessing these new buffer attributes can now be done via
'to_iio_dev_attr(attr)->buffer' inside the show/store handlers.

Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
Link: https://lore.kernel.org/r/20210215104043.91251-15-alexandru.ardelean@analog.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-03-11 20:47:04 +00:00
Alexandru Ardelean
3e3d11b2e4 iio: add reference to iio buffer on iio_dev_attr
This change adds a reference to a 'struct iio_buffer' object on the
iio_dev_attr object. This way, we can use the created iio_dev_attr objects
on per-buffer basis (since they're allocated anyway).

A minor downside of this change is that the number of parameters on
__iio_add_chan_devattr() grows by 1. This looks like it could do with a bit
of a re-think.

Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
Link: https://lore.kernel.org/r/20210215104043.91251-14-alexandru.ardelean@analog.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-03-11 20:47:04 +00:00
Alexandru Ardelean
d9a625744e iio: core: merge buffer/ & scan_elements/ attributes
With this change, we create a new directory for the IIO device called
buffer0, under which both the old buffer/ and scan_elements/ are stored.

This is done to simplify the addition of multiple IIO buffers per IIO
device. Otherwise we would need to add a bufferX/ and scan_elementsX/
directory for each IIO buffer.
With the current way of storing attribute groups, we can't have directories
stored under each other (i.e. scan_elements/ under buffer/), so the best
approach moving forward is to merge their attributes.

The old/legacy buffer/ & scan_elements/ groups are not stored on the opaque
IIO device object. This way the IIO buffer can have just a single
attribute_group object, saving a bit of memory when adding multiple IIO
buffers.

Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
Link: https://lore.kernel.org/r/20210215104043.91251-13-alexandru.ardelean@analog.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-03-11 20:47:03 +00:00
Alexandru Ardelean
e2b4d7aca9 iio: buffer: group attr count and attr alloc
If we want to merge the attributes of the buffer/ and scan_elements/
directories, we'll need to count all attributes first, then (depending on
the attribute group) either allocate 2 attribute groups, or a single one.
Historically an IIO buffer was described by 2 subdirectories under
/sys/bus/iio/iio:devicesX (i.e. buffer/ and scan_elements/); these subdirs
were actually 2 separate attribute groups on the iio_buffer object.

Moving forward, if we want to allow more than one buffer per IIO device,
keeping 2 subdirectories for each IIO buffer is a bit cumbersome
(especially for userpace ABI). So, we will merge the attributes of these 2
subdirs under a /sys/bus/iio/iio:devicesX/bufferY subdirectory. To do this,
we need to count all attributes first, and then distribute them based on
which buffer this is. For the first buffer, we'll need to also allocate the
legacy 2 attribute groups (for buffer/ and scan_elements/), and also a
/sys/bus/iio/iio:devicesX/buffer0 attribute group.

For buffer1 and above, just a single attribute group will be allocated (the
merged one).

Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
Link: https://lore.kernel.org/r/20210215104043.91251-12-alexandru.ardelean@analog.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-03-11 20:47:03 +00:00
Alexandru Ardelean
32f171724e iio: core: rework iio device group creation
Up until now, the device groups that an IIO device had were limited to 6.
Two of these groups would account for buffer attributes (the buffer/ and
scan_elements/ directories).

Since we want to add multiple buffers per IIO device, this number may not
be enough, when adding a second buffer. So, this change reallocates the
groups array whenever an IIO device group is added, via a
iio_device_register_sysfs_group() helper.

This also means that the groups array should be assigned to
'indio_dev.dev.groups' really late, right before {cdev_}device_add() is
called to do the entire setup.
And we also must take care to free this array when the sysfs resources are
being cleaned up.

With this change we can also move the 'groups' & 'groupcounter' fields to
the iio_dev_opaque object. Up until now, this didn't make a whole lot of
sense (especially since we weren't sure how multibuffer support would look
like in the end).
But doing it now kills one birds with one stone.

An alternative, would be to add a configurable Kconfig symbol
CONFIG_IIO_MAX_BUFFERS_PER_DEVICE (or something like that) and compute a
static maximum of the groups we can support per IIO device. But that would
probably annoy a few people since that would make the system less
configurable.

Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
Link: https://lore.kernel.org/r/20210215104043.91251-11-alexandru.ardelean@analog.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-03-11 20:47:03 +00:00
Alexandru Ardelean
e64506bf69 iio: core-trigger: make iio_device_register_trigger_consumer() an int return
Oddly enough the noop function is an int-return. This one seems to be void.
This change converts it to int, because we want to change how groups are
registered. With that change this function could error out with -ENOMEM.

Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
Link: https://lore.kernel.org/r/20210215104043.91251-10-alexandru.ardelean@analog.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-03-11 20:47:02 +00:00
Alexandru Ardelean
8ebaa3ff1e iio: core: register chardev only if needed
We only need a chardev if we need to support buffers and/or events.

With this change, a chardev will be created only if an IIO buffer is
attached OR an event_interface is configured.

Otherwise, no chardev will be created, and the IIO device will get
registered with the 'device_add()' call.

Quite a lot of IIO devices don't really need a chardev, so this is a minor
improvement to the IIO core, as the IIO device will take up (slightly)
fewer resources.

In order to not create a chardev, we mostly just need to not initialize the
indio_dev->dev.devt field. If that is un-initialized, cdev_device_add()
behaves like device_add().

This change has a small chance of breaking some userspace ABI, because it
removes un-needed chardevs. While these chardevs (that are being removed)
have always been unusable, it is likely that some scripts may check their
existence (for whatever logic).
And we also hope that before opening these chardevs, userspace would have
already checked for some pre-conditions to make sure that opening these
chardevs makes sense.
For the most part, there is also the hope that it would be easier to change
userspace code than revert this. But in the case that reverting this is
required, it should be easy enough to do it.

Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
Link: https://lore.kernel.org/r/20210215104043.91251-9-alexandru.ardelean@analog.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-03-11 20:47:02 +00:00
Alexandru Ardelean
a02c09e42b iio: buffer-dma,adi-axi-adc: introduce devm_iio_dmaengine_buffer_setup()
This change does a conversion of the devm_iio_dmaengine_buffer_alloc() to
devm_iio_dmaengine_buffer_setup(). This will allocate an IIO DMA buffer and
attach it to the IIO device, similar to devm_iio_triggered_buffer_setup()
(though the underlying code is different, the final logic is the same).

Since the only user of the devm_iio_dmaengine_buffer_alloc() was the
adi-axi-adc driver, this change does the replacement in a single go in the
driver.

Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
Link: https://lore.kernel.org/r/20210215104043.91251-7-alexandru.ardelean@analog.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-03-11 20:47:02 +00:00
Alexandru Ardelean
99f6e8215b iio: kfifo: un-export devm_iio_kfifo_allocate() function
At this point all drivers should use devm_iio_kfifo_buffer_setup() instead
of manually allocating via devm_iio_kfifo_allocate() and assigning ops and
modes.

With this change, the devm_iio_kfifo_allocate() will be made private to the
IIO core, since all drivers should call either
devm_iio_kfifo_buffer_setup() or devm_iio_triggered_buffer_setup() to
create a kfifo buffer.

Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
Link: https://lore.kernel.org/r/20210215104043.91251-6-alexandru.ardelean@analog.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-03-11 20:47:01 +00:00
Alexandru Ardelean
e03ed893e2 iio: accel: sca3000: use devm_iio_kfifo_buffer_setup() helper
This change makes use of the devm_iio_kfifo_buffer_setup() helper, however
the unwind order is changed.
The life-time of the kfifo object is attached to the parent device object.
This is to make the driver a bit more consistent with the other IIO
drivers, even though (as it is now before this change) it shouldn't be a
problem.

Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
Link: https://lore.kernel.org/r/20210215104043.91251-5-alexandru.ardelean@analog.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-03-11 20:47:01 +00:00
Alexandru Ardelean
17395ce299 iio: make use of devm_iio_kfifo_buffer_setup() helper
All drivers that already call devm_iio_kfifo_allocate() &
iio_device_attach_buffer() are simple to convert to
iio_device_attach_kfifo_buffer() in a single go.

This change does that; the unwind order is preserved.
What is important, is that the devm_iio_kfifo_buffer_setup() be called
after the indio_dev->modes is assigned, to make sure that
INDIO_BUFFER_SOFTWARE flag is set and not overridden by the assignment to
indio_dev->modes.

Also, the INDIO_BUFFER_SOFTWARE has been removed from the assignments of
'indio_dev->modes' because it is set by devm_iio_kfifo_buffer_setup().

Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
Reviewed-by: Gwendal Grignou <gwendal@chromium.org>
Reviewed-by: Matt Ranostay <matt.ranostay@konsulko.com>x
Link: https://lore.kernel.org/r/20210215104043.91251-4-alexandru.ardelean@analog.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-03-11 20:47:01 +00:00
Alexandru Ardelean
e36db6a069 iio: kfifo: add devm_iio_kfifo_buffer_setup() helper
This change adds the devm_iio_kfifo_buffer_setup() helper/short-hand,
which groups the simple routine of allocating a kfifo buffers via
devm_iio_kfifo_allocate() and calling iio_device_attach_buffer().

The mode_flags parameter is required, as the IIO kfifo supports 2 modes:
INDIO_BUFFER_SOFTWARE & INDIO_BUFFER_TRIGGERED.
The setup_ops parameter is optional.

This function will be a bit more useful when needing to define multiple
buffers per IIO device.

The naming for this function has been inspired from
iio_triggered_buffer_setup() since that one does a kfifo alloc + a pollfunc
alloc. So, this should have a more familiar ring to what it is.

Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
Link: https://lore.kernel.org/r/20210215104043.91251-3-alexandru.ardelean@analog.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-03-11 20:47:01 +00:00
Lars-Peter Clausen
0bf49ffbfe iio: Add basic unit test for iio_format_value()
The IIO core provides a function to do formatting of fixedpoint numbers.

In the past there have been some issues with the implementation of the
function where for example negative numbers were not handled correctly.

Introduce a basic unit test based on kunit that tests the function and
ensures that the generated output matches the expected output.

This gives us some confidence that future modifications to the function
implementation will not break ABI compatibility.

To run the unit tests follow the kunit documentation and add

  CONFIG_IIO=y
  CONFIG_IIO_TEST_FORMAT=y

to the .kunitconfig and run

  > ./tools/testing/kunit/kunit.py run
  Configuring KUnit Kernel ...
  Building KUnit Kernel ...
  Starting KUnit Kernel ...
  ============================================================
  ======== [PASSED] iio-format ========
  [PASSED] iio_test_iio_format_value_integer
  [PASSED] iio_test_iio_format_value_fixedpoint
  [PASSED] iio_test_iio_format_value_fractional
  [PASSED] iio_test_iio_format_value_fractional_log2
  [PASSED] iio_test_iio_format_value_multiple
  ============================================================
  Testing complete. 21 tests run. 0 failed. 0 crashed.
  Elapsed time: 8.242s total, 0.001s configuring, 3.865s building, 0.000s running

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Link: https://lore.kernel.org/r/20201215191743.2725-3-lars@metafoo.de
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-03-11 20:47:00 +00:00
Lars-Peter Clausen
38a52cdef5 iio: iio_format_value(): Fix IIO_VAL_FRACTIONAL_LOG2 values between -1.0 and 0.0
When formatting a value using IIO_VAL_FRACTIONAL_LOG2 and the values is
between -1 and 0 the sign is omitted.

We need the same trick as for IIO_VAL_FRACTIONAL to make sure this gets
formatted correctly.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Link: https://lore.kernel.org/r/20201215191743.2725-2-lars@metafoo.de
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-03-11 20:47:00 +00:00
Lars-Peter Clausen
2646a95df9 iio: iio_format_value(): Use signed temporary for IIO_VAL_FRACTIONAL_LOG2
IIO_VAL_FRACTIONAL_LOG2 works with signed values, yet the temporary we use
is unsigned. This works at the moment because the variable is implicitly
cast to signed everywhere where it is used.

But it will certainly be cleaner to use a signed variable in the first
place.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Link: https://lore.kernel.org/r/20201215191743.2725-1-lars@metafoo.de
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-03-11 20:47:00 +00:00
Bhaskar Chowdhury
a04e3db514 iio: proximity: sx9500: Fix a spelling postive to positive
s/postive/positive/

Signed-off-by: Bhaskar Chowdhury <unixbhaskar@gmail.com>
Acked-by: Randy Dunlap <rdunlap@infradead.org>
Link: https://lore.kernel.org/r/20210210085704.1228068-1-unixbhaskar@gmail.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-03-11 20:47:00 +00:00
Hans de Goede
30132fe466 iio: accel: kxcjk-1013: Set label based on accel-location on 2-accel yoga-style 2-in-1s
Some 2-in-1 laptops / convertibles with 360° (yoga-style) hinges,
use 2 KXCJ91008 accelerometers:
1 in their display using an ACPI HID of "KIOX010A"; and
1 in their base    using an ACPI HID of "KIOX020A"

Since in this case we know the location of each accelerometer,
set the label for the accelerometers to the standardized
"accel-display" resp. "accel-base" labels. This way userspace
can use the labels to get the location.

This was tested on a Medion Akoya E2228T MD60250.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Link: https://lore.kernel.org/r/20210207160901.110643-4-hdegoede@redhat.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-03-11 20:46:59 +00:00
Hans de Goede
788348a5f7 iio: accel: bmc150: Set label based on accel-location on 2-accel yoga-style 2-in-1s
Some 2-in-1 laptops / convertibles with 360° (yoga-style) hinges,
use 2 bmc150 accelerometers, defined by a single BOSC0200 ACPI
device node (1 in their base and 1 in their display).

Since in this case we know the location of each accelerometer,
set the label for the accelerometers to the standardized
"accel-display" resp. "accel-base" labels. This way userspace
can use the labels to get the location.

This was tested on a Lenovo ThinkPad Yoga 11e 4th gen (N3450 CPU).

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Link: https://lore.kernel.org/r/20210207160901.110643-3-hdegoede@redhat.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-03-11 20:46:59 +00:00
Hans de Goede
6f71bf1991 iio: core: Allow drivers to specify a label without it coming from of
Only set indio_dev->label from of/dt if there actually is a label
specified in of.

This allows drivers to set a label without this being overwritten with
NULL when there is no label specified in of. This is esp. useful on
devices where of is not used at all, such as your typical x86/ACPI device.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
Link: https://lore.kernel.org/r/20210207160901.110643-2-hdegoede@redhat.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-03-11 20:46:59 +00:00
Tomislav Denis
d935eddd27 iio: adc: Add driver for Texas Instruments ADS131E0x ADC family
The ADS131E0x are a family of multichannel, simultaneous sampling,
24-bit, delta-sigma, analog-to-digital converters (ADCs) with a
built-in programmable gain amplifier (PGA), internal reference
and an onboard oscillator.

Datasheet: https://www.ti.com/lit/ds/symlink/ads131e08.pdf
Signed-off-by: Tomislav Denis <tomislav.denis@avl.com>
Link: https://lore.kernel.org/r/20210202084107.3260-2-tomislav.denis@avl.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-03-11 20:46:58 +00:00
Mike Looijmans
c19ae6be75 iio: accel: Add support for the Bosch-Sensortec BMI088
The BMI088 is a combined module with both accelerometer and gyroscope.
This adds the accelerometer driver support for the SPI interface.
The gyroscope part is already supported by the BMG160 driver.

Signed-off-by: Mike Looijmans <mike.looijmans@topic.nl>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Link: https://lore.kernel.org/r/20210125150732.23873-2-mike.looijmans@topic.nl
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-03-11 20:46:58 +00:00
zuoqilin
0071aa3002 iio:adc:dac:ad5791 typo fix of regster
change 'regster' to 'register'

Signed-off-by: zuoqilin <zuoqilin@yulong.com>
Link: https://lore.kernel.org/r/20210128021905.963-1-zuoqilin1@163.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-03-11 20:46:57 +00:00
Ahmad Fatoum
8a09054f3e iio: adc: stm32-adc: enable timestamping for non-DMA usage
For non-DMA usage, we have an easy way to associate a timestamp with a
sample: iio_pollfunc_store_time stores a timestamp in the primary
trigger IRQ handler and stm32_adc_trigger_handler runs in the IRQ thread
to push out the buffer along with the timestamp.

For this to work, the driver needs to register an IIO_TIMESTAMP channel.
Do this.

For DMA, it's not as easy, because we don't push the buffers out of
stm32_adc_trigger, but out of stm32_adc_dma_buffer_done, which runs in
a tasklet scheduled after a DMA completion.

Preferably, the DMA controller would copy us the timestamp into that buffer
as well. Until this is implemented, restrict timestamping support to
only PIO. For low-frequency sampling, PIO is probably good enough.

Cc: Holger Assmann <has@pengutronix.de>
Acked-by: Fabrice Gasnier <fabrice.gasnier@foss.st.com>
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
Link: https://lore.kernel.org/r/20210125194824.30549-1-a.fatoum@pengutronix.de
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-03-11 20:46:57 +00:00
Ye Xiang
6c3b615379 iio: hid-sensor-rotation: Fix quaternion data not correct
Because the data of HID_USAGE_SENSOR_ORIENT_QUATERNION defined by ISH FW
is s16, but quaternion data type is in_rot_quaternion_type(le:s16/32X4>>0),
need to transform data type from s16 to s32

May require manual backporting.

Fixes: fc18dddc06 ("iio: hid-sensors: Added device rotation support")
Signed-off-by: Ye Xiang <xiang.ye@intel.com>
Link: https://lore.kernel.org/r/20210130102546.31397-1-xiang.ye@intel.com
Cc: <Stable@vger.kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-03-11 20:46:56 +00:00
Jonathan Cameron
c03e2df6e1 iio:adc:stm32-adc: Add HAS_IOMEM dependency
Seems that there are config combinations in which this driver gets enabled
and hence selects the MFD, but with out HAS_IOMEM getting pulled in
via some other route.  MFD is entirely contained in an
if HAS_IOMEM block, leading to the build issue in this bugzilla.

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

Cc: <Stable@vger.kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-03-11 20:46:56 +00:00
Ahmad Fatoum
f40e800530 iio: st_sensors: fix typo in comment
s/timetamping/timestamping/

Cc: trivial@kernel.org
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
Link: https://lore.kernel.org/r/20210121153945.5499-1-a.fatoum@pengutronix.de
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-03-11 20:46:55 +00:00
Rafael J. Wysocki
94e17d606e IIO: acpi-als: Get rid of ACPICA message printing
Use acpi_evaluation_failure_warn() introduced previously instead of
the ACPICA-specific ACPI_EXCEPTION() macro to log warning messages
regarding ACPI object evaluation failures and drop the
ACPI_MODULE_NAME() definition only used by the ACPICA message
printing macro.

Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Acked-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-03-08 19:10:30 +01:00
Dinghao Liu
6dbbbe4cfd iio: gyro: mpu3050: Fix error handling in mpu3050_trigger_handler
There is one regmap_bulk_read() call in mpu3050_trigger_handler
that we have caught its return value bug lack further handling.
Check and terminate the execution flow just like the other three
regmap_bulk_read() calls in this function.

Fixes: 3904b28efb ("iio: gyro: Add driver for the MPU-3050 gyroscope")
Signed-off-by: Dinghao Liu <dinghao.liu@zju.edu.cn>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Link: https://lore.kernel.org/r/20210301080421.13436-1-dinghao.liu@zju.edu.cn
Cc: <Stable@vger.kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-03-06 17:15:13 +00:00
Ye Xiang
141e7633aa iio: hid-sensor-temperature: Fix issues of timestamp channel
This patch fixes 2 issues of timestamp channel:
1. This patch ensures that there is sufficient space and correct
alignment for the timestamp.
2. Correct the timestamp channel scan index.

Fixes: 59d0f2da35 ("iio: hid: Add temperature sensor support")
Signed-off-by: Ye Xiang <xiang.ye@intel.com>
Cc: <Stable@vger.kernel.org>
Link: https://lore.kernel.org/r/20210303063615.12130-4-xiang.ye@intel.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-03-06 17:06:14 +00:00
Ye Xiang
37e89e574d iio: hid-sensor-humidity: Fix alignment issue of timestamp channel
This patch ensures that, there is sufficient space and correct
alignment for the timestamp.

Fixes: d7ed89d5aa ("iio: hid: Add humidity sensor support")
Signed-off-by: Ye Xiang <xiang.ye@intel.com>
Cc: <Stable@vger.kernel.org>
Link: https://lore.kernel.org/r/20210303063615.12130-2-xiang.ye@intel.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-03-06 17:03:04 +00:00
Linus Torvalds
5d26c176d5 - Use the newly introduced 'hot' and 'critical' ops for the acpi
thermal driver (Daniel Lezcano)
 
 - Remove the notify ops as it is no longer used (Daniel Lezcano)
 
 - Remove the 'forced passive' option and the unused bind/unbind
   functions (Daniel Lezcano)
 
 - Remove the THERMAL_TRIPS_NONE and the code cleanup around this
   macro (Daniel Lezcano)
 
 - Rework the delays to make them pre-computed instead of computing
   them again and again at each polling interval (Daniel Lezcano)
 
 - Remove the pointless 'thermal_zone_device_reset' function (Daniel
   Lezcano)
 
 - Use the critical and hot ops to prevent an unexpected system
   shutdown on int340x (Kai-Heng Feng)
 
 - Make the cooling device state private to the thermal subsystem
   (Daniel Lezcano)
 
 - Prevent to use not-power-aware actor devices with the power
   allocator governor (Lukasz Luba)
 
 - Remove 'zx' and 'tango' support along with the corresponding
   platforms (Arnd Bergman)
 
 - Fix several issues on the Omap thermal driver (Tony Lindgren)
 
 - Add support for adc-tm5 PMIC thermal monitor for Qcom
   platforms. Please note those changes rely on an immutable branch:
   iio-thermal-5.11-rc1/ib-iio-thermal-5.11-rc1 from the iio tree
   (Dmitry Baryshkov)
 
 - Fix an initialization loop in the adc-tm5 (Colin Ian King)
 
 - Fix a return error check in the cpufreq cooling device (Viresh Kumar)
 -----BEGIN PGP SIGNATURE-----
 
 iQEzBAABCAAdFiEEGn3N4YVz0WNVyHskqDIjiipP6E8FAmAvkKMACgkQqDIjiipP
 6E9yFggAmXy8t2j1mRvn/KLU+teTGIoSFkZ8mBnY2Sgip97IRZRhCwAZbUKOW0eI
 bvpAzBjacxdZHT7OxxvGzCOq/zlAh4UoStI8bMpzdUWPdkAj4ippArLYGvagLym8
 WEQysWnrr8V1RCZbQuBNjyLwjf0fcXkzIBU1mbZXA8T8Y6Yn646TdtsrVT4Idg1j
 MOg7PAHBcTSY/wOReZKJ5TB1yvo2tNOuGOqUVbrIAHlRkiNTVHirVUq6aZGtTTKp
 7ukcu8EI/o7XKBdQ5d9MZaHdwkcyAIJj4jdjmjkUJpa8VYQFPjayNyN3I+Py9lH2
 jtWVYHQxZbY166IZP2yeXFjPzd6elw==
 =Jmz4
 -----END PGP SIGNATURE-----

Merge tag 'thermal-v5.12-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/thermal/linux

Pull thermal updates from Daniel Lezcano:

 - Use the newly introduced 'hot' and 'critical' ops for the acpi
   thermal driver (Daniel Lezcano)

 - Remove the notify ops as it is no longer used (Daniel Lezcano)

 - Remove the 'forced passive' option and the unused bind/unbind
   functions (Daniel Lezcano)

 - Remove the THERMAL_TRIPS_NONE and the code cleanup around this macro
   (Daniel Lezcano)

 - Rework the delays to make them pre-computed instead of computing them
   again and again at each polling interval (Daniel Lezcano)

 - Remove the pointless 'thermal_zone_device_reset' function (Daniel
   Lezcano)

 - Use the critical and hot ops to prevent an unexpected system shutdown
   on int340x (Kai-Heng Feng)

 - Make the cooling device state private to the thermal subsystem
   (Daniel Lezcano)

 - Prevent to use not-power-aware actor devices with the power allocator
   governor (Lukasz Luba)

 - Remove 'zx' and 'tango' support along with the corresponding
   platforms (Arnd Bergman)

 - Fix several issues on the Omap thermal driver (Tony Lindgren)

 - Add support for adc-tm5 PMIC thermal monitor for Qcom platforms
   (Dmitry Baryshkov)

 - Fix an initialization loop in the adc-tm5 (Colin Ian King)

 - Fix a return error check in the cpufreq cooling device (Viresh Kumar)

* tag 'thermal-v5.12-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/thermal/linux: (26 commits)
  thermal: cpufreq_cooling: freq_qos_update_request() returns < 0 on error
  thermal: qcom: Fix comparison with uninitialized variable channels_available
  thermal: qcom: add support for adc-tm5 PMIC thermal monitor
  dt-bindings: thermal: qcom: add adc-thermal monitor bindings
  thermal: ti-soc-thermal: Use non-inverted define for omap4
  thermal: ti-soc-thermal: Simplify polling with iopoll
  thermal: ti-soc-thermal: Fix stuck sensor with continuous mode for 4430
  thermal: ti-soc-thermal: Skip pointless register access for dra7
  thermal/drivers/zx: Remove zx driver
  thermal/drivers/tango: Remove tango driver
  thermal: power allocator: fail binding for non-power actor devices
  thermal/core: Make cooling device state change private
  thermal: intel: pch: Fix unexpected shutdown at critical temperature
  thermal: int340x: Fix unexpected shutdown at critical temperature
  thermal/core: Remove pointless thermal_zone_device_reset() function
  thermal/core: Remove ms based delay fields
  thermal/core: Use precomputed jiffies for the polling
  thermal/core: Precompute the delays from msecs to jiffies
  thermal/core: Remove unused macro THERMAL_TRIPS_NONE
  thermal/core: Remove THERMAL_TRIPS_NONE test
  ...
2021-02-22 09:39:11 -08:00
Linus Walleij
4f5434086d iio: adc: ab8500-gpadc: Fix off by 10 to 3
Fix an off by three orders of magnitude error in the AB8500
GPADC driver. Luckily it showed up quite quickly when trying
to make use of it. The processed reads were returning
microvolts, microamperes and microcelsius instead of millivolts,
milliamperes and millicelsius as advertised.

Cc: stable@vger.kernel.org
Fixes: 07063bbfa9 ("iio: adc: New driver for the AB8500 GPADC")
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Link: https://lore.kernel.org/r/20201224011700.1059659-1-linus.walleij@linaro.org
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-02-21 16:17:10 +00:00
Jonathan Cameron
121875b28e iio:adc:stm32-adc: Add HAS_IOMEM dependency
Seems that there are config combinations in which this driver gets enabled
and hence selects the MFD, but with out HAS_IOMEM getting pulled in
via some other route.  MFD is entirely contained in an
if HAS_IOMEM block, leading to the build issue in this bugzilla.

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

Cc: <Stable@vger.kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Link: https://lore.kernel.org/r/20210124195034.22576-1-jic23@kernel.org
2021-02-21 16:01:09 +00:00
Dan Carpenter
a71266e454 iio: adis16400: Fix an error code in adis16400_initial_setup()
This is to silence a new Smatch warning:

    drivers/iio/imu/adis16400.c:492 adis16400_initial_setup()
    warn: sscanf doesn't return error codes

If the condition "if (st->variant->flags & ADIS16400_HAS_SLOW_MODE) {"
is false then we return 1 instead of returning 0 and probe will fail.

Fixes: 72a868b38b ("iio: imu: check sscanf return value")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Cc: <Stable@vger.kernel.org>
Link: https://lore.kernel.org/r/YCwgFb3JVG6qrlQ+@mwanda
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-02-21 15:25:58 +00:00