aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/iio (follow)
AgeCommit message (Collapse)AuthorFilesLines
2019-03-31iio: core: fix a possible circular locking dependencyFabrice Gasnier1-2/+2
This fixes a possible circular locking dependency detected warning seen with: - CONFIG_PROVE_LOCKING=y - consumer/provider IIO devices (ex: "voltage-divider" consumer of "adc") When using the IIO consumer interface, e.g. iio_channel_get(), the consumer device will likely call iio_read_channel_raw() or similar that rely on 'info_exist_lock' mutex. typically: ... mutex_lock(&chan->indio_dev->info_exist_lock); if (chan->indio_dev->info == NULL) { ret = -ENODEV; goto err_unlock; } ret = do_some_ops() err_unlock: mutex_unlock(&chan->indio_dev->info_exist_lock); return ret; ... Same mutex is also hold in iio_device_unregister(). The following deadlock warning happens when: - the consumer device has called an API like iio_read_channel_raw() at least once. - the consumer driver is unregistered, removed (unbind from sysfs) ====================================================== WARNING: possible circular locking dependency detected 4.19.24 #577 Not tainted ------------------------------------------------------ sh/372 is trying to acquire lock: (kn->count#30){++++}, at: kernfs_remove_by_name_ns+0x3c/0x84 but task is already holding lock: (&dev->info_exist_lock){+.+.}, at: iio_device_unregister+0x18/0x60 which lock already depends on the new lock. the existing dependency chain (in reverse order) is: -> #1 (&dev->info_exist_lock){+.+.}: __mutex_lock+0x70/0xa3c mutex_lock_nested+0x1c/0x24 iio_read_channel_raw+0x1c/0x60 iio_read_channel_info+0xa8/0xb0 dev_attr_show+0x1c/0x48 sysfs_kf_seq_show+0x84/0xec seq_read+0x154/0x528 __vfs_read+0x2c/0x15c vfs_read+0x8c/0x110 ksys_read+0x4c/0xac ret_fast_syscall+0x0/0x28 0xbedefb60 -> #0 (kn->count#30){++++}: lock_acquire+0xd8/0x268 __kernfs_remove+0x288/0x374 kernfs_remove_by_name_ns+0x3c/0x84 remove_files+0x34/0x78 sysfs_remove_group+0x40/0x9c sysfs_remove_groups+0x24/0x34 device_remove_attrs+0x38/0x64 device_del+0x11c/0x360 cdev_device_del+0x14/0x2c iio_device_unregister+0x24/0x60 release_nodes+0x1bc/0x200 device_release_driver_internal+0x1a0/0x230 unbind_store+0x80/0x130 kernfs_fop_write+0x100/0x1e4 __vfs_write+0x2c/0x160 vfs_write+0xa4/0x17c ksys_write+0x4c/0xac ret_fast_syscall+0x0/0x28 0xbe906840 other info that might help us debug this: Possible unsafe locking scenario: CPU0 CPU1 ---- ---- lock(&dev->info_exist_lock); lock(kn->count#30); lock(&dev->info_exist_lock); lock(kn->count#30); *** DEADLOCK *** ... cdev_device_del() can be called without holding the lock. It should be safe as info_exist_lock prevents kernelspace consumers to use the exported routines during/after provider removal. cdev_device_del() is for userspace. Help to reproduce: See example: Documentation/devicetree/bindings/iio/afe/voltage-divider.txt sysv { compatible = "voltage-divider"; io-channels = <&adc 0>; output-ohms = <22>; full-ohms = <222>; }; First, go to iio:deviceX for the "voltage-divider", do one read: $ cd /sys/bus/iio/devices/iio:deviceX $ cat in_voltage0_raw Then, unbind the consumer driver. It triggers above deadlock warning. $ cd /sys/bus/platform/drivers/iio-rescale/ $ echo sysv > unbind Note I don't actually expect stable will pick this up all the way back into IIO being in staging, but if's probably valid that far back. Signed-off-by: Fabrice Gasnier <fabrice.gasnier@st.com> Fixes: ac917a81117c ("staging:iio:core set the iio_dev.info pointer to null on unregister") Cc: <Stable@vger.kernel.org> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-03-24iio: ad_sigma_delta: select channel when reading registerDragos Bogdan1-0/+1
The desired channel has to be selected in order to correctly fill the buffer with the corresponding data. The `ad_sd_write_reg()` already does this, but for the `ad_sd_read_reg_raw()` this was omitted. Fixes: af3008485ea03 ("iio:adc: Add common code for ADI Sigma Delta devices") Signed-off-by: Dragos Bogdan <dragos.bogdan@analog.com> Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com> Cc: <Stable@vger.kernel.org> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-03-16iio: pms7003: select IIO_TRIGGERED_BUFFERArnd Bergmann1-0/+1
Without IIO_TRIGGERED_BUFFER, this driver fails to link: drivers/iio/chemical/pms7003.o: In function `pms7003_probe': pms7003.c:(.text+0x21c): undefined reference to `devm_iio_triggered_buffer_setup' pms7003.c:(.text+0x21c): relocation truncated to fit: R_AARCH64_CALL26 against undefined symbol `devm_iio_triggered_buffer_setup' Fixes: a1d642266c14 ("iio: chemical: add support for Plantower PMS7003 sensor") Signed-off-by: Arnd Bergmann <arnd@arndb.de> Acked-by: Tomasz Duszynski <tduszyns@gmail.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-03-16iio: cros_ec: Fix the maths for gyro scale calculationGwendal Grignou1-3/+4
Calculation did not use IIO_DEGREE_TO_RAD and implemented a variant to avoid precision loss as we aim a nano value. The offset added to avoid rounding error, though, doesn't give us a close result to the expected value. E.g. For 1000dps, the result should be: (1000 * pi ) / 180 >> 15 ~= 0.000532632218 But with current calculation we get $ cat scale 0.000547890 Fix the calculation by just doing the maths involved for a nano value val * pi * 10e12 / (180 * 2^15) so we get a closer result. $ cat scale 0.000532632 Fixes: c14dca07a31d ("iio: cros_ec_sensors: add ChromeOS EC Contiguous Sensors driver") Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Signed-off-by: Enric Balletbo i Serra <enric.balletbo@collabora.com> Cc: <Stable@vger.kernel.org> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-03-16iio: adc: xilinx: prevent touching unclocked h/w on removeSven Van Asbroeck1-1/+1
In remove, the clock is disabled before canceling the delayed work. This means that the delayed work may be touching unclocked hardware. Fix by disabling the clock after the delayed work is fully canceled. This is consistent with the probe error path order. Signed-off-by: Sven Van Asbroeck <TheSven73@gmail.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-03-16iio: adc: xilinx: fix potential use-after-free on probeSven Van Asbroeck1-0/+1
If probe errors out after request_irq(), its error path does not explicitly cancel the delayed work, which may have been scheduled by the interrupt handler. This means the delayed work may still be running when the core frees the private structure (struct xadc). This is a potential use-after-free. Fix by inserting cancel_delayed_work_sync() in the probe error path. Signed-off-by: Sven Van Asbroeck <TheSven73@gmail.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-03-16iio: adc: xilinx: fix potential use-after-free on removeSven Van Asbroeck1-1/+1
When cancel_delayed_work() returns, the delayed work may still be running. This means that the core could potentially free the private structure (struct xadc) while the delayed work is still using it. This is a potential use-after-free. Fix by calling cancel_delayed_work_sync(), which waits for any residual work to finish before returning. Signed-off-by: Sven Van Asbroeck <TheSven73@gmail.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-03-16iio: dac: mcp4725: add missing powerdown bits in store eepromJean-Francois Dagenais1-0/+1
When issuing the write DAC register and write eeprom command, the two powerdown bits (PD0 and PD1) are assumed by the chip to be present in the bytes sent. Leaving them at 0 implies "powerdown disabled" which is a different state that the current one. By adding the current state of the powerdown in the i2c write, the chip will correctly power-on exactly like as it is at the moment of store_eeprom call. This is documented in MCP4725's datasheet, FIGURE 6-2: "Write Commands for DAC Input Register and EEPROM" and MCP4726's datasheet, FIGURE 6-3: "Write All Memory Command". Signed-off-by: Jean-Francois Dagenais <jeff.dagenais@gmail.com> Acked-by: Peter Meerwald-Stadler <pmeerw@pmeerw.net> Cc: <Stable@vger.kernel.org> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-03-09io: accel: kxcjk1013: restore the range after resume.he, bo1-0/+2
On some laptops, kxcjk1013 is powered off when system enters S3. We need restore the range regiter during resume. Otherwise, the sensor doesn't work properly after S3. Signed-off-by: he, bo <bo.he@intel.com> Signed-off-by: Chen, Hu <hu1.chen@intel.com> Reviewed-by: Hans de Goede <hdegoede@redhat.com> Cc: <Stable@vger.kernel.org> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-03-09iio:chemical:bme680: Fix SPI read interfaceMike Looijmans4-62/+118
The SPI interface implementation was completely broken. When using the SPI interface, there are only 7 address bits, the upper bit is controlled by a page select register. The core needs access to both ranges, so implement register read/write for both regions. The regmap paging functionality didn't agree with a register that needs to be read and modified, so I implemented a custom paging algorithm. This fixes that the device wouldn't even probe in SPI mode. The SPI interface then isn't different from I2C, merged them into the core, and the I2C/SPI named registers are no longer needed. Implemented register value caching for the registers to reduce the I2C/SPI data transfers considerably. The calibration set reads as all zeroes until some undefined point in time, and I couldn't determine what makes it valid. The datasheet mentions these registers but does not provide any hints on when they become valid, and they aren't even enumerated in the memory map. So check the calibration and retry reading it from the device after each measurement until it provides something valid. Despite the size this is suitable for a stable backport given that it seems the SPI support never worked. Signed-off-by: Mike Looijmans <mike.looijmans@topic.nl> Fixes: 1b3bd8592780 ("iio: chemical: Add support for Bosch BME680 sensor"); Cc: <Stable@vger.kernel.org> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-03-09iio:chemical:bme680: Fix, report temperature in millidegreesMike Looijmans1-9/+7
The standard unit for temperature is millidegrees Celcius. Adapt the driver to report in millidegrees instead of degrees. Signed-off-by: Mike Looijmans <mike.looijmans@topic.nl> Fixes: 1b3bd8592780 ("iio: chemical: Add support for Bosch BME680 sensor"); Cc: <Stable@vger.kernel.org> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-03-09iio: chemical: fix missing Kconfig block for sgp30Jonathan Cameron1-0/+13
I clearly messed up applying this patch. Not sure how but the entire Kconfig block is missing. This patch puts it back as it was in the original patch. Reported-by: Andreas Brauchli <a.brauchli@elementarea.net> Fixes: ce514124161a ("iio: chemical: sgp30: Support Sensirion SGP30/SGPC3 sensors") Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-03-09iio: adc: at91: disable adc channel interrupt in timeout caseGeorg Ottinger1-11/+17
Having a brief look at at91_adc_read_raw() it is obvious that in the case of a timeout the setting of AT91_ADC_CHDR and AT91_ADC_IDR registers is omitted. If 2 different channels are queried we can end up with a situation where two interrupts are enabled, but only one interrupt is cleared in the interrupt handler. Resulting in a interrupt loop and a system hang. Signed-off-by: Georg Ottinger <g.ottinger@abatec.at> Acked-by: Ludovic Desroches <ludovic.desroches@microchip.com> Cc: <Stable@vger.kernel.org> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-03-09iio: gyro: mpu3050: fix chip ID readingSergey Larin1-3/+5
According to the datasheet, the last bit of CHIP_ID register controls I2C bus, and the first one is unused. Handle this correctly. Note that there are chips out there that have a value such that the id check currently fails. Signed-off-by: Sergey Larin <cerg2010cerg2010@mail.ru> Reviewed-by: Linus Walleij <linus.walleij@linaro.org> Cc: <Stable@vger.kernel.org> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-03-09iio: Fix scan mask selectionLars-Peter Clausen1-3/+2
The trialmask is expected to have all bits set to 0 after allocation. Currently kmalloc_array() is used which does not zero the memory and so random bits are set. This results in random channels being enabled when they shouldn't. Replace kmalloc_array() with kcalloc() which has the same interface but zeros the memory. Note the fix is actually required earlier than the below fixes tag, but will require a manual backport due to move from kmalloc to kmalloc_array. Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com> Fixes commit 057ac1acdfc4 ("iio: Use kmalloc_array() in iio_scan_mask_set()"). Cc: <Stable@vger.kernel.org> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-03-09iio/gyro/bmg160: Use millidegrees for temperature scaleMike Looijmans1-3/+3
Standard unit for temperature is millidegrees Celcius, whereas this driver was reporting in degrees. Fix the scale factor in the driver. Signed-off-by: Mike Looijmans <mike.looijmans@topic.nl> Cc: <Stable@vger.kernel.org> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-03-08Merge tag 'mfd-next-5.1' of git://git.kernel.org/pub/scm/linux/kernel/git/lee/mfdLinus Torvalds3-0/+371
Pull MFD updates from Lee Jones: "New Drivers: - Add STMPE ADC Input driver - Add STMicroelectronics STPMIC1 Parent driver - Add STMicroelectronics STPMIC1 OnKey Misc driver - Add STMicroelectronics STPMIC1 Watchdog driver - Add Cirrus Logic Lochnagar Parent driver - Add TQ-Systems TQMX86 Parent driver New Device Support: - Add support for ADC to STMPE New (or moved) Functionality: - Move Lightbar functionality to its own driver; cros_ec_lightbar - Move VBC functionality to its own driver; cros_ec_vbc - Move VBC functionality to its own driver; cros_ec_vbc - Move DebugFS functionality to its own driver; cros_ec_debugfs - Move SYSFS functionality to its own driver; cros_ec_sysfs - Add support for input voltage options; tps65218 Fixes: - Use devm_* managed resources; cros_ec - Device Tree documentation; stmpe, aspeed-lpc, lochnagar - Trivial Clean-ups; stmpe - Rip out broken modular code; aat2870-core, adp5520, as3711, db8500-prcmu, htc-i2cpld, max8925-core, rc5t583, sta2x11-mfd, syscon, tps65090, tps65910, tps68470 tps80031, wm831x-spi, wm831x-i2c, wm831x-core, wm8350-i2c, wm8350-core, wm8400-core - Kconfig fixups; INTEL_SOC_PMIC - Improve error path; sm501, sec-core - Use struct_size() helper; sm501 - Constify; at91-usart - Use pointers instead of copying data; at91-usart - Deliver proper return value; cros_ec_dev - Trivial formatting/whitespace; sec-core" * tag 'mfd-next-5.1' of git://git.kernel.org/pub/scm/linux/kernel/git/lee/mfd: (53 commits) mfd: mxs-lradc: Mark expected switch fall-through mfd: sec-core: Cleanup formatting to a consistent style mfd: tqmx86: IO controller with I2C, Wachdog and GPIO mfd: intel-lpss: Move linux/pm.h to the local header mfd: cros_ec_dev: Return number of bytes read with CROS_EC_DEV_IOCRDMEM mfd: tps68470: Drop unused MODULE_DEVICE_TABLE mfd: at91-usart: No need to copy mfd_cell in probe mfd: at91-usart: Constify at91_usart_spi_subdev and at91_usart_serial_subdev mfd: lochnagar: Add support for the Cirrus Logic Lochnagar mfd: lochnagar: Add initial binding documentation dt-bindings: mfd: aspeed-lpc: Make parameter optional mfd: sec-core: Return gracefully instead of BUG() if device cannot match mfd: sm501: Use struct_size() in devm_kzalloc() mfd: sm501: Fix potential NULL pointer dereference mfd: Kconfig: Fix I2C_DESIGNWARE_PLATFORM dependencies mfd: tps65218.c: Add input voltage options mfd: wm8400-core: Make it explicitly non-modular mfd: wm8350-core: Drop unused module infrastructure from non-modular code mfd: wm8350-i2c: Make it explicitly non-modular mfd: wm831x-core: Drop unused module infrastructure from non-modular code ...
2019-03-06Merge tag 'staging-5.1-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/stagingLinus Torvalds55-115/+5927
Pull staging/IIO updates from Greg KH: "Here is the big staging/iio driver pull request for 5.1-rc1. Lots of good IIO driver updates and cleanups in here as always. Combined with the removal of the xgifb driver, we have a net "loss" of over 9000 lines in the pull request, always a nice thing. As the outreachy application process is currently happening, there are loads of tiny checkpatch cleanup fixes all over the staging tree, which accounts for the majority of the fixups" * tag 'staging-5.1-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging: (341 commits) staging: mt7621-dma: remove license boilerplate text staging: mt7621-dma: add SPDX GPL-2.0+ license identifier Staging: ks7010: Replace typecast to int Staging: vt6655: Align a static function declaration staging: speakup: fix line over 80 characters. staging: mt7621-eth: Remove license boilerplate text staging: mt7621-eth: Add SPDX license identifier staging: ks7010: removed custom Michael MIC implementation. staging: rtl8192e: Fix space and suspect issue Staging: vt6655: Modify comment style of SPDX License Identifier Staging: vt6655: Modify comment style for SPDX-License-Identifier Staging: vt6655: Align a function declaration Staging: vt6655: Alignment of function declaration staging: rtl8712: Fix indentation issue staging: wilc1000: fix incorrent type in initializer staging: rtl8188eu: remove unused P2P_PRIVATE_IOCTL_SET_LEN staging: rtl8188eu: remove unused enum P2P_PROTO_WK_ID staging: rtl8723bs: Remove duplicated include from drv_types.h Staging: vt6655: Alignment should match open parenthesis staging: erofs: fix mis-acted TAIL merging behavior ...
2019-03-06iio: adc: fix warning in Qualcomm PM8xxx HK/XOADC driverLinus Torvalds1-7/+3
The pm8xxx_get_channel() implementation is unclear, and causes gcc to suddenly generate odd warnings. The trigger for the warning (at least for me) was the entirely unrelated commit 79a4e91d1bb2 ("device.h: Add __cold to dev_<level> logging functions"), which apparently changes gcc code generation in the caller function enough to cause this: drivers/iio/adc/qcom-pm8xxx-xoadc.c: In function ‘pm8xxx_xoadc_probe’: drivers/iio/adc/qcom-pm8xxx-xoadc.c:633:8: warning: ‘ch’ may be used uninitialized in this function [-Wmaybe-uninitialized] ret = pm8xxx_read_channel_rsv(adc, ch, AMUX_RSV4, ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ &read_nomux_rsv4, true); ~~~~~~~~~~~~~~~~~~~~~~~ drivers/iio/adc/qcom-pm8xxx-xoadc.c:426:27: note: ‘ch’ was declared here struct pm8xxx_chan_info *ch; ^~ because gcc for some reason then isn't able to see that the termination condition for the "for( )" loop in that function is also the condition for returning NULL. So it's not _actually_ uninitialized, but the function is admittedly just unnecessarily oddly written. Simplify and clarify the function, making gcc also see that it always returns a valid initialized value. Cc: Joe Perches <joe@perches.com> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Cc: Andy Gross <andy.gross@linaro.org> Cc: David Brown <david.brown@linaro.org> Cc: Jonathan Cameron <jic23@kernel.org> Cc: Hartmut Knaack <knaack.h@gmx.de> Cc: Lars-Peter Clausen <lars@metafoo.de> Cc: Peter Meerwald-Stadler <pmeerw@pmeerw.net> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2019-02-13Merge tag 'iio-for-5.1b' of git://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio into staging-nextGreg Kroah-Hartman25-71/+1480
Jonathan writes: Second set of new device support, features and cleanup for IIO in the 5.1 cycle. There are a few late breaking fixes in here that weren't worth trying to rush into 5.0 as they have been with us for quite a while. New device support * ad7476 - add support for TI ADS786X parts that are compatible with this Analog Devices driver. Good to see some simple devices are so similar. * Ingenic jz47xx SoC ADCs - new driver and bindings * Plantower PMS7003 partical sensor - new driver and bindings including vendor prefix. * TI DAC7612 - new driver and bindings for this dual DAC. New features * ad7768-1 - Sampling frequency control * bmi160 - Data ready trigger support, including open-drain dt binding. Cleanup / minor fixes. * Analog Device DACs - Fix some inconsistent licenses. These are only ones where there were two different license marked in the same file, and hence were previously unclear. * ads124s08 - Spelling fix. * adxl345 - Parameter alignement tidy up. * bmi160 - SPDX - correct a note on the types of supported interrupts which was too strict. - use iio_pollfunc_store_time to grab an earlier timestamp. - use if (ret) instead of if (ret < 0) to be consistent whilst simplifying some handling where ret was effectively getting written to 0 even though it was always already 0. * exynos_adc - Fix a null pointer dereference on unbind. - Fix number of channels on Exynos4x12 devices to be 4 rather than 8. * lpc32xx-adc - Move DT bindings doc out of staging. Oops, I missed this one when moving the driver. - SPDX. * npcm-adc - drop documentation of reset node as going to be done differently. It's a new driver this cycle so no need to support the previous binding going forwards. * sps30 - Fix an issue with a loop timeout test that meant it would never identify a timeout. - Mark deliberate switch fall throughs. * tag 'iio-for-5.1b' of git://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio: (26 commits) iio: adc: exynos-adc: Use proper number of channels for Exynos4x12 dt-binding: iio: remove rst node from NPCM ADC document dt-bindings: iio: chemical: pms7003: add device tree support dt-bindings: add Plantower to the vendor prefixes iio: chemical: add support for Plantower PMS7003 sensor iio:chemical:sps30 Supress some switch fallthrough warnings. iio:adc:lpc32xx use SPDX-License-Identifier dt-bindings: iio: adc: move lpc32xx-adc out of staging iio: adc: ads124s08: fix spelling mistake "converions" -> "conversions" iio: adc: exynos-adc: Fix NULL pointer exception on unbind iio: chemical: sps30: fix a loop timeout test iio:accel:adxl345: Change alignment to match paranthesis iio:dac:dac7612: device tree bindings iio:dac:ti-dac7612: Add driver for Texas Instruments DAC7612 iio: adc: ad7476: Add support for TI ADS786X ADCs iio: adc: ad7768-1: Add support for setting the sampling frequency drivers: iio: dac: Fix wrong license for ADI drivers IIO: add Ingenic JZ47xx ADC driver. dt-bindings: iio/adc: Add bindings for Ingenic JZ47xx SoCs ADC. dt-bindings: iio/adc: Add docs for Ingenic JZ47xx SoCs ADC. ...
2019-02-12iio: adc: exynos-adc: Use proper number of channels for Exynos4x12Krzysztof Kozlowski1-0/+17
Exynos4212 and Exynos4412 have only four ADC channels so using "samsung,exynos-adc-v1" compatible (for eight channels ADCv1) on them is wrong. Add a new compatible for Exynos4x12. Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org> Cc: <Stable@vger.kernel.org> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-02-11iio: chemical: add support for Plantower PMS7003 sensorTomasz Duszynski3-0/+351
Add support for Plantower PMS7003 particulate matter sensor. Signed-off-by: Tomasz Duszynski <tduszyns@gmail.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-02-11iio:chemical:sps30 Supress some switch fallthrough warnings.Jonathan Cameron1-0/+3
Fixes warnings reported on linux-next but marking one path and adding an explicit return in the other. Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> Cc: Andreas Brauchli <a.brauchli@elementarea.net> Acked-by: Tomasz Duszynski <tduszyns@gmail.com>
2019-02-11Merge 5.0-rc6 into staging-nextGreg Kroah-Hartman3-21/+65
We need the staging fixes in here as well. Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2019-02-09iio:adc:lpc32xx use SPDX-License-IdentifierGregory CLEMENT1-14/+1
Convert the driver to SPDX license description which allow removing several lines in the file. Signed-off-by: Gregory CLEMENT <gregory.clement@bootlin.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-02-09iio: adc: ads124s08: fix spelling mistake "converions" -> "conversions"Colin Ian King1-4/+4
There is a spelling mistake in several dev_err messages. Fix these. Signed-off-by: Colin Ian King <colin.king@canonical.com> Acked-by: Dan Murphy <dmurphy@ti.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-02-09iio: adc: exynos-adc: Fix NULL pointer exception on unbindKrzysztof Kozlowski1-1/+1
Fix NULL pointer exception on device unbind when device tree does not contain "has-touchscreen" property. In such case the input device is not registered so it should not be unregistered. $ echo "12d10000.adc" > /sys/bus/platform/drivers/exynos-adc/unbind Unable to handle kernel NULL pointer dereference at virtual address 00000474 ... (input_unregister_device) from [<c0772060>] (exynos_adc_remove+0x20/0x80) (exynos_adc_remove) from [<c0587d5c>] (platform_drv_remove+0x20/0x40) (platform_drv_remove) from [<c05860f0>] (device_release_driver_internal+0xdc/0x1ac) (device_release_driver_internal) from [<c0583ecc>] (unbind_store+0x60/0xd4) (unbind_store) from [<c031b89c>] (kernfs_fop_write+0x100/0x1e0) (kernfs_fop_write) from [<c029709c>] (__vfs_write+0x2c/0x17c) (__vfs_write) from [<c0297374>] (vfs_write+0xa4/0x184) (vfs_write) from [<c0297594>] (ksys_write+0x4c/0xac) (ksys_write) from [<c0101000>] (ret_fast_syscall+0x0/0x28) Fixes: 2bb8ad9b44c5 ("iio: exynos-adc: add experimental touchscreen support") Cc: <stable@vger.kernel.org> Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-02-09iio: chemical: sps30: fix a loop timeout testDan Carpenter1-1/+1
The "while (tries--) {" loop is a postop so it exits with "tries" set to -1. Fixes: 232e0f6ddeae ("iio: chemical: add support for Sensirion SPS30 sensor") Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-02-09iio:accel:adxl345: Change alignment to match paranthesisLuciana da Costa Marques1-2/+2
Align broken line to match upper line parenthesis. Solves the checkpatch.pl's message: CHECK: Alignment should match open parenthesis Signed-off-by: Luciana da Costa Marques <lucianadacostamarques@gmail.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-02-09iio:dac:ti-dac7612: Add driver for Texas Instruments DAC7612Ricardo Ribalda Delgado3-0/+195
It is a driver for Texas Instruments Dual, 12-Bit Serial Input Digital-to-Analog Converter. Datasheet of this chip: http://www.ti.com/lit/ds/sbas106/sbas106.pdf Signed-off-by: Ricardo Ribalda Delgado <ricardo@ribalda.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-02-09iio: adc: ad7476: Add support for TI ADS786X ADCsRicardo Ribalda Delgado2-4/+27
Add support for Texas Instruments ADS7866, ADS7867 and ADS7868 8/10/12 bit Single channel ADC. Datasheet: http://www.ti.com/lit/ds/symlink/ads7868.pdf Signed-off-by: Ricardo Ribalda Delgado <ricardo@ribalda.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-02-09iio: adc: ad7768-1: Add support for setting the sampling frequencyStefan Popa1-3/+199
The AD7768-1 core ADC receives a master clock signal (MCLK). The MCLK frequency combined with the MCLK division and the digital filter decimation rates, determines the sampling frequency. Along with MCLK_DIV, the power mode is also configured according to datasheet recommendations. From user space, available sampling frequencies can be read. However, it is not required for an exact value to be entered, since the driver will look for the closest available match. When the device configuration changes (for example, if the filter decimation rate changes), a SYNC_IN pulse is required. Signed-off-by: Stefan Popa <stefan.popa@analog.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-02-09drivers: iio: dac: Fix wrong license for ADI driversStefan Popa5-5/+5
Analog Devices drivers are typically GPL v2 only. This patch fixes the inconsistencies between the module license and SPDX. Signed-off-by: Stefan Popa <stefan.popa@analog.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-02-09IIO: add Ingenic JZ47xx ADC driver.Artur Rojek3-0/+374
Add an IIO driver for the ADC hardware present on Ingenic JZ47xx SoCs. Signed-off-by: Artur Rojek <contact@artur-rojek.eu> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-02-09iio:bmi160: use if (ret) instead of if (ret < 0)Martin Kelly1-22/+18
We are using "if (ret < 0)" in many places in which the function returns 0 on success. Use "if (ret)" instead for better clarity and correctness. Signed-off-by: Martin Kelly <martin@martingkelly.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-02-09iio:bmi160: use iio_pollfunc_store_timeMartin Kelly1-3/+3
Currently, we snap the timestamp after reading from the buffer and processing the event. When the IIO poll function is triggered by an interrupt, we can get a slightly more accurate timestamp by snapping it prior to reading the data, since the data was already generated prior to entering the trigger handler. This is not going to make a huge difference, but we might as well improve slightly. Do this by using iio_pollfunc_store_time as other drivers do. Signed-off-by: Martin Kelly <martin@martingkelly.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-02-09iio:bmi160: add drdy interrupt supportMartin Kelly2-3/+278
Add interrupt support for the data ready signal on the BMI160, which fires an interrupt whenever new accelerometer/gyroscope data is ready to read. Signed-off-by: Martin Kelly <martin@martingkelly.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-02-09iio:bmi160: add SPDX identifiersMartin Kelly3-11/+3
Add SPDX identifiers (GPL 2) for the BMI160 driver. bmi160.h had an identifier, but the other files did not. Signed-off-by: Martin Kelly <martin@martingkelly.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-02-04Merge tag 'iio-for-5.1a' of git://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio into staging-nextGreg Kroah-Hartman41-52/+4455
Jonathan writes: First set of new device support, features and cleanup for IIO in the 5.1 cycle A number of interesting new devices supported plus a good set of staging cleanup including one graduation and one drop. New device support * ad56886 - Add support for AD5674R/AD5679R with some minor driver changes to support more channels. * ad7768 - New driver and dt bindings for this 24 bit ADC. * max44009 - New driver and dt bindings for this ambient light sensor. * mpu6050 - Support the ICM 20602 IMU. Minor tweaks due to slightly different register map. * NPCM adc - New driver and dt bindings for this BMC ADC. * Sensiron SGP30 - Modifiers for ethanol and H2. - New driver and dt bindings. - Follow patch added self cleaning support. * Sensiron SPS30 - New channel type for mass concentration. - New driver and bindings. - Minor tidy up patch followed (drop fmt specifier as unused) * st_pressure - lps22hh support. ID plus information structures and dt bindings. * ti-ads124s08 - Add binding doc and driver. Staging graduations * ad7606 driver and bindings. Staging drops * ad7152 CDC driver dropped. This part is near EoL and no one is known to be using it. If anyone surfaces obviously we can bring the driver back. If not, good to drop it to avoid wasting anyone's time cleaning it up. New features * bme680 - DT support and bindings doc. * isl29018 - Add regulator for VCC. * mag3110 - Add regulators for supplies. * meson-saradc - Support the temperature sensors of more SoCs. * mma8452 - Add regulators for power suplies and binding docs to reflect them. * st-accel - Support the undocumented but it seems fairly common _ONT ACPI method to specify orientation of the sensor. Cleanup, minor fixes and fixes for staging driver that have been broken a long time * ad5933 - Drop platform data alternative to specifying the reference voltage using a regulator. - Use the clock framework to contorl the reference clock. - Add a DT binding doc to cover the defacto binding. * ad7280a - Split up some big functions to improve readability. * ad7606 - Allow for timeout if interrupt never occurs. - Use devm functions to simplify probe and remove. - Use the find_closest macro to avoid need for precise values from userspace. - Add missing vendor prefixes for various DT properties. Note the driver is in staging still and there are no known devicetrees. - Add explict OF device ID table. - Simplify the Kconfig choices - Change to a threaded IRQ. - SPDX and simple stype fixes. * ad7816 - Drop unnecessary variable init. * ad9523 - Check a return value that was ignored. * ad9833 - Drop platform data. It was just setting most values to the hardware defaults. - Use the clock framework to provide the input clock. * adt7316 (lots of staging cleanup) - Fix some wrong register / bit definitions - Invert the logic of the check for an ldac pin so it actually makes sense. - Read the right register to get internal vref settings - Allow adt751x chips to use the internal vref for all DAC channels rather than a subset. - Remove dac vref bypass control from parts that don't have one. - Make the store DAC update mode function consistent with the show one. - Fix some spellings and other minor tidy up. - Avoid passing irq numbers around by putting all the irq logic in one place. - Fix an issue with the resolution of DAC control. - Fix support of the high resolution DAC mode (for temp proportional output) where supported. - Fix DAC read and write calculations. * st_lsm6dsx - Drop an unused variable (set but not read) * xilinx-xadc - Check an unhandled return value. * tag 'iio-for-5.1a' of git://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio: (67 commits) iio: chemical: sps30: remove printk format specifier staging: iio: frequency: ad9833: Load clock using clock framework staging: iio: frequency: ad9833: Get frequency value statically dt-bindings: iio: light: Add max44009 iio: light: add driver for MAX44009 dt-bindings: iio: adc: Add docs for AD7768-1 iio: adc: Add AD7768-1 ADC basic support staging: iio: cdc: ad7152: remove driver completely iio: imu: mpu6050: Add support for the ICM 20602 IMU dt-bindings: iio: imu: add icm20602 bindings to mpu6050 dt-bindings: iio: pressure: add LPS22HH bindings iio: st_accel: use ACPI orientation data iio: adc: add NPCM ADC driver dt-binding: iio: add NPCM ADC documentation iio: chemical: sps30: allow changing self cleaning period dt-bindings: iio: chemical: Add bindings for bme680 iio: chemical: bme680: Add device-tree support iio:st_pressure:initial lps22hh sensor support iio: accell: mma8452: add vdd/vddio regulator operation support dt-bindings: iio: accel: mma8452: add power supplies property ...
2019-02-03Merge tag 'iio-fixes-5.0a' of git://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio into staging-linusGreg Kroah-Hartman3-21/+65
Jonathan writes: First set of IIO fixes for the 5.0 cycle. Been a busy month, so these are rather later than they should have been. * atlas-ph-sensor: - Temperature scale didn't correspond to the ABI. * axp288: - A few different fixes around the TS-pin handling. * ti-ads8688 - Not enough space in the buffer used to build the scan to allow for the timestamp. * tools - iio_generic_buffer - Make num_loops signed so that we really are running for ever rather than just a long time when we specify -1. * tag 'iio-fixes-5.0a' of git://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio: iio: ti-ads8688: Update buffer allocation for timestamps tools: iio: iio_generic_buffer: make num_loops signed iio: adc: axp288: Fix TS-pin handling iio: chemical: atlas-ph-sensor: correct IIO_TEMP values to millicelsius
2019-02-02iio: chemical: sps30: remove printk format specifierTomasz Duszynski1-2/+0
pr_fmt is used by printk wrappers. There are not any in the driver code so remove the format specifier. Signed-off-by: Tomasz Duszynski <tduszyns@gmail.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-02-02iio: light: add driver for MAX44009Robert Eshleman3-0/+566
The MAX44009 is a low-power ambient light sensor from Maxim Integrated. It differs from the MAX44000 in that it doesn't have proximity sensing and that it requires far less current (1 micro-amp vs 5 micro-amps). The register mapping and feature set between the two are different enough to require a new driver for the MAX44009. Developed and tested with a BeagleBone Black and UDOO Neo (i.MX6SX) Supported features: * Reading lux (processed value) * Rising and falling illuminance threshold events * Configuring integration time https://datasheets.maximintegrated.com/en/ds/MAX44009.pdf Signed-off-by: Robert Eshleman <bobbyeshleman@gmail.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-02-02iio: adc: Add AD7768-1 ADC basic supportStefan Popa3-0/+473
The ad7768-1 is a single channel, precision 24-bit analog to digital converter (ADC). This basic patch configures the device in fast mode, with 32 kSPS and leaves the default sinc5 filter. Two data conversion modes are made available. When data is retrieved by using the read_raw attribute, one shot single conversion mode is set. The continuous conversion mode is enabled when the triggered buffer mechanism is used. To assure correct data retrieval, the driver waits for the interrupt triggered by the low to high transition of the DRDY pin. Datasheets: Link: https://www.analog.com/media/en/technical-documentation/data-sheets/ad7768-1.pdf Signed-off-by: Stefan Popa <stefan.popa@analog.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-02-02iio: imu: mpu6050: Add support for the ICM 20602 IMURandolph Maaßen5-7/+58
The Invensense ICM-20602 is a 6-axis MotionTracking device that combines a 3-axis gyroscope and an 3-axis accelerometer. It is very similar to the ICM-20608 imu which is already supported by the mpu6050 driver. The main difference is that the ICM-20602 has the i2c bus disable bit in a separate register. Signed-off-by: Randolph Maaßen <gaireg@gaireg.de> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-02-02iio: st_accel: use ACPI orientation dataDaniel Drake1-1/+170
Platform-specific ST accelerometer mount matrix information can be provided by returning a package of 6 integers from the ACPI _ONT method. This has been seen on Acer products such as Veriton Z4860G, Z6860G and A890, which include a ST SMO8840 sensor. We have also confirmed experimentally that the Windows driver uses such information. The _ONT data format was explained by a ST vendor contact. However, strangely enough, the _ONT transformations must be applied after first applying another mount matrix which we determined experimentally. ST have not commented on why this is the case, but we imagine that perhaps earlier devices (before _ONT was introduced) required this translation and hence it became 'standard.' Interpret the _ONT data and export the equivalent mount matrix to userspace. If no _ONT data is present, no mount matrix is exported. Signed-off-by: Daniel Drake <drake@endlessm.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-02-01Merge branches 'ib-mfd-iio-input-5.1', 'ib-mfd-input-watchdog-5.1' and 'ib-mfd-platform-5.1' into ibs-for-mfd-mergedLee Jones1-1/+4
2019-01-19iio: adc: add NPCM ADC driverTomer Maimon3-0/+346
Add Nuvoton NPCM BMC Analog-to-Digital Converter(ADC) driver. The NPCM ADC is a 10-bit converter for eight channel inputs. Signed-off-by: Tomer Maimon <tmaimon77@gmail.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-01-19iio: chemical: sps30: allow changing self cleaning periodTomasz Duszynski1-18/+125
Sensor can periodically trigger self cleaning. Period can be changed by writing a new value to a dedicated attribute. Upon attribute read current period gets returned. Signed-off-by: Tomasz Duszynski <tduszyns@gmail.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-01-19iio: chemical: bme680: Add device-tree supportSebastien Bourdelin2-0/+15
This commit allow the driver to work with device-tree. Signed-off-by: Sebastien Bourdelin <sebastien.bourdelin@gmail.com> Acked-by: Himanshu Jha <himanshujha199640@gmail.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-01-19iio:st_pressure:initial lps22hh sensor supportmario tesi5-1/+82
Initial support for ST LPS22HH pressure sensor. Datasheet: http://www2.st.com/resource/en/datasheet/lps22hh.pdf Features: * pressure, temperature data and timestamping channels * sampling frequency selection [1..200] Hz * interrupt based trigger * over I2C or SPI interface Signed-off-by: mario tesi <mario.tesi@st.com> Acked-by: Denis Ciocca <denis.ciocca@st.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>