aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/iio (follow)
AgeCommit message (Collapse)AuthorFilesLines
2021-11-10Merge tag 'tag-chrome-platform-for-v5.16' of git://git.kernel.org/pub/scm/linux/kernel/git/chrome-platform/linuxLinus Torvalds1-2/+1
Pull chrome platform updates from Benson Leung: "cros_ec_typec: - Clean up use of cros_ec_check_features cros_ec_*: - Rename and move cros_ec_pd_command to cros_ec_command, and make changes to cros_ec_typec and cros_ec_proto to use the new common command, reducing duplication. sensorhub: - simplify getting .driver_data in cros_ec_sensors_core and cros_ec_sensorhub misc: - Maintainership change. Enric Balletbo i Serra has moved on from Collabora, so removing him from chrome/platform maintainers. Thanks for all of your hard work maintaining this, Enric, and best of luck to you in your new role! - Add Prashant Malani as driver maintainer for cros_ec_typec.c and cros_usbpd_notify. He was already principal contributor of these drivers" * tag 'tag-chrome-platform-for-v5.16' of git://git.kernel.org/pub/scm/linux/kernel/git/chrome-platform/linux: platform/chrome: cros_ec_proto: Use ec_command for check_features platform/chrome: cros_ec_proto: Use EC struct for features MAINTAINERS: Chrome: Drop Enric Balletbo i Serra platform/chrome: cros_ec_typec: Use cros_ec_command() platform/chrome: cros_ec_proto: Add version for ec_command platform/chrome: cros_ec_proto: Make data pointers void platform/chrome: cros_usbpd_notify: Move ec_command() platform/chrome: cros_usbpd_notify: Rename cros_ec_pd_command() platform/chrome: cros_ec: Fix spelling mistake "responsed" -> "response" platform/chrome: cros_ec_sensorhub: simplify getting .driver_data iio: common: cros_ec_sensors: simplify getting .driver_data platform/chrome: cros-ec-typec: Cleanup use of check_features platform/chrome: cros_ec_proto: Fix check_features ret val MAINTAINERS: Add Prashant's maintainership of cros_ec drivers
2021-11-08Merge tag 'mfd-next-5.16' of git://git.kernel.org/pub/scm/linux/kernel/git/lee/mfdLinus Torvalds1-90/+130
Pull MFD updates from Lee Jones: "Removed Drivers: - Remove support for TI TPS80031/TPS80032 PMICs New Device Support: - Add support for Magnetic Reader to TI AM335x - Add support for DA9063_EA to Dialog DA9063 - Add support for SC2730 PMIC to Spreadtrum SC27xx - Add support for MacBookPro16,2 ICL-N UART Intel LPSS PCI - Add support for lots of new PMICS in QCom SPMI PMIC - Add support for ADC to Diolan DLN2 New Functionality: - Add support for Power Off to Rockchip RK817 Fix-ups: - Simplify Regmap passing to child devices in hi6421-spmi-pmic - SPDX licensing updates in ti_am335x_tscadc - Improve error handling in ti_am335x_tscadc - Expedite clock search in ti_am335x_tscadc - Generic simplifications in ti_am335x_tscadc - Use generic macros/defines in ti_am335x_tscadc - Remove unused code in ti_am335x_tscadc, cros_ec_dev - Convert to GPIOD in wcd934x - Add namespacing in ti_am335x_tscadc - Restrict compilation to relevant arches in intel_pmt - Provide better description/documentation in exynos_lpass - Add SPI device ID table in altera-a10sr, motorola-cpcap, sprd-sc27xx-spi - Change IRQ handling in qcom-pm8xxx - Split out I2C and SPI code in arizona - Explicitly include used headers in altera-a10sr - Convert sysfs show() function to in sysfs_emit - Standardise *_exit() and *_remove() return values in mc13xxx, stmpe, tps65912 - Trivial (style/spelling/whitespace) fixups in ti_am335x_tscadc, qcom-spmi-pmic, max77686-private - Device Tree fix-ups in ti,am3359-tscadc, samsung,s2mps11, samsung,s2mpa01, samsung,s5m8767, brcm,misc, brcm,cru, syscon, qcom,tcsr, xylon,logicvc, max77686, x-powers,ac100, x-powers,axp152, x-powers,axp209-gpio, syscon, qcom,spmi-pmic Bug Fixes: - Balance refcounting (get/put) in ti_am335x_tscadc, mfd-core - Fix IRQ trigger type in sec-irq, max77693, max14577 - Repair off-by-one in altera-sysmgr - Add explicit 'select MFD_CORE' to MFD_SIMPLE_MFD_I2C" * tag 'mfd-next-5.16' of git://git.kernel.org/pub/scm/linux/kernel/git/lee/mfd: (95 commits) mfd: simple-mfd-i2c: Select MFD_CORE to fix build error mfd: tps80031: Remove driver mfd: max77686: Correct tab-based alignment of register addresses mfd: wcd934x: Replace legacy gpio interface for gpiod dt-bindings: mfd: qcom: pm8xxx: Add pm8018 compatible mfd: dln2: Add cell for initializing DLN2 ADC mfd: qcom-spmi-pmic: Add missing PMICs supported by socinfo mfd: qcom-spmi-pmic: Document ten more PMICs in the binding mfd: qcom-spmi-pmic: Sort compatibles in the driver mfd: qcom-spmi-pmic: Sort the compatibles in the binding mfd: janz-cmoio: Replace snprintf in show functions with sysfs_emit mfd: altera-a10sr: Include linux/module.h mfd: tps65912: Make tps65912_device_exit() return void mfd: stmpe: Make stmpe_remove() return void mfd: mc13xxx: Make mc13xxx_common_exit() return void dt-bindings: mfd: syscon: Add samsung,exynosautov9-sysreg compatible mfd: altera-sysmgr: Fix a mistake caused by resource_size conversion dt-bindings: gpio: Convert X-Powers AXP209 GPIO binding to a schema dt-bindings: mfd: syscon: Add rk3368 QoS register compatible mfd: arizona: Split of_match table into I2C and SPI versions ...
2021-10-24iio: frequency: adrf6780: Fix adrf6780_spi_{read,write}()Nathan Chancellor1-2/+2
Clang warns: drivers/iio/frequency/adrf6780.c:117:1: error: all paths through this function will call itself [-Werror,-Winfinite-recursion] { ^ drivers/iio/frequency/adrf6780.c:138:1: error: all paths through this function will call itself [-Werror,-Winfinite-recursion] { ^ 2 errors generated. The underscore variants should be used here. Link: https://github.com/ClangBuiltLinux/linux/issues/1490 Fixes: 63aaf6d06d87 ("iio: frequency: adrf6780: add support for ADRF6780") Acked-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> Signed-off-by: Nathan Chancellor <nathan@kernel.org> Link: https://lore.kernel.org/r/20211022195656.1513147-1-nathan@kernel.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2021-10-24Merge tag 'iio-for-5.16b' of https://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio into char-misc-nextGreg Kroah-Hartman26-231/+1116
Jonathan writes: 2nd set of IIO new driver, cleanups and features for the 5.16 cycle New device support * adrf6780 microwave upconverter. - New driver for this interesting device including bindings. Features * lite-on ltr501 - Add dt-bindings including vendor ID and of_device_id table. - Add regulator support. * sensiron,scd4x - Add reporting of channel scale. Cleanups including fixes for things in this cycle * Tree wide: Another set of dev_err_probe() introductions to reduce noise in logs when deferred probing is needed and provide more debug info. Devices included this time: - amlogic,meson_saradc - capella,cm3605 - fsl,imx7d - maxim,max1118 - maxim,max1241 - nxp,lpc18xx - qcom,pm8xxxx-xoadc - rockchip,saradc - sharp,gp2ap002 - sterricson,ab8500 - ti,ads7950 * core - iio:buffer - Fix a path where a ret value is not intialized. * channel-mux - Add support to mux core subsystem for a settling delay and use it in the iio-channel-mux driver. - Fix a few dt binding warnings. * nxp,lpc18xx - Convert to devm_ functions for all of probe and drop remove() * st,lsm6dsx - Suppress a warning due to lack of handling of an enum *_MAX entry that is just there to get the size. * st,stm32-adc - Add generic channel binding, deprecating the old approach. - Add nvmem support to get calibration data for the vrefint channel and use it to perform such calibration. - Add a binding for sample-time to the generic channel description as it can be per channel. * ti,adc128s052 - Use devm_ managed functions and drop remove() * vti,sca3000 - Use sign_extend32() rather than opencoding. * xilinx,xadc - Drop irq field from state structure as now just used in probe. * tag 'iio-for-5.16b' of https://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio: (36 commits) dt-bindings: iio: frequency: add adrf6780 doc iio: frequency: adrf6780: add support for ADRF6780 iio: chemical: scd4x: Add a scale for the co2 concentration reading dt-bindings: iio: io-channel-mux: allow duplicate channel, labels dt-bindings: iio: io-channel-mux: add optional #io-channel-cells iio: adc: adc128s052: Simplify adc128_probe() iio: multiplexer: iio-mux: Support settle-time-us property dt-bindings: iio: io-channel-mux: Add property for settle time mux: add support for delay after muxing iio: adc: stm32-adc: use generic binding for sample-time iio: adc: stm32-adc: add vrefint calibration support iio: adc: stm32-adc: add support of internal channels iio: adc: stm32-adc: add support of generic channels binding iio: adc: stm32-adc: split channel init into several routines dt-bindings: iio: stm32-adc: add nvmem support for vrefint internal channel dt-bindings: iio: stm32-adc: add generic channel binding iio: accel: sca3000: Use sign_extend32() instead of opencoding sign extension. iio: xilinx-xadc: Remove `irq` field from state struct iio: imu: st_lsm6dsx: Avoid potential array overflow in st_lsm6dsx_set_odr() iio: light: gp2ap002: Make use of the helper function dev_err_probe() ...
2021-10-24Merge tag 'iio-fixes-for-5.16a' of https://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio into char-misc-nextGreg Kroah-Hartman6-17/+41
Jonathan writes: First set of IIO fixes for the 5.16 cycle As these are very late in the 5.15 cycle and non are particularly urgent, they can wait for the merge window. Key element in this set is Yang Yingliang has identified a number of issues in error paths introduced recently when we added multiple buffer support. Other fixes: * adi,ad5662 - Fix handling of i2c_master_send() return value. * adi,ad5766 - Fix a wrong dt-property name that indicated wrong units and did not mach the bindings. - Associated 'fix' of the bindings example to have a possible scale. * st,pressure-spi - Add some missing entries to the spi_device_id table to ensure auto-loading works. * ti,tsc2046 - Fix a backwards comparison leading to a false dev_warn * tag 'iio-fixes-for-5.16a' of https://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio: iio: buffer: Fix memory leak in iio_buffers_alloc_sysfs_and_mask() iio: adc: tsc2046: fix scan interval warning iio: core: fix double free in iio_device_unregister_sysfs() iio: core: check return value when calling dev_set_name() iio: buffer: Fix memory leak in iio_buffer_register_legacy_sysfs_groups() iio: buffer: Fix double-free in iio_buffers_alloc_sysfs_and_mask() iio: buffer: Fix memory leak in __iio_buffer_alloc_sysfs_and_mask() iio: buffer: check return value of kstrdup_const() iio: dac: ad5446: Fix ad5622_write() return value Documentation:devicetree:bindings:iio:dac: Fix val drivers: iio: dac: ad5766: Fix dt property name iio: st_pressure_spi: Add missing entries SPI to device ID table
2021-10-21iio: frequency: adrf6780: add support for ADRF6780Antoniu Miclaus3-0/+540
The ADRF6780 is a silicon germanium (SiGe) design, wideband, microwave upconverter optimized for point to point microwave radio designs operating in the 5.9 GHz to 23.6 GHz frequency range. Datasheet: https://www.analog.com/media/en/technical-documentation/data-sheets/ADRF6780.pdf Signed-off-by: Antoniu Miclaus <antoniu.miclaus@analog.com> Link: https://lore.kernel.org/r/20211021113244.56936-1-antoniu.miclaus@analog.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-10-21iio: chemical: scd4x: Add a scale for the co2 concentration readingRoan van Dijk1-2/+7
This patch adds a scale for the co2 concentration reading. The reading is expressed in percent after applying the scale to the raw value. Signed-off-by: Roan van Dijk <roan@protonic.nl> Link: https://lore.kernel.org/r/20211021140018.3051213-1-roan@protonic.nl Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-10-21iio: adc: adc128s052: Simplify adc128_probe()Christophe JAILLET1-23/+10
Turn 'adc128_probe()' into a full resource managed function to simplify the code. This way, the .remove function can be removed. Doing so, the only 'spi_get_drvdata()' call is removed and the corresponding 'spi_set_drvdata()' can be removed as well. Suggested-by: Alexandru Ardelean <ardeleanalex@gmail.com> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr> Reviewed-by: Alexandru Ardelean <ardeleanalex@gmail.com> Link: https://lore.kernel.org/r/4fa7fcc59c40e27af0569138d656c698a53dbd44.1630002770.git.christophe.jaillet@wanadoo.fr Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-10-21iio: multiplexer: iio-mux: Support settle-time-us propertyVincent Whitchurch1-1/+6
If the devicetree specifies that the hardware requires a settle time, pass this time on to the mux APIs. Signed-off-by: Vincent Whitchurch <vincent.whitchurch@axis.com> Reviewed-by: Lars-Peter Clausen <lars@metafoo.de> Tested-by: Lars-Peter Clausen <lars@metafoo.de> Acked-by: Peter Rosin <peda@axentia.se> Link: https://lore.kernel.org/r/20211007134641.13417-4-vincent.whitchurch@axis.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-10-21iio: buffer: Fix memory leak in iio_buffers_alloc_sysfs_and_mask()Yang Yingliang1-5/+7
When 'iio_dev_opaque->buffer_ioctl_handler' alloc fails in iio_buffers_alloc_sysfs_and_mask(), the 'attrs' allocated in iio_buffer_register_legacy_sysfs_groups() will be leaked: unreferenced object 0xffff888108568d00 (size 128): comm "88", pid 2014, jiffies 4294963294 (age 26.920s) hex dump (first 32 bytes): 80 3e da 02 80 88 ff ff 00 3a da 02 80 88 ff ff .>.......:...... 00 35 da 02 80 88 ff ff 00 38 da 02 80 88 ff ff .5.......8...... backtrace: [<0000000095a9e51e>] __kmalloc+0x1a3/0x2f0 [<00000000faa3735e>] iio_buffers_alloc_sysfs_and_mask+0xfa3/0x1480 [industrialio] [<00000000a46384dc>] __iio_device_register+0x52e/0x1b40 [industrialio] [<00000000210af05e>] __devm_iio_device_register+0x22/0x80 [industrialio] [<00000000730d7b41>] adjd_s311_probe+0x195/0x200 [adjd_s311] [<00000000c0f70eb9>] i2c_device_probe+0xa07/0xbb0 The iio_buffer_register_legacy_sysfs_groups() is called in __iio_buffer_alloc_sysfs_and_mask(), so move the iio_buffer_unregister_legacy_sysfs_groups() into __iio_buffer_free_sysfs_and_mask(), then the memory will be freed. Reported-by: Hulk Robot <hulkci@huawei.com> Fixes: d9a625744ed0 ("iio: core: merge buffer/ & scan_elements/ attributes") Signed-off-by: Yang Yingliang <yangyingliang@huawei.com> Link: https://lore.kernel.org/r/20211018063718.1971240-1-yangyingliang@huawei.com Cc: <Stable@vger.kernel.org> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-10-21iio: adc: ti_am335x_adc: Add the am437x compatibleMiquel Raynal1-0/+1
This driver supports both the legacy controller (am33xx) and the extended one (am437x), so let's add a new compatible. Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com> Acked-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> Signed-off-by: Lee Jones <lee.jones@linaro.org> Link: https://lore.kernel.org/r/20211015081506.933180-46-miquel.raynal@bootlin.com
2021-10-21iio: adc: ti_am335x_adc: Add the scale informationMiquel Raynal1-0/+18
Without the scale, the values returned to the user are just a picture of the input voltage against the full scale range of the ADC. We need to provide the actual conversion factor to get milli-Volts values. Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com> Acked-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> Signed-off-by: Lee Jones <lee.jones@linaro.org> Link: https://lore.kernel.org/r/20211015081506.933180-45-miquel.raynal@bootlin.com
2021-10-21iio: adc: ti_am335x_adc: Add a unit to the timeout delayMiquel Raynal1-2/+2
The lack of unit in the macro name kind of tricked me when I was troubleshooting an issue. Physical constants should always get a unit. Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com> Acked-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> Signed-off-by: Lee Jones <lee.jones@linaro.org> Link: https://lore.kernel.org/r/20211015081506.933180-44-miquel.raynal@bootlin.com
2021-10-21iio: adc: ti_am335x_adc: Gather the checks on the delaysMiquel Raynal1-20/+30
Move the checks over the delays provided in the device tree to the location where these values are read to clarify where they come from. There are no functional changes besides the device structure used to display the warnings: let's use the ADC instead of the MFD device. Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com> Acked-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> Signed-off-by: Lee Jones <lee.jones@linaro.org> Link: https://lore.kernel.org/r/20211015081506.933180-43-miquel.raynal@bootlin.com
2021-10-21iio: adc: ti_am335x_adc: Get rid of useless gotosMiquel Raynal1-4/+3
Gotos jumping to a return statement are not really useful, drop them. Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com> Acked-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> Signed-off-by: Lee Jones <lee.jones@linaro.org> Link: https://lore.kernel.org/r/20211015081506.933180-42-miquel.raynal@bootlin.com
2021-10-21iio: adc: ti_am335x_adc: Fix styleMiquel Raynal1-52/+52
These warnings are reported by checkpatch.pl essentially. Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com> Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> Signed-off-by: Lee Jones <lee.jones@linaro.org> Link: https://lore.kernel.org/r/20211015081506.933180-41-miquel.raynal@bootlin.com
2021-10-21iio: adc: ti_am335x_adc: Replace license text with SPDX tagMiquel Raynal1-9/+1
Drop the text license and replace it with an equivalent SPDX license tag identifier which also matches the MODULE_LICENSE("GPL"). Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com> Acked-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> Signed-off-by: Lee Jones <lee.jones@linaro.org> Link: https://lore.kernel.org/r/20211015081506.933180-40-miquel.raynal@bootlin.com
2021-10-21iio: adc: ti_am335x_adc: Wait the idle state to avoid stallsMiquel Raynal1-2/+22
At least on a am4372, a simple: $ cat /sys/bus/iio/devices/iio\:deviceX/in_voltage*_raw can stall forever. It seems that it comes from the fact that the internal state machine does not have enough time to return to its idle state in this situation before receiving another request, leading to an internal stall. Add a tiadc_wait_idle() helper to ensure no new conversion is requested while the FSM is still busy. Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com> Acked-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> Signed-off-by: Lee Jones <lee.jones@linaro.org> Link: https://lore.kernel.org/r/20211015081506.933180-39-miquel.raynal@bootlin.com
2021-10-21mfd: ti_am335x_tscadc: Rename the subsystem enable macroMiquel Raynal1-3/+3
This bit is common to all devices (ADC, Touchscreen, Magnetic reader) so make it clear that it can be used from any location by operating a mechanical rename: s/CNTRLREG_TSCSSENB/CNTRLREG_SSENB/ Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com> Acked-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> Signed-off-by: Lee Jones <lee.jones@linaro.org> Link: https://lore.kernel.org/r/20211015081506.933180-31-miquel.raynal@bootlin.com
2021-10-21mfd: ti_am335x_tscadc: Clarify the maximum values for DT entriesMiquel Raynal1-9/+9
Clearly define the maximum open delay and sample delay. Use these definitions in place of a mask (which works because this is the first field in the register) and an open-coded value. While at it reword a little bit the error messages to make them look clearer and similar. Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com> Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> Signed-off-by: Lee Jones <lee.jones@linaro.org> Link: https://lore.kernel.org/r/20211015081506.933180-29-miquel.raynal@bootlin.com
2021-10-20mfd: ti_am335x_tscadc: Use BIT(), GENMASK() and FIELD_PREP() when relevantMiquel Raynal1-1/+1
Clean the ti_am335x_tscadc.h header by: * converting masks to GENMASK() * converting regular shifts to BIT() * using FIELD_PREP() when relevant Sometimes reorder the lines to be able to use the relevant bitmask. Mind the s/%d/%ld/ change in a log due to the type change following the use of FIELD_PREP() in the header. Suggested-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com> Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> Signed-off-by: Lee Jones <lee.jones@linaro.org> Link: https://lore.kernel.org/r/20211015081506.933180-28-miquel.raynal@bootlin.com
2021-10-20iio: adc: stm32-adc: use generic binding for sample-timeOlivier Moysan1-29/+41
Add st,min-sample-time-nsecs to channel generic binding. Sample time can be defined par channel node. If a channel is configured as differential, the same sample time applies for both inputs. Keep support of legacy st,min-sample-time-nsecs property for backward compatibility. Signed-off-by: Olivier Moysan <olivier.moysan@foss.st.com> Reviewed-by: Fabrice Gasnier <fabrice.gasnier@foss.st.com> Link: https://lore.kernel.org/r/20211014131228.4692-8-olivier.moysan@foss.st.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-10-20iio: adc: stm32-adc: add vrefint calibration supportOlivier Moysan1-6/+68
Add support of vrefint calibration. If a channel is labeled as vrefint, get vrefint calibration from non volatile memory for this channel. vrefint channel is exposed as a processed channel returning the actual value of vrefp: vrefp = 3.3 x vrefint_cal / vrefint_data A conversion on vrefint channel allows to update scale factor according to vrefint deviation, compared to vrefint calibration value. Signed-off-by: Olivier Moysan <olivier.moysan@foss.st.com> Reviewed-by: Fabrice Gasnier <fabrice.gasnier@foss.st.com> Link: https://lore.kernel.org/r/20211014131228.4692-7-olivier.moysan@foss.st.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-10-20iio: adc: stm32-adc: add support of internal channelsOlivier Moysan3-3/+146
Add support of ADC2 internal channels VDDCORE, VREFINT and VBAT. The reserved label name "vddcore", "vrefint" and "vbat" must be used in Device Tree channel node, to enable the corresponding internal channel. Note: This patch does not provide support of internal channels for F4 and H7. Signed-off-by: Olivier Moysan <olivier.moysan@foss.st.com> Reviewed-by: Fabrice Gasnier <fabrice.gasnier@foss.st.com> Link: https://lore.kernel.org/r/20211014131228.4692-6-olivier.moysan@foss.st.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-10-20iio: adc: stm32-adc: add support of generic channels bindingOlivier Moysan1-9/+86
Add support of generic IIO channel binding: ./devicetree/bindings/iio/adc/adc.yaml Keep support of st,adc-channels and st,adc-diff-channels for backward compatibility. Signed-off-by: Olivier Moysan <olivier.moysan@foss.st.com> Reviewed-by: Fabrice Gasnier <fabrice.gasnier@foss.st.com> Link: https://lore.kernel.org/r/20211014131228.4692-5-olivier.moysan@foss.st.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-10-20iio: adc: stm32-adc: split channel init into several routinesOlivier Moysan1-44/+87
Split stm32_adc_chan_of_init channel initialization function into several routines to increase readability and prepare channel generic binding handling. Signed-off-by: Olivier Moysan <olivier.moysan@foss.st.com> Reviewed-by: Fabrice Gasnier <fabrice.gasnier@foss.st.com> Link: https://lore.kernel.org/r/20211014131228.4692-4-olivier.moysan@foss.st.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-10-20iio: accel: sca3000: Use sign_extend32() instead of opencoding sign extension.Jonathan Cameron1-2/+1
Whilst nice to get rid of this non obvious code, this also clears a static checker warning: drivers/iio/accel/sca3000.c:734 sca3000_read_raw() warn: no-op. '((*val) << 19) >> 19' Reported-by: Dan Carpenter <dan.carpenter@oracle.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> Reviewed-by: Lars-Peter Clausen <lars@metafoo.de> Link: https://lore.kernel.org/r/20211017160303.72441-1-jic23@kernel.org
2021-10-20iio: xilinx-xadc: Remove `irq` field from state structLars-Peter Clausen2-4/+2
Since commit 2a9685d1a3b7 ("iio: adc: xilinx: use more devres helpers and remove remove()") the `irq` field from XADC driver state struct is only used in the `probe()` function. Use the local `irq` variable throughout the `probe()` function and remove the now unused field from the state struct. Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Link: https://lore.kernel.org/r/20211017121551.24063-1-lars@metafoo.de Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-10-20iio: imu: st_lsm6dsx: Avoid potential array overflow in st_lsm6dsx_set_odr()Teng Qi1-2/+4
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-20iio: light: gp2ap002: Make use of the helper function dev_err_probe()Cai Huoqing1-14/+10
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/20211008092656.421-3-caihuoqing@baidu.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-10-20iio: light: cm3605: Make use of the helper function dev_err_probe()Cai Huoqing1-14/+15
When possible use dev_err_probe help to properly deal with the PROBE_DEFER error, the benefit is that DEFER issue will be logged in the devices_deferred debugfs file. Using dev_err_probe() can reduce code size, and the error value gets printed. Signed-off-by: Cai Huoqing <caihuoqing@baidu.com> Reviewed-by: Linus Walleij <linus.walleij@linaro.org> Link: https://lore.kernel.org/r/20211008092656.421-1-caihuoqing@baidu.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-10-20iio: adc: ti-ads7950: Make use of the helper function dev_err_probe()Cai Huoqing1-2/+2
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/20211008092858.495-9-caihuoqing@baidu.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-10-20iio: adc: rockchip_saradc: Make use of the helper function dev_err_probe()Cai Huoqing1-15/+12
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/20211008092858.495-8-caihuoqing@baidu.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-10-20iio: adc: qcom-pm8xxx-xoadc: Make use of the helper function dev_err_probe()Cai Huoqing1-5/+4
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. BTW, change the return value from 'ENXIO' to 'ENODEV', perfer ENODEV which means no such device. Signed-off-by: Cai Huoqing <caihuoqing@baidu.com> Reviewed-by: Linus Walleij <linus.walleij@linaro.org> Link: https://lore.kernel.org/r/20211008092858.495-7-caihuoqing@baidu.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-10-20iio: adc: meson_saradc: Make use of the helper function dev_err_probe()Cai Huoqing1-22/+17
When possible use dev_err_probe help to properly deal with the PROBE_DEFER error, the benefit is that DEFER issue will be logged in the devices_deferred debugfs file. Using dev_err_probe() can reduce code size, and the error value gets printed. Signed-off-by: Cai Huoqing <caihuoqing@baidu.com> Reviewed-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com> Tested-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com> #Meson8b Odroid-C1 Link: https://lore.kernel.org/r/20211008092858.495-6-caihuoqing@baidu.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-10-20iio: adc: max1241: Make use of the helper function dev_err_probe()Cai Huoqing1-9/+8
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/20211008092858.495-5-caihuoqing@baidu.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-10-20iio: adc: max1118: Make use of the helper function dev_err_probe()Cai Huoqing1-4/+3
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/20211008092858.495-4-caihuoqing@baidu.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-10-20iio: adc: lpc18xx_adc: Make use of the helper function dev_err_probe()Cai Huoqing1-8/+6
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/20211008092858.495-3-caihuoqing@baidu.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-10-20iio: adc: imx7d_adc: Make use of the helper function dev_err_probe()Cai Huoqing1-12/+6
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/20211008092858.495-2-caihuoqing@baidu.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-10-20iio: adc: ab8500-gpadc: Make use of the helper function dev_err_probe()Cai Huoqing1-13/+9
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/20211008092858.495-1-caihuoqing@baidu.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-10-20iio: buffer: Fix uninitialized variable retColin Ian King1-1/+1
When !iio_buffer_space_available(rb) is true and signal_pending(current) is false the end of the do-while loop is reached and the uninitialized variable ret is zero checked. Fix this by initializing variable ret to zero. Addresses-Coverity: ("Uninitialized scalar variable") Fixes: 9eeee3b0bf19 ("iio: Add output buffer support") Signed-off-by: Colin Ian King <colin.king@canonical.com> Link: https://lore.kernel.org/r/20211015153254.33783-1-colin.king@canonical.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-10-20iio: adc: lpc18xx_adc: Convert probe to device managed versionAndré Gustavo Nakagomi Lopez1-30/+31
The remove function and the goto sections are not necessary if devm functions are used. Convert device register to devm version. Add hook functions to release device resources, and use them inside probe with devm_add_action, which will release resources on driver detach. To maintain the order of which device resources were released/reseted, register the hook functions as soon as resources are obtained/initialized. Since devres actions are called on driver detach, the remove function and the error-handling goto sections are no longer necessary. Signed-off-by: André Gustavo Nakagomi Lopez <andregnl@usp.br> Link: https://lore.kernel.org/r/YWnMsGlc/I35gYvy@Andryuu.br Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-10-20iio: light: ltr501: Add of_device_id tableNikita Travkin1-0/+9
Add of_device_id table so the driver can be used on DT platforms without relying on i2c_device_id fallback. (So DT schema validation is possible) Signed-off-by: Nikita Travkin <nikita@trvn.ru> Link: https://lore.kernel.org/r/20211006163058.145842-4-nikita@trvn.ru Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-10-20iio: light: ltr501: Add rudimentary regulator supportNikita Travkin1-0/+28
On some platforms the supply regulators must be enabled before the sensor can work. Add vdd and vddio regulators for the sensor and IO bus power respectively. Signed-off-by: Nikita Travkin <nikita@trvn.ru> Link: https://lore.kernel.org/r/20211006163058.145842-3-nikita@trvn.ru Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-10-19Merge tag 'iio-for-5.16a-split-take4' of https://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio into char-misc-nextGreg Kroah-Hartman140-1491/+6134
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-19iio: imx8qxp-adc: mark PM functions as __maybe_unusedArnd Bergmann1-2/+2
Without CONFIG_PM_SLEEP, the runtime suspend/resume functions are unused, producing a warning: drivers/iio/adc/imx8qxp-adc.c:433:12: error: 'imx8qxp_adc_runtime_resume' defined but not used [-Werror=unused-function] 433 | static int imx8qxp_adc_runtime_resume(struct device *dev) | ^~~~~~~~~~~~~~~~~~~~~~~~~~ drivers/iio/adc/imx8qxp-adc.c:419:12: error: 'imx8qxp_adc_runtime_suspend' defined but not used [-Werror=unused-function] 419 | static int imx8qxp_adc_runtime_suspend(struct device *dev) | ^~~~~~~~~~~~~~~~~~~~~~~~~~~ Mark them as __maybe_unused to shut up the compiler. Fixes: 1e23dcaa1a9f ("iio: imx8qxp-adc: Add driver support for NXP IMX8QXP ADC") Signed-off-by: Arnd Bergmann <arnd@arndb.de> Reviewed-by: Cai Huoqing <caihuoqing@baidu.com> Link: https://lore.kernel.org/r/20211013144338.2261316-1-arnd@kernel.org Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-10-19iio: pressure: ms5611: Make ms5611_remove() return voidUwe Kleine-König4-6/+8
Up to now ms5611_remove() returns zero unconditionally. Make it return void instead which makes it easier to see in the callers that there is no error to handle. Also the return value of i2c and spi remove callbacks is ignored anyway. Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Reviewed-by: Alexandru Ardelean <ardeleanalex@gmail.com> Link: https://lore.kernel.org/r/20211013203223.2694577-16-u.kleine-koenig@pengutronix.de Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-10-19iio: potentiometer: max5487: Don't return an error in .remove()Uwe Kleine-König1-1/+6
The only effect of returning an error in an spi .remove() callback is that the spi core issues a generic warning message. Instead emit a more specific error message and return 0 to not report the same issue twice. Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Reviewed-by: Alexandru Ardelean <ardeleanalex@gmail.com> Link: https://lore.kernel.org/r/20211013203223.2694577-15-u.kleine-koenig@pengutronix.de Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-10-19iio: magn: hmc5843: Make hmc5843_common_remove() return voidUwe Kleine-König4-6/+8
Up to now hmc5843_common_remove() returns zero unconditionally. Make it return void instead which makes it easier to see in the callers that there is no error to handle. Also the return value of i2c and spi remove callbacks is ignored anyway. Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Reviewed-by: Alexandru Ardelean <ardeleanalex@gmail.com> Link: https://lore.kernel.org/r/20211013203223.2694577-14-u.kleine-koenig@pengutronix.de Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-10-19iio: health: afe4403: Don't return an error in .remove()Uwe Kleine-König1-4/+2
The only effect of returning an error in an spi .remove() callback is that the spi core issues another warning message. Don't report the same problem twice and return 0 unconditionally instead. Also degrade the log level to warning, as nothing really bad is expected from a failure to put the device in suspend mode. Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Reviewed-by: Alexandru Ardelean <ardeleanalex@gmail.com> Link: https://lore.kernel.org/r/20211013203223.2694577-12-u.kleine-koenig@pengutronix.de Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>