iio: add new backend framework
Subsystems (6)
Nuno Sa
maintainerv9 cover iio: add new backend framework
v2:
https://lore.kernel.org/r/[email protected]
v3:
https://lore.kernel.org/linux-iio/[email protected]/
v4:
https://lore.kernel.org/r/[email protected]
v5:
https://lore.kernel.org/r/[email protected]
v6:
https://lore.kernel.org/r/[email protected]
v7
https://lore.kernel.org/r/[email protected]
v8:
https://lore.kernel.org/r/[email protected]
Changes in v9:
- Patch 2
* io-backends-cells > io-backend-cells in both the property and example;
* Add proper ':' termination.
- Patch 5
* Adapted Copyright (2024 included);
* Added missing headers;
* Changed log pr_* to dev_*;
* Allocate first struct iio_backend_buffer_pair and error out in failure
(before we could be left with a buffer and not freeing it);
* Fixed io-backends-names > io-backend-names;
* Reworked getting the index when 'name' is given as suggested by Andy.
* Turned dev_dbg() -> dev_err() after fwnode_find_reference() as
the optional get was dropped; * Used cleanup.h everywhere for consistency.
Jonathan, the series is based on next-20240202 since it already includes the io-channels fix Rob applied in his tree. I guess it should land in rc3 so after you rebase, all patches should apply cleanly (if applying them of course :)). Let me know if anything fails...
(also dropped the devlink Reviewers from the Cc list as that patch was dropped).
Keeping the block diagram so we don't have to follow links to check one of the typical setups.
------------------------------------------------------- ------------------ | ----------- ------------ ------- FPGA | | ADC |------------------------| | AXI ADC |---------| DMA CORE |------| RAM | | | (Frontend/IIO) | Serial Data (eg: LVDS) | |(backend)|---------| |------| | | | |------------------------| ----------- ------------ ------- | ------------------ -------------------------------------------------------
---
Nuno Sa (6):
dt-bindings: adc: ad9467: add new io-backend property
dt-bindings: adc: axi-adc: update bindings for backend framework
iio: buffer-dmaengine: export buffer alloc and free functions
iio: add the IIO backend framework
iio: adc: ad9467: convert to backend framework
iio: adc: adi-axi-adc: move to backend framework
Olivier Moysan (1):
of: property: add device link support for io-backends
.../devicetree/bindings/iio/adc/adi,ad9467.yaml | 4 + .../devicetree/bindings/iio/adc/adi,axi-adc.yaml | 8 +- MAINTAINERS | 8 + drivers/iio/Kconfig | 9 + drivers/iio/Makefile | 1 + drivers/iio/adc/Kconfig | 4 +- drivers/iio/adc/ad9467.c | 268 ++++++++----- drivers/iio/adc/adi-axi-adc.c | 379 +++++-------------- drivers/iio/buffer/industrialio-buffer-dmaengine.c | 8 +- drivers/iio/industrialio-backend.c | 414 +++++++++++++++++++++ drivers/of/property.c | 2 + include/linux/iio/adc/adi-axi-adc.h | 68 ---- include/linux/iio/backend.h | 72 ++++ include/linux/iio/buffer-dmaengine.h | 3 + 14 files changed, 795 insertions(+), 453 deletions(-)
---
base-commit: 076d56d74f17e625b3d63cf4743b3d7d02180379
change-id: 20231219-iio-backend-a3dc1a6a7a58 --
Thanks!
- Nuno Sá
Nuno Sa
maintainerPATCH v9 1/7 dt-bindings: adc: ad9467: add new io-backend property
The ad9467 will make use of the new IIO backend framework which is a provider - consumer interface where IIO backends provide services to consumers. As such, and being this device a consumer, add the new generic io-backend property to the bindings.
--- Documentation/devicetree/bindings/iio/adc/adi,ad9467.yaml | 4 ++++ 1 file changed, 4 insertions(+)
Documentation/devicetree/bindings/iio/adc/adi,ad9467.yaml +4 -0
@@ -44,6 +44,9 @@ properties: Pin that controls the powerdown mode of the device. maxItems: 1 + io-backends: + maxItems: 1 + reset-gpios: description: Reset pin for the device.
@@ -68,6 +71,7 @@ examples: reg = <0>; clocks = <&adc_clk>; clock-names = "adc-clk"; + io-backends = <&iio_backend>; }; }; ...
Signature · 1 line
2.43.0
Nuno Sa
maintainerPATCH v9 2/7 dt-bindings: adc: axi-adc: update bindings for backend framework
In reply to Nuno Sa'adi,adc-dev' is now deprecated and must not be used anymore. Hence, also remove it from being required.
The reason why it's being deprecated is because the axi-adc CORE is now an IIO service provider hardware (IIO backends) for consumers to make use of. Before, the logic with 'adi,adc-dev' was the opposite (it was kind of consumer referencing other nodes/devices) and that proved to be wrong and to not scale.
Now, IIO consumers of this hardware are expected to reference it using the io-backends property. Hence, the new '#io-backend-cells' is being added so the device is easily identified as a provider.
--- Documentation/devicetree/bindings/iio/adc/adi,axi-adc.yaml | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
Documentation/devicetree/bindings/iio/adc/adi,axi-adc.yaml +5 -3
@@ -39,12 +39,15 @@ properties: $ref: /schemas/types.yaml#/definitions/phandle description: A reference to a the actual ADC to which this FPGA ADC interfaces to. + deprecated: true + + '#io-backend-cells': + const: 0 required: - compatible - dmas - reg - - adi,adc-dev additionalProperties: false
@@ -55,7 +58,6 @@ examples: reg = <0x44a00000 0x10000>; dmas = <&rx_dma 0>; dma-names = "rx"; - - adi,adc-dev = <&spi_adc>; + #io-backend-cells = <0>; }; ...
Signature · 1 line
2.43.0
Nuno Sa
maintainerPATCH v9 3/7 of: property: add device link support for io-backends
In reply to Nuno SaFrom: Olivier Moysan <[email protected]>
Add support for creating device links out of more DT properties.
--- drivers/of/property.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/of/property.c +2 -0
@@ -1245,6 +1245,7 @@ DEFINE_SIMPLE_PROP(interconnects, "interconnects", "#interconnect-cells") DEFINE_SIMPLE_PROP(iommus, "iommus", "#iommu-cells") DEFINE_SIMPLE_PROP(mboxes, "mboxes", "#mbox-cells") DEFINE_SIMPLE_PROP(io_channels, "io-channels", "#io-channel-cells") +DEFINE_SIMPLE_PROP(io_backends, "io-backends", "#io-backend-cells") DEFINE_SIMPLE_PROP(interrupt_parent, "interrupt-parent", NULL) DEFINE_SIMPLE_PROP(dmas, "dmas", "#dma-cells")DEFINE_SIMPLE_PROP (power_domains,"power-domains" ,"#power-domain-cells" )
@@ -1335,6 +1336,7 @@ static const struct supplier_bindings of_supplier_bindings[] = { { .parse_prop = parse_iommu_maps, .optional = true, }, { .parse_prop = parse_mboxes, }, { .parse_prop = parse_io_channels, }, + { .parse_prop = parse_io_backends, }, { .parse_prop = parse_interrupt_parent, }, { .parse_prop = parse_dmas, .optional = true, }, { .parse_prop = parse_power_domains, },
Signature · 1 line
2.43.0
Nuno Sa
maintainerPATCH v9 4/7 iio: buffer-dmaengine: export buffer alloc and free functions
In reply to Nuno SaExport iio_dmaengine_buffer_free() and iio_dmaengine_buffer_alloc(). This is in preparation of introducing IIO backends support. This will allow us to allocate a buffer and control it's lifetime from a device different from the one holding the DMA firmware properties. Effectively, in this case the struct device holding the firmware information about the DMA channels is not the same as iio_dev->dev.parent (typical case).
While at it, namespace the buffer-dmaengine exports and update the current user of these buffers.
--- drivers/iio/adc/adi-axi-adc.c | 1 + drivers/iio/buffer/industrialio-buffer-dmaengine.c | 8 +++++--- include/linux/iio/buffer-dmaengine.h | 3 +++ 3 files changed, 9 insertions(+), 3 deletions(-)
drivers/iio/adc/adi-axi-adc.c +1 -0
@@ -447,3 +447,4 @@ module_platform_driver(adi_axi_adc_driver);MODULE_AUTHOR ("Michael Hennerich <[email protected]>" );MODULE_DESCRIPTION ("Analog Devices Generic AXI ADC IP core driver" );MODULE_LICENSE ("GPL v2" ); +MODULE_IMPORT_NS (IIO_DMAENGINE_BUFFER );
drivers/iio/buffer/industrialio-buffer-dmaengine.c +5 -3
@@ -159,7 +159,7 @@ static const struct iio_dev_attr *iio_dmaengine_buffer_attrs[] = {* Once done using the buffer iio_dmaengine_buffer_free() should be used to * release it. */ -static struct iio_buffer *iio_dmaengine_buffer_alloc (struct device *dev, +struct iio_buffer *iio_dmaengine_buffer_alloc (struct device *dev,const char *channel) {struct dmaengine_buffer *dmaengine_buffer;
@@ -210,6 +210,7 @@ static struct iio_buffer *iio_dmaengine_buffer_alloc(struct device *dev,kfree (dmaengine_buffer);return ERR_PTR (ret); } +EXPORT_SYMBOL_NS_GPL (iio_dmaengine_buffer_alloc,IIO_DMAENGINE_BUFFER );/** * iio_dmaengine_buffer_free() - Free dmaengine buffer
@@ -217,7 +218,7 @@ static struct iio_buffer *iio_dmaengine_buffer_alloc(struct device *dev,* * Frees a buffer previously allocated with iio_dmaengine_buffer_alloc(). */ -static void iio_dmaengine_buffer_free (struct iio_buffer *buffer) +void iio_dmaengine_buffer_free (struct iio_buffer *buffer) {struct dmaengine_buffer *dmaengine_buffer =iio_buffer_to_dmaengine_buffer (buffer);
@@ -227,6 +228,7 @@ static void iio_dmaengine_buffer_free(struct iio_buffer *buffer)iio_buffer_put (buffer); } +EXPORT_SYMBOL_NS_GPL (iio_dmaengine_buffer_free,IIO_DMAENGINE_BUFFER );static void __devm_iio_dmaengine_buffer_free (void *buffer) {
@@ -287,7 +289,7 @@ int devm_iio_dmaengine_buffer_setup(struct device *dev,return iio_device_attach_buffer (indio_dev, buffer); } -EXPORT_SYMBOL_GPL (devm_iio_dmaengine_buffer_setup); +EXPORT_SYMBOL_NS_GPL (devm_iio_dmaengine_buffer_setup,IIO_DMAENGINE_BUFFER );MODULE_AUTHOR ("Lars-Peter Clausen <[email protected]>" );MODULE_DESCRIPTION ("DMA buffer for the IIO framework" );
include/linux/iio/buffer-dmaengine.h +3 -0
@@ -10,6 +10,9 @@struct iio_dev ;struct device ; +struct iio_buffer *iio_dmaengine_buffer_alloc (struct device *dev, +const char *channel); +void iio_dmaengine_buffer_free (struct iio_buffer *buffer);int devm_iio_dmaengine_buffer_setup (struct device *dev,struct iio_dev *indio_dev,const char *channel);
Signature · 1 line
2.43.0
Nuno Sa
maintainerPATCH v9 5/7 iio: add the IIO backend framework
In reply to Nuno SaThis is a Framework to handle complex IIO aggregate devices.
The typical architecture is to have one device as the frontend device which can be "linked" against one or multiple backend devices. All the IIO and userspace interface is expected to be registers/managed by the frontend device which will callback into the backends when needed (to get/set some configuration that it does not directly control).
The basic framework interface is pretty simple:
- Backends should register themselves with @devm_iio_backend_register()
- Frontend devices should get backends with @devm_iio_backend_get()
--- MAINTAINERS | 8 + drivers/iio/Kconfig | 9 + drivers/iio/Makefile | 1 + drivers/iio/industrialio-backend.c | 414 +++++++++++++++++++++++++++++++++++++ include/linux/iio/backend.h | 72 +++++++ 5 files changed, 504 insertions(+)
MAINTAINERS +8 -0
@@ -10403,6 +10403,14 @@ L: [email protected] S: Maintained F: drivers/media/rc/iguanair.c +IIO BACKEND FRAMEWORK +M: Nuno Sa <[email protected]> +R: Olivier Moysan <[email protected]> +L: [email protected] +S: Maintained +F: drivers/iio/industrialio-backend.c +F: include/linux/iio/backend.h + IIO DIGITAL POTENTIOMETER DAC M: Peter Rosin <[email protected]> L: [email protected]
drivers/iio/Kconfig +9 -0
@@ -71,6 +71,15 @@ config IIO_TRIGGERED_EVENT help Provides helper functions for setting up triggered events. +config IIO_BACKEND + tristate + help + Framework to handle complex IIO aggregate devices. The typical + architecture that can make use of this framework is to have one + device as the frontend device which can be "linked" against one or + multiple backend devices. The framework then makes it easy to get + and control such backend devices. + source "drivers/iio/accel/Kconfig" source "drivers/iio/adc/Kconfig" source "drivers/iio/addac/Kconfig"
drivers/iio/Makefile +1 -0
@@ -13,6 +13,7 @@ obj-$(CONFIG_IIO_GTS_HELPER) += industrialio-gts-helper.o obj-$(CONFIG_IIO_SW_DEVICE) += industrialio-sw-device.o obj-$(CONFIG_IIO_SW_TRIGGER) += industrialio-sw-trigger.o obj-$(CONFIG_IIO_TRIGGERED_EVENT) += industrialio-triggered-event.o +obj-$(CONFIG_IIO_BACKEND) += industrialio-backend.o obj-y += accel/ obj-y += adc/
drivers/iio/industrialio-backend.c new file +414 -0
414 lines not on this page · raw message
include/linux/iio/backend.h new file +72 -0
72 lines not on this page · raw message
Signature · 1 line
2.43.0
Re: [PATCH v9 5/7] iio: add the IIO backend framework
Quoted 11 lines · On Tue, Feb 6, 2024 at 12:08 PM Nuno Sa via B4 Relay…
From: Nuno Sa <[email protected]>
This is a Framework to handle complex IIO aggregate devices.
The typical architecture is to have one device as the frontend device which can be "linked" against one or multiple backend devices. All the IIO and userspace interface is expected to be registers/managed by the frontend device which will callback into the backends when needed (to get/set some configuration that it does not directly control).
Quoted 3 lines
The basic framework interface is pretty simple:
- Backends should register themselves with @devm_iio_backend_register()
- Frontend devices should get backends with @devm_iio_backend_get()
Not sure what the meaning of @ in the above lines.
...
Quoted 5 lines
+/*
+ * Framework to handle complex IIO aggregate devices.
+ *
+ * The typical architecture is to have one device as the frontend device which
+ * can be "linked" against one or multiple backend devices.
Can we have an ASCII art with an example?
Quoted 19 lines
All the IIO and
+ * userspace interface is expected to be registers/managed by the frontend
+ * device which will callback into the backends when needed (to get/set some
+ * configuration that it does not directly control).
+ *
+ * The framework interface is pretty simple:
+ * - Backends should register themselves with @devm_iio_backend_register()
+ * - Frontend devices should get backends with @devm_iio_backend_get()
+ *
+ * Also to note that the primary target for this framework are converters like
+ * ADC/DACs so @iio_backend_ops will have some operations typical of converter
+ * devices. On top of that, this is "generic" for all IIO which means any kind
+ * of device can make use of the framework. That said, If the @iio_backend_ops
+ * struct begins to grow out of control, we can always refactor things so that
+ * theindustrialio-backend.cis only left with the really generic stuff. Then,
+ * we can build on top of it depending on the needs.
+ *
+ * Copyright (C) 2023-2024 Analog Devices Inc.
+ */
...
Quoted 2 lines
+/*
+ * Helper macros to call backend ops. Makes sure the option is supported
Missing period.
Quoted 1 line
+ */
...
Quoted 6 lines
+/**
+ *iio_backend_chan_enable- Enable a backend channel
+ * @back: Backend device
+ * @chan: Channel number
+ *
+ * RETURNS:
Not sure if this is the style used in other IIO core files...
Quoted 2 lines
+ * 0 on success, negative error number on failure.
+ */
...
drivers/iio/industrialio-backend.c line 247
Quoted 3 lines
drivers/iio/industrialio-backend.c new file +3
-0+if (!try_module_get (back->owner)) { +dev_err (dev,"Cannot get module reference\n" ); +return -ENODEV ;
devm_*() are supposed to be used only at ->probe() stage, hence dev_err_probe() is fine (and eventually would be nice to have for the sake of making messaging uniform).
Quoted 1 line
+ }
...
drivers/iio/industrialio-backend.c line 258
Quoted 5 lines
drivers/iio/industrialio-backend.c new file +5
-0+ link =device_link_add (dev, back->dev,DL_FLAG_AUTOREMOVE_CONSUMER ); +if (!link) { +dev_err (dev,"Could not link to supplier(%s)\n" , +dev_name (back->dev)); +return -EINVAL ;
Ditto.
Quoted 1 line
+ }
...
drivers/iio/industrialio-backend.c line 285
Quoted 3 lines
drivers/iio/industrialio-backend.c new file +3
-0+if (name) { + ret =device_property_match_string (dev,"io-backend-names" , + name);
One line?
Quoted 6 lines
drivers/iio/industrialio-backend.c new file +6
-0+if (ret <0 ) +return ERR_PTR (ret); + index = ret; + }else { + index =0 ; + }
...
drivers/iio/industrialio-backend.c line 296
Quoted 4 lines
drivers/iio/industrialio-backend.c new file +4
-0+ fwnode =fwnode_find_reference (dev_fwnode (dev),"io-backends" , index); +if (IS_ERR (fwnode)) { +dev_err (dev,"Cannot get Firmware reference\n" ); +return ERR_CAST (fwnode);
dev_err_probe() ?
Quoted 1 line
+ }
...
drivers/iio/industrialio-backend.c line 388
Quoted 3 lines
drivers/iio/industrialio-backend.c new file +3
-0+if (!ops) { +dev_err (dev,"No backend ops given\n" ); +return -EINVAL ;
dev_err_probe() ?
Quoted 1 line
+ }
Signature · 2 lines
With Best Regards, Andy Shevchenko
Re: [PATCH v9 5/7] iio: add the IIO backend framework
Quoted 13 lines · Andy Shevchenko
Quoted 11 lines · On Tue, Feb 6, 2024 at 12:08 PM Nuno Sa via B4 Relay…
From: Nuno Sa <[email protected]>
This is a Framework to handle complex IIO aggregate devices.
The typical architecture is to have one device as the frontend device which can be "linked" against one or multiple backend devices. All the IIO and userspace interface is expected to be registers/managed by the frontend device which will callback into the backends when needed (to get/set some configuration that it does not directly control).
Quoted 6 lines
Quoted 3 lines
The basic framework interface is pretty simple:
- Backends should register themselves with @devm_iio_backend_register()
- Frontend devices should get backends with @devm_iio_backend_get()Not sure what the meaning of @ in the above lines.
No special meaning...
Quoted 10 lines
...
Quoted 6 lines
+/*
+ * Framework to handle complex IIO aggregate devices.
+ *
+ * The typical architecture is to have one device as the frontend device which
+ * can be "linked" against one or multiple backend devices.Can we have an ASCII art with an example?
I do have one in the cover and spoke on the possibility of having it here but no one really expressed any interest on it. Personally, for now, I'm also not seeing it as *that* important.
Quoted 76 lines
Quoted 28 lines
All the IIO and
+ * userspace interface is expected to be registers/managed by the frontend
+ * device which will callback into the backends when needed (to get/set some
+ * configuration that it does not directly control).
+ *
+ * The framework interface is pretty simple:
+ * - Backends should register themselves with @devm_iio_backend_register()
+ * - Frontend devices should get backends with @devm_iio_backend_get()
+ *
+ * Also to note that the primary target for this framework are converters like
+ * ADC/DACs so @iio_backend_ops will have some operations typical of converter
+ * devices. On top of that, this is "generic" for all IIO which means any kind
+ * of device can make use of the framework. That said, If the @iio_backend_ops
+ * struct begins to grow out of control, we can always refactor things so that
+ * theindustrialio-backend.cis only left with the really generic stuff. Then,
+ * we can build on top of it depending on the needs.
+ *
+ * Copyright (C) 2023-2024 Analog Devices Inc.
+ */...
Quoted 2 lines
+/*
+ * Helper macros to call backend ops. Makes sure the option is supportedMissing period.
Quoted 1 line
+ */
...
Quoted 6 lines
+/**
+ *iio_backend_chan_enable- Enable a backend channel
+ * @back: Backend device
+ * @chan: Channel number
+ *
+ * RETURNS:Not sure if this is the style used in other IIO core files...
Quoted 2 lines
+ * 0 on success, negative error number on failure.
+ */...
Quoted 3 lines
+ if (!try_module_get(back->owner)) {
+dev_err(dev, "Cannot get module reference\n"); + return-ENODEV;devm_*() are supposed to be used only at ->probe() stage, hence
dev_err_probe()is fine (and eventually would be nice to have for the sake of making messaging uniform).Quoted 1 line
+ }
...
Quoted 5 lines
+ link =
device_link_add(dev, back->dev, DL_FLAG_AUTOREMOVE_CONSUMER); + if (!link) {
+ dev_err(dev, "Could not link to supplier(%s)\n", +dev_name(back->dev));
+ return-EINVAL;Ditto.
Quoted 1 line
+ }
Quoted 7 lines
...
Quoted 3 lines
+ if (name) {
+ ret = device_property_match_string(dev, "io-backend-names", + name);One line?
Would pass the 80 limit column. I would not mind at all to have the one liner but I'm playing by Jonathan's rules. Stick with that limit unless it hurts readability.
Quoted 20 lines
Quoted 7 lines
+ if (ret < 0)
+ returnERR_PTR(ret);
+ index = ret;
+ } else {
+ index = 0;
+ }...
Quoted 5 lines
+ fwnode =
fwnode_find_reference(dev_fwnode(dev), "io-backends", index);
+ if (IS_ERR(fwnode)) {
+dev_err(dev, "Cannot get Firmware reference\n"); + returnERR_CAST(fwnode);
dev_err_probe()?Quoted 1 line
+ }
Quoted 7 lines
...
Quoted 3 lines
+ if (!ops) {
+dev_err(dev, "No backend ops given\n"); + return-EINVAL;
dev_err_probe()?
Yeah, I can switch to that as on top of being devm APIs, these APIs are really intended to be called during probe().
- Nuno Sá
Nuno Sa
maintainerPATCH v9 6/7 iio: adc: ad9467: convert to backend framework
In reply to Nuno SaConvert the driver to use the new IIO backend framework. The device functionality is expected to be the same (meaning no added or removed features).
Also note this patch effectively breaks ABI and that's needed so we can properly support this device and add needed features making use of the new IIO framework.
Giving the lack of features (and devices supported) in the ad9467 driver compared with the ADI out of tree version, we don't expect any user of the upstream driver so no one should notice the ABI breakage. However, if someone is affected by this, ADI will happily support in transitioning to the backend framework.
--- drivers/iio/adc/Kconfig | 2 +- drivers/iio/adc/ad9467.c | 268 +++++++++++++++++++++++++++++++---------------- 2 files changed, 179 insertions(+), 91 deletions(-)
drivers/iio/adc/Kconfig +1 -1
@@ -307,7 +307,7 @@ config AD799X config AD9467 tristate "Analog Devices AD9467 High Speed ADC driver" depends on SPI - depends on ADI_AXI_ADC + select IIO_BACKEND help Say yes here to build support for Analog Devices: * AD9467 16-Bit, 200 MSPS/250 MSPS Analog-to-Digital Converter
drivers/iio/adc/ad9467.c +178 -90
444 lines not on this page · raw message
Signature · 1 line
2.43.0
Re: [PATCH v9 6/7] iio: adc: ad9467: convert to backend framework
Quoted 7 lines · On Tue, Feb 6, 2024 at 12:08 PM Nuno Sa via B4 Relay…
From: Nuno Sa <[email protected]>
Convert the driver to use the new IIO backend framework. The device functionality is expected to be the same (meaning no added or removed features).
Quoted 5 lines
Also note this patch effectively breaks ABI and that's needed so we can properly support this device and add needed features making use of the new IIO framework.
Giving the lack of features (and devices supported) in the ad9467 driver
Given
Quoted 3 lines
compared with the ADI out of tree version, we don't expect any user of the upstream driver so no one should notice the ABI breakage. However, if someone is affected by this, ADI will happily support in transitioning
support transitioning
Quoted 1 line
to the backend framework.
...
Quoted 5 lines
drivers/iio/adc/ad9467.c +0
-3- .max_rate = 250000000UL, - .max_rate = 500000000UL, - .max_rate = 125000000UL,
...
Quoted 4 lines
drivers/iio/adc/ad9467.c +4
-0+static int ad9467_update_scan_mode (struct iio_dev *indio_dev, +const unsigned long *scan_mask) +{ +struct ad9467_state *st =iio_priv (indio_dev);
drivers/iio/adc/ad9467.c static int ad9467_read_avail(struct adi_axi_adc_conv *conv, · line 399
Quoted 10 lines
drivers/iio/adc/ad9467.c +9
-0+unsigned int c; +int ret; + +for (c =0 ; c < st->info->num_channels; c++) { +if (test_bit (c, scan_mask)) + ret =iio_backend_chan_enable (st->back, c); +else + ret =iio_backend_chan_disable (st->back, c); +
Unneeded blank line.
Quoted 6 lines
drivers/iio/adc/ad9467.c +6
-0+if (ret) +return ret; + } + +return 0 ; +}
....
drivers/iio/adc/ad9467.c static int ad9467_reset(struct device *dev) · line 494
Quoted 6 lines
drivers/iio/adc/ad9467.c +6
-0+ st->back =devm_iio_backend_get (&st->spi->dev,NULL ); +/* If not found, don't error out as we might have legacy DT property */ +if (!IS_ERR (st->back)) +return 0 ; +if (PTR_ERR (st->back) != -ENOENT ) +return PTR_ERR (st->back);
This looks hackish...
Perhaps
ret = PTR_ERR_OR_ZERO(st->back);
if (ret && ret == -ENOENT)
return _a_new_helper_with_below_code_you_have();return ret;
Signature · 2 lines
With Best Regards, Andy Shevchenko
Re: [PATCH v9 6/7] iio: adc: ad9467: convert to backend framework
Quoted 2 lines · Andy Shevchenko
On Tue, Feb 6, 2024 at 12:08 PM Nuno Sa via B4 Relay <[email protected]> wrote:
...
Quoted 5 lines
drivers/iio/adc/ad9467.c static const struct iio_chan_spec ad9467_channels[] = { · line 263
Quoted 5 lines
drivers/iio/adc/ad9467.c +0
-3- .max_rate = 250000000UL, - .max_rate = 500000000UL, - .max_rate = 125000000UL,
Forget to comment that these might be preliminary converted to use multipliers from units.h...
Signature · 2 lines
With Best Regards, Andy Shevchenko
Re: [PATCH v9 6/7] iio: adc: ad9467: convert to backend framework
Quoted 7 lines · Andy Shevchenko
Quoted 2 lines · Andy Shevchenko
On Tue, Feb 6, 2024 at 12:08 PM Nuno Sa via B4 Relay <[email protected]> wrote:
...
Quoted 9 lines
Quoted 5 lines
Quoted 5 lines
- .max_rate = 250000000UL,
- .max_rate = 500000000UL,
- .max_rate = 125000000UL,
Forget to comment that these might be preliminary converted to use multipliers from
units.h...
Note this is just a conversion and I want to change the least possible. I can do that in a follow up patch.
- Nuno Sá
Re: [PATCH v9 6/7] iio: adc: ad9467: convert to backend framework
Quoted 5 lines · Nuno Sá
Quoted 4 lines · Andy Shevchenko
Quoted 2 lines · Andy Shevchenko
On Tue, Feb 6, 2024 at 12:08 PM Nuno Sa via B4 Relay <[email protected]> wrote:
...
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 3 lines
drivers/iio/adc/ad9467.c +0
-2- .max_rate = 250000000UL, - .max_rate = 500000000UL,
Quoted 8 lines
Quoted 5 lines
Quoted 1 line
Quoted 1 line
- .max_rate = 125000000UL,
Forget to comment that these might be preliminary converted to use multipliers from
units.h...Note this is just a conversion and I want to change the least possible. I can do that in a follow up patch.
Yes, that's the idea.
Signature · 2 lines
With Best Regards, Andy Shevchenko
Re: [PATCH v9 6/7] iio: adc: ad9467: convert to backend framework
Quoted 19 lines · Andy Shevchenko
Quoted 5 lines · Nuno Sá
Quoted 4 lines · Andy Shevchenko
Quoted 2 lines · Andy Shevchenko
On Tue, Feb 6, 2024 at 12:08 PM Nuno Sa via B4 Relay <[email protected]> wrote:
...
Quoted 10 lines
Quoted 9 lines
Quoted 5 lines
Quoted 5 lines
- .max_rate = 250000000UL,
- .max_rate = 500000000UL,
- .max_rate = 125000000UL,
Forget to comment that these might be preliminary converted to use multipliers from
units.h...
Quoted 6 lines
Quoted 3 lines
Note this is just a conversion and I want to change the least possible. I can do that
in a follow up patch.Yes, that's the idea.
To be clear, what I meant is to send it after the series is applied. Not intending to include a new patch in the series :)
- Nuno Sá
Re: [PATCH v9 6/7] iio: adc: ad9467: convert to backend framework
In reply to Andy ShevchenkoQuoted 61 lines · Andy Shevchenko
Quoted 7 lines · On Tue, Feb 6, 2024 at 12:08 PM Nuno Sa via B4 Relay…
From: Nuno Sa <[email protected]>
Convert the driver to use the new IIO backend framework. The device functionality is expected to be the same (meaning no added or removed features).
Quoted 5 lines
Also note this patch effectively breaks ABI and that's needed so we can properly support this device and add needed features making use of the new IIO framework.
Giving the lack of features (and devices supported) in the ad9467 driver
Given
Quoted 3 lines
compared with the ADI out of tree version, we don't expect any user of the upstream driver so no one should notice the ABI breakage. However, if someone is affected by this, ADI will happily support in transitioning
support transitioning
Quoted 1 line
to the backend framework.
...
Quoted 5 lines
- .max_rate = 250000000UL,
- .max_rate = 500000000UL,
- .max_rate = 125000000UL,
...
Quoted 4 lines
drivers/iio/adc/ad9467.c +4
-0+static int ad9467_update_scan_mode (struct iio_dev *indio_dev, + const unsigned long *scan_mask) +{ + struct ad9467_state *st = iio_priv(indio_dev);drivers/iio/adc/ad9467.c static int ad9467_read_avail(struct adi_axi_adc_conv *conv, · line 399
Quoted 10 lines
drivers/iio/adc/ad9467.c +9
-0+ unsigned int c; + int ret; + + for (c = 0; c < st->info->num_channels; c++) { + if (test_bit(c, scan_mask)) + ret = iio_backend_chan_enable(st->back, c); + else + ret = iio_backend_chan_disable(st->back, c); +Unneeded blank line.
Quoted 6 lines
+ if (ret)
+ return ret;
+ }drivers/iio/adc/ad9467.c +3
-0+ + return 0; +}....
Quoted 9 lines
Quoted 6 lines
+
st->back=devm_iio_backend_get(&st->spi->dev, NULL);
+ /* If not found, don't error out as we might have legacy DT property */ + if (!IS_ERR(st->back))
+ return 0;
+ if (PTR_ERR(st->back)!=-ENOENT)
+ returnPTR_ERR(st->back);This looks hackish...
This was suggested by Jonathan so I'm keen in leaving it as-is
- Nuno Sá
Re: [PATCH v9 6/7] iio: adc: ad9467: convert to backend framework
Quoted 3 lines · Nuno Sá
Quoted 2 lines · Andy Shevchenko
On Tue, Feb 6, 2024 at 12:08 PM Nuno Sa via B4 Relay <[email protected]> wrote:
...
Quoted 10 lines
Quoted 8 lines
drivers/iio/adc/ad9467.c static int ad9467_reset(struct device *dev) · line 494
Quoted 6 lines
drivers/iio/adc/ad9467.c +6
-0+ st->back =devm_iio_backend_get (&st->spi->dev,NULL ); +/* If not found, don't error out as we might have legacy DT property */ +if (!IS_ERR (st->back)) +return 0 ; +if (PTR_ERR (st->back) != -ENOENT ) +return PTR_ERR (st->back);This looks hackish...
This was suggested by Jonathan so I'm keen in leaving it as-is
I think I proposed how to improve it. Jonathan?
Signature · 2 lines
With Best Regards, Andy Shevchenko
Re: [PATCH v9 6/7] iio: adc: ad9467: convert to backend framework
Quoted 15 lines · Andy Shevchenko
Quoted 3 lines · Nuno Sá
Quoted 2 lines · Andy Shevchenko
On Tue, Feb 6, 2024 at 12:08 PM Nuno Sa via B4 Relay <[email protected]> wrote:
...
Quoted 8 lines
Quoted 8 lines
Quoted 7 lines
+
st->back=devm_iio_backend_get(&st->spi->dev, NULL); + /* If not found, don't error out as we might have legacy DT property */
+ if (!IS_ERR(st->back))
+ return 0;
+ if (PTR_ERR(st->back)!=-ENOENT)
+ returnPTR_ERR(st->back);
Quoted 6 lines
Quoted 3 lines
Quoted 1 line
This looks hackish...
This was suggested by Jonathan so I'm keen in leaving it as-is
I think I proposed how to improve it. Jonathan?
Well, you did change it around so that we have the typical 'if (ret)' pattern. But, honestly, that is also bringing an arguably useless helper. So, yes, currently we are not doing the typical "check for errors first" pattern but I do think that the code is perfectly fine and readable as it is.
It's also already pretty late in the review process of the series and there was already some back and forth so to me, the above is really a minor detail and I'm not keen on changing it at this stage (unless Jonathan really feels strong about doing it).
I'll spin a v10 with your dev_err_probe() suggestion later today but at this point I would prefer to not have to spin another one (afterwards) unless really needed (meaning, not because of minor details).
- Nuno Sá
Jonathan Cameron
maintainerRe: [PATCH v9 6/7] iio: adc: ad9467: convert to backend framework
Quoted 28 lines · On Wed, 07 Feb 2024 10:23:36 +0100 Nuno Sá <[email protected]> wrote:
Quoted 15 lines · Andy Shevchenko
Quoted 3 lines · Nuno Sá
Quoted 2 lines · Andy Shevchenko
On Tue, Feb 6, 2024 at 12:08 PM Nuno Sa via B4 Relay <[email protected]> wrote:
...
Quoted 8 lines
Quoted 8 lines
Quoted 7 lines
+
st->back=devm_iio_backend_get(&st->spi->dev, NULL); + /* If not found, don't error out as we might have legacy DT property */
+ if (!IS_ERR(st->back))
+ return 0;
+ if (PTR_ERR(st->back)!=-ENOENT)
+ returnPTR_ERR(st->back);Quoted 6 lines
Quoted 3 lines
Quoted 1 line
This looks hackish...
This was suggested by Jonathan so I'm keen in leaving it as-is
I think I proposed how to improve it. Jonathan?
Well, you did change it around so that we have the typical 'if (ret)' pattern. But, honestly, that is also bringing an arguably useless helper. So, yes, currently we are not doing the typical "check for errors first" pattern but I do think that the code is perfectly fine and readable as it is.
Quoted 4 lines
It's also already pretty late in the review process of the series and there was already some back and forth so to me, the above is really a minor detail and I'm not keen on changing it at this stage (unless Jonathan really feels strong about doing it).
It's odd code I don't expect to see anywhere else, so I'm not that fussed if it takes a little more thinking than normal (and you have a comment there to help us!)
So I'm fine with leaving this as it stands
Jonathan
Quoted 6 lines
I'll spin a v10 with your
dev_err_probe()suggestion later today but at this point I would prefer to not have to spin another one (afterwards) unless really needed (meaning, not because of minor details).- Nuno Sá
Nuno Sa
maintainerPATCH v9 7/7 iio: adc: adi-axi-adc: move to backend framework
In reply to Nuno SaMove to the IIO backend framework. Devices supported by adi-axi-adc now register themselves as backend devices.
--- drivers/iio/adc/Kconfig | 2 +- drivers/iio/adc/adi-axi-adc.c | 378 +++++++++--------------------------- include/linux/iio/adc/adi-axi-adc.h | 68 ------- 3 files changed, 92 insertions(+), 356 deletions(-)
drivers/iio/adc/Kconfig +1 -1
@@ -325,7 +325,7 @@ config ADI_AXI_ADC select IIO_BUFFER_HW_CONSUMER select IIO_BUFFER_DMAENGINE select REGMAP_MMIO - depends on OF + select IIO_BACKEND help Say yes here to build support for Analog Devices Generic AXI ADC IP core. The IP core is used for interfacing with
drivers/iio/adc/adi-axi-adc.c +91 -287
489 lines not on this page · raw message
include/linux/iio/adc/adi-axi-adc.h deleted +0 -68
68 lines not on this page · raw message
Signature · 1 line
2.43.0