Commit graph

687 commits

Author SHA1 Message Date
Andrea Merello
50fe984f37 iio: imu: add BNO055 I2C driver
Add an I2C driver for communicating to a BNO055 IMU via I2C bus and enable
the BNO055 core driver to work in this scenario.

Signed-off-by: Andrea Merello <andrea.merello@iit.it>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Link: https://lore.kernel.org/r/20220907132205.28021-14-andrea.merello@iit.it
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2022-09-21 18:42:56 +01:00
Andrea Merello
2eef5a9cc6 iio: imu: add BNO055 serdev driver
Add a serdev driver for communicating to a BNO055 IMU via serial bus, and
enable the BNO055 core driver to work in this scenario.

Signed-off-by: Andrea Merello <andrea.merello@iit.it>
Link: https://lore.kernel.org/r/20220907132205.28021-13-andrea.merello@iit.it
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2022-09-21 18:42:56 +01:00
Andrea Merello
4aefe1c2bd iio: imu: add Bosch Sensortec BNO055 core driver
Add the core driver for the BNO055 IMU from Bosch. This IMU can be
connected via both serial and I2C busses; separate patches will add support
for them.

The driver supports "AMG" (Accelerometer, Magnetometer, Gyroscope) mode,
that provides raw data from the said internal sensors, and a couple of
"fusion" modes (i.e. the IMU also does calculations in order to provide
euler angles, quaternions, linear acceleration and gravity measurements).

In fusion modes the AMG data is still available (with some calibration
refinements done by the IMU), but certain settings such as low pass filters
cut-off frequency and sensors' ranges are fixed, while in AMG mode they can
be customized; this is why AMG mode can still be interesting.

Signed-off-by: Andrea Merello <andrea.merello@iit.it>
Link: https://lore.kernel.org/r/20220907132205.28021-9-andrea.merello@iit.it
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2022-09-21 18:42:56 +01:00
Lorenzo Bianconi
186b9e3845 iio: imu: st_lsm6dsx: add support to LSM6DSTX
Add support to STM LSM6DSTX (acc + gyro) Mems sensor.
The LSM6DSTX sensor can use LSM6DST as fallback device since it
implements all the LSM6DSTX features currently implemented in
st_lsm6dsx.

Datasheet: https://www.st.com/resource/en/datasheet/lsm6dstx.pdf
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Link: https://lore.kernel.org/r/573a232b0f320b2ec92c56fa24393cfb275183fb.1663262890.git.lorenzo@kernel.org
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2022-09-21 18:42:54 +01:00
Wolfram Sang
a723df3d43 iio: imu: inv_mpu6050: move from strlcpy with unused retval to strscpy
Follow the advice of the below link and prefer 'strscpy' in this
subsystem. Conversion is 1:1 because the return value is not used.
Generated by a coccinelle script.

Link: https://lore.kernel.org/r/CAHk-=wgfRnXz0W3D37d01q3JFkr_i_uTL=V6A6G1oUZcprmknw@mail.gmail.com/
Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2022-08-19 18:23:48 +01:00
Uwe Kleine-König
ed5c2f5fd1 i2c: Make remove callback return void
The value returned by an i2c driver's remove function is mostly ignored.
(Only an error message is printed if the value is non-zero that the
error is ignored.)

So change the prototype of the remove function to return no value. This
way driver authors are not tempted to assume that passing an error to
the upper layer is a good idea. All drivers are adapted accordingly.
There is no intended change of behaviour, all callbacks were prepared to
return 0 before.

Reviewed-by: Peter Senna Tschudin <peter.senna@gmail.com>
Reviewed-by: Jeremy Kerr <jk@codeconstruct.com.au>
Reviewed-by: Benjamin Mugnier <benjamin.mugnier@foss.st.com>
Reviewed-by: Javier Martinez Canillas <javierm@redhat.com>
Reviewed-by: Crt Mori <cmo@melexis.com>
Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Acked-by: Marek Behún <kabel@kernel.org> # for leds-turris-omnia
Acked-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Petr Machata <petrm@nvidia.com> # for mlxsw
Reviewed-by: Maximilian Luz <luzmaximilian@gmail.com> # for surface3_power
Acked-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com> # for bmc150-accel-i2c + kxcjk-1013
Reviewed-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> # for media/* + staging/media/*
Acked-by: Miguel Ojeda <ojeda@kernel.org> # for auxdisplay/ht16k33 + auxdisplay/lcd2s
Reviewed-by: Luca Ceresoli <luca.ceresoli@bootlin.com> # for versaclock5
Reviewed-by: Ajay Gupta <ajayg@nvidia.com> # for ucsi_ccg
Acked-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> # for iio
Acked-by: Peter Rosin <peda@axentia.se> # for i2c-mux-*, max9860
Acked-by: Adrien Grassein <adrien.grassein@gmail.com> # for lontium-lt8912b
Reviewed-by: Jean Delvare <jdelvare@suse.de> # for hwmon, i2c-core and i2c/muxes
Acked-by: Corey Minyard <cminyard@mvista.com> # for IPMI
Reviewed-by: Vladimir Oltean <olteanv@gmail.com>
Acked-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Acked-by: Sebastian Reichel <sebastian.reichel@collabora.com> # for drivers/power
Acked-by: Krzysztof Hałasa <khalasa@piap.pl>
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
2022-08-16 12:46:26 +02:00
Uwe Kleine-König
33dae107b6 iio: imu: adis16475: Benefit from devm_clk_get_enabled() to simplify
Make use of devm_clk_get_enabled() to replace some code that effectively
open codes this new function.

Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Link: https://lore.kernel.org/r/20220808204740.307667-13-u.kleine-koenig@pengutronix.de
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2022-08-15 22:30:03 +01:00
Greg Kroah-Hartman
2a3c8f8a44 IIO new device support, features and minor fixes for 5.20
Several on-running cleanup efforts dominate this time, plus the DMA
 safety alignment issue identified due to improved understanding of
 the restrictions as a result of Catalin Marinas' efforts in that area.
 
 One immutable branch in here due to MFD and SPMI elements needed for
 the qcom-rradc driver.
 
 Device support
 * bmi088
   - Add support for bmi085 (accelerometer part of IMU)
   - Add support for bmi090l (accelerometer part of IMU)
 * mcp4922
   - Add support for single channel device MCP4921
 * rzg2l-adc
   - Add compatible and minor tweaks to support RZ/G2UL ADC
 * sca3300
   - Add support for scl3300 including refactoring driver to support
     multiple device types and cleanup noticed whilst working on driver.
 * spmi-rradc
   - New driver for Qualcomm SPMI Round Robin ADC including necessary
     additional utility functions in SPMI core and related MFD driver.
 * ti-dac55781
   - Add compatible for DAC121C081 which is very similar to existing parts.
 
 Features
 * core
   - Warn on iio_trigger_get() on an unregistered IIO trigger.
 * bma400
   - Triggered buffer support
   - Activity and step counting
   - Misc driver improvements such as devm and header ordering
 * cm32181
   - Add PM support.
 * cros_ec
   - Sensor location support
 * sx9324
   - Add precharge resistor setting
   - Add internal compensation resistor setting
   - Add CS idle/sleep mode.
 * sx9360
   - Add precharge resistor setting
 * vl53l0x
   - Handle reset GPIO, regulator and relax handling of irq type.
 
 Cleanup and minor fixes:
 
 Treewide changes
 - Cleanup of error handling in remove functions in many drivers.
 - Update dt-binding maintainers for a number of ADI bindings.
 - Several sets of conversion of drivers from device tree specific to
   generic device properties. Includes fixing up various related
   header and Kconfig issues.
 - Drop include of of.h from iio.h and fix up drivers that need to include
   it directly.
 - More moves of clusters of drivers into appropriate IIO_XXX namespaces.
 - Tree wide fix of a long running bug around DMA safety requirements.
   IIO was using __cacheline_aligned to pad iio_priv() structures. This
   worked for a long time by coincidence, but correct alignment is
   ARCH_KMALLOC_MINALIGN.  As there is activity around this area, introduce
   an IIO local IIO_DMA_MINALIGN to allow for changing it in one place rather
   than every driver in future. Note, there have been no reports of this
   bug in the wild, and it may not happen on any platforms supported by
   upstream, so no rush to backport these fixes.
 
 Other cleanup
 * core
   - Switch to ida_alloc()/free()
   - Drop unused iio_get_time_res()
   - Octal permissions and DEVICE_ATTR_* macros.
   - Cleanup bared unsigned usage.
 * MAINTAINERS
   - Add include/dt-bindings/iio/ to the main IIO entry.
 * ad5380
   - Comment syntax fix.
 * ad74413r
   - Call to for_each_set_bit_from(), with from value as 0 replaced.
 * ad7768-1
   - Drop explicit setting of INDIO_BUFFER_TRIGGERED as now done by the core.
 * adxl345
   - Fix wrong address in dt-binding example.
 * adxl367
   - Drop extra update of FIFO watermark.
 * at91-sama5d2
   - Limit requested watermark to the hwfifo size.
 * bmg160, bme680
   - Typos
 * cio-dac
   - Switch to iomap rather than direct use of ioports
 * kxsd9
   - Replace CONFIG_PM guards with new PM macros that let the compiler
     cleanly remove the unused code and structures when !CONFIG_PM
 * lsm6dsx
   - Use new pm_sleep_ptr() and EXPORT_SIMPLE_DEV_PM_OPS(). Then move
     to Namespace.
 * meson_saradc - general cleanup.
   - Avoid attaching resources to iio_dev->dev
   - Use same struct device for all error messages
   - Convert to dev_err_probe() and use local struct device *dev to
     reduce code complexity.
   - Use devm_clk_get_optional() instead of hand rolling.
   - Use regmap_read_poll_timeout() instead of hand rolling.
 * mma7660
   - Drop ACPI_PTR() use that is unhelpful.
 * mpu3050
   - Stop exporting symbols not used outside of module
   - Switch to new DEFINE_RUNTIME_DEV_PM_OPS() macro and move to Namespace.
 * ping
   - Typo fix
 * qcom-spmi-rradc
   - Typo fix
 * sc27xx
   - Convert to generic struct u32_fract
 * srf08
   - Drop a redundant check on !val
 * st_lsm6dsx
   - Limit the requested watermark to the hwfifo size.
 * stm32-adc
   - Use generic_handle_domain_irq() instead of opencoding.
   - Fix handling of ADC disable.
 * stm32-dac
   - Use str_enabled_disable() instead of open coding.
 * stx104
   - Switch to iomap rather than direct use of ioports
 * tsc2046
   - Drop explicit setting of INDIO_BUFFER_TRIGGERED as now done by the core.
 * tsl2563
   - Replace flush_scheduled_work() with cancel_delayed_work_sync()
   - Replace cancel_delayed_work() with cancel_delayed_work_sync()
 * vl53l0x
   - Make the VDD regulator optional by allowing a dummy regulator.
 -----BEGIN PGP SIGNATURE-----
 
 iQJFBAABCAAvFiEEbilms4eEBlKRJoGxVIU0mcT0FogFAmLQBwARHGppYzIzQGtl
 cm5lbC5vcmcACgkQVIU0mcT0FohMHRAAi3nPM3IchXe886olumRgX5ke75vU+FNT
 sqQjqlpl6X7j5yNLU+HF6lC7zg3QzDnfWJ3Uo4C7s2sW7zO0997lkFx4jvF3yW9y
 0nLDgYm1Y1te/qR84BE355pMEsYEJVZyPI/Z8UfuBh6IfnSDeTE5ZwCvlRMAchtp
 AX+j1114FQvZ8yfdIlFjlN4vYSxCGgEZzfWYhpch/Jv1y2Q0L17bpv/KWGt1AYaF
 VugmKoNTM3WzIABBNGWQ4l4ZVVuVpuiVUL90AKv6Qf+yDSqw94tuIM0NZpJ1rqLr
 7tH568m7Eewh7zBp88PRB9XDiZVERvzdVQaT22+wlX+Vhn/SKeoK8PPpdLWD1YyG
 hXB0p+FGKncoKKgK1w9L7qRRNmsQDHowNHYMSjnzeBuyGQyEqwAXzNvvbiCqHh8y
 7b8GW+CYo7//wIarg74Xl+/4LwdCGcMUJNuTm1efEgC7yGToY7JD63DNo3sylaII
 bfoT06/yogaay/rVLZs5n+MvDONaDt4AbTTErG48s0TzqD/O8Ys85AF0IvKwQ80N
 WMxe4y+gdJ6VuU+ww9+6WdUzxnx+5gt+ZA2iLxZFekOIUi3Tj+q47F+17Jvwyt7U
 2wQzdtvNhHPwD5CqYpxD4iH/z5YFCtIHKjmUsVyAWGVbeuSS/QvFzpf39YWxBWO+
 W1w6RStUbXo=
 =IcsE
 -----END PGP SIGNATURE-----

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

Jonathan writes:

IIO new device support, features and minor fixes for 5.20

Several on-running cleanup efforts dominate this time, plus the DMA
safety alignment issue identified due to improved understanding of
the restrictions as a result of Catalin Marinas' efforts in that area.

One immutable branch in here due to MFD and SPMI elements needed for
the qcom-rradc driver.

Device support
* bmi088
  - Add support for bmi085 (accelerometer part of IMU)
  - Add support for bmi090l (accelerometer part of IMU)
* mcp4922
  - Add support for single channel device MCP4921
* rzg2l-adc
  - Add compatible and minor tweaks to support RZ/G2UL ADC
* sca3300
  - Add support for scl3300 including refactoring driver to support
    multiple device types and cleanup noticed whilst working on driver.
* spmi-rradc
  - New driver for Qualcomm SPMI Round Robin ADC including necessary
    additional utility functions in SPMI core and related MFD driver.
* ti-dac55781
  - Add compatible for DAC121C081 which is very similar to existing parts.

Features
* core
  - Warn on iio_trigger_get() on an unregistered IIO trigger.
* bma400
  - Triggered buffer support
  - Activity and step counting
  - Misc driver improvements such as devm and header ordering
* cm32181
  - Add PM support.
* cros_ec
  - Sensor location support
* sx9324
  - Add precharge resistor setting
  - Add internal compensation resistor setting
  - Add CS idle/sleep mode.
* sx9360
  - Add precharge resistor setting
* vl53l0x
  - Handle reset GPIO, regulator and relax handling of irq type.

Cleanup and minor fixes:

Treewide changes
- Cleanup of error handling in remove functions in many drivers.
- Update dt-binding maintainers for a number of ADI bindings.
- Several sets of conversion of drivers from device tree specific to
  generic device properties. Includes fixing up various related
  header and Kconfig issues.
- Drop include of of.h from iio.h and fix up drivers that need to include
  it directly.
- More moves of clusters of drivers into appropriate IIO_XXX namespaces.
- Tree wide fix of a long running bug around DMA safety requirements.
  IIO was using __cacheline_aligned to pad iio_priv() structures. This
  worked for a long time by coincidence, but correct alignment is
  ARCH_KMALLOC_MINALIGN.  As there is activity around this area, introduce
  an IIO local IIO_DMA_MINALIGN to allow for changing it in one place rather
  than every driver in future. Note, there have been no reports of this
  bug in the wild, and it may not happen on any platforms supported by
  upstream, so no rush to backport these fixes.

Other cleanup
* core
  - Switch to ida_alloc()/free()
  - Drop unused iio_get_time_res()
  - Octal permissions and DEVICE_ATTR_* macros.
  - Cleanup bared unsigned usage.
* MAINTAINERS
  - Add include/dt-bindings/iio/ to the main IIO entry.
* ad5380
  - Comment syntax fix.
* ad74413r
  - Call to for_each_set_bit_from(), with from value as 0 replaced.
* ad7768-1
  - Drop explicit setting of INDIO_BUFFER_TRIGGERED as now done by the core.
* adxl345
  - Fix wrong address in dt-binding example.
* adxl367
  - Drop extra update of FIFO watermark.
* at91-sama5d2
  - Limit requested watermark to the hwfifo size.
* bmg160, bme680
  - Typos
* cio-dac
  - Switch to iomap rather than direct use of ioports
* kxsd9
  - Replace CONFIG_PM guards with new PM macros that let the compiler
    cleanly remove the unused code and structures when !CONFIG_PM
* lsm6dsx
  - Use new pm_sleep_ptr() and EXPORT_SIMPLE_DEV_PM_OPS(). Then move
    to Namespace.
* meson_saradc - general cleanup.
  - Avoid attaching resources to iio_dev->dev
  - Use same struct device for all error messages
  - Convert to dev_err_probe() and use local struct device *dev to
    reduce code complexity.
  - Use devm_clk_get_optional() instead of hand rolling.
  - Use regmap_read_poll_timeout() instead of hand rolling.
* mma7660
  - Drop ACPI_PTR() use that is unhelpful.
* mpu3050
  - Stop exporting symbols not used outside of module
  - Switch to new DEFINE_RUNTIME_DEV_PM_OPS() macro and move to Namespace.
* ping
  - Typo fix
* qcom-spmi-rradc
  - Typo fix
* sc27xx
  - Convert to generic struct u32_fract
* srf08
  - Drop a redundant check on !val
* st_lsm6dsx
  - Limit the requested watermark to the hwfifo size.
* stm32-adc
  - Use generic_handle_domain_irq() instead of opencoding.
  - Fix handling of ADC disable.
* stm32-dac
  - Use str_enabled_disable() instead of open coding.
* stx104
  - Switch to iomap rather than direct use of ioports
* tsc2046
  - Drop explicit setting of INDIO_BUFFER_TRIGGERED as now done by the core.
* tsl2563
  - Replace flush_scheduled_work() with cancel_delayed_work_sync()
  - Replace cancel_delayed_work() with cancel_delayed_work_sync()
* vl53l0x
  - Make the VDD regulator optional by allowing a dummy regulator.

* tag 'iio-for-5.20a' of https://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio: (244 commits)
  iio: adc: xilinx-xadc: Drop duplicate NULL check in xadc_parse_dt()
  iio: adc: xilinx-xadc: Make use of device properties
  iio: light: cm32181: Add PM support
  iio: adc: ad778-1: do not explicity set INDIO_BUFFER_TRIGGERED mode
  iio: adc: ti-tsc2046: do not explicity set INDIO_BUFFER_TRIGGERED mode
  iio: adc: stm32-adc: disable adc before calibration
  iio: adc: stm32-adc: make safe adc disable
  iio: dac: ad5380: align '*' each line and drop unneeded blank line
  iio: adc: qcom-spmi-rradc: Fix spelling mistake "coherrency" -> "coherency"
  iio: Don't use bare "unsigned"
  dt-bindings: iio: dac: mcp4922: expand for mcp4921 support
  iio: dac: mcp4922: add support to mcp4921
  iio: chemical: sps30: Move symbol exports into IIO_SPS30 namespace
  iio: pressure: bmp280: Move symbol exports to IIO_BMP280 namespace
  iio: imu: bmi160: Move exported symbols to IIO_BMI160 namespace
  iio: adc: stm32-adc: Use generic_handle_domain_irq()
  proximity: vl53l0x: Make VDD regulator actually optional
  MAINTAINERS: add include/dt-bindings/iio to IIO SUBSYSTEM AND DRIVERS
  dt-bindings: iio/accel: Fix adi,adxl345/6 example I2C address
  iio: gyro: bmg160: Fix typo in comment
  ...
2022-07-14 15:04:49 +02:00
Jonathan Cameron
2a8efd8b29 iio: imu: bmi160: Move exported symbols to IIO_BMI160 namespace
Avoid unnecessary pollution of the global symbol namespace by
moving library functions in to a specific namespace and import
that into the drivers that make use of the functions.

For more info: https://lwn.net/Articles/760045/

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Link: https://lore.kernel.org/r/20220220173701.502331-2-jic23@kernel.org
Reviewed-By: Joe Simmons-Talbott <joetalbott@gmail.com>
Link: https://lore.kernel.org/r/20220604155306.422937-2-jic23@kernel.org
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2022-06-21 21:30:31 +01:00
Greg Kroah-Hartman
315f7e15c2 1st set of IIO fixes for the 5.19 cycle.
Most of these have been in next for a long time. Unfortunately there
 was one stray patch in the branch (wasn't a fix), so I've just rebased
 to remove that.
 
 * testing
   - Fix a missing MODULE_LICENSE() warning by restricting possible build
     configs.
 * Various drivers
   - Fix ordering of iio_get_trigger() being called before
     iio_trigger_register()
 * adi,admv1014
   - Fix dubious x & !y warning.
 * adi,axi-adc
   - Fix missing of_node_put() in error and normal paths.
 * aspeed,adc
   - Add missing of_node_put()
 * fsl,mma8452
   - Fix broken probing from device tree.
   - Drop check on return value of i2c write to device to cause reset as
     ACK will be missing (device reset before sending it).
 * fsl,vf610
   - Fix documentation of in_conversion_mode ABI.
 * iio-trig-sysfs
   - Ensure irq work has finished before freeing the trigger.
 * invensense,mpu3050
  - Disable regulators in error path.
 * invensense,icm42600
   - Fix collision of enum value of 0 with error path where 0 is no match.
 * renesas,rzg2l_Adc
   - Add missing fwnode_handle_put() in error path.
 * rescale
   - Fix a boolean logic bug for detection of raw + scale affecting an
     obscure corner case.
 * semtech,sx9324
   - Check return value of read of pin_defs
 * st,stm32-adc:
   - Fix interaction across ADC instances for some supported devices.
   - Drop false spurious IRQ messages.
   - Fix calibration value handling.  If we can't calibrate don't expose the
     vref_int channel.
   - Fix maximum clock rate for stm32pm15x
 * ti,ads131e08
   - Add missing fwnode_handle_put() in error paths.
 * xilinx,ams
   - Fix variable checked for error from platform_get_irq()
 * x-powers,axp288
   - Overide TS_PIN bias current for boards where it is not correctly
     initialized.
 * yamaha,yas530
   - Fix inverted check on calibration data being all zeros.
 -----BEGIN PGP SIGNATURE-----
 
 iQJFBAABCAAvFiEEbilms4eEBlKRJoGxVIU0mcT0FogFAmKvUOsRHGppYzIzQGtl
 cm5lbC5vcmcACgkQVIU0mcT0Foj9+BAAgT/0u5a8SNuu0Cwu9JrHt/d8PHX5ZKfz
 CDzagToCptHIYbJfXPnoVi0rGoUWaKG5Oo6Z+1vEQ9jRy4HyAWSR/MrInbSyYdc9
 hiHiHEyhycjbe+Dc/NLd859fnQNGXhg5bp32u+nO5JGAQBM93KF7r05salO/XT1O
 34D3waV1cWcyhA9JqQysD/xczkYaWsuwGU33N7D5hfe9Ws0UqoQESYoUrO7N+RMr
 6AwT2qMvmIeoKkIupVw+N58knaSRN8qUACN9+BiR4dQyL40iu1BSrVSH4RCvTlsc
 WBGDz4G50lmRg3bE/bI1T53lFGjMpvjgOXOOP025llazumOM5azhhHGlA/iPk7a7
 NMPd1Oxuo7fGqASZiR0I6X4pfo2UEtwwusfIb+QfNZQ2bgEExPKtk4F/20Tpi4JY
 OV37Q3tTFYx3Wn+rpmzN50GDjMprgNBwYewmE8yAsoXVpsgmkqTVMqDMkmvEQBav
 ajuoUNC/ncMtfjWhphEKOUw2L96acltfIM1PTnMWEUaQq2FyidJM2DcoBh8MOZaa
 ms7qO9Hbab/+qPZJJfEQ/O+SkVDP/SWZdGYiazJdda731LzpPdwlQM2oGJjsNeQE
 4F5TWgTVfG/gN47NXyp53zbxls0nkvLy09I1xiUPA23DKnhiD+dsGK72OWth6cd2
 DQ++coHl140=
 =AtPS
 -----END PGP SIGNATURE-----

Merge tag 'iio-fixes-for-5.19a' of https://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio into char-misc-next

Jonathan writes:

1st set of IIO fixes for the 5.19 cycle.

Most of these have been in next for a long time. Unfortunately there
was one stray patch in the branch (wasn't a fix), so I've just rebased
to remove that.

* testing
  - Fix a missing MODULE_LICENSE() warning by restricting possible build
    configs.
* Various drivers
  - Fix ordering of iio_get_trigger() being called before
    iio_trigger_register()
* adi,admv1014
  - Fix dubious x & !y warning.
* adi,axi-adc
  - Fix missing of_node_put() in error and normal paths.
* aspeed,adc
  - Add missing of_node_put()
* fsl,mma8452
  - Fix broken probing from device tree.
  - Drop check on return value of i2c write to device to cause reset as
    ACK will be missing (device reset before sending it).
* fsl,vf610
  - Fix documentation of in_conversion_mode ABI.
* iio-trig-sysfs
  - Ensure irq work has finished before freeing the trigger.
* invensense,mpu3050
 - Disable regulators in error path.
* invensense,icm42600
  - Fix collision of enum value of 0 with error path where 0 is no match.
* renesas,rzg2l_Adc
  - Add missing fwnode_handle_put() in error path.
* rescale
  - Fix a boolean logic bug for detection of raw + scale affecting an
    obscure corner case.
* semtech,sx9324
  - Check return value of read of pin_defs
* st,stm32-adc:
  - Fix interaction across ADC instances for some supported devices.
  - Drop false spurious IRQ messages.
  - Fix calibration value handling.  If we can't calibrate don't expose the
    vref_int channel.
  - Fix maximum clock rate for stm32pm15x
* ti,ads131e08
  - Add missing fwnode_handle_put() in error paths.
* xilinx,ams
  - Fix variable checked for error from platform_get_irq()
* x-powers,axp288
  - Overide TS_PIN bias current for boards where it is not correctly
    initialized.
* yamaha,yas530
  - Fix inverted check on calibration data being all zeros.

* tag 'iio-fixes-for-5.19a' of https://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio: (26 commits)
  iio:proximity:sx9324: Check ret value of device_property_read_u32_array()
  iio: accel: mma8452: ignore the return value of reset operation
  iio: adc: stm32: fix maximum clock rate for stm32mp15x
  iio: adc: stm32: fix vrefint wrong calibration value handling
  iio: imu: inv_icm42600: Fix broken icm42600 (chip id 0 value)
  iio: adc: vf610: fix conversion mode sysfs node name
  iio: adc: adi-axi-adc: Fix refcount leak in adi_axi_adc_attach_client
  iio: test: fix missing MODULE_LICENSE for IIO_RESCALE=m
  iio:humidity:hts221: rearrange iio trigger get and register
  iio:chemical:ccs811: rearrange iio trigger get and register
  iio:accel:mxc4005: rearrange iio trigger get and register
  iio:accel:kxcjk-1013: rearrange iio trigger get and register
  iio:accel:bma180: rearrange iio trigger get and register
  iio: afe: rescale: Fix boolean logic bug
  iio: adc: aspeed: Fix refcount leak in aspeed_adc_set_trim_data
  iio: adc: stm32: Fix IRQs on STM32F4 by removing custom spurious IRQs message
  iio: adc: stm32: Fix ADCs iteration in irq handler
  iio: adc: ti-ads131e08: add missing fwnode_handle_put() in ads131e08_alloc_channels()
  iio: adc: rzg2l_adc: add missing fwnode_handle_put() in rzg2l_adc_parse_properties()
  iio: trigger: sysfs: fix use-after-free on remove
  ...
2022-06-20 09:49:52 +02:00
Jean-Baptiste Maneyrol
106b391e1b iio: imu: inv_icm42600: Fix broken icm42600 (chip id 0 value)
The 0 value used for INV_CHIP_ICM42600 was not working since the
match in i2c/spi was checking against NULL value.

To keep this check, add a first INV_CHIP_INVALID 0 value as safe
guard.

Fixes: 31c24c1e93 ("iio: imu: inv_icm42600: add core of new inv_icm42600 driver")
Signed-off-by: Jean-Baptiste Maneyrol <jean-baptiste.maneyrol@tdk.com>
Link: https://lore.kernel.org/r/20220609102301.4794-1-jmaneyrol@invensense.com
Cc: <Stable@vger.kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2022-06-19 17:22:49 +01:00
Paul Cercueil
9e5b4cd2e9 iio: imu: st_lsm6dsx: Limit requested watermark value to hwfifo size
Instead of returning an error if the watermark value is too high, which
the core will silently ignore anyway, limit the value to the hardware
FIFO size; a lower-than-requested value is still better than using the
default, which is usually 1.

Cc: Lorenzo Bianconi <lorenzo.bianconi83@gmail.com>
Signed-off-by: Paul Cercueil <paul@crapouillou.net>
Acked-by: Lorenzo Bianconi <lorenzo@kernel.org>
Link: https://lore.kernel.org/r/20220117102512.31725-1-paul@crapouillou.net
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2022-06-15 22:07:09 +01:00
Jonathan Cameron
2b059449b5 iio: imu: lsm6dsx: Move exported symbols to the IIO_LSM6DSX namespace
Avoid unnecessary pollution of the global symbol namespace by
moving library functions in to a specific namespace and import
that into the drivers that make use of the functions.

For more info: https://lwn.net/Articles/760045/

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Link: https://lore.kernel.org/r/20220220181522.541718-9-jic23@kernel.org
Acked-by: Lorenzo Bianconi <lorenzo@kernel.org>
Link: https://lore.kernel.org/r/20220604161223.461847-6-jic23@kernel.org
2022-06-15 22:07:09 +01:00
Jonathan Cameron
acc416ff7d iio: imu: lsm6dsx: Use new pm_sleep_ptr() and EXPORT_SIMPLE_DEV_PM_OPS()
These new functions move the burden of removing unused code when
CONFIG_PM_SLEEP is not defined onto the compiler rather than requiring
the use of CONFIG_PM guards and similar.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Link: https://lore.kernel.org/r/20220220181522.541718-8-jic23@kernel.org
Acked-by: Lorenzo Bianconi <lorenzo@kernel.org>
Link: https://lore.kernel.org/r/20220604161223.461847-5-jic23@kernel.org
2022-06-15 22:07:09 +01:00
Jonathan Cameron
54e03562bb iio: imu: mpu6050: Fix alignment for DMA safety
____cacheline_aligned is an insufficient guarantee for non-coherent DMA
on platforms with 128 byte cachelines above L1.  Switch to the updated
IIO_DMA_MINALIGN definition.

Fixes: 6b0cc5dce0 ("iio:imu:inv_mpu6050 Fix dma and ts alignment and data leak issues.")
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Acked-by: Jean-Baptiste Maneyrol <jean-baptiste.maneyrol@tdk.com>
Acked-by: Nuno Sá <nuno.sa@analog.com>
Link: https://lore.kernel.org/r/20220508175712.647246-80-jic23@kernel.org
2022-06-14 11:53:18 +01:00
Jonathan Cameron
b0aa05065a iio: imu: inv_icm42600: Fix alignment for DMA safety in buffer code.
Second fix for this driver due to different introducing patches.

____cacheline_aligned is an insufficient guarantee for non-coherent DMA
on platforms with 128 byte cachelines above L1.  Switch to the updated
IIO_DMA_MINALIGN definition.

Fixes: 7f85e42a6c ("iio: imu: inv_icm42600: add buffer support in iio devices")
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Cc: Jean-Baptiste Maneyrol <jmaneyrol@invensense.com>
Acked-by: Jean-Baptiste Maneyrol <jean-baptiste.maneyrol@tdk.com>
Acked-by: Nuno Sá <nuno.sa@analog.com>
Link: https://lore.kernel.org/r/20220508175712.647246-79-jic23@kernel.org
2022-06-14 11:53:18 +01:00
Jonathan Cameron
848847702b iio: imu: inv_icm42600: Fix alignment for DMA safety
Partial fix for this driver as a second instance was introduced in
a later patch.

____cacheline_aligned is an insufficient guarantee for non-coherent DMA
on platforms with 128 byte cachelines above L1.  Switch to the updated
IIO_DMA_MINALIGN definition.

Fixes: a095fadb44 ("iio: imu: inv_icm42600: add gyroscope IIO device")
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Acked-by: Jean-Baptiste Maneyrol <jean-baptiste.maneyrol@tdk.com>
Acked-by: Nuno Sá <nuno.sa@analog.com>
Link: https://lore.kernel.org/r/20220508175712.647246-78-jic23@kernel.org
2022-06-14 11:53:18 +01:00
Jonathan Cameron
c9a8417a13 iio: imu: fxos8700: Fix alignment for DMA safety
____cacheline_aligned is an insufficient guarantee for non-coherent DMA
on platforms with 128 byte cachelines above L1.  Switch to the updated
IIO_DMA_MINALIGN definition.

Fixes: 84e5ddd5c4 ("iio: imu: Add support for the FXOS8700 IMU")
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Cc: Robert Jones <rjones@gateworks.com>
Acked-by: Nuno Sá <nuno.sa@analog.com>
Link: https://lore.kernel.org/r/20220508175712.647246-77-jic23@kernel.org
2022-06-14 11:53:18 +01:00
Andy Shevchenko
39f0b95619 iio: imu: st_lsm6dsx: Switch from of headers to mod_devicetable.h
There is nothing directly using of specific interfaces in this driver,
so lets not include the headers.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://lore.kernel.org/r/20220507173440.29053-1-andriy.shevchenko@linux.intel.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2022-06-11 14:35:26 +01:00
Greg Kroah-Hartman
bcfa954650 First set of IIO new device support, features and cleanup for 5.19
Usual mixed bag. Stand out this time is Andy Shevchenko's continuing
 effort to move drivers over the generic firmware interfaces.
 
 Device support
 * sprd,sc2720
   - upm9620 binding addition.
   - Refactor and support for sc2720, sc2721 and sc2730.
 * ti,ads1015
   - Refactor driver and add support for TLA2024.
 
 Device support (IDs only)
 * invensense,mpu6050
   - Add ID for ICM-20608-D.
 * st,accel:
   -  Add ID for lis302dl.
 * st,lsm6dsx
   - Add support for ASM330LHHX (can fallback to LSM6DSR.)
 
 Features
 * convert drivers to device properties
   - IIO core
   - adi,ad7266
   - adi,adis16480
   - adi,adxl355
   - bosch,bmi160
   - domintech,dmard06
   - fsl,fxas21002c
   - invensense,mpu3050
   - linear,ltc2983
   - linear,ltc2632
   - maxbotix,mb1232
   - maxim,max31856
   - maxim,max31865
   - multiplexer
   - ping
   - rescale
   - taos,tsl2772
 * core
   - Add runtime check on whether realbits fit in storagebits for each
     channel.
 * adi,ad_sigma_delta
   - Add sequencer support and relevant update_scan_mode callbacks for
     adi,ad7192 and adi,ad7124.
 
 Cleanup and minor fixes
 * MAINTAINERS
   - Update Lorenzo Bianconi's email address for IIO drivers.
   - Add entry for ad3552r and update maintainer in dt-binding doc.
 * tree-wide
   - Replace strtobool() with kstrtobool().
   - Drop false OF dependencies.
 * core
   - Tidy up and document IIO modes.
   - Take iio_buffer_enabled() out of header allowing current_mode to be
     moved to the opaque structure.
   - As all kfifo buffers use the same mode value, drop that parameter
     and set it unconditionally.
   - White space fixes and similar.
   - Drop use of list iterator variable for
     list_for_each_entry_continue_reverse and use list_prepare_entry to
     restart.
 * sysfs-trigger
   - Replace use of 'found' variable with dedicate list iterator variable.
 * adi,ad7124
   - Drop misleading shift.
 * adi,ad2s1210
   - Remove redundant local variable assignment.
 * adi,adis16480
   - Use local device pointer to reduce repetition.
   - Improve handling of clocks.
 * domintech,dmard09
   - White space.
 * dummy driver
   - Improve error handling.
 * fsl,mma8452
   - Add missing documentation of name element.
 * invensense,mpu3050
   - Stop remove() returning non 0.
 * kionix,kxsd9
   - White space.
 * linear,ltc2688
   - Use local variable for struct device.
   - Combine of_node_put() error handling paths.
 * linear,ltc2983
   - Avoid use of constants in messages where a define is available.
 * microchip,mcp4131
   - Fix compatible in dt example.
 * pni,rm3100
   - Stop directly accessing iio_dev->current_mode just to find out
     if the buffer is enabled.
 * renesas,rzg2l
   - Relax kconfig constraint to include newer devices.
 * sprd,sc27xx
   - Fix wrong scaling mask.
   - Improve the calibration values.
 * samsung,ssp
   - Replace a 'found' variable in favor of an explicit value that was
     found.
 * sensortek,stk3xx
   - Add proximity-near-level binding and driver support.
 * st,st_sensors:
   - Drop unused accel_type enum.
   - Return early in *_write_raw()
   - Drop unnecessary locking in _avail functions.
   - Add local lock to protect odr against concurrent updates allowing
     mlock to no longer be used outside of the core.
   - Use iio_device_claim_direct_mode() rather than racy checking of
     the current mode.
 * st,stmpe-adc
   - Fix checks on wait_for_completion_timeout().
   - Allow use of of_device_id for matching.
 * st,stm32-dfsdm
   - Stop accessing iio_dev->current_mode to find out if the buffer
     is enabled (so we can hide that variable in the opaque structure)
 * st,vl53l0x
   - Fix checks on wait_for_completion_timeout.
 * ti,ads1015
   - Add missing ID for ti,ads1115 in binding doc.
   - Convert from repeated chip ID look up to selecting static const
     data.
   - Switch to read_avail() callback.
 * ti,ads8688
   - Use of_device_id for driver matching.
 * ti,palmas-adc
   - Drop a warning on minor calibration mismatch leading to slightly
     negative values after applying the calibration.
 -----BEGIN PGP SIGNATURE-----
 
 iQJFBAABCAAvFiEEbilms4eEBlKRJoGxVIU0mcT0FogFAmJy4f0RHGppYzIzQGtl
 cm5lbC5vcmcACgkQVIU0mcT0FohyzQ//e2RJF/oUjd5WreX9fywnK2qwXE0n6yfQ
 OrXuLvdAZ4ZwELmQyCg7XWVZY1u6JXvW1/TJXpjI0Y4sXSCSs+Z514BJOQYOrEyv
 2MH5mqkXq5IeskKAOxKBLeOz8e8txKyB2S4lDSVH11y40i32U+3SMdZHUt4ThVJU
 xd6FMJqEvXrbramQSj3O61YvICBedOcoKe4Da7nJtmr42zkDuBYJRlmtCnRoXx1l
 wrNgozEdqMh/JIRayVjlKfPpu3OiEFwt/uKvLEepKei/djUMdRnMyjTcXTziDGNg
 +B/51pWm7BLKE3YiqVAFZGBOi7OXZ0bRFVaUZyPOOP/xRr7DrdDRgFVpM4/Z9D0y
 p3anrWwkp6UF+IlatxjIDNGiAlWlWgNUZsFxWBMjRHAunOGhlrTNV7PVh81+LNBM
 I8Z9B+FDW/ECuxRSP2oK0an+4fVwJiOfGWSnuo6cIkW2ewh8kwr6Vvnu3bDytyew
 7xU9TvJN3fhYgU8pWK1VQ3ZIYan4zcAL/v40KBHDVIF49iKerYbKHGkCI4vJvakH
 lzf+dsUzYfQesTmB2sQUDdVvwpBtVd/xbD+mytRWv3bjapGIZ9r9LDGbjr8rgH0M
 egyPpxfdfVYjTWdpIx/tDHfyPEkuL7EjitKV7B83NbMq0N6GhQN2sT8L8DM7aC5p
 0x7kV5B4ZnE=
 =wZYX
 -----END PGP SIGNATURE-----

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

Jonathan writes:

First set of IIO new device support, features and cleanup for 5.19

Usual mixed bag. Stand out this time is Andy Shevchenko's continuing
effort to move drivers over the generic firmware interfaces.

Device support
* sprd,sc2720
  - upm9620 binding addition.
  - Refactor and support for sc2720, sc2721 and sc2730.
* ti,ads1015
  - Refactor driver and add support for TLA2024.

Device support (IDs only)
* invensense,mpu6050
  - Add ID for ICM-20608-D.
* st,accel:
  -  Add ID for lis302dl.
* st,lsm6dsx
  - Add support for ASM330LHHX (can fallback to LSM6DSR.)

Features
* convert drivers to device properties
  - IIO core
  - adi,ad7266
  - adi,adis16480
  - adi,adxl355
  - bosch,bmi160
  - domintech,dmard06
  - fsl,fxas21002c
  - invensense,mpu3050
  - linear,ltc2983
  - linear,ltc2632
  - maxbotix,mb1232
  - maxim,max31856
  - maxim,max31865
  - multiplexer
  - ping
  - rescale
  - taos,tsl2772
* core
  - Add runtime check on whether realbits fit in storagebits for each
    channel.
* adi,ad_sigma_delta
  - Add sequencer support and relevant update_scan_mode callbacks for
    adi,ad7192 and adi,ad7124.

Cleanup and minor fixes
* MAINTAINERS
  - Update Lorenzo Bianconi's email address for IIO drivers.
  - Add entry for ad3552r and update maintainer in dt-binding doc.
* tree-wide
  - Replace strtobool() with kstrtobool().
  - Drop false OF dependencies.
* core
  - Tidy up and document IIO modes.
  - Take iio_buffer_enabled() out of header allowing current_mode to be
    moved to the opaque structure.
  - As all kfifo buffers use the same mode value, drop that parameter
    and set it unconditionally.
  - White space fixes and similar.
  - Drop use of list iterator variable for
    list_for_each_entry_continue_reverse and use list_prepare_entry to
    restart.
* sysfs-trigger
  - Replace use of 'found' variable with dedicate list iterator variable.
* adi,ad7124
  - Drop misleading shift.
* adi,ad2s1210
  - Remove redundant local variable assignment.
* adi,adis16480
  - Use local device pointer to reduce repetition.
  - Improve handling of clocks.
* domintech,dmard09
  - White space.
* dummy driver
  - Improve error handling.
* fsl,mma8452
  - Add missing documentation of name element.
* invensense,mpu3050
  - Stop remove() returning non 0.
* kionix,kxsd9
  - White space.
* linear,ltc2688
  - Use local variable for struct device.
  - Combine of_node_put() error handling paths.
* linear,ltc2983
  - Avoid use of constants in messages where a define is available.
* microchip,mcp4131
  - Fix compatible in dt example.
* pni,rm3100
  - Stop directly accessing iio_dev->current_mode just to find out
    if the buffer is enabled.
* renesas,rzg2l
  - Relax kconfig constraint to include newer devices.
* sprd,sc27xx
  - Fix wrong scaling mask.
  - Improve the calibration values.
* samsung,ssp
  - Replace a 'found' variable in favor of an explicit value that was
    found.
* sensortek,stk3xx
  - Add proximity-near-level binding and driver support.
* st,st_sensors:
  - Drop unused accel_type enum.
  - Return early in *_write_raw()
  - Drop unnecessary locking in _avail functions.
  - Add local lock to protect odr against concurrent updates allowing
    mlock to no longer be used outside of the core.
  - Use iio_device_claim_direct_mode() rather than racy checking of
    the current mode.
* st,stmpe-adc
  - Fix checks on wait_for_completion_timeout().
  - Allow use of of_device_id for matching.
* st,stm32-dfsdm
  - Stop accessing iio_dev->current_mode to find out if the buffer
    is enabled (so we can hide that variable in the opaque structure)
* st,vl53l0x
  - Fix checks on wait_for_completion_timeout.
* ti,ads1015
  - Add missing ID for ti,ads1115 in binding doc.
  - Convert from repeated chip ID look up to selecting static const
    data.
  - Switch to read_avail() callback.
* ti,ads8688
  - Use of_device_id for driver matching.
* ti,palmas-adc
  - Drop a warning on minor calibration mismatch leading to slightly
    negative values after applying the calibration.

* tag 'iio-for-5.19a' of https://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio: (95 commits)
  iio: ti-ads8688: use of_device_id for OF matching
  iio: stmpe-adc: use of_device_id for OF matching
  dt-bindings: iio: Fix incorrect compatible strings in examples
  iio: gyro: mpu3050: Make mpu3050_common_remove() return void
  iio: dac: ltc2632: Make use of device properties
  iio: temperature: max31865: Make use of device properties
  iio: proximity: mb1232: Switch to use fwnode_irq_get()
  iio: imu: adis16480: Improve getting the optional clocks
  iio: imu: adis16480: Use temporary variable for struct device
  iio: imu: adis16480: Make use of device properties
  staging: iio: ad2s1210: remove redundant assignment to variable negative
  iio: adc: sc27xx: add support for PMIC sc2730
  iio: adc: sc27xx: add support for PMIC sc2720 and sc2721
  iio: adc: sc27xx: refactor some functions for support more PMiCs
  iio: adc: sc27xx: structure adjustment and optimization
  iio: adc: sc27xx: Fine tune the scale calibration values
  iio: adc: sc27xx: fix read big scale voltage not right
  dt-bindings:iio:adc: add sprd,ump9620-adc dt-binding
  iio: proximity: stk3310: Export near level property for proximity sensor
  dt-bindings: iio: light: stk33xx: Add proximity-near-level
  ...
2022-05-19 16:53:08 +02:00
Andy Shevchenko
cb55b44285 iio: imu: adis16480: Improve getting the optional clocks
The extended clocks are optional and may not be present for some
configurations supported by this driver. Nevertheless, in case
the clock is provided but some error happens during its getting,
that error handling should be done properly.

Use devm_clk_get_optional() API and report possible errors using
dev_err_probe() to handle properly -EPROBE_DEFER error.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Nuno Sá <nuno.sa@analog.com>
Tested-by: Nuno Sá <nuno.sa@analog.com>
Link: https://lore.kernel.org/r/20220414131559.24694-3-andriy.shevchenko@linux.intel.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2022-04-28 19:22:56 +01:00
Andy Shevchenko
79f4dc9dec iio: imu: adis16480: Use temporary variable for struct device
Use temporary variable for struct device to make code neater.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Nuno Sá <nuno.sa@analog.com>
Tested-by: Nuno Sá <nuno.sa@analog.com>
Link: https://lore.kernel.org/r/20220414131559.24694-2-andriy.shevchenko@linux.intel.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2022-04-28 19:22:56 +01:00
Andy Shevchenko
9eec6e510b iio: imu: adis16480: Make use of device properties
Convert the module to be property provider agnostic and allow
it to be used on non-OF platforms.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Nuno Sá <nuno.sa@analog.com>
Tested-by: Nuno Sá <nuno.sa@analog.com>
Link: https://lore.kernel.org/r/20220414131559.24694-1-andriy.shevchenko@linux.intel.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2022-04-28 19:22:56 +01:00
Andy Shevchenko
5f474919fa iio: imu: bmi160: Make use of device properties
Convert the module to be property provider agnostic and allow
it to be used on non-OF platforms.

While at it, reuse temporary device pointer in the same function.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://lore.kernel.org/r/20220414131804.25227-1-andriy.shevchenko@linux.intel.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2022-04-28 19:22:54 +01:00
Lorenzo Bianconi
fdd70d7aad iio: imu: st_lsm6dsx: add support to ASM330LHHX
Add support to STM ASM330LHHX (acc + gyro) automotive Mems sensor.
The ASM330LHHX sensor can use LSM6DSR as fallback device since it
implements all the ASM330LHHX features currently implemented in
st_lsm6dsx.

Datasheet: https://www.st.com/resource/en/datasheet/asm330lhhx.pdf
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Link: https://lore.kernel.org/r/04e2644772a6761a25c36bb9679979567fdebda3.1649100168.git.lorenzo@kernel.org
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2022-04-28 19:22:54 +01:00
Fawzi Khaber
b5d6ba09b1 iio: imu: inv_icm42600: Fix I2C init possible nack
This register write to REG_INTF_CONFIG6 enables a spike filter that
is impacting the line and can prevent the I2C ACK to be seen by the
controller. So we don't test the return value.

Fixes: 7297ef1e26 ("iio: imu: inv_icm42600: add I2C driver")
Signed-off-by: Fawzi Khaber <fawzi.khaber@tdk.com>
Signed-off-by: Jean-Baptiste Maneyrol <jean-baptiste.maneyrol@tdk.com>
Link: https://lore.kernel.org/r/20220411111533.5826-1-jmaneyrol@invensense.com
Cc: <Stable@vger.kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2022-04-16 15:03:58 +01:00
Miquel Raynal
f67c6c73cb iio: core: Simplify the registration of kfifo buffers
Among all the users of the kfifo buffers, no one uses the
INDIO_BUFFER_HARDWARE mode. So let's take this as a general rule and
simplify a little bit the internals - overall the documentation - by
eliminating unused specific cases. Use the INDIO_BUFFER_SOFTWARE mode by
default with kfifo buffers, which will basically mimic what all the "non
direct" modes do.

Cc: Benson Leung <bleung@chromium.org>
Cc: Guenter Roeck <groeck@chromium.org>
Cc: Jyoti Bhayana <jbhayana@google.com>
Cc: Jean-Baptiste Maneyrol <jmaneyrol@invensense.com>
Cc: Lorenzo Bianconi <lorenzo.bianconi83@gmail.com>
Cc: Michael Hennerich <Michael.Hennerich@analog.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/r/20220207143840.707510-13-miquel.raynal@bootlin.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2022-04-10 16:25:46 +01:00
Tong Zhang
d926054d55 iio:imu:bmi160: disable regulator in error path
Regulator should be disabled in error path as mentioned in _regulator_put().
Also disable accel if gyro cannot be enabled.

[   16.233604] WARNING: CPU: 0 PID: 2177 at drivers/regulator/core.c:2257 _regulator_put
[   16.240453] Call Trace:
[   16.240572]  <TASK>
[   16.240676]  regulator_put+0x26/0x40
[   16.240853]  regulator_bulk_free+0x26/0x50
[   16.241050]  release_nodes+0x3f/0x70
[   16.241225]  devres_release_group+0x147/0x1c0
[   16.241441]  ? bmi160_core_probe+0x175/0x3a0 [bmi160_core]

Fixes: 5dea3fb066 ("iio: imu: bmi160: added regulator support")
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Tong Zhang <ztong0001@gmail.com>
Link: https://lore.kernel.org/r/20220327154005.806049-1-ztong0001@gmail.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2022-04-04 09:19:01 +01:00
Michael Srba
6dc2c8711a iio: imu: inv_mpu6050: Add support for ICM-20608-D
The difference between the ICM-20608-D and the other ICM-20608
variants is the addition of a DMP (Digital Motion Processor) core.
This difference is deemed substantial enough to change the WHOAMI
register value.
Since this driver doesn't currently acknowledge the exisence of
something like a DMP core, simply copy ICM-20608 except for the
aforementioned WHOAMI register.

Signed-off-by: Michael Srba <Michael.Srba@seznam.cz>
Acked-by: Jean-Baptiste Maneyrol <jean-baptiste.maneyrol@tdk.com>
Link: https://lore.kernel.org/r/20220323121550.16096-3-michael.srba@seznam.cz
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2022-04-04 09:11:24 +01:00
Greg Kroah-Hartman
cc6ce5ac2c First set of new device support, fixes, cleanups and features for IIO in 5.18
This cycle we had quite a few series that applied similar changes
 to lots of drivers. To keep this description manageable I have
 called those out in their own section rather than per driver.
 
 Particularly pleased to see the long running AFE precision series
 going in this cycle.
 
 Series includes some late breaking fixes.
 
 New device support
 * adi,ada4250 amplifier
   - New driver and dt bindings for this programmable gain amplifier.
 * adi,admv1014 microwave down-converter
   - New driver, dt bindings and some device specific ABI that
     may be generalized as more drivers for devices similar to this
     are added.
 * adi,admv4420 K Band down-converter.
   - New driver and dt bindings.
 * adi,adxl367 accelerometer driver.
   - New driver, dt-bindings + some new IIO ABI definitions to support
     reference magnitude events where an estimate of the acceleration
     due to gravity has been removed.
   - A few fixes as follow up patches.
 * adi,ltc2688 DAC with toggle and dither modes.
   - New driver and bindings. Includes some new driver specific (for now)
     ABI for handling toggle mode and the addition of a dither waveform to
     the DAC output.
 * AFE (analog front end) add support for additional types of analog device
   in front of an ADC.
   - RTD temperature sensors with dt bindings.
   - Temperature transducers wit dt bindings.
   - Related cleanup and features listed in other sections below.
 * maxim,ds3502 potentiometer.
   - Add support to ds1803 driver which required significant rework.
 * mediatek,mt2701-auxadc driver
   - Add mediatek,mt8186-auxadc - id table and chip specific info only.
 * semtech,sx9324, semtech,ax9360
   - Substantial refactoring of sx9310 to extract core logic for reuse
     into a separate module
   - New driver using this supporting sx9324 proximity sensors.
   - New driver using this supporting sx9360 proximity sensors.
 * silan,sc7a20
   - Compatible with the st,lis2dh (or nearly anyway) so add ID and
     chip specific info to enable support. Also silan vendor ID added
     for dt-bindings.
 
 Staging graduation
 * adi,ad7280a monitoring ADC for stacked lithium-ion batteries in
   electric cars and similar.
   - Substantial rework of driver required to bring inline with current
     IIO best practice. An unusual device in IIO so some interesting features
     we may see more of in future.
 
 Multiple driver/core cleanup
 - Use sysfs_emit() in simple locations where there is no path to change
   to various core created attributes.
 - Trivial white space fixes around inconsistency between space after { and
   before } in id tables.
 - Introduce new handling for fractional types to avoid repeated similar
   implementations. Use this in 3 drivers. Note this is also targeted
   at future use in the AFE driver and was motivated by discussions
   around the precision related work on that driver.
 - of related header cleanups - drop of*.h and add mod_devicetable.h as
   appropriate.
 - Move a number of symbol exports into IIO_* namespaces.  Two categories,
   1) Library used by multiple drivers e.g. st_sensors
   2) Core driver module exporting functions used by bus specific modules.
   A few related cleanups in this set.
 - Switch from CONFIG_PM_* guards to new DEFINE_SIMPLE_DEV_PM_OPS() and
   similar to simplify drivers and take advantage of these new macros
   allowing the compiler to do the job or removing unused code without
   the need for __maybe_unused markings. Conversion of other drivers to
   these new macros ongoing.
 
 Features
 * adi,adf4350
   - Switch from of specific to generic device properties enabling use with
     other firmware types.
 * adi,adx345
   - Switch from of specific to generic device properties.
   - Add ACPI ID ADS0345
   - Related driver cleanup.
 * adi,hmc425a
   - Switch from of specific to generic device properties.
 * afe analog rescaler driver
   - Wider range of types supported for scale.
   - Support offset.
   - Kunit tests.
 * atlas,ezo-sensor
   - Convert from of to device properties.
 * fsl,mma8452
   - Support mount matrix.
 * infineon,dps310:
   - Add ACPI ID IFX3100.
 * invensense,mpu6050
   - Convert to generic device properties.
 * maxim,ds1803
   - Add out_raw_available before supporting more devices.
   - Convert from of specific to device properties.
 * samsung,ssp_sensors
   - Convert from of specific to device properties.
 * st,stm32-timer trigger
   - Convert from of specific to device properties.
 * ti,hdc101x
   - Add ACPI ID TXNW1010.
 * ti,tsc2046:
   - Add read_raw support to enable use of iio_hwmon and similar.
 
 Fixes / cleanup.
 * mailmap
   - Update for Cai Huoqing
 * MAINTAINERS
   - Fix Analog Devices related links.
   - Add entry for ADRF6780
   - Add entry for ADMV1013
   - Add entry for AD7293
   - Add entry for ADMV8818
   - Update files listed for adis-lib
 * iio core:
   - Fix wrong comment about current_mode being something a driver should
     ever access.
   - Use struct_size() rather than open coding in industrialio-hw-consumer
 * adi,axl355
   - Use units.h definitions instead of local versions.
 * adi,adis-lib
   - Simplify *updated_bits() macro
   - Whitespace cleanup.
 * afe - Note many of these fixes only apply to particular configurations
   so the problems have probably not been seen in the wild, but will be
   visible with new usecases enabled this cycle.
   - Fix application of consumer scale for IIO_VAL_INT.
   - Apply a scale of 1 when no scale is provided.
   - Make best effort to establish a valid offset value for fractional
     cases.
   - Use s64 for scale calculations where parameters may be signed.
   - Tidy up include order.
   - Improve accuracy for small fractional sales
   - Reduce risk of integer overflow.
 * ams,as3935
   - Use devm_delayed_work_autocancel() to replace open coded equivalent.
 * aspeed,adc
   - Fix wrong use of divider flag.
 * atmel,sama5d2-adc
   - Relax atmel,trigger-edge-type to optional.
   - Drop Ludovic Desroches from listed maintainers of the dt-binding
     inline with previous MAINTAINERS entry update.
 * fsl,mma8452
   - Fix probing when i2c_device_id used.
   - dev_get_drvdata() on the iio_dev->dev, no longer returns iio_dev.
     Use dev_to_iio_dev() instead. Note the original path in here
     worked more by luck than design.
 * invensense,mpu6050
   - Drop ACPI_PTR() protection to avoid an unused warning.
   - Use fact ACPI_COMPANION() returns null when ACPI_HANDLE() does to
     simplify handling.
 * motorola,cpcap-adc
   - Drop unused assignment.
 * qcom,spmi-adc
   - Fix wrong example of 'reg' in binding document.
 * renesas,rzg2l-adc
   - Trivial typo fix.
 * semtech,sx9360
   - Fix wrong register handling for event generation.
 * st_sensors
   - Allow manual disabling of I2C or SPI module if not needed for a particular
     board. Default is still to enable the bus specific module if
     appropriate bus is supported.
 * st,lsm6dsx
   - dev_get_drvdata() on the iio_dev->dev, no longer returns iio_dev.
     Use dev_to_iio_dev() instead.
 * ti,palmas-gpadc
   - Split the interrupt fields in the dt-binding example
 * ti,tsc2046
   - Rework state machine to improve readability after recent debugging of
     an issue fixed elsewhere.
   - Add a sanity check to avoid very large memory allocations if a crazy
     delay is specified.
 * ti,twl6030
   - Add error handling if devm_request_threaded_irq() fails.
 * xilinx,ams
   - Use devm_delayed_work_autocancel() instead of open coding equivalent.
   - Fix missing required clock entry in dt-binding.
   - Fix miss counting of channels resulting in ps channels not
     being enabled.
   - Fix incorrect values written to sequencer registers.
   - Fix sequence for single channel reading.
 -----BEGIN PGP SIGNATURE-----
 
 iQJFBAABCAAvFiEEbilms4eEBlKRJoGxVIU0mcT0FogFAmIfdM8RHGppYzIzQGtl
 cm5lbC5vcmcACgkQVIU0mcT0FoiGlQ//UyRpMX9Bv97LAbMDnqIHLYroTLJA3WFQ
 AaL/DKB1cVjBCoHlp24qaQrmncvifPF7sKJGKWf7yCHL5fraAYL/kHsCo/jECTho
 QOk9QaPAMP9ChOoVoP8iz5qrdF2qyoFUG69bX+QYeKhSKzcK1QPRTQ13LIL43d9p
 OJX47Cu7FfFwuAs5VKSVgpcII0tctv+Fdo6BkkeI+6w/vx2sFSzRaqRtc1ZU4Uav
 s51dM9JMos52e/G8yQAEOC24QUId4EHxo7QR8WjzZ47yIHRulpYwM6pWAtvOqEy9
 eV++yz581+Uqs/qaDDk8nJdpa8aEv/NvfAK6gufB9UOWziMoR3G1pPFWoOLbcyIt
 IcUG+QyyEiIlmlwDE/m2OcSMzsxgrkEHNb3SE7ZkWZKP8OasGdVMHa7yEKCgLmzM
 S8EY9TsNA50A2VtowAPrdk74TVG2WeIDvEH2MMAUMjgW2DzsW9cmwFrziyj7ZPLX
 onoEjd/kpL2zzAArEadvzD1z1lLJcOUWn8ST2kbPQG8n/rp5y2u5PvgWRoO9zJlD
 ztX614XYRgRUhMrgb0q0nCTi07mnBZrR3P8Hnx1HOoZon/DIqPSL7NumITG09cQc
 fHqewQOU/WqoTH4tNvfywnBL/VAcxKFlc0B2rWIvp6dD5b0TU34ZdebcjLT1zYeC
 6YQKbRaRjVg=
 =UnWv
 -----END PGP SIGNATURE-----

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

Jonathan writes:

First set of new device support, fixes, cleanups and features for IIO in 5.18

This cycle we had quite a few series that applied similar changes
to lots of drivers. To keep this description manageable I have
called those out in their own section rather than per driver.

Particularly pleased to see the long running AFE precision series
going in this cycle.

Series includes some late breaking fixes.

New device support
* adi,ada4250 amplifier
  - New driver and dt bindings for this programmable gain amplifier.
* adi,admv1014 microwave down-converter
  - New driver, dt bindings and some device specific ABI that
    may be generalized as more drivers for devices similar to this
    are added.
* adi,admv4420 K Band down-converter.
  - New driver and dt bindings.
* adi,adxl367 accelerometer driver.
  - New driver, dt-bindings + some new IIO ABI definitions to support
    reference magnitude events where an estimate of the acceleration
    due to gravity has been removed.
  - A few fixes as follow up patches.
* adi,ltc2688 DAC with toggle and dither modes.
  - New driver and bindings. Includes some new driver specific (for now)
    ABI for handling toggle mode and the addition of a dither waveform to
    the DAC output.
* AFE (analog front end) add support for additional types of analog device
  in front of an ADC.
  - RTD temperature sensors with dt bindings.
  - Temperature transducers wit dt bindings.
  - Related cleanup and features listed in other sections below.
* maxim,ds3502 potentiometer.
  - Add support to ds1803 driver which required significant rework.
* mediatek,mt2701-auxadc driver
  - Add mediatek,mt8186-auxadc - id table and chip specific info only.
* semtech,sx9324, semtech,ax9360
  - Substantial refactoring of sx9310 to extract core logic for reuse
    into a separate module
  - New driver using this supporting sx9324 proximity sensors.
  - New driver using this supporting sx9360 proximity sensors.
* silan,sc7a20
  - Compatible with the st,lis2dh (or nearly anyway) so add ID and
    chip specific info to enable support. Also silan vendor ID added
    for dt-bindings.

Staging graduation
* adi,ad7280a monitoring ADC for stacked lithium-ion batteries in
  electric cars and similar.
  - Substantial rework of driver required to bring inline with current
    IIO best practice. An unusual device in IIO so some interesting features
    we may see more of in future.

Multiple driver/core cleanup
- Use sysfs_emit() in simple locations where there is no path to change
  to various core created attributes.
- Trivial white space fixes around inconsistency between space after { and
  before } in id tables.
- Introduce new handling for fractional types to avoid repeated similar
  implementations. Use this in 3 drivers. Note this is also targeted
  at future use in the AFE driver and was motivated by discussions
  around the precision related work on that driver.
- of related header cleanups - drop of*.h and add mod_devicetable.h as
  appropriate.
- Move a number of symbol exports into IIO_* namespaces.  Two categories,
  1) Library used by multiple drivers e.g. st_sensors
  2) Core driver module exporting functions used by bus specific modules.
  A few related cleanups in this set.
- Switch from CONFIG_PM_* guards to new DEFINE_SIMPLE_DEV_PM_OPS() and
  similar to simplify drivers and take advantage of these new macros
  allowing the compiler to do the job or removing unused code without
  the need for __maybe_unused markings. Conversion of other drivers to
  these new macros ongoing.

Features
* adi,adf4350
  - Switch from of specific to generic device properties enabling use with
    other firmware types.
* adi,adx345
  - Switch from of specific to generic device properties.
  - Add ACPI ID ADS0345
  - Related driver cleanup.
* adi,hmc425a
  - Switch from of specific to generic device properties.
* afe analog rescaler driver
  - Wider range of types supported for scale.
  - Support offset.
  - Kunit tests.
* atlas,ezo-sensor
  - Convert from of to device properties.
* fsl,mma8452
  - Support mount matrix.
* infineon,dps310:
  - Add ACPI ID IFX3100.
* invensense,mpu6050
  - Convert to generic device properties.
* maxim,ds1803
  - Add out_raw_available before supporting more devices.
  - Convert from of specific to device properties.
* samsung,ssp_sensors
  - Convert from of specific to device properties.
* st,stm32-timer trigger
  - Convert from of specific to device properties.
* ti,hdc101x
  - Add ACPI ID TXNW1010.
* ti,tsc2046:
  - Add read_raw support to enable use of iio_hwmon and similar.

Fixes / cleanup.
* mailmap
  - Update for Cai Huoqing
* MAINTAINERS
  - Fix Analog Devices related links.
  - Add entry for ADRF6780
  - Add entry for ADMV1013
  - Add entry for AD7293
  - Add entry for ADMV8818
  - Update files listed for adis-lib
* iio core:
  - Fix wrong comment about current_mode being something a driver should
    ever access.
  - Use struct_size() rather than open coding in industrialio-hw-consumer
* adi,axl355
  - Use units.h definitions instead of local versions.
* adi,adis-lib
  - Simplify *updated_bits() macro
  - Whitespace cleanup.
* afe - Note many of these fixes only apply to particular configurations
  so the problems have probably not been seen in the wild, but will be
  visible with new usecases enabled this cycle.
  - Fix application of consumer scale for IIO_VAL_INT.
  - Apply a scale of 1 when no scale is provided.
  - Make best effort to establish a valid offset value for fractional
    cases.
  - Use s64 for scale calculations where parameters may be signed.
  - Tidy up include order.
  - Improve accuracy for small fractional sales
  - Reduce risk of integer overflow.
* ams,as3935
  - Use devm_delayed_work_autocancel() to replace open coded equivalent.
* aspeed,adc
  - Fix wrong use of divider flag.
* atmel,sama5d2-adc
  - Relax atmel,trigger-edge-type to optional.
  - Drop Ludovic Desroches from listed maintainers of the dt-binding
    inline with previous MAINTAINERS entry update.
* fsl,mma8452
  - Fix probing when i2c_device_id used.
  - dev_get_drvdata() on the iio_dev->dev, no longer returns iio_dev.
    Use dev_to_iio_dev() instead. Note the original path in here
    worked more by luck than design.
* invensense,mpu6050
  - Drop ACPI_PTR() protection to avoid an unused warning.
  - Use fact ACPI_COMPANION() returns null when ACPI_HANDLE() does to
    simplify handling.
* motorola,cpcap-adc
  - Drop unused assignment.
* qcom,spmi-adc
  - Fix wrong example of 'reg' in binding document.
* renesas,rzg2l-adc
  - Trivial typo fix.
* semtech,sx9360
  - Fix wrong register handling for event generation.
* st_sensors
  - Allow manual disabling of I2C or SPI module if not needed for a particular
    board. Default is still to enable the bus specific module if
    appropriate bus is supported.
* st,lsm6dsx
  - dev_get_drvdata() on the iio_dev->dev, no longer returns iio_dev.
    Use dev_to_iio_dev() instead.
* ti,palmas-gpadc
  - Split the interrupt fields in the dt-binding example
* ti,tsc2046
  - Rework state machine to improve readability after recent debugging of
    an issue fixed elsewhere.
  - Add a sanity check to avoid very large memory allocations if a crazy
    delay is specified.
* ti,twl6030
  - Add error handling if devm_request_threaded_irq() fails.
* xilinx,ams
  - Use devm_delayed_work_autocancel() instead of open coding equivalent.
  - Fix missing required clock entry in dt-binding.
  - Fix miss counting of channels resulting in ps channels not
    being enabled.
  - Fix incorrect values written to sequencer registers.
  - Fix sequence for single channel reading.

* tag 'iio-for-5.18a' of https://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio: (245 commits)
  iio: adc: xilinx-ams: Fix single channel switching sequence
  iio: adc: xilinx-ams: Fixed wrong sequencer register settings
  iio: adc: xilinx-ams: Fixed missing PS channels
  dt-bindings: iio: adc: zynqmp_ams: Add clock entry
  iio: accel: mma8452: use the correct logic to get mma8452_data
  iio: adc: aspeed: Add divider flag to fix incorrect voltage reading.
  iio: imu: st_lsm6dsx: use dev_to_iio_dev() to get iio_dev struct
  dt-bindings: iio: Add ltc2688 documentation
  iio: ABI: add ABI file for the LTC2688 DAC
  iio: dac: add support for ltc2688
  dt-bindings: iio: afe: add bindings for temperature transducers
  dt-bindings: iio: afe: add bindings for temperature-sense-rtd
  iio: afe: rescale: add temperature transducers
  iio: afe: rescale: add RTD temperature sensor support
  iio: test: add basic tests for the iio-rescale driver
  iio: afe: rescale: reduce risk of integer overflow
  iio: afe: rescale: fix accuracy for small fractional scales
  iio: afe: rescale: add offset support
  iio: afe: rescale: add INT_PLUS_{MICRO,NANO} support
  iio: afe: rescale: expose scale processing function
  ...
2022-03-18 12:41:32 +01:00
Haibo Chen
6270bf1f01 iio: imu: st_lsm6dsx: use dev_to_iio_dev() to get iio_dev struct
dev_get_drvdata() on iio_dev->dev no longer returns the iio_dev.
Use dev_to_iio_dev() to get iio_dev struct.

Fixes: 8b7651f259 ("iio: iio_device_alloc(): Remove unnecessary self drvdata")
Signed-off-by: Haibo Chen <haibo.chen@nxp.com>
Link: https://lore.kernel.org/r/1645702191-9400-1-git-send-email-haibo.chen@nxp.com
Cc: <Stable@vger.kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2022-03-02 13:38:13 +00:00
Jonathan Cameron
da123e2949 iio:imu:kmx61: Switch from CONFIG_PM* guards to pm_ptr() etc
Letting the compiler remove these functions when the kernel is built
without one or  more of CONFIG_PM/CONFIG_PM_SLEEP support is simpler and
less error prone than the use of #ifdef based config guards.

Removing instances of this approach from IIO also stops them being
copied into new drivers.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Reviewed-by: Paul Cercueil <paul@crapouillou.net>
Link: https://lore.kernel.org/r/20220130193147.279148-42-jic23@kernel.org
2022-02-18 11:46:04 +00:00
Jonathan Cameron
6c9304d6af iio:imu:adis: Move exports into IIO_ADISLIB namespace
In order to avoid unneessary pollution of the global symbol namespace
move the common/library functions into a specific namespace and import
that into the various specific device drivers that use them.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Cc: Lars-Peter Clausen <lars@metafoo.de>
Cc: Song Bao Hua (Barry Song) <song.bao.hua@hisilicon.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Link: https://lore.kernel.org/r/20220130205701.334592-9-jic23@kernel.org
2022-02-18 11:42:26 +00:00
Jonathan Cameron
0805b5121f iio:st-sensors: Move exports into IIO_ST_SENSORS namespace
To avoid unnecessary pollution of the global symbol namespace move the
driver core and type specific core exports into their a new namespace
and import that where needed.

For more info see https://lwn.net/Articles/760045/

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Cc: Andy Shevchenko <andy.shevchenko@gmail.com>
Cc: Linus Walleij <linus.walleij@linaro.org>
Cc: Denis Ciocca <denis.ciocca@st.com>
Link: https://lore.kernel.org/r/20220116180535.2367780-14-jic23@kernel.org
2022-02-18 11:36:54 +00:00
Lorenzo Bianconi
ea85bf9064 iio: imu: st_lsm6dsx: wait for settling time in st_lsm6dsx_read_oneshot
We need to wait for sensor settling time (~ 3/ODR) before reading data
in st_lsm6dsx_read_oneshot routine in order to avoid corrupted samples.

Fixes: 290a6ce11d ("iio: imu: add support to lsm6dsx driver")
Reported-by: Mario Tesi <mario.tesi@st.com>
Tested-by: Mario Tesi <mario.tesi@st.com>
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Link: https://lore.kernel.org/r/b41ebda5535895298716c76d939f9f165fcd2d13.1644098120.git.lorenzo@kernel.org
Cc: <Stable@vger.kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2022-02-07 20:45:49 +00:00
Andy Shevchenko
889bdfc336 iio: imu: inv_mpu6050: Make use of device properties
Convert the module to be property provider agnostic and allow
it to be used on non-OF platforms.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://lore.kernel.org/r/20220203155920.18586-3-andriy.shevchenko@linux.intel.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2022-02-06 15:28:02 +00:00
Andy Shevchenko
1ef6ff6ef8 iio: imu: inv_mpu6050: Check ACPI companion directly
Instead of checking for ACPI handle followed by extracting a companion
device, do the latter first and use it for checks.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://lore.kernel.org/r/20220203155920.18586-2-andriy.shevchenko@linux.intel.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2022-02-06 15:27:33 +00:00
Andy Shevchenko
c53c7740bd iio: imu: inv_mpu6050: Drop wrong use of ACPI_PTR()
ACPI_PTR() is more harmful than helpful. For example, in this case
if CONFIG_ACPI=n, the ID table left unused which is not what we want.

Instead of adding ifdeffery or attribute here and there, drop ACPI_PTR().

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://lore.kernel.org/r/20220203155920.18586-1-andriy.shevchenko@linux.intel.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2022-02-06 15:26:43 +00:00
Miaoqian Lin
632fe0bb8c iio: Fix error handling for PM
The pm_runtime_enable will increase power disable depth.
If the probe fails, we should use pm_runtime_disable() to balance
pm_runtime_enable(). In the PM Runtime docs:
    Drivers in ->remove() callback should undo the runtime PM changes done
    in ->probe(). Usually this means calling pm_runtime_disable(),
    pm_runtime_dont_use_autosuspend() etc.
We should do this in error handling.

Fix this problem for the following drivers: bmc150, bmg160, kmx61,
kxcj-1013, mma9551, mma9553.

Fixes: 7d0ead5c3f ("iio: Reconcile operation order between iio_register/unregister and pm functions")
Signed-off-by: Miaoqian Lin <linmq006@gmail.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://lore.kernel.org/r/20220106112309.16879-1-linmq006@gmail.com
Cc: <Stable@vger.kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2022-01-30 14:50:34 +00:00
Nuno Sá
b0e85f95e3 iio:imu:adis16480: fix buffering for devices with no burst mode
The trigger handler defined in the driver assumes that burst mode is
being used. Hence, for devices that do not support it, we have to use
the adis library default trigger implementation.

Tested-by: Julia Pineda <julia.pineda@analog.com>
Fixes: 941f130881 ("iio: adis16480: support burst read function")
Signed-off-by: Nuno Sá <nuno.sa@analog.com>
Link: https://lore.kernel.org/r/20220114132608.241-1-nuno.sa@analog.com
Cc: <Stable@vger.kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2022-01-23 18:23:48 +00:00
Nuno Sá
c39010ea6b iio: adis: stylistic changes
Minor stylistic changes to address checkptach complains when called with
'--strict'.

Signed-off-by: Nuno Sá <nuno.sa@analog.com>
Link: https://lore.kernel.org/r/20220122130905.99-3-nuno.sa@analog.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2022-01-23 18:03:37 +00:00
Nikita Yushchenko
26b2ec2e9a iio: st_sensors: don't always auto-enable I2C and SPI interface drivers
This patch makes I2C and SPI interface drivers for STMicroelectronics
sensor chips individually selectable via Kconfig.

The default is kept unchanged - I2C and SPI interface drivers are still
selected by default if the corresponding bus support is available.

However, the patch makes it possible to explicitly disable drivers
that are not needed for a particular target.

Signed-off-by: Nikita Yushchenko <nikita.yoush@cogentembedded.com>
Acked-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://lore.kernel.org/r/20220110152432.3799227-1-nikita.yoush@cogentembedded.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2022-01-23 18:03:35 +00:00
Jonathan Cameron
6713847817 iio:imu:inv_mpu6050: Suppress clang W=1 warning about pointer to enum conversion.
Cast to a uintptr_t rather than directly to the enum.

As per the discussion in below linked media patch.

Link: https://lore.kernel.org/linux-media/CAK8P3a2ez6nEw4d+Mqa3XXAz0RFTZHunqqRj6sCt7Y_Eqqs0rw@mail.gmail.com/
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Cc: Baptiste Mansuy <bmansuy@invensense.com>
Cc: Jean-Baptiste Maneyrol <jmaneyrol@invensense.com>
Cc: Linus Walleij <linus.walleij@linaro.org>
Reviewed-by: Nathan Chancellor <nathan@kernel.org>
Link: https://lore.kernel.org/r/20211128172445.2616166-9-jic23@kernel.org
2021-12-21 15:10:09 +00:00
Jonathan Cameron
072cc9816c iio:imu:inv_icm42600: Suppress clang W=1 warning about pointer to enum conversion.
Cast to a uintptr_t rather than directly to the enum.

As per the discussion in below linked media patch.

Link: https://lore.kernel.org/linux-media/CAK8P3a2ez6nEw4d+Mqa3XXAz0RFTZHunqqRj6sCt7Y_Eqqs0rw@mail.gmail.com/
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Cc: Jean-Baptiste Maneyrol <jmaneyrol@invensense.com>
Reviewed-by: Nathan Chancellor <nathan@kernel.org>
Link: https://lore.kernel.org/r/20211128172445.2616166-8-jic23@kernel.org
2021-12-21 15:10:09 +00:00
Lorenzo Bianconi
35619155d0 iio: imu: st_lsm6dsx: add dts property to disable sensor-hub
Introduce the capability to disable sensorhub through a device-tree
property since there are some configurations where users want to
explicitly disable sensor-hub auto-probing at bootstrap.
A typical configuration is when the sensorhub clock/data lines are connected
to a pull-up resistor since no slave sensors are connected to the i2c master.
If SDO/SA0 line is connected to the same pull-up resistor, when the driver
tries to probe slave devices connected on sensor-hub, it will force SDO/SA0
line to low, modifying the device i2c address.

Tested-by: Mario Tesi <mario.tesi@st.com>
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Link: https://lore.kernel.org/r/ad7894e7b1c6fb3427fab3f623bb942860ad45cf.1636816719.git.lorenzo@kernel.org
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-12-04 15:34:17 +00:00
Teng Qi
94be878c88 iio: imu: st_lsm6dsx: Avoid potential array overflow in st_lsm6dsx_set_odr()
The length of hw->settings->odr_table is 2 and ref_sensor->id is an enum
variable whose value is between 0 and 5.
However, the value ST_LSM6DSX_ID_MAX (i.e. 5) is not caught properly in
 switch (sensor->id) {

If ref_sensor->id is ST_LSM6DSX_ID_MAX, an array overflow will ocurrs in
function st_lsm6dsx_check_odr():
  odr_table = &sensor->hw->settings->odr_table[sensor->id];

and in function st_lsm6dsx_set_odr():
  reg = &hw->settings->odr_table[ref_sensor->id].reg;

To avoid this array overflow, handle ST_LSM6DSX_ID_GYRO explicitly and
return -EINVAL for the default case.

The enum value ST_LSM6DSX_ID_MAX is only present as an easy way to check
the limit and as such is never used, however this is not locally obvious.

Reported-by: TOTE Robot <oslab@tsinghua.edu.cn>
Signed-off-by: Teng Qi <starmiku1207184332@gmail.com>
Acked-by: Lorenzo Bianconi <lorenzo@kernel.org>
Link: https://lore.kernel.org/r/20211011114003.976221-1-starmiku1207184332@gmail.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-10-20 14:43:53 +01:00
Greg Kroah-Hartman
6bce28cb49 First set of IIO new device and feature support for the 5.16 cycle
Counter subsystem changes now sent separately.
 
 This has been a busy cycle, so lots here and a few more stragglers to
 come next week.
 
 Big new feature in this cycle is probably output buffer support.
 This has been in the works for a very long time so it's great to see
 Mihail pick up the challenge and build upon his predecessors work to finally
 bring this feature to mainline.
 
 New device support
 ------------------
 
 * adi,adxl313
   - New driver and dt bindings for this low power accelerometer.
 * adi,adxl355
   - New driver and dt bindings for this accelerometer.
   - Later series adds buffer support.
 * asahi-kasei,ak8975
   - Minor additions to driver to support ak09916
 * aspeed,aspeed-adc
   - Substantial rework plus feature additions to add support for the
     ast2600 including a new dt bindings doc.
 * atmel,at91_sama5d2
   - Rework and support introduced for the sama7g5 parts.
 * maxim,max31865
   - New driver and bindings for this RTD temperature sensor chip.
 * nxp,imx8qxp
   - New driver and bindings for the ADC found on the i.MX 8QuadXPlus Soc.
 * senseair,sunrise
   - New driver and bindings for this family of carbon dioxide gas sensors.
 * sensiron,scd4x
   - New driver and bindings for this carbon dioxide gas sensor.
 
 New features
 ------------
 
 * Output buffer support.  Works in a similar fashion to input buffers, but
   in this case userspace pushes data into the kfifo which is then drained
   to the device when a trigger occurs.  Support added to the ad5766 DAC
   driver.
 * Core, devm_iio_map_array_register() to avoid need for
   devm_add_action_or_reset() based cleanup in fully managed allocation
   drivers.
 * Core iio_push_to_buffers_with_ts_unaligned() function to safely handle a
   few drivers where it really hard to ensure the correct data alignment in
   an iio_push_to_buffers_with_timestamp() call. Note this uses a bounce
   buffer so should be avoided whenever possible.  Used in the ti,adc108s102,
   invense,mpu3050 and adi,adis16400.  This closes the last   known set
   of drivers with alignment issues at this interface.
 * maxim,max1027
   - Substantial rework to this driver main target of which was supporting
     use of other triggers than it's own EOC interrupt.
   - Transfer optimization.
 * nxp,fxls8962af
   - Threshold even support including using it as a wakeup source.
 
 Cleanups, minor fixes etc
 -------------------------
 
 Chances of a common type to multiple drivers:
 
 * devm_ conversion and drop of .remove() callbacks in:
   - adi,ad5064
   - adi,ad7291
   - adi,ad7303
   - adi,ad7746
   - adi,ad9832
   - adi,adis16080
   - dialog,da9150-gpadc
   - intel,mrfld_adc
   - marvell,berlin2
   - maxim,max1363
   - maxim,max44000
   - nuvoton,nau7802
   - st_sensors (includes a lot of rework!)
   - ti,ads8344
   - ti,lp8788
 
 * devm_platform_ioremap_resource() used to reduce boilerplate
   - cirrus,ep93xx
   - rockchip,saradc
   - stm,stm32-dac
 
 * Use dev_err_probe() in more places to both not print on deferred probe and
   ensure a reason for the deferral is available for debug purposes.
   - adi,ad8801
   - capella,cm36651
   - linear,ltc1660
   - maxim,ds4424
   - maxim,max5821
   - microchip,mcp4922
   - nxp,lpc18xx
   - onnn,noa1305
   - st,lsm9ds0
   - st,st_sensors
   - st,stm32-dac
   - ti,afe4403
   - ti,afe4404
   - ti,dac7311
 
 * Drop error returns in SPI and I2C remove() functions as they are ignored and
   long term plan is to change these all over to returning void. In some cases
   these patches just make it 'obvious' they always return 0 where it was the
   case before but not easy to tell.
   - adi,ad5380
   - adi,ad5446
   - adi,ad5686
   - adi,ad5592r
   - bosch,bma400
   - bosch,bmc150
   - fsl,mma7455
   - honeywell,hmc5843
   - kionix,kxsd9
   - maxim,max5487
   - meas,ms5611
   - ti,afe4403
 
 Driver specific changes
 
 * adi,ad5770r
   - Bring driver inline with documented bindings.
 * adi,ad7746
   - Trivial style fix
 * adi,ad7949
   - Express some magic values as the underlying parts via new #defines.
   - Make it work with SPI controllers that don't support 14 or 16 bit messages
   - Support selection of voltage reference from dt including expanding the
     dt-bindings to cover this new functionality.
 * adi,ad799x
   - Implement selection of external reference voltage on AD7991, AD7995 and
     AD7999.
   - Add missing dt-bindings doc for devices supported by this driver.
 * adi,adislib
   - Move interrupt startup to better location in startup flow.
   - Handle devices that cannot mask/unmask the drdy pin and must instead mask
     at the interrupt controller.  Applies to the adis16460 and adis16475 from
     which we then drop equivalent code.
 * adi,ltc2983
   - Add support for optional reset pin.
   - Fail to probe if no channels specified in dt binding.
 * asahi-kasei,ak8975
   - dt-binding additions of missing vid-supply regulator.
 * aspeed,aspeed-adc
   - Typo fix.
 * fsl,mma7660
   - Mark acpi_device_id table __maybe_unused to avoid build warning.
 * fsl,imx25-gcq
   - Avoid initializing regulators that aren't used.
 * invensense,mpu3050
   - Drop a dead protection against a clash with the old input driver.
 * invensense,mpu6050
   - Rework code to not use strcpy() and hence avoid possibility of wrong sized
     buffers. Note this wasn't a bug, but the new code is a lot more readable.
   - Mark acpi_device_id table __maybe_unused to avoid build warning.
 * kionix,kxcjk1013
   - dt-binding addition to note it supports interrupts.
 * marvell,berlin2-adc
   - Enable COMPILE_TEST building.
 * maxim,max1027
   - Avoid returning success in an error path.
 * nxp,imx8qxp
   - Fix warning when runtime pm not enabled via __maybe_unused.
 * ricoh,rn5t618
   - Use the new devm_iio_map_array_register() instead of open coding the same.
 * samsung,exynos_adc
   - Improve kconfig help text.
 * st,lsm6dsx
   - Move max_fifo_size into the fifo_ops structure where the other configuration
     parameters are found.
 * st,st_sensors:
   - Reorder to ensure we turn the power off after removing userspace interfaces.
 * senseair,sunrise
   - Add missing I2C dependency.
 * ti,twl6030
   - Small code tidy up.
 -----BEGIN PGP SIGNATURE-----
 
 iQJFBAABCAAvFiEEbilms4eEBlKRJoGxVIU0mcT0FogFAmFudVERHGppYzIzQGtl
 cm5lbC5vcmcACgkQVIU0mcT0Foiepg//R5DRm1gMFGP/dl2P8u6KD2oXNmbqc3J0
 +EPRTkyTyawQzc21wdxUh3oObgxmDS6P7Cr17z9viGse2PsUjza4Sptic3Zqi3Kv
 FzeXZaP0GY9nC+hAyz+dSkMKNw19mkCYYEIWhDwYFpXMiOV8QlT+6pFgOiffofeR
 GYMUoV2XeuxR6OH0zMOuYKTzjOCYC+VJTP4BfeUetpRZQyllgFOA+5KX4ZWTiJMV
 eGCaq3Hhn6IQa7ATgYUBYJyMkAXQDrKDaMxiaCIuh/k3bgjAkfhkV48mu2cHTsX9
 v0q21JkgmBenwNP/OQ6mxmWR9SFY4eB22Ptkd1foTPjAsqoST7qmqEBhhLrRb/fB
 HkL0I7M4tWDqSTJKgdn+UHYrKFW9oBHIt5SK1tCS+zTYIn1wEmkY/w/9MuZllBFO
 VKu5q2ypf/yGgCqPIZilK69mrZd7/72rE6tr3oefUF2iUVLdh9fI1TjGGyoT6GZ5
 ZlEIfGHRpcRGHFiA4e+6tTx9VLr8m1B5YVvBWWPlruYe8ep7MmD3KjUcwINiRyNs
 5rdBl2RI8VAUBbQ+60VWn03e/0kuRESpFC3Gf/ng+6hRSUbRFe4lZw60GbyFDXwV
 m1odTlkXA7l6oRG9f5COhE/oNO7dsfMO74W6+yzhWICnxjgJFosaaZTLw8F9QJdS
 m3z9tSU84js=
 =htmG
 -----END PGP SIGNATURE-----

Merge tag 'iio-for-5.16a-split-take4' of https://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio into char-misc-next

Jonathan writes:

First set of IIO new device and feature support for the 5.16 cycle

Counter subsystem changes now sent separately.

This has been a busy cycle, so lots here and a few more stragglers to
come next week.

Big new feature in this cycle is probably output buffer support.
This has been in the works for a very long time so it's great to see
Mihail pick up the challenge and build upon his predecessors work to finally
bring this feature to mainline.

New device support
------------------

* adi,adxl313
  - New driver and dt bindings for this low power accelerometer.
* adi,adxl355
  - New driver and dt bindings for this accelerometer.
  - Later series adds buffer support.
* asahi-kasei,ak8975
  - Minor additions to driver to support ak09916
* aspeed,aspeed-adc
  - Substantial rework plus feature additions to add support for the
    ast2600 including a new dt bindings doc.
* atmel,at91_sama5d2
  - Rework and support introduced for the sama7g5 parts.
* maxim,max31865
  - New driver and bindings for this RTD temperature sensor chip.
* nxp,imx8qxp
  - New driver and bindings for the ADC found on the i.MX 8QuadXPlus Soc.
* senseair,sunrise
  - New driver and bindings for this family of carbon dioxide gas sensors.
* sensiron,scd4x
  - New driver and bindings for this carbon dioxide gas sensor.

New features
------------

* Output buffer support.  Works in a similar fashion to input buffers, but
  in this case userspace pushes data into the kfifo which is then drained
  to the device when a trigger occurs.  Support added to the ad5766 DAC
  driver.
* Core, devm_iio_map_array_register() to avoid need for
  devm_add_action_or_reset() based cleanup in fully managed allocation
  drivers.
* Core iio_push_to_buffers_with_ts_unaligned() function to safely handle a
  few drivers where it really hard to ensure the correct data alignment in
  an iio_push_to_buffers_with_timestamp() call. Note this uses a bounce
  buffer so should be avoided whenever possible.  Used in the ti,adc108s102,
  invense,mpu3050 and adi,adis16400.  This closes the last   known set
  of drivers with alignment issues at this interface.
* maxim,max1027
  - Substantial rework to this driver main target of which was supporting
    use of other triggers than it's own EOC interrupt.
  - Transfer optimization.
* nxp,fxls8962af
  - Threshold even support including using it as a wakeup source.

Cleanups, minor fixes etc
-------------------------

Chances of a common type to multiple drivers:

* devm_ conversion and drop of .remove() callbacks in:
  - adi,ad5064
  - adi,ad7291
  - adi,ad7303
  - adi,ad7746
  - adi,ad9832
  - adi,adis16080
  - dialog,da9150-gpadc
  - intel,mrfld_adc
  - marvell,berlin2
  - maxim,max1363
  - maxim,max44000
  - nuvoton,nau7802
  - st_sensors (includes a lot of rework!)
  - ti,ads8344
  - ti,lp8788

* devm_platform_ioremap_resource() used to reduce boilerplate
  - cirrus,ep93xx
  - rockchip,saradc
  - stm,stm32-dac

* Use dev_err_probe() in more places to both not print on deferred probe and
  ensure a reason for the deferral is available for debug purposes.
  - adi,ad8801
  - capella,cm36651
  - linear,ltc1660
  - maxim,ds4424
  - maxim,max5821
  - microchip,mcp4922
  - nxp,lpc18xx
  - onnn,noa1305
  - st,lsm9ds0
  - st,st_sensors
  - st,stm32-dac
  - ti,afe4403
  - ti,afe4404
  - ti,dac7311

* Drop error returns in SPI and I2C remove() functions as they are ignored and
  long term plan is to change these all over to returning void. In some cases
  these patches just make it 'obvious' they always return 0 where it was the
  case before but not easy to tell.
  - adi,ad5380
  - adi,ad5446
  - adi,ad5686
  - adi,ad5592r
  - bosch,bma400
  - bosch,bmc150
  - fsl,mma7455
  - honeywell,hmc5843
  - kionix,kxsd9
  - maxim,max5487
  - meas,ms5611
  - ti,afe4403

Driver specific changes

* adi,ad5770r
  - Bring driver inline with documented bindings.
* adi,ad7746
  - Trivial style fix
* adi,ad7949
  - Express some magic values as the underlying parts via new #defines.
  - Make it work with SPI controllers that don't support 14 or 16 bit messages
  - Support selection of voltage reference from dt including expanding the
    dt-bindings to cover this new functionality.
* adi,ad799x
  - Implement selection of external reference voltage on AD7991, AD7995 and
    AD7999.
  - Add missing dt-bindings doc for devices supported by this driver.
* adi,adislib
  - Move interrupt startup to better location in startup flow.
  - Handle devices that cannot mask/unmask the drdy pin and must instead mask
    at the interrupt controller.  Applies to the adis16460 and adis16475 from
    which we then drop equivalent code.
* adi,ltc2983
  - Add support for optional reset pin.
  - Fail to probe if no channels specified in dt binding.
* asahi-kasei,ak8975
  - dt-binding additions of missing vid-supply regulator.
* aspeed,aspeed-adc
  - Typo fix.
* fsl,mma7660
  - Mark acpi_device_id table __maybe_unused to avoid build warning.
* fsl,imx25-gcq
  - Avoid initializing regulators that aren't used.
* invensense,mpu3050
  - Drop a dead protection against a clash with the old input driver.
* invensense,mpu6050
  - Rework code to not use strcpy() and hence avoid possibility of wrong sized
    buffers. Note this wasn't a bug, but the new code is a lot more readable.
  - Mark acpi_device_id table __maybe_unused to avoid build warning.
* kionix,kxcjk1013
  - dt-binding addition to note it supports interrupts.
* marvell,berlin2-adc
  - Enable COMPILE_TEST building.
* maxim,max1027
  - Avoid returning success in an error path.
* nxp,imx8qxp
  - Fix warning when runtime pm not enabled via __maybe_unused.
* ricoh,rn5t618
  - Use the new devm_iio_map_array_register() instead of open coding the same.
* samsung,exynos_adc
  - Improve kconfig help text.
* st,lsm6dsx
  - Move max_fifo_size into the fifo_ops structure where the other configuration
    parameters are found.
* st,st_sensors:
  - Reorder to ensure we turn the power off after removing userspace interfaces.
* senseair,sunrise
  - Add missing I2C dependency.
* ti,twl6030
  - Small code tidy up.

* tag 'iio-for-5.16a-split-take4' of https://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio: (148 commits)
  iio: imx8qxp-adc: mark PM functions as __maybe_unused
  iio: pressure: ms5611: Make ms5611_remove() return void
  iio: potentiometer: max5487: Don't return an error in .remove()
  iio: magn: hmc5843: Make hmc5843_common_remove() return void
  iio: health: afe4403: Don't return an error in .remove()
  iio: dac: ad5686: Make ad5686_remove() return void
  iio: dac: ad5592r: Make ad5592r_remove() return void
  iio: dac: ad5446: Make ad5446_remove() return void
  iio: dac: ad5380: Make ad5380_remove() return void
  iio: accel: mma7455: Make mma7455_core_remove() return void
  iio: accel: kxsd9: Make kxsd9_common_remove() return void
  iio: accel: bmi088: Make bmi088_accel_core_remove() return void
  iio: accel: bmc150: Make bmc150_accel_core_remove() return void
  iio: accel: bma400: Make bma400_remove() return void
  drivers:iio:dac:ad5766.c: Add trigger buffer
  iio: triggered-buffer: extend support to configure output buffers
  iio: kfifo-buffer: Add output buffer support
  iio: Add output buffer support
  iio: documentation: Document scd4x calibration use
  drivers: iio: chemical: Add support for Sensirion SCD4x CO2 sensor
  ...
2021-10-19 11:44:28 +02:00
Cai Huoqing
b42baaa3e2 iio: st_lsm9ds0: Make use of the helper function dev_err_probe()
When possible use dev_err_probe help to properly deal with the
PROBE_DEFER error, the benefit is that DEFER issue will be logged
in the devices_deferred debugfs file.
Using dev_err_probe() can reduce code size, and the error value
gets printed.

Signed-off-by: Cai Huoqing <caihuoqing@baidu.com>
Link: https://lore.kernel.org/r/20210928014055.1431-2-caihuoqing@baidu.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-10-19 08:30:44 +01:00
Jonathan Cameron
d7a83bc38d iio: imu: adis16400: Fix buffer alignment requirements.
iio_push_to_buffers_with_timestamp() requires that the buffer
is 8 byte alignment to ensure an inserted timestamp is naturally aligned.

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

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

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

Fixes: 5075e0720d ("iio: imu: adis: generalize burst mode support")
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Reviewed-by: Nuno Sá <nuno.sa@analog.com>
Link: https://lore.kernel.org/r/20210613151039.569883-5-jic23@kernel.org
2021-10-19 08:29:22 +01:00
Nuno Sá
23a3b67c52 iio: adis16460: make use of the new unmasked_drdy flag
The library can now handle enabling/disabling IRQs for devices that
cannot unmask the data ready pin. Hence there's no need to provide an
'enable_irq' callback anymore.

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

Signed-off-by: Nuno Sá <nuno.sa@analog.com>
Link: https://lore.kernel.org/r/20210903141423.517028-5-nuno.sa@analog.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-10-19 08:27:34 +01:00
Nuno Sá
cab85eadd7 iio: adis16475: make use of the new unmasked_drdy flag
The library can now handle enabling/disabling IRQs for devices that
cannot unmask the data ready pin. Hence there's no need to provide an
'enable_irq' callback anymore.

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

Signed-off-by: Nuno Sá <nuno.sa@analog.com>
Link: https://lore.kernel.org/r/20210903141423.517028-4-nuno.sa@analog.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-10-19 08:27:34 +01:00
Nuno Sá
31fa357ac8 iio: adis: handle devices that cannot unmask the drdy pin
Some devices can't mask/unmask the data ready pin and in those cases
each driver was just calling '{dis}enable_irq()' to control the trigger
state. This change, moves that handling into the library by introducing
a new boolean in the data structure that tells the library that the
device cannot unmask the pin.

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

Signed-off-by: Nuno Sá <nuno.sa@analog.com>
Link: https://lore.kernel.org/r/20210903141423.517028-3-nuno.sa@analog.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-10-19 08:27:34 +01:00
Nuno Sá
b600bd7eb3 iio: adis: do not disabe IRQs in 'adis_init()'
With commit ecb010d441 ("iio: imu: adis: Refactor adis_initial_startup")
we are doing a HW or SW reset to the device which means that we'll get
the default state of the data ready pin (which is enabled). Hence there's
no point in disabling the IRQ in the init function. Moreover, this
function is intended to initialize internal data structures and not
really do anything on the device.

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

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

Fixes: ecb010d441 ("iio: imu: adis: Refactor adis_initial_startup")
Signed-off-by: Nuno Sá <nuno.sa@analog.com>
Link: https://lore.kernel.org/r/20210903141423.517028-2-nuno.sa@analog.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-10-19 08:27:34 +01:00
Lorenzo Bianconi
1b7da2fa18 iio: imu: st_lsm6dsx: move max_fifo_size in st_lsm6dsx_fifo_ops
Move max_fifo_size in st_lsm6dsx_fifo_ops in order to have all
FIFO configuration parameters in st_lsm6dsx_fifo_ops structure.
This patch does not introduce any logic change, just small code
rearrangement.

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Link: https://lore.kernel.org/r/3262ad9d9d1497e19ea1bab208c495c2b9a98994.1632664866.git.lorenzo@kernel.org
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-10-19 08:27:34 +01:00
Daniel Palmer
3b38706466 iio: imu: inv_mpu6050: Mark acpi match table as maybe unused
When building kernels without ACPI support the table is declared
but is not used because ACPI_PTR() turns it into a NULL.

Add the __maybe_unused attribute to stop the compiler whining.

Signed-off-by: Daniel Palmer <daniel@0x0f.com>
Acked-by: Jean-Baptiste Maneyrol <jmaneyrol@invensense.com>
Link: https://lore.kernel.org/r/20210913112913.2148026-1-daniel@0x0f.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-10-17 11:05:53 +01:00
Nuno Sá
ea1945c2f7 iio: adis16480: fix devices that do not support sleep mode
Not all devices supported by this driver support being put to sleep
mode. For those devices, when calling 'adis16480_stop_device()' on the
unbind path, we where actually writing in the SYNC_SCALE register.

Fixes: 80cbc848c4 ("iio: imu: adis16480: Add support for ADIS16490")
Fixes: 82e7a1b250 ("iio: imu: adis16480: Add support for ADIS1649x family of devices")
Signed-off-by: Nuno Sá <nuno.sa@analog.com>
Link: https://lore.kernel.org/r/20210903141423.517028-6-nuno.sa@analog.com
Cc: <Stable@vger.kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-09-26 16:22:25 +01:00
Nuno Sá
9da1b86865 iio: adis16475: fix deadlock on frequency set
With commit 39c024b51b
("iio: adis16475: improve sync scale mode handling"), two deadlocks were
introduced:
 1) The call to 'adis_write_reg_16()' was not changed to it's unlocked
    version.
 2) The lock was not being released on the success path of the function.

This change fixes both these issues.

Fixes: 39c024b51b ("iio: adis16475: improve sync scale mode handling")
Signed-off-by: Nuno Sá <nuno.sa@analog.com>
Reviewed-by: Alexandru Ardelean <ardeleanalex@gmail.com>
Link: https://lore.kernel.org/r/20210920090047.74903-1-nuno.sa@analog.com
Cc: <Stable@vger.kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-09-25 16:01:06 +01:00
Alexandru Ardelean
e426965154 iio: st_sensors: remove reference to parent device object on st_sensor_data
The idea behind it, is that all devm_ calls in ST sensors are bound to the
parent device object.

However, the reference to that object is kept on both the st_sensor_data
struct and the IIO object parent (indio_dev->dev.parent).

This change only adds a bit consistency and uses the reference stored on
indio_dev->dev.parent, to enforce the assumption that all ST sensors' devm_
calls are bound to the same reference as the one store on st_sensor_data.

Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Alexandru Ardelean <aardelean@deviqon.com>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Link: https://lore.kernel.org/r/20210823112204.243255-6-aardelean@deviqon.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-09-14 12:00:32 +01:00
Alexandru Ardelean
6b658c31bb iio: st_sensors: remove all driver remove functions
At this point all ST driver remove functions do iio_device_unregister().
This change removes them from them and replaces all iio_device_register()
with devm_iio_device_register().

This can be done in a single change relatively easy, since all these remove
functions are define in st_sensors.h.

Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Alexandru Ardelean <aardelean@deviqon.com>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Link: https://lore.kernel.org/r/20210823112204.243255-5-aardelean@deviqon.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-09-14 12:00:31 +01:00
Len Baker
d722f1e06f drivers/iio: Remove all strcpy() uses
strcpy() performs no bounds checking on the destination buffer. This
could result in linear overflows beyond the end of the buffer, leading
to all kinds of misbehaviors. So, remove all the uses and add
devm_kstrdup() or devm_kasprintf() instead.

Also, modify the "for" loop conditions to clarify the access to the
st->orientation.rotation buffer.

This patch is an effort to clean up the proliferation of str*()
functions in the kernel and a previous step in the path to remove
the strcpy function from the kernel entirely [1].

[1] https://github.com/KSPP/linux/issues/88

Signed-off-by: Len Baker <len.baker@gmx.com>
Link: https://lore.kernel.org/r/20210815174204.126593-1-len.baker@gmx.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-09-14 12:00:30 +01:00
Greg Kroah-Hartman
a30514a076 Merge 5.14-rc6 into staging-next
We need the IIO fixes in here as well.

Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2021-08-16 09:02:59 +02:00
Jonathan Cameron
9c6cd755b5 iio: st-sensors: Remove some unused includes and add some that should be there
The st-sensors drivers have changed in structure over time, and includes
have not always kept up with this.  Let's bring them back to nearer
the ideal.

Identified with the  include-what-you-use tool and careful checking of
its suggestions.

Note I haven't been particularly aggressive here, so this is just the
cases where the include obviously isn't needed rather than the more
subtle corners.

Note I took the opportunity to add mod_devicetable.h as I generally
prefer to see that when acpi or of match tables are present.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Cc: Linus Walleij <linus.walleij@linaro.org>
Cc: Denis Ciocca <denis.ciocca@st.com>
Cc: Hans de Goede <hdegoede@redhat.com>
Acked-by: Linus Walleij <linus.walleij@linaro.org>
Link: https://lore.kernel.org/r/20210608175149.4019289-1-jic23@kernel.org
2021-07-24 15:59:00 +01:00
Baptiste Mansuy
e46a36d92d Add startup time for each chip using inv_mpu6050 driver
Add startup time for each chip familly. This allows a better behaviour of
the gyro and the accel. The gyro has now the time to stabilise itself
thus making initial data discarding for gyro irrelevant.

Signed-off-by: Baptiste Mansuy <bmansuy@invensense.com>
Acked-by: Jean-Baptiste Maneyrol <jmaneyrol@invensense.com>
Link: https://lore.kernel.org/r/20210621085731.9212-1-bmansuy@invensense.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-07-19 09:51:59 +01:00
Antti Keränen
7e77ef8b8d iio: adis: set GPIO reset pin direction
Set reset pin direction to output as the reset pin needs to be an active
low output pin.

Co-developed-by: Hannu Hartikainen <hannu@hrtk.in>
Signed-off-by: Hannu Hartikainen <hannu@hrtk.in>
Signed-off-by: Antti Keränen <detegr@rbx.email>
Reviewed-by: Nuno Sá <nuno.sa@analog.com>
Fixes: ecb010d441 ("iio: imu: adis: Refactor adis_initial_startup")
Link: https://lore.kernel.org/r/20210708095425.13295-1-detegr@rbx.email
Cc: <Stable@vger.kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-07-17 18:41:04 +01:00
Jonathan Cameron
40b54cbebf iio: imu: mpu6050: Balance runtime pm + use pm_runtime_resume_and_get()
Remove an unblanced pm_runtime_put_sync_suspend() call
in inv_pu_pm_disable().  Not this call is not a bug, because the runtime
pm core will not allow the reference counter to go negative.  It is
however confusing and serves no purpose.

pm_runtime_resume_and_get() case found using coccicheck script under
review at:
https://lore.kernel.org/lkml/20210427141946.2478411-1-Julia.Lawall@inria.fr/

pm_runtime_resume_and_get() returns <= 0 only so simplify related checks
to bring this more inline with nearby calls.

This is a prequel to taking a closer look at the runtime pm in IIO drivers
in general.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Cc: Jean-Baptiste Maneyrol <jmaneyrol@invensense.com>
Reviewed-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Link: https://lore.kernel.org/r/20210516162103.1332291-2-jic23@kernel.org
2021-06-16 14:53:13 +01:00
Alexandru Ardelean
21fd77afa1 iio: imu: remove unused private data assigned with spi_set_drvdata()
These were usually used before the conversion to devm_ functions, so that
the remove hook would be able to retrieve the pointer and do cleanups on
remove.
When the conversion happened, they should have been removed, but were
omitted.

Some drivers were copied from drivers that fit the criteria described
above. In any case, in order to prevent more drivers from being used as
example (and have spi_set_drvdata() needlessly set), this change removes it
from the IIO IMU group.

Signed-off-by: Alexandru Ardelean <aardelean@deviqon.com>
Link: https://lore.kernel.org/r/20210513122512.93187-1-aardelean@deviqon.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-06-13 17:00:17 +01:00
Jonathan Cameron
e8951f0878 iio: imu: inv_mpu6050: Drop use of %hhx format string.
Since:
commit cbacb5ab0a ("docs: printk-formats: Stop encouraging use of
unnecessary %h[xudi] and %hh[xudi]")
use of these format strings has been discouraged.

Use the 0x02x form as the length specifier when used with # includes
the 0x prefix and is very unlikely to be what was intended by the author.

Part of a series removing all uses from IIO in the interestings of
avoiding providing bad examples for people to copy.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Cc: Nathan Chancellor <nathan@kernel.org>
Reviewed-by: Nathan Chancellor <nathan@kernel.org>
Link: https://lore.kernel.org/r/20210603180612.3635250-4-jic23@kernel.org
2021-06-09 18:31:03 +01:00
Jonathan Cameron
9654c414bf iio: adis: Cleanout unused headers
0-day recently added the include-what-you-use header checker and
it gave a warning on an adis patch.  As such I decided to
run it on all the adis drivers and see if it made sensible suggestions.

Note this doesn't represent a complete list of what it suggested changing
as I filtered out a few on the basis they are standard headers used to
effectively include a bunch of other headers.

Could split this into a patch per driver if people prefer.

Note to anyone else trying this tool is that it is somewhat
of a loose cannon so you will be wanting to carefully check any
suggestions before proposing patches!

I thought about also reorganising the headers whilst here, but
that would make this patch harder to read, or lead to another rather
noisy patch across most of the files.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Reviewed-by: Alexandru Ardelean <ardeleanalex@gmail.com>
Link: https://lore.kernel.org/r/20210603193616.3708447-1-jic23@kernel.org
2021-06-04 09:28:10 +01:00
Andy Shevchenko
b892770a2c iio: Drop Duplicated "mount-matrix" parameter
All of the users of iio_read_mount_matrix() are using the very same
property name. Moreover, the property name is hard coded in the API
documentation.

Make this clear and avoid duplication now and in the future.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Sean Nyekjaer <sean@geanix.com>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Link: https://lore.kernel.org/r/20210518112546.44592-1-andriy.shevchenko@linux.intel.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-06-03 18:24:13 +01:00
Nuno Sa
941f130881 iio: adis16480: support burst read function
Some supported devices support burst read function. This provides a method
for reading a batch of data (status, temperature, gyroscopes,
accelerometers, time stamp/data counter, and CRC code), which does not
require a stall time between each 16-bit segment and only requires one
command on the DIN line to initiate. Devices supporting this mode
are:

 * adis16495-1
 * adis16495-2
 * adis16495-3
 * adis16497-1
 * adis16497-2
 * adis16497-3

Reviewed-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Nuno Sa <nuno.sa@analog.com>
Link: https://lore.kernel.org/r/20210422103735.136367-1-nuno.sa@analog.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-06-03 18:24:12 +01:00
Jonathan Cameron
2d082b6ed2 iio: imu: kmx61: Balance runtime pm + use pm_runtime_resume_and_get()
No point in calling pm_runtime_put_noidle() that isn't balancing a get.
Note no actual impact because the runtime pm core protects against
a negative reference counter.

For the pm_runtime_resume_and_get() main interest is in clearing
out this old pattern to avoid it getting coppied into new submissions.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Reviewed-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Link: https://lore.kernel.org/r/20210509113354.660190-10-jic23@kernel.org
2021-05-17 13:54:26 +01:00
Sean Nyekjaer
f7d5c18a8c iio: imu: st_lsm6dsx: correct ODR in header
Fix wrongly stated 13 Hz ODR for accelerometers, the correct ODR is 12.5 Hz

Signed-off-by: Sean Nyekjaer <sean@geanix.com>
Acked-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-05-17 13:54:23 +01:00
Andy Shevchenko
6731ca3999 iio: st_sensors: Add lsm9ds0 IMU support
We can utilize separate drivers for accelerometer and magnetometer,
so here is the glue driver to enable LSM9DS0 IMU support.

The idea was suggested by Crestez Dan Leonard in [1]. The proposed change
was sent as RFC due to race condition concerns, which are indeed possible.

In order to amend the initial change, I went further by providing a specific
multi-instantiate probe driver that reuses existing accelerometer and
magnetometer.

[1]: https://lore.kernel.org/patchwork/patch/670353/

Suggested-by: Crestez Dan Leonard <leonard.crestez@intel.com>
Cc: mr.lahorde@laposte.net
Cc: Matija Podravec <matija_podravec@fastmail.fm>
Cc: Sergey Borishchenko <borischenko.sergey@gmail.com>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://lore.kernel.org/r/20210414195454.84183-6-andriy.shevchenko@linux.intel.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-05-17 13:54:22 +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
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
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
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
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
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
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
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
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
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
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
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
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
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
Stephan Gerhold
4df685091d iio: imu: inv_mpu6050: Add support for MPU-6880
MPU-6880 seems to be very similar to MPU-6500 and it works
fine with some minor additions for the mpu6050 driver.

Add the necessary defines for it and make it use the same registers
as MPU-6500 but with a FIFO size of 4096.

Signed-off-by: Stephan Gerhold <stephan@gerhold.net>
Acked-by: Jean-Baptiste Maneyrol <jmaneyrol@invensense.com>
Cc: Jean-Baptiste Maneyrol <jmaneyrol@invensense.com>
Link: https://lore.kernel.org/r/20201202104656.5119-2-stephan@gerhold.net
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-01-09 14:25:30 +00:00