aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/iio/adc (follow)
AgeCommit message (Collapse)AuthorFilesLines
2021-09-01Merge tag 'staging-5.15-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/stagingLinus Torvalds8-36/+789
Pull IIO and staging driver updates from Greg KH: "Here is the big set of staging and IIO driver updates for 5.15-rc1. Also included in here are the counter driver subsystem updates as the IIO drivers needed them. Lots of churn in some staging drivers, we dropped the "old" rtl8188eu driver and replaced it with a newer version of the driver that had been maintained out-of-tree by Larry with the end goal of actually being able to get this driver out of staging eventually. Despite that driver being "newer" the line count of this pull request is going up. Some drivers moved out of staging as well, which is always nice to see, that is why there are additions to the mfc and misc driver subsystems. All of these were acked by the various subsystem maintainers involved. But by far, as normal, it's coding style cleanups all over the drivers/staging/ tree in here. Full details of these changes are in the shortlog. All of these have been in linux-next for a while with no reported problems" [ Note: the r8188eu merge clashed with commit 89939e890605 ("staging: rtlwifi: use siocdevprivate") from the networking tree. When resolving the issue, I noted that the whole r8188eu rtw_android code is dead since commit ae7471cae00a ("staging: r8188eu: remove rtw_ioctl function"). End result: the merge resolution was to throw all of that away, rather than do the mindless fixup to code that isn't actually reachable - Linus ] * tag 'staging-5.15-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging: (551 commits) staging: vt6655: Remove filenames in files staging: r8188eu: add extra TODO entries staging: vt6656: Remove filenames in files staging: wlan-ng: fix invalid assignment warning staging: r8188eu: rename fields of struct rtl_ps staging: r8188eu: remove ODM_DynamicPrimaryCCA_DupRTS() staging: r8188eu: rename fields of struct dyn_primary_cca staging: r8188eu: rename struct field Wifi_Error_Status staging: r8188eu: Provide a TODO file for this driver staging: r8188eu: remove unneeded variable staging: r8188eu: remove unneeded conversions to bool staging: r8188eu: remove {read,write}_macreg staging: r8188eu: core: remove condition with no effect staging: r8188eu: remove ethernet.h header file staging: r8188eu: remove ip.h header file staging: r8188eu: remove if_ether.h header file staging: r8188eu: make rtw_deinit_intf_priv return void staging: r8188eu: use is_multicast_ether_addr in os_dep/recv_linux.c staging: r8188eu: use is_multicast_ether_addr in hal/rtl8188eu_xmit.c staging: r8188eu: use is_multicast_ether_addr in core/rtw_xmit.c ...
2021-08-30Merge tag 'for-v5.15' of git://git.kernel.org/pub/scm/linux/kernel/git/sre/linux-power-supplyLinus Torvalds1-0/+23
Pull power supply and reset updates from Sebastian Reichel: "Battery/charger related: - cros-peripheral-charger: new driver - mt6360-charger: new driver - simple-battery: support reading chemistry info - max17042-battery: add max77849 support - sbs-battery: add time_to_empty_now support - smb347-charger: prepare USB OTG support - rn5t618: add voltage_now support - axp288: cleanup & optimizations - max17042_battery: cleanups - ab8500: cleanups - misc minor cleanups and DT binding fixes reset related: - tps65086-restart: new driver - linkstation-poweroff: support NETGEAR ReadyNAS Duo v2" * tag 'for-v5.15' of git://git.kernel.org/pub/scm/linux/kernel/git/sre/linux-power-supply: (51 commits) power: supply: core: Fix parsing of battery chemistry/technology power: supply: max17042_battery: log SOC threshold using debug log level power: supply: max17042_battery: more robust chip type checks power: supply: max17042_battery: fix typo in MAx17042_TOFF power: supply: max17042_battery: clean up MAX17055_V_empty power: supply: smb347-charger: Implement USB VBUS regulator power: supply: smb347-charger: Add missing pin control activation power: supply: smb347-charger: Utilize generic regmap caching power: supply: smb347-charger: Make smb347_set_writable() IRQ-safe dt-bindings: power: supply: smb347-charger: Document USB VBUS regulator power: reset: Add TPS65086 restart driver dt-bindings: power: supply: max17042: describe interrupt power: supply: max17042: remove duplicated STATUS bit defines power: supply: max17042: handle fails of reading status register power: supply: core: Parse battery chemistry/technology dt-bindings: power: Extend battery bindings with chemistry power: reset: linkstation-poweroff: add new device power: reset: linkstation-poweroff: prepare for new devices power: supply: bq24735: reorganize ChargeOption command macros power: supply: rn5t618: Add voltage_now property ...
2021-08-17Merge tag 'iio-for-5.15b' of https://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio into staging-nextGreg Kroah-Hartman4-7/+651
Jonathan writes: 2nd set of new IIO device support and cleanups for the 5.15 cycle. A small pull request to pick up a few new drivers and some cleanup and fix patches. New device support * ad5110 non-volatile digital potentiometer - New driver * renesas rzl/gl2 12-bit / 8 channel ADC block - New driver and bindings Minor or late breaking fixes and cleanups * ltc2983 - Fix a false assumption of initial interrupt during probe(). * hp03 - Use devm_* to simplify probe and allow the remove function to be dropped. * rockchip_saradc - Use a regulator notifier to reduce overheads of querying the scale. * tag 'iio-for-5.15b' of https://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio: iio: adc: Add driver for Renesas RZ/G2L A/D converter dt-bindings: iio: adc: Add binding documentation for Renesas RZ/G2L A/D converter iio: pressure: hp03: update device probe to register with devm functions iio: adc: rockchip_saradc: add voltage notifier so get referenced voltage once at probe iio: ltc2983: fix device probe iio: potentiometer: Add driver support for AD5110 dt-bindings: iio: potentiometer: Add AD5110 in trivial-devices
2021-08-16Merge 5.14-rc6 into staging-nextGreg Kroah-Hartman2-3/+2
We need the IIO fixes in here as well. Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2021-08-15iio: adc: Add driver for Renesas RZ/G2L A/D converterLad Prabhakar3-0/+611
Add ADC driver support for Renesas RZ/G2L A/D converter in SW trigger mode. A/D Converter block is a successive approximation analog-to-digital converter with a 12-bit accuracy and supports a maximum of 8 input channels. Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com> Reviewed-by: Biju Das <biju.das.jz@bp.renesas.com> Link: https://lore.kernel.org/r/20210804202118.25745-3-prabhakar.mahadev-lad.rj@bp.renesas.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-08-15iio: adc: rockchip_saradc: add voltage notifier so get referenced voltage once at probeDavid Wu1-7/+40
Add voltage notifier, no need to query regulator voltage for every saradc read, just get regulator voltage once at probe. Signed-off-by: David Wu <david.wu@rock-chips.com> Signed-off-by: Simon Xue <xxm@rock-chips.com> Reviewed-by: Heiko Stuebner <heiko@sntech.de> Link: https://lore.kernel.org/r/20210810011007.54066-1-xxm@rock-chips.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-08-13iio: adc: rn5t618: Add iio mapAndreas Kemnade1-0/+23
Add iio map to allow power driver to read out values as a consumer. This approach does not block later addition of devicetree support which would be helpful if there is an in-kernel consumer for AIN0/1. Signed-off-by: Andreas Kemnade <andreas@kemnade.info> Acked-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2021-08-08iio: ep93xx: Prepare clock before using itAlexander Sverdlin1-3/+3
Use clk_prepare_enable()/clk_disable_unprepare() in preparation for switch to Common Clock Framework, otherwise the following is visible: WARNING: CPU: 0 PID: 1 at drivers/clk/clk.c:1011 clk_core_enable+0x9c/0xbc Enabling unprepared ep93xx-adc CPU: 0 PID: 1 Comm: swapper Not tainted 5.13.0-rc5-... #1 Hardware name: Cirrus Logic EDB9302 Evaluation Board [<c000d5b0>] (unwind_backtrace) from [<c000c590>] (show_stack+0x10/0x18) [<c000c590>] (show_stack) from [<c03a5f38>] (dump_stack+0x20/0x2c) [<c03a5f38>] (dump_stack) from [<c03a2098>] (__warn+0x98/0xc0) [<c03a2098>] (__warn) from [<c03a2150>] (warn_slowpath_fmt+0x90/0xc0) [<c03a2150>] (warn_slowpath_fmt) from [<c01d8358>] (clk_core_enable+0x9c/0xbc) [<c01d8358>] (clk_core_enable) from [<c01d8698>] (clk_core_enable_lock+0x18/0x30) [<c01d8698>] (clk_core_enable_lock) from [<c0266560>] (ep93xx_adc_probe+0xe4/0x1a0) [<c0266560>] (ep93xx_adc_probe) from [<c02126e0>] (platform_probe+0x34/0x80) [<c02126e0>] (platform_probe) from [<c0210bf8>] (really_probe+0xe8/0x394) [<c0210bf8>] (really_probe) from [<c0211464>] (device_driver_attach+0x5c/0x64) [<c0211464>] (device_driver_attach) from [<c02114e8>] (__driver_attach+0x7c/0xec) [<c02114e8>] (__driver_attach) from [<c020f1b4>] (bus_for_each_dev+0x78/0xc4) [<c020f1b4>] (bus_for_each_dev) from [<c0211570>] (driver_attach+0x18/0x24) [<c0211570>] (driver_attach) from [<c020fab4>] (bus_add_driver+0x140/0x1cc) [<c020fab4>] (bus_add_driver) from [<c0211c44>] (driver_register+0x74/0x114) [<c0211c44>] (driver_register) from [<c02134f8>] (__platform_driver_register+0x18/0x24) [<c02134f8>] (__platform_driver_register) from [<c0470148>] (ep93xx_adc_driver_init+0x10/0x1c) [<c0470148>] (ep93xx_adc_driver_init) from [<c045ce88>] (do_one_initcall+0x7c/0x1a4) [<c045ce88>] (do_one_initcall) from [<c045d184>] (kernel_init_freeable+0x17c/0x1fc) [<c045d184>] (kernel_init_freeable) from [<c03a64d0>] (kernel_init+0x8/0xf8) [<c03a64d0>] (kernel_init) from [<c00082d8>] (ret_from_fork+0x14/0x3c) ... ep93xx-adc ep93xx-adc: Cannot enable clock ep93xx-adc: probe of ep93xx-adc failed with error -108 Signed-off-by: Alexander Sverdlin <alexander.sverdlin@gmail.com> Link: https://lore.kernel.org/r/20210613233041.128961-2-alexander.sverdlin@gmail.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-08-08iio: adc: fsl-imx25-gcq: adjust irq check to match docs and simplify codeTang Bin1-6/+3
For the function of platform_get_irq(), the example in platform.c is * int irq = platform_get_irq(pdev, 0); * if (irq < 0) * return irq; the return value of zero is unnecessary to check, so make the right check and simplify code. Note that platform_get_irq() is documented as never returning 0 so this is a minor optmization rather than a fix. Co-developed-by: Zhang Shengju <zhangshengju@cmss.chinamobile.com> Signed-off-by: Zhang Shengju <zhangshengju@cmss.chinamobile.com> Signed-off-by: Tang Bin <tangbin@cmss.chinamobile.com> Link: https://lore.kernel.org/r/20210802120929.33760-1-tangbin@cmss.chinamobile.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-07-31iio/adc: ingenic: add JZ4760B support to the sadc driverChristophe Branchereau1-0/+10
The JZ4760B variant differs slightly from the JZ4760: it has a bit called VBAT_SEL in the CFG register. In order to correctly sample the battery voltage on existing handhelds using this SOC, the bit must be cleared. We leave the possibility to set the bit, by using the "ingenic,use-internal-divider" in the devicetree. Signed-off-by: Christophe Branchereau <cbranchereau@gmail.com> Link: https://lore.kernel.org/r/20210726082033.351533-5-cbranchereau@gmail.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-07-31iio/adc: ingenic: add JZ4760 support to the sadc driverChristophe Branchereau1-4/+78
The jz4760 sadc is very similar to the jz4770 one, but has a VREF of 2.5V and 3 aux channels. modify ingenic_adc_read_chan_info_raw() needs a change to account for it. Signed-off-by: Christophe Branchereau <cbranchereau@gmail.com> Reviewed-by: Paul Cercueil <paul@crapouillou.net> Link: https://lore.kernel.org/r/20210726082033.351533-4-cbranchereau@gmail.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-07-31iio/adc: ingenic: rename has_aux2 to has_aux_mdChristophe Branchereau1-5/+5
The jz4760(b) socs have 3 aux channels. The purpose of has_aux2 is to set the MD bits used to select the AUX channel to be sampled, not to describe the hardware. Rename it to a more appropriate name. Signed-off-by: Christophe Branchereau <cbranchereau@gmail.com> Reviewed-by: Paul Cercueil <paul@crapouillou.net> Link: https://lore.kernel.org/r/20210726082033.351533-2-cbranchereau@gmail.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-07-31iio: adc: Fix incorrect exit of for-loopColin Ian King1-2/+2
Currently the for-loop that scans for the optimial adc_period iterates through all the possible adc_period levels because the exit logic in the loop is inverted. I believe the comparison should be swapped and the continue replaced with a break to exit the loop at the correct point. Addresses-Coverity: ("Continue has no effect") Fixes: e08e19c331fb ("iio:adc: add iio driver for Palmas (twl6035/7) gpadc") Signed-off-by: Colin Ian King <colin.king@canonical.com> Link: https://lore.kernel.org/r/20210730071651.17394-1-colin.king@canonical.com Cc: <stable@vger.kernel.org> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-07-25iio: adc: meson-saradc: Fix indentation of arguments after a line-breakMartin Blumenstingl1-4/+4
Align the function arguments after a line-break with the opening parenthesis on the previous line. No functional changes intended. Signed-off-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com> Link: https://lore.kernel.org/r/20210717233718.332267-4-martin.blumenstingl@googlemail.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-07-25iio: adc: meson-saradc: Add missing space between if and parenthesisMartin Blumenstingl1-1/+1
Add a missing space between if and the opening parenthesis to make the coding style consistent across the whole driver. No functional changes intended. Signed-off-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com> Link: https://lore.kernel.org/r/20210717233718.332267-3-martin.blumenstingl@googlemail.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-07-25iio: adc: meson-saradc: Disable BL30 integration on G12A and newer SoCsMartin Blumenstingl1-1/+9
G12A and newer don't use the SAR ADC to read the SoC temperature from within the firmware. Instead there's now a dedicated thermal sensor. Disable the BL30 integration for G12A and newer SoCs to save a few CPU cycles when reading samples. Adding a separate struct meson_sar_adc_data is a good idea anyways because starting with G12A there's some extra registers to read the samples in a simplified way. Signed-off-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com> Link: https://lore.kernel.org/r/20210717233718.332267-2-martin.blumenstingl@googlemail.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-07-24iio: adc: fsl-imx25-gcq: Use the defined variable to clean codeTang Bin1-4/+4
Use the defined variable "dev" to make the code cleaner. Co-developed-by: Zhang Shengju <zhangshengju@cmss.chinamobile.com> Signed-off-by: Zhang Shengju <zhangshengju@cmss.chinamobile.com> Signed-off-by: Tang Bin <tangbin@cmss.chinamobile.com> Link: https://lore.kernel.org/r/20210720125945.11548-1-tangbin@cmss.chinamobile.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-07-17iio: adc: ti-ads7950: Ensure CS is deasserted after reading channelsUwe Kleine-König1-1/+0
The ADS7950 requires that CS is deasserted after each SPI word. Before commit e2540da86ef8 ("iio: adc: ti-ads7950: use SPI_CS_WORD to reduce CPU usage") the driver used a message with one spi transfer per channel where each but the last one had .cs_change set to enforce a CS toggle. This was wrongly translated into a message with a single transfer and .cs_change set which results in a CS toggle after each word but the last which corrupts the first adc conversion of all readouts after the first readout. Fixes: e2540da86ef8 ("iio: adc: ti-ads7950: use SPI_CS_WORD to reduce CPU usage") Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Reviewed-by: David Lechner <david@lechnology.com> Tested-by: David Lechner <david@lechnology.com> Cc: <Stable@vger.kernel.org> Link: https://lore.kernel.org/r/20210709101110.1814294-1-u.kleine-koenig@pengutronix.de Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-07-17iio: adc: rockchip_saradc: add support for rk3568 saradcSimon Xue1-1/+21
It is similar to other devices, but with 8 channels. Signed-off-by: Simon Xue <xxm@rock-chips.com> Reviewed-by: Heiko Stuebner <heiko@sntech.de> Link: https://lore.kernel.org/r/20210712014507.97477-1-xxm@rock-chips.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-06-16iio: adc: ads1015: Balance runtime pm + pm_runtime_resume_and_get()Jonathan Cameron1-4/+1
The call to pm_runtime_put_noidle() in remove() is not balancing a counter increment. Note this doesn't matter as the runtime pm core will not allow the counter to go negative. However, it is confusing to the reader so let's remove it. The pm_runtime_resume_and_get() replacement was found using coccicheck script under review at: https://lore.kernel.org/lkml/20210427141946.2478411-1-Julia.Lawall@inria.fr/ 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> Reviewed-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org> Link: https://lore.kernel.org/r/20210516162103.1332291-3-jic23@kernel.org
2021-06-14iio: adc: ti-ads8688: Fix alignment of buffer in iio_push_to_buffers_with_timestamp()Jonathan Cameron1-1/+2
Add __aligned(8) to ensure the buffer passed to iio_push_to_buffers_with_timestamp() is suitable for the naturally aligned timestamp that will be inserted. Fixes: f214ff521fb1 ("iio: ti-ads8688: Update buffer allocation for timestamps") Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> Reviewed-by: Nuno Sá <nuno.sa@analog.com> Link: https://lore.kernel.org/r/20210613152301.571002-5-jic23@kernel.org
2021-06-14iio: adc: mxs-lradc: Fix buffer alignment in iio_push_to_buffers_with_timestamp()Jonathan Cameron1-1/+2
To make code more readable, use a structure to express the channel layout and ensure the timestamp is 8 byte aligned. Add a comment on why the buffer is the size it is as not immediately obvious. Found during an audit of all calls of this function. Fixes: 6dd112b9f85e ("iio: adc: mxs-lradc: Add support for ADC driver") Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> Cc: Andreas Klinger <ak@it-klinger.de> Reviewed-by: Nuno Sá <nuno.sa@analog.com> Link: https://lore.kernel.org/r/20210613152301.571002-4-jic23@kernel.org
2021-06-14iio: adc: hx711: Fix buffer alignment in iio_push_to_buffers_with_timestamp()Jonathan Cameron1-2/+2
To make code more readable, use a structure to express the channel layout and ensure the timestamp is 8 byte aligned. Found during an audit of all calls of this function. Fixes: d3bf60450d47 ("iio: hx711: add triggered buffer support") Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> Cc: Andreas Klinger <ak@it-klinger.de> Reviewed-by: Nuno Sá <nuno.sa@analog.com> Link: https://lore.kernel.org/r/20210613152301.571002-3-jic23@kernel.org
2021-06-14iio: adc: at91-sama5d2: Fix buffer alignment in iio_push_to_buffers_with_timestamp()Jonathan Cameron1-1/+2
To make code more readable, use a structure to express the channel layout and ensure the timestamp is 8 byte aligned. Found during an audit of all calls of this function. Fixes: 5e1a1da0f8c9 ("iio: adc: at91-sama5d2_adc: add hw trigger and buffer support") Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> Cc: Eugen Hristev <eugen.hristev@microchip.com> Reviewed-by: Nuno Sá <nuno.sa@analog.com> Link: https://lore.kernel.org/r/20210613152301.571002-2-jic23@kernel.org
2021-06-13iio: adc: remove unused private data assigned with spi_set_drvdata()Alexandru Ardelean11-20/+0
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 ADC group. Signed-off-by: Alexandru Ardelean <aardelean@deviqon.com> Link: https://lore.kernel.org/r/20210513111035.77950-1-aardelean@deviqon.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-06-13iio: adc: ad_sigma_delta: remove ad_sd_{setup,cleanup}_buffer_and_trigger()Alexandru Ardelean1-86/+0
Since all AD Sigma-Delta drivers now use the devm_ad_sd_setup_buffer_and_trigger() function, we can remove the old ad_sd_{setup,cleanup}_buffer_and_trigger() functions. This way we can discourage new drivers that use the ad_sigma_delta lib-driver to use these (older functions). Signed-off-by: Alexandru Ardelean <aardelean@deviqon.com> Link: https://lore.kernel.org/r/20210513120752.90074-13-aardelean@deviqon.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-06-13iio: adc: ad7124: Use devm_ managed calls for all of probe() + drop remove()Jonathan Cameron1-33/+15
As not many steps were not already devm_ managed, use devm_add_action_or_reset() to handle the rest. This also uses the new devm_ad_sd_setup_buffer_and_trigger() function. Reviewed-by: Alexandru Ardelean <ardeleanalex@gmail.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> Signed-off-by: Alexandru Ardelean <aardelean@deviqon.com> Link: https://lore.kernel.org/r/20210513120752.90074-12-aardelean@deviqon.com
2021-06-13iio: adc: ad7192: convert to device-managed functionsAlexandru Ardelean1-53/+36
With the devm_ad_sd_setup_buffer_and_trigger() helper, it's a bit easier now to convert the probe of the AD7192 driver to use device-managed functions. The regulators and the mclk requires devm_add_action_or_reset() callbacks though. Signed-off-by: Alexandru Ardelean <aardelean@deviqon.com> Link: https://lore.kernel.org/r/20210513120752.90074-11-aardelean@deviqon.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-06-13iio: adc: ad7192: use devm_clk_get_optional() for mclkAlexandru Ardelean1-3/+3
The devm_clk_get_optional() helper returns NULL when devm_clk_get() returns -ENOENT. This makes things slightly cleaner. The added benefit is mostly cosmetic. Also, a minor detail with this call, is that the reference for the parent device is taken as `spi->dev` instead of `&st->sd.spi->dev` (which looks a little quirky). Signed-off-by: Alexandru Ardelean <aardelean@deviqon.com> Link: https://lore.kernel.org/r/20210513120752.90074-10-aardelean@deviqon.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-06-13iio: adc: ad7780: convert to device-managed functionsAlexandru Ardelean1-28/+10
With the devm_ad_sd_setup_buffer_and_trigger() helper, it's a bit easier now to convert the probe of the AD7780 driver to use device-managed functions. Only the regulator disable requires a devm_add_action_or_reset() callback. This change does that, cleaning up the driver a bit. Signed-off-by: Alexandru Ardelean <aardelean@deviqon.com> Link: https://lore.kernel.org/r/20210513120752.90074-9-aardelean@deviqon.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-06-13iio: adc: ad7791: convert to device-managed functionsAlexandru Ardelean1-31/+13
With the devm_ad_sd_setup_buffer_and_trigger() helper, it's a bit easier now to convert the probe of the AD7791 driver to use device-managed functions. Only the regulator disable requires a devm_add_action_or_reset() callback. This change does that, cleaning up the driver a bit. Signed-off-by: Alexandru Ardelean <aardelean@deviqon.com> Link: https://lore.kernel.org/r/20210513120752.90074-8-aardelean@deviqon.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-06-13iio: adc: ad7793: convert to device-managed functionsAlexandru Ardelean1-38/+15
With the devm_ad_sd_setup_buffer_and_trigger() helper, it's a bit easier now to convert the probe of the AD7793 driver to use device-managed functions. Only the regulator disable requires a devm_add_action_or_reset() callback. This change does that, cleaning up the driver a bit. Signed-off-by: Alexandru Ardelean <aardelean@deviqon.com> Link: https://lore.kernel.org/r/20210513120752.90074-7-aardelean@deviqon.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-06-13iio: adc: ad_sigma_delta: introduct devm_ad_sd_setup_buffer_and_trigger()Alexandru Ardelean1-0/+60
This is a version of ad_sd_setup_buffer_and_trigger() with all underlying functions (that are used) being replaced with their device-managed variants. One thing to take care here is with {devm_}iio_trigger_alloc(), where both functions take a parent-device object as the first parameter. To make sure nothing quirky is happening, the devm_ad_sd_probe_trigger() function is checking that the provided 'dev' reference is the same as the one stored on the 'struct ad_sigma_delta' driver data. Signed-off-by: Alexandru Ardelean <aardelean@deviqon.com> Link: https://lore.kernel.org/r/20210513120752.90074-6-aardelean@deviqon.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-06-09Merge tag 'iio-for-5.14a' of https://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio into staging-nextGreg Kroah-Hartman33-275/+997
Jonathan writes: 1st set of new IIO/counter device support, features and cleanup for 5.14 There are a couple of large cleanup sets in here alongside a number of new drivers. Note an immutable branch merged to add a stub for i2c_verify_client() as needed to avoid a build issue in the fxls8962af driver as a result of a workaround for a device errata that only applies when i2c interface is used. Counters ======== New device support * intel,quadrature encoder peripheral found on Elkhart Lake platforms. - New driver. IIO === New device support * amstaos,tsl2591 ambient light sensor. - New driver + bindings - Follow up fix to ensure some local variables are suitable for error handling. * fsl,fxls8962af + fsl,fxls8964af accelerometers - New driver + bindings - Includes an errata work around that cause a build bot failure fixed by adding a stub to i2c. * kionix,kxcjk-1013 - Add support for KX023-1025 device. Mostly a different register map that needed to be supported. * murata,sca3300 accelerometer - New driver + bindings * st,lsm9ds0 IMU - Rework of st,sensors driver to cleanly support this new glue driver that enables the two parts of the LSM9DS0. * ti,tsc2046 touchscreen controller ADC. - New driver. Intent here is to use this with existing IIO consumer drivers such as resistive-adc-touch. - Follow up fix to avoid an issue with unsigned subtraction in error check. * ti,tmp117 digital temperature sensor - New driver + bindings Features * adi,ad5755 - Add missing dt-binding doc * adi,ad7298 - Add ACPI ID used on Intel Galileo Gen 1 boards. - Add missing dt-binding doc * adi,ad7476 - Add missing dt-binding doc * adi,ad7746 - Add missing dt-binding doc for this driver that will hopefully move out of staging shortly. Update staging driver to use the binding instead of platform data. * adi,adis16201 + adis16209 - Add missing dt-binding doc * adi,adis16480 - Support burst mode for adis16495 and adis16497 parts. * bosch,bma220 - Add missing dt-binding doc * fsl,mma7455 - Add missing dt-binding doc * iio-rescale - Support handling of processed channels from provider. Some ADCs require (typically non linear) calibration functions to be applied, and so provide only IIO_CHAN_INFO_PROCESSED read back. They can be used as providers to the iio-rescale driver which needs to handle them somewhat differently from IIO_CHAN_INFO_RAW * sensiron,sps30 - Support the serial interface. Note this required significant refactoring of existing driver. * st,st-sensors - Add mount matrix support for normal dt-binding whilst continuing to support the odd ACPI approach for accelerometers. * ti,dac082s085 + similar - Add missing dt-binding doc * trivial-devices - add entries for - memsic,mx4005, memsic,mx6255 and memsic,mxc6655 - sensortek,stk8312 and sensortek,stk8ba50 Cleanup / minor fixes * core - Use devm_add_action_or_reset() to replace boilerplate in several driver and core IIO devm_* functions. - Fix an error path issue introduced by above, that could return an error pointer rather than the expected null from dev_iio_device_alloc() - Move more IIO internals related fields from struct iio_dev to struct iio_dev_opaque. - Drop unused final update of in_loc in demux setup. * Docs - Move some docs from driver specific to core dos to avoid replication of names which the documentation builder does not allow. Note this means adding a few device specific notes to the general docs to cover the more unusual uses of the ABI. - ABI: Move old buffer/* and scan_elements/* docs to obsolete as now we have the bufferX/* variant. Not we are not getting rid of these interfaces, just encouraging new code to use the new interface. * IIO wide: - Tidy up new cases of dev.parent etc being set in drivers as the core now does it. - Fix more cases of possible miss-aligned buffers when passed to iio_push_to_buffers_with_timestamp(). Note we only have one known instance of anyone seeing this bug actually happening, so this has been a low priority cleanup effort for several cycles. - sysfs_emit() used in more drivers. - Runtime pm tidy up and use of pm_runtime_resume_and_get() - Buffer alignment fixes as iio_push_to_buffers_with_timestamp requires that the timestamp when inserted by naturally aligned + consumers can assume that all fields are naturally aligned. Part of a long running effort, with at least 2 more series to come tackling additional variants. - Stop specifying "mount-matrix" property name in every lookup of the mount matrix from firmware by hard coding it in the core. * adi,ad7476 - Handle the variety of different regulators used by the parts supported by this driver (came up in dt-binding review) * adi,ad7746 - Trivial drop of if (ret) return ret; return 0; pattern - Tidy up comments - Pull capdac setup out to own function. * adi,ad7766 - Trivial drop of if (ret) return ret; return 0; pattern * adi,adis - Avoid returning error codes in interrupt handlers. - Handle a failure in spi_write in the trigger handler. - Rework to add updating of device page after changing it. - Don't push data to IIO buffers when read failed. - Add configuration of burst max speed to core avoid handling this in each driver. - Use the adis_dev_lock() helper in adis16260 and adis16136 drivers. - Excessive includes cleanup via include-what-you-use static checker after zero day highlighted that these needed updating. * afe - Amend binding to add #io-channel-cells, thus allowing this IIO consumer to also be an IIO provider. * aosong,am2315 - Drop ACPI id. Unlikely this one is in the wild and it isn't valid ACPI naming. * bosch,bma180 - Adding missing bandwidth settings (500, 1000 Hz) * bosch,bme680 - Drop ACPI id. Unlikely this one is in the wild and it isn't valid ACPI naming. * ep93xx_adc, - Drop a redundant error print. * maxim,max118 - Convert remainder of probe() to devm_ managed functions. - Avoid some repeated jumping back and forth between iio_dev and spi structures. * maxim,max11100 - Use get_unaligned_be16() instead of open coding. - Convert remainder of probe() to devm_ managed functions. * samsung,exynos_adc - Unused error value dropped. * sensiron,sgp30 - Drop use of %hx in favor of %x and letting the normal type conversion work. * sensortek,stk8312 - Add lowercase device id and note uppercase version deprecated. - Drop ACPI id. Unlikely this one is in the wild and it isn't valid ACPI naming. * sprx,sc72xx_adc - add MODULE_DEVICE_TABLE * st,lsm6dsx - Fix docs of valid ODRs * st,sensors - dt-binding rework. Two efforts on this crossed in a previous cycle so this update cherry picks the best of the two yaml conversions. - Don't copy the channel spec array as now ext_info is no longer modified. * st,stm32-adc - tidy up some docs that were marked as kernel-doc but aren't. * ti,adc081c, ti,adc0832, ti,adc108s102 and ti,adc161s626 - Convert remainder of probe() functions to devm_ managed functions to simplify error handing and remove paths. * tag 'iio-for-5.14a' of https://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio: (171 commits) i2c: core: Add stub for i2c_verify_client() if !CONFIG_I2C iio: adis: Cleanout unused headers iio: accel: bma180: Add missing 500 Hz / 1000 Hz bandwidth counter: Add support for Intel Quadrature Encoder Peripheral staging: iio: cdc: ad7746: extract capac setup to own function staging: iio: cdc: ad7746: clean up probe return staging: iio: cdc: ad7746: remove ordinary comments iio: adc: ti-adc161s626: Use devm managed functions for all of probe. iio: adc: ti-adc108s102: Use devm managed functions for all of probe() iio: adc: ti-adc0832: Use devm managed functions for all of probe() iio: adc: ti-adc081c: Use devm managed functions for all of probe() iio: adc: max1118: Avoid jumping back and forth between spi and iio structures iio: adc: max1118: Use devm_ managed functions for all of probe iio: adc: max11100: Use devm_ functions for rest of probe() iio: adc: max11100: Use get_unaligned_be16() rather than opencoding. iio: chemical: sgp30: Drop use of %hx in format string. iio: gyro: st_gyro: Support mount matrix iio: magnetometer: st_magn: Support mount matrix iio: accel: st_sensors: Stop copying channels iio: accel: st_sensors: Support generic mounting matrix ...
2021-06-03iio: adc: ti-adc161s626: Use devm managed functions for all of probe.Jonathan Cameron1-33/+18
Simplifies error handling and allows us to drop remove entirely. The regulator handling in this driver was unusual as it would try to acquire the regulator, but if that failed with an error would continue. We should get a stub regulator if one isn't provided in DT and an error could indicate an actual problem preventing the device being powered (perhaps a need to defer). So this handling is cleaned up (arguably that might be a fix but given no one has run into it, I haven't broken it out separately. Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> Cc: Matt Ranostay <matt.ranostay@konsulko.com> Acked-by: Matt Ranostay <matt.ranostay@konsulko.com> Reviewed-by: Alexandru Ardelean <aardelean@deviqon.com> Link: https://lore.kernel.org/r/20210516172520.1398835-9-jic23@kernel.org
2021-06-03iio: adc: ti-adc108s102: Use devm managed functions for all of probe()Jonathan Cameron1-30/+15
Simplifies error handling and lets us drop remove() entirely. Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> Cc: Bogdan Pricop <bogdan.pricop@emutex.com> Reviewed-by: Alexandru Ardelean <aardelean@deviqon.com> Link: https://lore.kernel.org/r/20210516172520.1398835-8-jic23@kernel.org
2021-06-03iio: adc: ti-adc0832: Use devm managed functions for all of probe()Jonathan Cameron1-27/+12
Simplifies error handling, plus allows us to drop the remove() function entirely. Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> Cc: Akinobu Mita <akinobu.mita@gmail.com> Reviewed-by: Alexandru Ardelean <aardelean@deviqon.com> Link: https://lore.kernel.org/r/20210516172520.1398835-7-jic23@kernel.org
2021-06-03iio: adc: ti-adc081c: Use devm managed functions for all of probe()Jonathan Cameron1-29/+14
Simplifies error handling and allows us to drop remove() entirely. Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> Reviewed-by: Alexandru Ardelean <aardelean@deviqon.com> Link: https://lore.kernel.org/r/20210516172520.1398835-6-jic23@kernel.org
2021-06-03iio: adc: max1118: Avoid jumping back and forth between spi and iio structuresJonathan Cameron1-13/+9
Changing from passing the spi structure into various functions to passing struct iio_dev avoids use of spi_get_drvdata and lets us stop setting that at all. Previous code was unnecessarily complex. Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> Reviewed-by: Alexandru Ardelean <aardelean@deviqon.com> Link: https://lore.kernel.org/r/20210516172520.1398835-5-jic23@kernel.org
2021-06-03iio: adc: max1118: Use devm_ managed functions for all of probeJonathan Cameron1-31/+15
This simplifies error handling and allows us to drop the remove function entirely. Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> Cc: Akinobu Mita <akinobu.mita@gmail.com> Reviewed-by: Alexandru Ardelean <aardelean@deviqon.com> Link: https://lore.kernel.org/r/20210516172520.1398835-4-jic23@kernel.org
2021-06-03iio: adc: max11100: Use devm_ functions for rest of probe()Jonathan Cameron1-22/+9
By using devm_add_action_or_reset() to manage the regulator disable, it becomes simple to use managed functions for all of remove. This simplifies error handling and allows us to drop the remove() function entirely. Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> Cc: Jacopo Mondi <jacopo@jmondi.org> Reviewed-by: Alexandru Ardelean <aardelean@deviqon.com> Link: https://lore.kernel.org/r/20210516172520.1398835-3-jic23@kernel.org
2021-06-03iio: adc: max11100: Use get_unaligned_be16() rather than opencoding.Jonathan Cameron1-1/+2
The function is more explicit in showing the intent + quicker on some platforms. Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> Cc: Jacopo Mondi <jacopo@jmondi.org> Reviewed-by: Alexandru Ardelean <aardelean@deviqon.com> Link: https://lore.kernel.org/r/20210516172520.1398835-2-jic23@kernel.org
2021-06-03iio: adc: tsc2046: fix a warning message in tsc2046_adc_update_scan_mode()Dan Carpenter1-1/+1
These variables are unsigned so the condition can't be less than zero and the warning message will never be printed. Fixes: 9374e8f5a38d ("iio: adc: add ADC driver for the TI TSC2046 controller") Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com> Link: https://lore.kernel.org/r/YJ+ZuO43TnguY5vq@mwanda Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-05-22iio: adc: ad7793: Add missing error code in ad7793_setup()YueHaibing1-0/+1
Set error code while device ID query failed. Fixes: 88bc30548aae ("IIO: ADC: New driver for AD7792/AD7793 3 Channel SPI ADC") Signed-off-by: YueHaibing <yuehaibing@huawei.com> Cc: <Stable@vger.kernel.org> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-05-22iio: adc: ad7923: Fix undersized rx buffer.Jonathan Cameron1-1/+3
Fixes tag is where the max channels became 8, but timestamp space was missing before that. Fixes: 851644a60d20 ("iio: adc: ad7923: Add support for the ad7908/ad7918/ad7928") Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> Cc: Daniel Junho <djunho@gmail.com> Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com> Link: https://lore.kernel.org/r/20210501165314.511954-3-jic23@kernel.org Cc: <Stable@vger.kernel.org>
2021-05-22iio: adc: ad7768-1: Fix too small buffer passed to iio_push_to_buffers_with_timestamp()Jonathan Cameron1-2/+6
Add space for the timestamp to be inserted. Also ensure correct alignment for passing to iio_push_to_buffers_with_timestamp() Fixes: a5f8c7da3dbe ("iio: adc: Add AD7768-1 ADC basic support") Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com> Link: https://lore.kernel.org/r/20210501165314.511954-2-jic23@kernel.org Cc: <Stable@vger.kernel.org>
2021-05-17iio:adc:ad7766: Fix unnecessary check in ad7766_probe()Tang Bin1-4/+1
In the function ad7766_probe(), the return value of devm_iio_device_register() can be zero or ret, Thus it is unnecessary to repeated check here. Signed-off-by: Tang Bin <tangbin@cmss.chinamobile.com> Signed-off-by: Zhang Shengju <zhangshengju@cmss.chinamobile.com> Co-developed-by: Zhang Shengju <zhangshengju@cmss.chinamobile.com> Link: https://lore.kernel.org/r/20210511134739.948-1-tangbin@cmss.chinamobile.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-05-17iio: adc: vf610: Fix buffer alignment in iio_push_to_buffers_with_timestamp()Jonathan Cameron1-3/+7
To make code more readable, use a structure to express the channel layout and ensure the timestamp is 8 byte aligned. Found during an audit of all calls of uses of iio_push_to_buffers_with_timestamp() Fixes: 0010d6b44406 ("iio: adc: vf610: Add IIO buffer support for Vybrid ADC") Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> Cc: Stefan-Gabriel Mirea <stefan-gabriel.mirea@nxp.com> Cc: Sanchayan Maity <maitysanchayan@gmail.com> Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com> Link: https://lore.kernel.org/r/20210501170121.512209-10-jic23@kernel.org
2021-05-17iio: adc: ti-ads1015: Fix buffer alignment in iio_push_to_buffers_with_timestamp()Jonathan Cameron1-4/+8
To make code more readable, use a structure to express the channel layout and ensure the timestamp is 8 byte aligned. Found during an audit of all calls of this function. Fixes: ecc24e72f437 ("iio: adc: Add TI ADS1015 ADC driver support") Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> Cc: Daniel Baluta <daniel.baluta@nxp.com> Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com> Link: https://lore.kernel.org/r/20210501170121.512209-9-jic23@kernel.org
2021-05-17iio: adc: rcar-gyroadc: Use pm_runtime_resume_and_get() and check in probe()Jonathan Cameron1-8/+7
1 instance found using coccicheck script under review at: https://lore.kernel.org/lkml/20210427141946.2478411-1-Julia.Lawall@inria.fr/ The other instance changed did not check for failure of the pm_runtime_get_sync() so that is added. Note the remaining pm_runtime_get_sync() call is left alone because it is not obvious what to do on failure to power up in remove() 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: Marek Vasut <marek.vasut@gmail.com> Reviewed-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org> Link: https://lore.kernel.org/r/20210509113354.660190-29-jic23@kernel.org