* [PATCH v4 01/11] MAINTAINERS: Add missing maintainer entry for AD8366 driver
2026-02-10 19:42 [PATCH v4 00/11] iio: amplifiers: ad8366: driver update and dt support Rodrigo Alencar via B4 Relay
@ 2026-02-10 19:42 ` Rodrigo Alencar via B4 Relay
2026-02-10 19:42 ` [PATCH v4 02/11] dt-bindings: iio: amplifiers: Add AD8366 support Rodrigo Alencar via B4 Relay
` (9 subsequent siblings)
10 siblings, 0 replies; 32+ messages in thread
From: Rodrigo Alencar via B4 Relay @ 2026-02-10 19:42 UTC (permalink / raw)
To: linux-kernel, linux-iio, devicetree
Cc: Michael Hennerich, Lars-Peter Clausen, Jonathan Cameron,
David Lechner, Andy Shevchenko, Rob Herring, Krzysztof Kozlowski,
Conor Dooley, Rodrigo Alencar
From: Rodrigo Alencar <rodrigo.alencar@analog.com>
Add maintainers entry for drivers/iio/amplifiers/ad8366.c
Signed-off-by: Rodrigo Alencar <rodrigo.alencar@analog.com>
---
MAINTAINERS | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/MAINTAINERS b/MAINTAINERS
index 1251965d70bd..ec9a6beb7619 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -1583,6 +1583,14 @@ W: https://ez.analog.com/linux-software-drivers
F: Documentation/devicetree/bindings/iio/adc/adi,ad7780.yaml
F: drivers/iio/adc/ad7780.c
+ANALOG DEVICES INC AD8366 DRIVER
+M: Michael Hennerich <Michael.Hennerich@analog.com>
+M: Rodrigo Alencar <rodrigo.alencar@analog.com>
+L: linux-iio@vger.kernel.org
+S: Supported
+W: https://ez.analog.com/linux-software-drivers
+F: drivers/iio/amplifiers/ad8366.c
+
ANALOG DEVICES INC AD9467 DRIVER
M: Michael Hennerich <Michael.Hennerich@analog.com>
M: Nuno Sa <nuno.sa@analog.com>
--
2.43.0
^ permalink raw reply related [flat|nested] 32+ messages in thread* [PATCH v4 02/11] dt-bindings: iio: amplifiers: Add AD8366 support
2026-02-10 19:42 [PATCH v4 00/11] iio: amplifiers: ad8366: driver update and dt support Rodrigo Alencar via B4 Relay
2026-02-10 19:42 ` [PATCH v4 01/11] MAINTAINERS: Add missing maintainer entry for AD8366 driver Rodrigo Alencar via B4 Relay
@ 2026-02-10 19:42 ` Rodrigo Alencar via B4 Relay
2026-02-10 19:42 ` [PATCH v4 03/11] iio: amplifiers: ad8366: remove unused include headers Rodrigo Alencar via B4 Relay
` (8 subsequent siblings)
10 siblings, 0 replies; 32+ messages in thread
From: Rodrigo Alencar via B4 Relay @ 2026-02-10 19:42 UTC (permalink / raw)
To: linux-kernel, linux-iio, devicetree
Cc: Michael Hennerich, Lars-Peter Clausen, Jonathan Cameron,
David Lechner, Andy Shevchenko, Rob Herring, Krzysztof Kozlowski,
Conor Dooley, Rodrigo Alencar, Conor Dooley
From: Rodrigo Alencar <rodrigo.alencar@analog.com>
Add device tree binding documentation for amplifiers and digital
attenuators. This covers different device variants with similar
SPI control. Each device has its own gain range and step, hence
no fallback compatibles are used.
Reviewed-by: Conor Dooley <conor.dooley@microchip.com>
Signed-off-by: Rodrigo Alencar <rodrigo.alencar@analog.com>
---
.../bindings/iio/amplifiers/adi,ad8366.yaml | 97 ++++++++++++++++++++++
MAINTAINERS | 1 +
2 files changed, 98 insertions(+)
diff --git a/Documentation/devicetree/bindings/iio/amplifiers/adi,ad8366.yaml b/Documentation/devicetree/bindings/iio/amplifiers/adi,ad8366.yaml
new file mode 100644
index 000000000000..2719de1166a1
--- /dev/null
+++ b/Documentation/devicetree/bindings/iio/amplifiers/adi,ad8366.yaml
@@ -0,0 +1,97 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/iio/amplifiers/adi,ad8366.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: AD8366 and similar Gain Amplifiers and Digital Attenuators
+
+maintainers:
+ - Michael Hennerich <michael.hennerich@analog.com>
+ - Rodrigo Alencar <rodrigo.alencar@analog.com>
+
+description:
+ Digital Variable Gain Amplifiers (VGAs) and Digital Attenuators with
+ SPI interface.
+
+properties:
+ compatible:
+ enum:
+ - adi,ad8366
+ - adi,ada4961
+ - adi,adl5240
+ - adi,adrf5720
+ - adi,adrf5730
+ - adi,adrf5731
+ - adi,hmc271a
+ - adi,hmc792a
+ - adi,hmc1018a
+ - adi,hmc1019a
+ - adi,hmc1119
+
+ reg:
+ maxItems: 1
+
+ vcc-supply:
+ description: Regulator that provides power to the device.
+
+ reset-gpios:
+ maxItems: 1
+
+ enable-gpios:
+ maxItems: 1
+ description: Power-up or Serial Mode Enable GPIO.
+
+required:
+ - compatible
+ - reg
+ - vcc-supply
+
+allOf:
+ - $ref: /schemas/spi/spi-peripheral-props.yaml#
+ - if:
+ not:
+ properties:
+ compatible:
+ contains:
+ const: adi,hmc271a
+ then:
+ properties:
+ reset-gpios: false
+ - if:
+ not:
+ properties:
+ compatible:
+ contains:
+ anyOf:
+ - const: adi,ad8366
+ - const: adi,ada4961
+ - const: adi,adrf5720
+ - const: adi,adrf5730
+ - const: adi,adrf5731
+ - const: adi,hmc792a
+ - const: adi,hmc1018a
+ - const: adi,hmc1019a
+ - const: adi,hmc1119
+ then:
+ properties:
+ enable-gpios: false
+
+unevaluatedProperties: false
+
+examples:
+ - |
+ #include <dt-bindings/gpio/gpio.h>
+ spi {
+ #address-cells = <1>;
+ #size-cells = <0>;
+
+ amplifier@0 {
+ compatible = "adi,ad8366";
+ reg = <0>;
+ spi-max-frequency = <1000000>;
+ vcc-supply = <&vcc_3v3>;
+ enable-gpios = <&gpio 0 GPIO_ACTIVE_HIGH>;
+ };
+ };
+...
diff --git a/MAINTAINERS b/MAINTAINERS
index ec9a6beb7619..ab4e487d603a 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -1589,6 +1589,7 @@ M: Rodrigo Alencar <rodrigo.alencar@analog.com>
L: linux-iio@vger.kernel.org
S: Supported
W: https://ez.analog.com/linux-software-drivers
+F: Documentation/devicetree/bindings/iio/amplifiers/adi,ad8366.yaml
F: drivers/iio/amplifiers/ad8366.c
ANALOG DEVICES INC AD9467 DRIVER
--
2.43.0
^ permalink raw reply related [flat|nested] 32+ messages in thread* [PATCH v4 03/11] iio: amplifiers: ad8366: remove unused include headers
2026-02-10 19:42 [PATCH v4 00/11] iio: amplifiers: ad8366: driver update and dt support Rodrigo Alencar via B4 Relay
2026-02-10 19:42 ` [PATCH v4 01/11] MAINTAINERS: Add missing maintainer entry for AD8366 driver Rodrigo Alencar via B4 Relay
2026-02-10 19:42 ` [PATCH v4 02/11] dt-bindings: iio: amplifiers: Add AD8366 support Rodrigo Alencar via B4 Relay
@ 2026-02-10 19:42 ` Rodrigo Alencar via B4 Relay
2026-02-10 19:57 ` Andy Shevchenko
2026-02-10 19:42 ` [PATCH v4 04/11] iio: amplifiers: ad8366: add local dev pointer to the probe function Rodrigo Alencar via B4 Relay
` (7 subsequent siblings)
10 siblings, 1 reply; 32+ messages in thread
From: Rodrigo Alencar via B4 Relay @ 2026-02-10 19:42 UTC (permalink / raw)
To: linux-kernel, linux-iio, devicetree
Cc: Michael Hennerich, Lars-Peter Clausen, Jonathan Cameron,
David Lechner, Andy Shevchenko, Rob Herring, Krzysztof Kozlowski,
Conor Dooley, Rodrigo Alencar
From: Rodrigo Alencar <rodrigo.alencar@analog.com>
Apply IWYU principle, removing the following headers:
- linux/device.h: no usage of devm_add_action_or_reset, device_attr...
- linux/kernel.h: no usage of container_of, kasprintf, ...
- linux/slab.h: memory management handled by iio
- linux/sysfs.h: sysfs interaction is managed by iio
- linux/iio/sysfs.h: not using iio device attributes in this driver
Being a small patch, the remaining includes are alphabetically sorted.
In gcc, compiling with -H allows for dependency visualization,
which indicates that except for linux/iio/sysfs.h, all removed
headers are indirectly included by the remaining headers.
Signed-off-by: Rodrigo Alencar <rodrigo.alencar@analog.com>
---
drivers/iio/amplifiers/ad8366.c | 15 +++++----------
1 file changed, 5 insertions(+), 10 deletions(-)
diff --git a/drivers/iio/amplifiers/ad8366.c b/drivers/iio/amplifiers/ad8366.c
index d06ac786501c..6382106ee6c7 100644
--- a/drivers/iio/amplifiers/ad8366.c
+++ b/drivers/iio/amplifiers/ad8366.c
@@ -11,19 +11,14 @@
* Copyright 2012-2019 Analog Devices Inc.
*/
-#include <linux/device.h>
-#include <linux/kernel.h>
-#include <linux/slab.h>
-#include <linux/sysfs.h>
-#include <linux/spi/spi.h>
-#include <linux/regulator/consumer.h>
-#include <linux/gpio/consumer.h>
-#include <linux/err.h>
-#include <linux/module.h>
#include <linux/bitrev.h>
+#include <linux/err.h>
+#include <linux/gpio/consumer.h>
+#include <linux/module.h>
+#include <linux/regulator/consumer.h>
+#include <linux/spi/spi.h>
#include <linux/iio/iio.h>
-#include <linux/iio/sysfs.h>
enum ad8366_type {
ID_AD8366,
--
2.43.0
^ permalink raw reply related [flat|nested] 32+ messages in thread* Re: [PATCH v4 03/11] iio: amplifiers: ad8366: remove unused include headers
2026-02-10 19:42 ` [PATCH v4 03/11] iio: amplifiers: ad8366: remove unused include headers Rodrigo Alencar via B4 Relay
@ 2026-02-10 19:57 ` Andy Shevchenko
2026-02-11 12:55 ` Rodrigo Alencar
0 siblings, 1 reply; 32+ messages in thread
From: Andy Shevchenko @ 2026-02-10 19:57 UTC (permalink / raw)
To: rodrigo.alencar
Cc: linux-kernel, linux-iio, devicetree, Michael Hennerich,
Lars-Peter Clausen, Jonathan Cameron, David Lechner,
Andy Shevchenko, Rob Herring, Krzysztof Kozlowski, Conor Dooley
On Tue, Feb 10, 2026 at 07:42:03PM +0000, Rodrigo Alencar via B4 Relay wrote:
> Apply IWYU principle, removing the following headers:
> - linux/device.h: no usage of devm_add_action_or_reset, device_attr...
> - linux/kernel.h: no usage of container_of, kasprintf, ...
> - linux/slab.h: memory management handled by iio
> - linux/sysfs.h: sysfs interaction is managed by iio
> - linux/iio/sysfs.h: not using iio device attributes in this driver
Yeah, but it also means to add (a lot of) missed headers...
array_size,h
dev_printk.h
mod_devicetable.h
mutex.h
stddef.h
(might be even more, this list was made just at the first glance).
> Being a small patch, the remaining includes are alphabetically sorted.
> In gcc, compiling with -H allows for dependency visualization,
> which indicates that except for linux/iio/sysfs.h, all removed
> headers are indirectly included by the remaining headers.
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 32+ messages in thread
* Re: [PATCH v4 03/11] iio: amplifiers: ad8366: remove unused include headers
2026-02-10 19:57 ` Andy Shevchenko
@ 2026-02-11 12:55 ` Rodrigo Alencar
2026-02-11 13:35 ` Andy Shevchenko
0 siblings, 1 reply; 32+ messages in thread
From: Rodrigo Alencar @ 2026-02-11 12:55 UTC (permalink / raw)
To: Andy Shevchenko, rodrigo.alencar
Cc: linux-kernel, linux-iio, devicetree, Michael Hennerich,
Lars-Peter Clausen, Jonathan Cameron, David Lechner,
Andy Shevchenko, Rob Herring, Krzysztof Kozlowski, Conor Dooley
On 26/02/10 09:57PM, Andy Shevchenko wrote:
> On Tue, Feb 10, 2026 at 07:42:03PM +0000, Rodrigo Alencar via B4 Relay wrote:
>
> > Apply IWYU principle, removing the following headers:
> > - linux/device.h: no usage of devm_add_action_or_reset, device_attr...
> > - linux/kernel.h: no usage of container_of, kasprintf, ...
> > - linux/slab.h: memory management handled by iio
> > - linux/sysfs.h: sysfs interaction is managed by iio
> > - linux/iio/sysfs.h: not using iio device attributes in this driver
>
> Yeah, but it also means to add (a lot of) missed headers...
>
> array_size,h
> dev_printk.h
> mod_devicetable.h
> mutex.h
> stddef.h
Are there proper guidelines for IWYU in the kernel?
Include headers end up including a bunch of others, so
the build finishes successfully anyways.
I understand that the concern is build time, so we better
include all small parts that are needed rather than a generic
header that includes that and much more.
This is the output of the iwyu tool without this patch series:
drivers/iio/amplifiers/ad8366.c should add these lines:
#include <stddef.h> // for NULL
#include "asm-generic/errno-base.h" // for EINVAL, ENOMEM
#include "linux/array_size.h" // for ARRAY_SIZE
#include "linux/compiler_attributes.h" // for __aligned
#include "linux/dev_printk.h" // for dev_err
#include "linux/iio/types.h" // for iio_chan_info_enum, iio_chan_...
#include "linux/math.h" // for abs
#include "linux/minmax.h" // for __cmp_op_max
#include "linux/mod_devicetable.h" // for spi_device_id
#include "linux/mutex.h" // for mutex_lock, mutex_unlock, mut...
#include "linux/mutex_types.h" // for mutex
#include "vdso/bits.h" // for BIT
drivers/iio/amplifiers/ad8366.c should remove these lines:
- #include <linux/device.h> // lines 14-14
- #include <linux/iio/sysfs.h> // lines 26-26
- #include <linux/kernel.h> // lines 15-15
- #include <linux/slab.h> // lines 16-16
- #include <linux/sysfs.h> // lines 17-17
The full include-list for drivers/iio/amplifiers/ad8366.c:
#include <linux/bitrev.h> // for bitrev8
#include <linux/err.h> // for IS_ERR, PTR_ERR
#include <linux/gpio/consumer.h> // for devm_gpiod_get_optional, gpio...
#include <linux/iio/iio.h> // for iio_priv, iio_dev, iio_chan_spec
#include <linux/module.h> // for MODULE_AUTHOR, MODULE_DESCRIP...
#include <linux/regulator/consumer.h> // for regulator_disable, devm_regul...
#include <linux/spi/spi.h> // for spi_device, spi_get_device_id
#include <stddef.h> // for NULL
#include "asm-generic/errno-base.h" // for EINVAL, ENOMEM
#include "linux/array_size.h" // for ARRAY_SIZE
#include "linux/compiler_attributes.h" // for __aligned
#include "linux/dev_printk.h" // for dev_err
#include "linux/iio/types.h" // for iio_chan_info_enum, iio_chan_...
#include "linux/math.h" // for abs
#include "linux/minmax.h" // for __cmp_op_max
#include "linux/mod_devicetable.h" // for spi_device_id
#include "linux/mutex.h" // for mutex_lock, mutex_unlock, mut...
#include "linux/mutex_types.h" // for mutex
#include "vdso/bits.h" // for BIT
After all the patches are applied the output is slightly different:
drivers/iio/amplifiers/ad8366.c should add these lines:
#include <stddef.h> // for size_t, NULL
#include "asm-generic/errno-base.h" // for EINVAL, ENOMEM
#include "asm-generic/int-ll64.h" // for u8
#include "linux/compiler_attributes.h" // for __aligned
#include "linux/dev_printk.h" // for dev_err_probe
#include "linux/iio/types.h" // for iio_chan_info_enum, iio_chan_...
#include "linux/math.h" // for DIV_ROUND_CLOSEST
#include "linux/minmax.h" // for __cmp_op_max
#include "linux/mutex_types.h" // for mutex
#include "linux/types.h" // for __be16
#include "vdso/bits.h" // for BIT
The full include-list for drivers/iio/amplifiers/ad8366.c:
#include <linux/bitrev.h> // for bitrev8
#include <linux/err.h> // for IS_ERR, PTR_ERR
#include <linux/gpio/consumer.h> // for devm_gpiod_get_optional, gpio...
#include <linux/iio/iio.h> // for iio_priv, iio_dev, iio_chan_spec
#include <linux/mod_devicetable.h> // for kernel_ulong_t, spi_device_id
#include <linux/module.h> // for MODULE_DEVICE_TABLE, MODULE_A...
#include <linux/mutex.h> // for mutex_lock, mutex_unlock, dev...
#include <linux/regulator/consumer.h> // for devm_regulator_get_enable
#include <linux/reset.h> // for devm_reset_control_get_option...
#include <linux/spi/spi.h> // for spi_write, spi_get_device_id
#include <linux/unaligned.h> // for put_unaligned_be16
#include <stddef.h> // for size_t, NULL
#include "asm-generic/errno-base.h" // for EINVAL, ENOMEM
#include "asm-generic/int-ll64.h" // for u8
#include "linux/compiler_attributes.h" // for __aligned
#include "linux/dev_printk.h" // for dev_err_probe
#include "linux/iio/types.h" // for iio_chan_info_enum, iio_chan_...
#include "linux/math.h" // for DIV_ROUND_CLOSEST
#include "linux/minmax.h" // for __cmp_op_max
#include "linux/mutex_types.h" // for mutex
#include "linux/types.h" // for __be16
#include "vdso/bits.h" // for BIT
--
Kind regards,
Rodrigo Alencar
^ permalink raw reply [flat|nested] 32+ messages in thread
* Re: [PATCH v4 03/11] iio: amplifiers: ad8366: remove unused include headers
2026-02-11 12:55 ` Rodrigo Alencar
@ 2026-02-11 13:35 ` Andy Shevchenko
2026-02-14 18:30 ` Jonathan Cameron
0 siblings, 1 reply; 32+ messages in thread
From: Andy Shevchenko @ 2026-02-11 13:35 UTC (permalink / raw)
To: Rodrigo Alencar
Cc: rodrigo.alencar, linux-kernel, linux-iio, devicetree,
Michael Hennerich, Lars-Peter Clausen, Jonathan Cameron,
David Lechner, Andy Shevchenko, Rob Herring, Krzysztof Kozlowski,
Conor Dooley
On Wed, Feb 11, 2026 at 12:55:30PM +0000, Rodrigo Alencar wrote:
> On 26/02/10 09:57PM, Andy Shevchenko wrote:
> > On Tue, Feb 10, 2026 at 07:42:03PM +0000, Rodrigo Alencar via B4 Relay wrote:
> >
> > > Apply IWYU principle, removing the following headers:
> > > - linux/device.h: no usage of devm_add_action_or_reset, device_attr...
> > > - linux/kernel.h: no usage of container_of, kasprintf, ...
> > > - linux/slab.h: memory management handled by iio
> > > - linux/sysfs.h: sysfs interaction is managed by iio
> > > - linux/iio/sysfs.h: not using iio device attributes in this driver
> >
> > Yeah, but it also means to add (a lot of) missed headers...
> >
> > array_size,h
> > dev_printk.h
> > mod_devicetable.h
> > mutex.h
> > stddef.h
>
> Are there proper guidelines for IWYU in the kernel?
> Include headers end up including a bunch of others, so
> the build finishes successfully anyways.
This is global stuff, no need to repeat this in the kernel documentation.
It's the same as asking documentation for KISS principle.
> I understand that the concern is build time, so we better
> include all small parts that are needed rather than a generic
> header that includes that and much more.
> This is the output of the iwyu tool without this patch series:
Have you applied the configuration Jonathan made for this tool in relation
to the Linux kernel project? By default the tool has a lot of noise, indeed.
And note, tool != principle. The tool is just an implementation of the helper
to enforce the principle in practice, but it may be not always suitable for
the certain project "as is".
In the below output some are valid, but some are just noise as there are
guarantees for the "proxying".
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 32+ messages in thread
* Re: [PATCH v4 03/11] iio: amplifiers: ad8366: remove unused include headers
2026-02-11 13:35 ` Andy Shevchenko
@ 2026-02-14 18:30 ` Jonathan Cameron
2026-02-15 7:31 ` Andy Shevchenko
0 siblings, 1 reply; 32+ messages in thread
From: Jonathan Cameron @ 2026-02-14 18:30 UTC (permalink / raw)
To: Andy Shevchenko
Cc: Rodrigo Alencar, rodrigo.alencar, linux-kernel, linux-iio,
devicetree, Michael Hennerich, Lars-Peter Clausen, David Lechner,
Andy Shevchenko, Rob Herring, Krzysztof Kozlowski, Conor Dooley
On Wed, 11 Feb 2026 15:35:32 +0200
Andy Shevchenko <andriy.shevchenko@intel.com> wrote:
> On Wed, Feb 11, 2026 at 12:55:30PM +0000, Rodrigo Alencar wrote:
> > On 26/02/10 09:57PM, Andy Shevchenko wrote:
> > > On Tue, Feb 10, 2026 at 07:42:03PM +0000, Rodrigo Alencar via B4 Relay wrote:
> > >
> > > > Apply IWYU principle, removing the following headers:
> > > > - linux/device.h: no usage of devm_add_action_or_reset, device_attr...
> > > > - linux/kernel.h: no usage of container_of, kasprintf, ...
> > > > - linux/slab.h: memory management handled by iio
> > > > - linux/sysfs.h: sysfs interaction is managed by iio
> > > > - linux/iio/sysfs.h: not using iio device attributes in this driver
> > >
> > > Yeah, but it also means to add (a lot of) missed headers...
> > >
> > > array_size,h
> > > dev_printk.h
> > > mod_devicetable.h
> > > mutex.h
> > > stddef.h
> >
> > Are there proper guidelines for IWYU in the kernel?
> > Include headers end up including a bunch of others, so
> > the build finishes successfully anyways.
>
> This is global stuff, no need to repeat this in the kernel documentation.
> It's the same as asking documentation for KISS principle.
>
> > I understand that the concern is build time, so we better
> > include all small parts that are needed rather than a generic
> > header that includes that and much more.
>
> > This is the output of the iwyu tool without this patch series:
>
> Have you applied the configuration Jonathan made for this tool in relation
> to the Linux kernel project? By default the tool has a lot of noise, indeed.
Worth noting that I'm still evolving my config and suspect there will still
be a bit of 'taste' applied to the output even once I conclude what the
best combinations are. So to give my view on the following..
> #include <stddef.h> // for NULL
Not this one.
> #include "asm-generic/errno-base.h" // for EINVAL, ENOMEM
Something to get to errnos is good, but not that one.
> #include "linux/array_size.h" // for ARRAY_SIZE
Yes - this is part of the kernel.h split up work.
> #include "linux/compiler_attributes.h" // for __aligned
Never that one, but I sometimes feel compiler.h is fine.
> #include "linux/dev_printk.h" // for dev_err
Yes if device.h doesn't have to be there for other reasons.
> #include "linux/iio/types.h" // for iio_chan_info_enum, iio_chan_...
No. We always need iio.h which will always include that.
> #include "linux/math.h" // for abs
yes
> #include "linux/minmax.h" // for __cmp_op_max
yes
> #include "linux/mod_devicetable.h" // for spi_device_id
yes
> #include "linux/mutex.h" // for mutex_lock, mutex_unlock, mut...
yes
> #include "linux/mutex_types.h" // for mutex
no as mutex.h will alays include that.
> #include "vdso/bits.h" // for BIT
Usually via bitops.h or similar. But if none of those are there anyway linux/bits.h
Jonathan
>
> And note, tool != principle. The tool is just an implementation of the helper
> to enforce the principle in practice, but it may be not always suitable for
> the certain project "as is".
>
> In the below output some are valid, but some are just noise as there are
> guarantees for the "proxying".
>
^ permalink raw reply [flat|nested] 32+ messages in thread
* Re: [PATCH v4 03/11] iio: amplifiers: ad8366: remove unused include headers
2026-02-14 18:30 ` Jonathan Cameron
@ 2026-02-15 7:31 ` Andy Shevchenko
2026-02-15 16:03 ` Jonathan Cameron
0 siblings, 1 reply; 32+ messages in thread
From: Andy Shevchenko @ 2026-02-15 7:31 UTC (permalink / raw)
To: Jonathan Cameron
Cc: Rodrigo Alencar, rodrigo.alencar, linux-kernel, linux-iio,
devicetree, Michael Hennerich, Lars-Peter Clausen, David Lechner,
Andy Shevchenko, Rob Herring, Krzysztof Kozlowski, Conor Dooley
On Sat, Feb 14, 2026 at 06:30:51PM +0000, Jonathan Cameron wrote:
> On Wed, 11 Feb 2026 15:35:32 +0200
> Andy Shevchenko <andriy.shevchenko@intel.com> wrote:
> > On Wed, Feb 11, 2026 at 12:55:30PM +0000, Rodrigo Alencar wrote:
> > > On 26/02/10 09:57PM, Andy Shevchenko wrote:
> > > > On Tue, Feb 10, 2026 at 07:42:03PM +0000, Rodrigo Alencar via B4 Relay wrote:
...
> > > > Yeah, but it also means to add (a lot of) missed headers...
> > > >
> > > > array_size,h
> > > > dev_printk.h
> > > > mod_devicetable.h
> > > > mutex.h
> > > > stddef.h
...
> > > This is the output of the iwyu tool without this patch series:
> >
> > Have you applied the configuration Jonathan made for this tool in relation
> > to the Linux kernel project? By default the tool has a lot of noise, indeed.
>
> Worth noting that I'm still evolving my config and suspect there will still
> be a bit of 'taste' applied to the output even once I conclude what the
> best combinations are. So to give my view on the following..
>
> > #include <stddef.h> // for NULL
> Not this one.
Why not? Here is the NULL in use, but...
> > #include "linux/compiler_attributes.h" // for __aligned
> Never that one, but I sometimes feel compiler.h is fine.
...taking into account this one, I would rather include linux/types.h
instead of any of them.
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 32+ messages in thread
* Re: [PATCH v4 03/11] iio: amplifiers: ad8366: remove unused include headers
2026-02-15 7:31 ` Andy Shevchenko
@ 2026-02-15 16:03 ` Jonathan Cameron
0 siblings, 0 replies; 32+ messages in thread
From: Jonathan Cameron @ 2026-02-15 16:03 UTC (permalink / raw)
To: Andy Shevchenko
Cc: Rodrigo Alencar, rodrigo.alencar, linux-kernel, linux-iio,
devicetree, Michael Hennerich, Lars-Peter Clausen, David Lechner,
Andy Shevchenko, Rob Herring, Krzysztof Kozlowski, Conor Dooley
On Sun, 15 Feb 2026 09:31:08 +0200
Andy Shevchenko <andriy.shevchenko@intel.com> wrote:
> On Sat, Feb 14, 2026 at 06:30:51PM +0000, Jonathan Cameron wrote:
> > On Wed, 11 Feb 2026 15:35:32 +0200
> > Andy Shevchenko <andriy.shevchenko@intel.com> wrote:
> > > On Wed, Feb 11, 2026 at 12:55:30PM +0000, Rodrigo Alencar wrote:
> > > > On 26/02/10 09:57PM, Andy Shevchenko wrote:
> > > > > On Tue, Feb 10, 2026 at 07:42:03PM +0000, Rodrigo Alencar via B4 Relay wrote:
>
> ...
>
> > > > > Yeah, but it also means to add (a lot of) missed headers...
> > > > >
> > > > > array_size,h
> > > > > dev_printk.h
> > > > > mod_devicetable.h
> > > > > mutex.h
> > > > > stddef.h
>
> ...
>
> > > > This is the output of the iwyu tool without this patch series:
> > >
> > > Have you applied the configuration Jonathan made for this tool in relation
> > > to the Linux kernel project? By default the tool has a lot of noise, indeed.
> >
> > Worth noting that I'm still evolving my config and suspect there will still
> > be a bit of 'taste' applied to the output even once I conclude what the
> > best combinations are. So to give my view on the following..
> >
> > > #include <stddef.h> // for NULL
> > Not this one.
>
> Why not? Here is the NULL in use, but...
>
> > > #include "linux/compiler_attributes.h" // for __aligned
> > Never that one, but I sometimes feel compiler.h is fine.
>
> ...taking into account this one, I would rather include linux/types.h
> instead of any of them.
>
That's where I'd go as well. I think this might be the first case
I've seen where there is no other reason to have linux/types.h (due to the
sub 8 bits bit depth and use of unsigned chars rather than u8) so
I kind of assumed it was there :(
^ permalink raw reply [flat|nested] 32+ messages in thread
* [PATCH v4 04/11] iio: amplifiers: ad8366: add local dev pointer to the probe function
2026-02-10 19:42 [PATCH v4 00/11] iio: amplifiers: ad8366: driver update and dt support Rodrigo Alencar via B4 Relay
` (2 preceding siblings ...)
2026-02-10 19:42 ` [PATCH v4 03/11] iio: amplifiers: ad8366: remove unused include headers Rodrigo Alencar via B4 Relay
@ 2026-02-10 19:42 ` Rodrigo Alencar via B4 Relay
2026-02-10 19:58 ` Andy Shevchenko
2026-02-10 19:42 ` [PATCH v4 05/11] iio: amplifiers: ad8366: use devm_mutex_init() and drop mutex_init() Rodrigo Alencar via B4 Relay
` (6 subsequent siblings)
10 siblings, 1 reply; 32+ messages in thread
From: Rodrigo Alencar via B4 Relay @ 2026-02-10 19:42 UTC (permalink / raw)
To: linux-kernel, linux-iio, devicetree
Cc: Michael Hennerich, Lars-Peter Clausen, Jonathan Cameron,
David Lechner, Andy Shevchenko, Rob Herring, Krzysztof Kozlowski,
Conor Dooley, Rodrigo Alencar
From: Rodrigo Alencar <rodrigo.alencar@analog.com>
Create local device pointer in the probe function to shorten lines,
making the code easier to read.
Signed-off-by: Rodrigo Alencar <rodrigo.alencar@analog.com>
---
drivers/iio/amplifiers/ad8366.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/iio/amplifiers/ad8366.c b/drivers/iio/amplifiers/ad8366.c
index 6382106ee6c7..3456a31cb1ee 100644
--- a/drivers/iio/amplifiers/ad8366.c
+++ b/drivers/iio/amplifiers/ad8366.c
@@ -240,11 +240,12 @@ static const struct iio_chan_spec ada4961_channels[] = {
static int ad8366_probe(struct spi_device *spi)
{
+ struct device *dev = &spi->dev;
struct iio_dev *indio_dev;
struct ad8366_state *st;
int ret;
- indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*st));
+ indio_dev = devm_iio_device_alloc(dev, sizeof(*st));
if (indio_dev == NULL)
return -ENOMEM;
--
2.43.0
^ permalink raw reply related [flat|nested] 32+ messages in thread* Re: [PATCH v4 04/11] iio: amplifiers: ad8366: add local dev pointer to the probe function
2026-02-10 19:42 ` [PATCH v4 04/11] iio: amplifiers: ad8366: add local dev pointer to the probe function Rodrigo Alencar via B4 Relay
@ 2026-02-10 19:58 ` Andy Shevchenko
2026-02-10 20:03 ` Andy Shevchenko
0 siblings, 1 reply; 32+ messages in thread
From: Andy Shevchenko @ 2026-02-10 19:58 UTC (permalink / raw)
To: rodrigo.alencar
Cc: linux-kernel, linux-iio, devicetree, Michael Hennerich,
Lars-Peter Clausen, Jonathan Cameron, David Lechner,
Andy Shevchenko, Rob Herring, Krzysztof Kozlowski, Conor Dooley
On Tue, Feb 10, 2026 at 07:42:04PM +0000, Rodrigo Alencar via B4 Relay wrote:
> Create local device pointer in the probe function to shorten lines,
> making the code easier to read.
Only a single place to convert?
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 32+ messages in thread
* Re: [PATCH v4 04/11] iio: amplifiers: ad8366: add local dev pointer to the probe function
2026-02-10 19:58 ` Andy Shevchenko
@ 2026-02-10 20:03 ` Andy Shevchenko
2026-02-14 18:34 ` Jonathan Cameron
0 siblings, 1 reply; 32+ messages in thread
From: Andy Shevchenko @ 2026-02-10 20:03 UTC (permalink / raw)
To: rodrigo.alencar
Cc: linux-kernel, linux-iio, devicetree, Michael Hennerich,
Lars-Peter Clausen, Jonathan Cameron, David Lechner,
Andy Shevchenko, Rob Herring, Krzysztof Kozlowski, Conor Dooley
On Tue, Feb 10, 2026 at 09:58:52PM +0200, Andy Shevchenko wrote:
> On Tue, Feb 10, 2026 at 07:42:04PM +0000, Rodrigo Alencar via B4 Relay wrote:
>
> > Create local device pointer in the probe function to shorten lines,
> > making the code easier to read.
>
> Only a single place to convert?
*Yes, I understand the intention, you need to explain that in the cover letter
and/or here in the comment block.
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 32+ messages in thread
* Re: [PATCH v4 04/11] iio: amplifiers: ad8366: add local dev pointer to the probe function
2026-02-10 20:03 ` Andy Shevchenko
@ 2026-02-14 18:34 ` Jonathan Cameron
0 siblings, 0 replies; 32+ messages in thread
From: Jonathan Cameron @ 2026-02-14 18:34 UTC (permalink / raw)
To: Andy Shevchenko
Cc: rodrigo.alencar, linux-kernel, linux-iio, devicetree,
Michael Hennerich, Lars-Peter Clausen, David Lechner,
Andy Shevchenko, Rob Herring, Krzysztof Kozlowski, Conor Dooley
On Tue, 10 Feb 2026 22:03:11 +0200
Andy Shevchenko <andriy.shevchenko@intel.com> wrote:
> On Tue, Feb 10, 2026 at 09:58:52PM +0200, Andy Shevchenko wrote:
> > On Tue, Feb 10, 2026 at 07:42:04PM +0000, Rodrigo Alencar via B4 Relay wrote:
> >
> > > Create local device pointer in the probe function to shorten lines,
> > > making the code easier to read.
> >
> > Only a single place to convert?
>
> *Yes, I understand the intention, you need to explain that in the cover letter
> and/or here in the comment block.
>
Consistency matters, so once you have this local variable use it everywhere.
There are a few others in the code as it stands. If you are going to happen to
remove all those lines in later patches, then fair enough to perhaps add a comment
to say that you haven't touched them for reasons of churn avoidance.
If not I'd expect all spi->dev usage in probe to be replaced.
Jonathan
^ permalink raw reply [flat|nested] 32+ messages in thread
* [PATCH v4 05/11] iio: amplifiers: ad8366: use devm_mutex_init() and drop mutex_init()
2026-02-10 19:42 [PATCH v4 00/11] iio: amplifiers: ad8366: driver update and dt support Rodrigo Alencar via B4 Relay
` (3 preceding siblings ...)
2026-02-10 19:42 ` [PATCH v4 04/11] iio: amplifiers: ad8366: add local dev pointer to the probe function Rodrigo Alencar via B4 Relay
@ 2026-02-10 19:42 ` Rodrigo Alencar via B4 Relay
2026-02-10 20:00 ` Andy Shevchenko
2026-02-14 18:36 ` Jonathan Cameron
2026-02-10 19:42 ` [PATCH v4 06/11] iio: amplifiers: ad8366: replace reset-gpio with reset controller Rodrigo Alencar via B4 Relay
` (5 subsequent siblings)
10 siblings, 2 replies; 32+ messages in thread
From: Rodrigo Alencar via B4 Relay @ 2026-02-10 19:42 UTC (permalink / raw)
To: linux-kernel, linux-iio, devicetree
Cc: Michael Hennerich, Lars-Peter Clausen, Jonathan Cameron,
David Lechner, Andy Shevchenko, Rob Herring, Krzysztof Kozlowski,
Conor Dooley, Rodrigo Alencar
From: Rodrigo Alencar <rodrigo.alencar@analog.com>
Adopt proper mutex lifecycle with devm_mutex_init(), replacing
mutex_init(). Also, Include linux/mutex.h header.
Signed-off-by: Rodrigo Alencar <rodrigo.alencar@analog.com>
---
drivers/iio/amplifiers/ad8366.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/drivers/iio/amplifiers/ad8366.c b/drivers/iio/amplifiers/ad8366.c
index 3456a31cb1ee..f0053a09cbb6 100644
--- a/drivers/iio/amplifiers/ad8366.c
+++ b/drivers/iio/amplifiers/ad8366.c
@@ -15,6 +15,7 @@
#include <linux/err.h>
#include <linux/gpio/consumer.h>
#include <linux/module.h>
+#include <linux/mutex.h>
#include <linux/regulator/consumer.h>
#include <linux/spi/spi.h>
@@ -251,6 +252,10 @@ static int ad8366_probe(struct spi_device *spi)
st = iio_priv(indio_dev);
+ ret = devm_mutex_init(dev, &st->lock);
+ if (ret)
+ return ret;
+
st->reg = devm_regulator_get(&spi->dev, "vcc");
if (!IS_ERR(st->reg)) {
ret = regulator_enable(st->reg);
@@ -259,7 +264,6 @@ static int ad8366_probe(struct spi_device *spi)
}
spi_set_drvdata(spi, indio_dev);
- mutex_init(&st->lock);
st->spi = spi;
st->type = spi_get_device_id(spi)->driver_data;
--
2.43.0
^ permalink raw reply related [flat|nested] 32+ messages in thread* Re: [PATCH v4 05/11] iio: amplifiers: ad8366: use devm_mutex_init() and drop mutex_init()
2026-02-10 19:42 ` [PATCH v4 05/11] iio: amplifiers: ad8366: use devm_mutex_init() and drop mutex_init() Rodrigo Alencar via B4 Relay
@ 2026-02-10 20:00 ` Andy Shevchenko
2026-02-14 18:36 ` Jonathan Cameron
1 sibling, 0 replies; 32+ messages in thread
From: Andy Shevchenko @ 2026-02-10 20:00 UTC (permalink / raw)
To: rodrigo.alencar
Cc: linux-kernel, linux-iio, devicetree, Michael Hennerich,
Lars-Peter Clausen, Jonathan Cameron, David Lechner,
Andy Shevchenko, Rob Herring, Krzysztof Kozlowski, Conor Dooley
On Tue, Feb 10, 2026 at 07:42:05PM +0000, Rodrigo Alencar via B4 Relay wrote:
> Adopt proper mutex lifecycle with devm_mutex_init(), replacing
> mutex_init(). Also, Include linux/mutex.h header.
mutex.h should be included before as it's not a new API added in this patch.
Otherwise LGTM.
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 32+ messages in thread
* Re: [PATCH v4 05/11] iio: amplifiers: ad8366: use devm_mutex_init() and drop mutex_init()
2026-02-10 19:42 ` [PATCH v4 05/11] iio: amplifiers: ad8366: use devm_mutex_init() and drop mutex_init() Rodrigo Alencar via B4 Relay
2026-02-10 20:00 ` Andy Shevchenko
@ 2026-02-14 18:36 ` Jonathan Cameron
2026-02-15 7:50 ` Andy Shevchenko
1 sibling, 1 reply; 32+ messages in thread
From: Jonathan Cameron @ 2026-02-14 18:36 UTC (permalink / raw)
To: Rodrigo Alencar via B4 Relay
Cc: rodrigo.alencar, linux-kernel, linux-iio, devicetree,
Michael Hennerich, Lars-Peter Clausen, David Lechner,
Andy Shevchenko, Rob Herring, Krzysztof Kozlowski, Conor Dooley
On Tue, 10 Feb 2026 19:42:05 +0000
Rodrigo Alencar via B4 Relay <devnull+rodrigo.alencar.analog.com@kernel.org> wrote:
> From: Rodrigo Alencar <rodrigo.alencar@analog.com>
>
> Adopt proper mutex lifecycle with devm_mutex_init(), replacing
> mutex_init(). Also, Include linux/mutex.h header.
Why move the *mutex_init()? Even if it is just because it looks better there,
not breaking up spi related stuff, then say that.
>
> Signed-off-by: Rodrigo Alencar <rodrigo.alencar@analog.com>
> ---
> drivers/iio/amplifiers/ad8366.c | 6 +++++-
> 1 file changed, 5 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/iio/amplifiers/ad8366.c b/drivers/iio/amplifiers/ad8366.c
> index 3456a31cb1ee..f0053a09cbb6 100644
> --- a/drivers/iio/amplifiers/ad8366.c
> +++ b/drivers/iio/amplifiers/ad8366.c
> @@ -15,6 +15,7 @@
> #include <linux/err.h>
> #include <linux/gpio/consumer.h>
> #include <linux/module.h>
> +#include <linux/mutex.h>
> #include <linux/regulator/consumer.h>
> #include <linux/spi/spi.h>
>
> @@ -251,6 +252,10 @@ static int ad8366_probe(struct spi_device *spi)
>
> st = iio_priv(indio_dev);
>
> + ret = devm_mutex_init(dev, &st->lock);
> + if (ret)
> + return ret;
> +
> st->reg = devm_regulator_get(&spi->dev, "vcc");
> if (!IS_ERR(st->reg)) {
> ret = regulator_enable(st->reg);
> @@ -259,7 +264,6 @@ static int ad8366_probe(struct spi_device *spi)
> }
>
> spi_set_drvdata(spi, indio_dev);
> - mutex_init(&st->lock);
> st->spi = spi;
> st->type = spi_get_device_id(spi)->driver_data;
>
>
^ permalink raw reply [flat|nested] 32+ messages in thread* Re: [PATCH v4 05/11] iio: amplifiers: ad8366: use devm_mutex_init() and drop mutex_init()
2026-02-14 18:36 ` Jonathan Cameron
@ 2026-02-15 7:50 ` Andy Shevchenko
0 siblings, 0 replies; 32+ messages in thread
From: Andy Shevchenko @ 2026-02-15 7:50 UTC (permalink / raw)
To: Jonathan Cameron
Cc: Rodrigo Alencar via B4 Relay, rodrigo.alencar, linux-kernel,
linux-iio, devicetree, Michael Hennerich, Lars-Peter Clausen,
David Lechner, Andy Shevchenko, Rob Herring, Krzysztof Kozlowski,
Conor Dooley
On Sat, Feb 14, 2026 at 06:36:16PM +0000, Jonathan Cameron wrote:
> On Tue, 10 Feb 2026 19:42:05 +0000
> Rodrigo Alencar via B4 Relay <devnull+rodrigo.alencar.analog.com@kernel.org> wrote:
> > Adopt proper mutex lifecycle with devm_mutex_init(), replacing
> > mutex_init(). Also, Include linux/mutex.h header.
>
> Why move the *mutex_init()? Even if it is just because it looks better there,
> not breaking up spi related stuff, then say that.
Yes, this needs to be recorded. But actually initialising mutex (and lock
in general) earlier is usually a good thing and in some cases might even
fix a hidden bug.
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 32+ messages in thread
* [PATCH v4 06/11] iio: amplifiers: ad8366: replace reset-gpio with reset controller
2026-02-10 19:42 [PATCH v4 00/11] iio: amplifiers: ad8366: driver update and dt support Rodrigo Alencar via B4 Relay
` (4 preceding siblings ...)
2026-02-10 19:42 ` [PATCH v4 05/11] iio: amplifiers: ad8366: use devm_mutex_init() and drop mutex_init() Rodrigo Alencar via B4 Relay
@ 2026-02-10 19:42 ` Rodrigo Alencar via B4 Relay
2026-02-14 18:37 ` Jonathan Cameron
2026-02-10 19:42 ` [PATCH v4 07/11] iio: amplifiers: ad8366: refactor device resource management Rodrigo Alencar via B4 Relay
` (4 subsequent siblings)
10 siblings, 1 reply; 32+ messages in thread
From: Rodrigo Alencar via B4 Relay @ 2026-02-10 19:42 UTC (permalink / raw)
To: linux-kernel, linux-iio, devicetree
Cc: Michael Hennerich, Lars-Peter Clausen, Jonathan Cameron,
David Lechner, Andy Shevchenko, Rob Herring, Krzysztof Kozlowski,
Conor Dooley, Rodrigo Alencar
From: Rodrigo Alencar <rodrigo.alencar@analog.com>
Remove reset_gpio from the device state struct and use the
reset_control interface instead, using a local variable,
as it is not being used anywhere else.
Signed-off-by: Rodrigo Alencar <rodrigo.alencar@analog.com>
---
drivers/iio/amplifiers/ad8366.c | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/drivers/iio/amplifiers/ad8366.c b/drivers/iio/amplifiers/ad8366.c
index f0053a09cbb6..67817dedd75d 100644
--- a/drivers/iio/amplifiers/ad8366.c
+++ b/drivers/iio/amplifiers/ad8366.c
@@ -17,6 +17,7 @@
#include <linux/module.h>
#include <linux/mutex.h>
#include <linux/regulator/consumer.h>
+#include <linux/reset.h>
#include <linux/spi/spi.h>
#include <linux/iio/iio.h>
@@ -38,7 +39,6 @@ struct ad8366_state {
struct spi_device *spi;
struct regulator *reg;
struct mutex lock; /* protect sensor state */
- struct gpio_desc *reset_gpio;
unsigned char ch[2];
enum ad8366_type type;
const struct ad8366_info *info;
@@ -242,6 +242,7 @@ static const struct iio_chan_spec ada4961_channels[] = {
static int ad8366_probe(struct spi_device *spi)
{
struct device *dev = &spi->dev;
+ struct reset_control *rstc;
struct iio_dev *indio_dev;
struct ad8366_state *st;
int ret;
@@ -276,9 +277,9 @@ static int ad8366_probe(struct spi_device *spi)
case ID_ADL5240:
case ID_HMC792:
case ID_HMC1119:
- st->reset_gpio = devm_gpiod_get_optional(&spi->dev, "reset", GPIOD_OUT_HIGH);
- if (IS_ERR(st->reset_gpio)) {
- ret = PTR_ERR(st->reset_gpio);
+ rstc = devm_reset_control_get_optional_exclusive_deasserted(dev, NULL);
+ if (IS_ERR(rstc)) {
+ ret = PTR_ERR(rstc);
goto error_disable_reg;
}
indio_dev->channels = ada4961_channels;
--
2.43.0
^ permalink raw reply related [flat|nested] 32+ messages in thread* Re: [PATCH v4 06/11] iio: amplifiers: ad8366: replace reset-gpio with reset controller
2026-02-10 19:42 ` [PATCH v4 06/11] iio: amplifiers: ad8366: replace reset-gpio with reset controller Rodrigo Alencar via B4 Relay
@ 2026-02-14 18:37 ` Jonathan Cameron
0 siblings, 0 replies; 32+ messages in thread
From: Jonathan Cameron @ 2026-02-14 18:37 UTC (permalink / raw)
To: Rodrigo Alencar via B4 Relay
Cc: rodrigo.alencar, linux-kernel, linux-iio, devicetree,
Michael Hennerich, Lars-Peter Clausen, David Lechner,
Andy Shevchenko, Rob Herring, Krzysztof Kozlowski, Conor Dooley
On Tue, 10 Feb 2026 19:42:06 +0000
Rodrigo Alencar via B4 Relay <devnull+rodrigo.alencar.analog.com@kernel.org> wrote:
> From: Rodrigo Alencar <rodrigo.alencar@analog.com>
>
> Remove reset_gpio from the device state struct and use the
> reset_control interface instead, using a local variable,
Prefer commit descriptions wrapped to 75 chars.
Remove reset_gpio from the device state struct and use the reset_control
interface instead, using a local variable, as it is not being used anywhere
else.
> as it is not being used anywhere else.
>
> Signed-off-by: Rodrigo Alencar <rodrigo.alencar@analog.com>
> ---
> drivers/iio/amplifiers/ad8366.c | 9 +++++----
> 1 file changed, 5 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/iio/amplifiers/ad8366.c b/drivers/iio/amplifiers/ad8366.c
> index f0053a09cbb6..67817dedd75d 100644
> --- a/drivers/iio/amplifiers/ad8366.c
> +++ b/drivers/iio/amplifiers/ad8366.c
> @@ -17,6 +17,7 @@
> #include <linux/module.h>
> #include <linux/mutex.h>
> #include <linux/regulator/consumer.h>
> +#include <linux/reset.h>
> #include <linux/spi/spi.h>
>
> #include <linux/iio/iio.h>
> @@ -38,7 +39,6 @@ struct ad8366_state {
> struct spi_device *spi;
> struct regulator *reg;
> struct mutex lock; /* protect sensor state */
> - struct gpio_desc *reset_gpio;
> unsigned char ch[2];
> enum ad8366_type type;
> const struct ad8366_info *info;
> @@ -242,6 +242,7 @@ static const struct iio_chan_spec ada4961_channels[] = {
> static int ad8366_probe(struct spi_device *spi)
> {
> struct device *dev = &spi->dev;
> + struct reset_control *rstc;
> struct iio_dev *indio_dev;
> struct ad8366_state *st;
> int ret;
> @@ -276,9 +277,9 @@ static int ad8366_probe(struct spi_device *spi)
> case ID_ADL5240:
> case ID_HMC792:
> case ID_HMC1119:
> - st->reset_gpio = devm_gpiod_get_optional(&spi->dev, "reset", GPIOD_OUT_HIGH);
> - if (IS_ERR(st->reset_gpio)) {
> - ret = PTR_ERR(st->reset_gpio);
> + rstc = devm_reset_control_get_optional_exclusive_deasserted(dev, NULL);
> + if (IS_ERR(rstc)) {
> + ret = PTR_ERR(rstc);
> goto error_disable_reg;
> }
> indio_dev->channels = ada4961_channels;
>
^ permalink raw reply [flat|nested] 32+ messages in thread
* [PATCH v4 07/11] iio: amplifiers: ad8366: refactor device resource management
2026-02-10 19:42 [PATCH v4 00/11] iio: amplifiers: ad8366: driver update and dt support Rodrigo Alencar via B4 Relay
` (5 preceding siblings ...)
2026-02-10 19:42 ` [PATCH v4 06/11] iio: amplifiers: ad8366: replace reset-gpio with reset controller Rodrigo Alencar via B4 Relay
@ 2026-02-10 19:42 ` Rodrigo Alencar via B4 Relay
2026-02-10 20:05 ` Andy Shevchenko
2026-02-10 19:42 ` [PATCH v4 08/11] iio: amplifiers: ad8366: prepare for device-tree support Rodrigo Alencar via B4 Relay
` (3 subsequent siblings)
10 siblings, 1 reply; 32+ messages in thread
From: Rodrigo Alencar via B4 Relay @ 2026-02-10 19:42 UTC (permalink / raw)
To: linux-kernel, linux-iio, devicetree
Cc: Michael Hennerich, Lars-Peter Clausen, Jonathan Cameron,
David Lechner, Andy Shevchenko, Rob Herring, Krzysztof Kozlowski,
Conor Dooley, Rodrigo Alencar
From: Rodrigo Alencar <rodrigo.alencar@analog.com>
Adhere modern device resource management with the following:
- Voltage regulator managed and enabled internally;
- IIO device registration handled with devm_iio_device_register();
- removal of goto's from the probe function;
- ad8366_remove() removed as it is not needed anymore;
With the drop of goto's dev_err_probe() is used to report probe errors.
Signed-off-by: Rodrigo Alencar <rodrigo.alencar@analog.com>
---
drivers/iio/amplifiers/ad8366.c | 50 +++++++++--------------------------------
1 file changed, 10 insertions(+), 40 deletions(-)
diff --git a/drivers/iio/amplifiers/ad8366.c b/drivers/iio/amplifiers/ad8366.c
index 67817dedd75d..343f370eae65 100644
--- a/drivers/iio/amplifiers/ad8366.c
+++ b/drivers/iio/amplifiers/ad8366.c
@@ -37,7 +37,6 @@ struct ad8366_info {
struct ad8366_state {
struct spi_device *spi;
- struct regulator *reg;
struct mutex lock; /* protect sensor state */
unsigned char ch[2];
enum ad8366_type type;
@@ -257,14 +256,10 @@ static int ad8366_probe(struct spi_device *spi)
if (ret)
return ret;
- st->reg = devm_regulator_get(&spi->dev, "vcc");
- if (!IS_ERR(st->reg)) {
- ret = regulator_enable(st->reg);
- if (ret)
- return ret;
- }
+ ret = devm_regulator_get_enable(dev, "vcc");
+ if (ret)
+ return dev_err_probe(dev, ret, "Failed to get regulator\n");
- spi_set_drvdata(spi, indio_dev);
st->spi = spi;
st->type = spi_get_device_id(spi)->driver_data;
@@ -278,17 +273,15 @@ static int ad8366_probe(struct spi_device *spi)
case ID_HMC792:
case ID_HMC1119:
rstc = devm_reset_control_get_optional_exclusive_deasserted(dev, NULL);
- if (IS_ERR(rstc)) {
- ret = PTR_ERR(rstc);
- goto error_disable_reg;
- }
+ if (IS_ERR(rstc))
+ return dev_err_probe(dev, PTR_ERR(rstc),
+ "Failed to get reset controller\n");
+
indio_dev->channels = ada4961_channels;
indio_dev->num_channels = ARRAY_SIZE(ada4961_channels);
break;
default:
- dev_err(&spi->dev, "Invalid device ID\n");
- ret = -EINVAL;
- goto error_disable_reg;
+ return dev_err_probe(dev, -EINVAL, "Invalid device ID\n");
}
st->info = &ad8366_infos[st->type];
@@ -298,31 +291,9 @@ static int ad8366_probe(struct spi_device *spi)
ret = ad8366_write(indio_dev, 0, 0);
if (ret < 0)
- goto error_disable_reg;
+ return dev_err_probe(dev, ret, "failed to write initial gain\n");
- ret = iio_device_register(indio_dev);
- if (ret)
- goto error_disable_reg;
-
- return 0;
-
-error_disable_reg:
- if (!IS_ERR(st->reg))
- regulator_disable(st->reg);
-
- return ret;
-}
-
-static void ad8366_remove(struct spi_device *spi)
-{
- struct iio_dev *indio_dev = spi_get_drvdata(spi);
- struct ad8366_state *st = iio_priv(indio_dev);
- struct regulator *reg = st->reg;
-
- iio_device_unregister(indio_dev);
-
- if (!IS_ERR(reg))
- regulator_disable(reg);
+ return devm_iio_device_register(dev, indio_dev);
}
static const struct spi_device_id ad8366_id[] = {
@@ -340,7 +311,6 @@ static struct spi_driver ad8366_driver = {
.name = KBUILD_MODNAME,
},
.probe = ad8366_probe,
- .remove = ad8366_remove,
.id_table = ad8366_id,
};
--
2.43.0
^ permalink raw reply related [flat|nested] 32+ messages in thread* Re: [PATCH v4 07/11] iio: amplifiers: ad8366: refactor device resource management
2026-02-10 19:42 ` [PATCH v4 07/11] iio: amplifiers: ad8366: refactor device resource management Rodrigo Alencar via B4 Relay
@ 2026-02-10 20:05 ` Andy Shevchenko
2026-02-11 12:10 ` Rodrigo Alencar
0 siblings, 1 reply; 32+ messages in thread
From: Andy Shevchenko @ 2026-02-10 20:05 UTC (permalink / raw)
To: rodrigo.alencar
Cc: linux-kernel, linux-iio, devicetree, Michael Hennerich,
Lars-Peter Clausen, Jonathan Cameron, David Lechner,
Andy Shevchenko, Rob Herring, Krzysztof Kozlowski, Conor Dooley
On Tue, Feb 10, 2026 at 07:42:07PM +0000, Rodrigo Alencar via B4 Relay wrote:
> Adhere modern device resource management with the following:
> - Voltage regulator managed and enabled internally;
> - IIO device registration handled with devm_iio_device_register();
> - removal of goto's from the probe function;
> - ad8366_remove() removed as it is not needed anymore;
>
> With the drop of goto's dev_err_probe() is used to report probe errors.
I think the regulator change should be split and go before the previous patch,
because that one affects the ordering in the error path and remove stage.
Otherwise LGTM.
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 32+ messages in thread
* Re: [PATCH v4 07/11] iio: amplifiers: ad8366: refactor device resource management
2026-02-10 20:05 ` Andy Shevchenko
@ 2026-02-11 12:10 ` Rodrigo Alencar
2026-02-11 13:30 ` Andy Shevchenko
0 siblings, 1 reply; 32+ messages in thread
From: Rodrigo Alencar @ 2026-02-11 12:10 UTC (permalink / raw)
To: Andy Shevchenko, rodrigo.alencar
Cc: linux-kernel, linux-iio, devicetree, Michael Hennerich,
Lars-Peter Clausen, Jonathan Cameron, David Lechner,
Andy Shevchenko, Rob Herring, Krzysztof Kozlowski, Conor Dooley
On 26/02/10 10:05PM, Andy Shevchenko wrote:
> On Tue, Feb 10, 2026 at 07:42:07PM +0000, Rodrigo Alencar via B4 Relay wrote:
>
> > Adhere modern device resource management with the following:
> > - Voltage regulator managed and enabled internally;
> > - IIO device registration handled with devm_iio_device_register();
> > - removal of goto's from the probe function;
> > - ad8366_remove() removed as it is not needed anymore;
> >
> > With the drop of goto's dev_err_probe() is used to report probe errors.
>
> I think the regulator change should be split and go before the previous patch,
> because that one affects the ordering in the error path and remove stage.
OK, that can be done, but the same way, the error check would change as
well as the dev_err_probe() args, not seeing much benefit there as the same
lines will have to be touched anyways.
--
Kind regards,
Rodrigo Alencar
^ permalink raw reply [flat|nested] 32+ messages in thread
* Re: [PATCH v4 07/11] iio: amplifiers: ad8366: refactor device resource management
2026-02-11 12:10 ` Rodrigo Alencar
@ 2026-02-11 13:30 ` Andy Shevchenko
2026-02-14 18:44 ` Jonathan Cameron
0 siblings, 1 reply; 32+ messages in thread
From: Andy Shevchenko @ 2026-02-11 13:30 UTC (permalink / raw)
To: Rodrigo Alencar
Cc: rodrigo.alencar, linux-kernel, linux-iio, devicetree,
Michael Hennerich, Lars-Peter Clausen, Jonathan Cameron,
David Lechner, Andy Shevchenko, Rob Herring, Krzysztof Kozlowski,
Conor Dooley
On Wed, Feb 11, 2026 at 12:10:11PM +0000, Rodrigo Alencar wrote:
> On 26/02/10 10:05PM, Andy Shevchenko wrote:
> > On Tue, Feb 10, 2026 at 07:42:07PM +0000, Rodrigo Alencar via B4 Relay wrote:
> >
> > > Adhere modern device resource management with the following:
> > > - Voltage regulator managed and enabled internally;
> > > - IIO device registration handled with devm_iio_device_register();
> > > - removal of goto's from the probe function;
> > > - ad8366_remove() removed as it is not needed anymore;
> > >
> > > With the drop of goto's dev_err_probe() is used to report probe errors.
> >
> > I think the regulator change should be split and go before the previous patch,
> > because that one affects the ordering in the error path and remove stage.
>
> OK, that can be done, but the same way,
> the error check would change as well as the dev_err_probe() args, not seeing
> much benefit there as the same lines will have to be touched anyways.
The point is to range the problems and target the more serious one first.
I consider the wrong ordering, (mis)use of devm_*() are in a priority to
just a simple cleanup.
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 32+ messages in thread
* Re: [PATCH v4 07/11] iio: amplifiers: ad8366: refactor device resource management
2026-02-11 13:30 ` Andy Shevchenko
@ 2026-02-14 18:44 ` Jonathan Cameron
0 siblings, 0 replies; 32+ messages in thread
From: Jonathan Cameron @ 2026-02-14 18:44 UTC (permalink / raw)
To: Andy Shevchenko
Cc: Rodrigo Alencar, rodrigo.alencar, linux-kernel, linux-iio,
devicetree, Michael Hennerich, Lars-Peter Clausen, David Lechner,
Andy Shevchenko, Rob Herring, Krzysztof Kozlowski, Conor Dooley
On Wed, 11 Feb 2026 15:30:44 +0200
Andy Shevchenko <andriy.shevchenko@intel.com> wrote:
> On Wed, Feb 11, 2026 at 12:10:11PM +0000, Rodrigo Alencar wrote:
> > On 26/02/10 10:05PM, Andy Shevchenko wrote:
> > > On Tue, Feb 10, 2026 at 07:42:07PM +0000, Rodrigo Alencar via B4 Relay wrote:
> > >
> > > > Adhere modern device resource management with the following:
> > > > - Voltage regulator managed and enabled internally;
> > > > - IIO device registration handled with devm_iio_device_register();
> > > > - removal of goto's from the probe function;
> > > > - ad8366_remove() removed as it is not needed anymore;
> > > >
> > > > With the drop of goto's dev_err_probe() is used to report probe errors.
> > >
> > > I think the regulator change should be split and go before the previous patch,
> > > because that one affects the ordering in the error path and remove stage.
> >
> > OK, that can be done, but the same way,
> > the error check would change as well as the dev_err_probe() args, not seeing
> > much benefit there as the same lines will have to be touched anyways.
>
> The point is to range the problems and target the more serious one first.
> I consider the wrong ordering, (mis)use of devm_*() are in a priority to
> just a simple cleanup.
>
Took me a minute to see what was meant here, but having realized original
code unwound as power off then reset when it had setup as power on then reset,
I agree entirely with Andy that should be fixed in the earlier patch.
Thanks,
Jonathan
^ permalink raw reply [flat|nested] 32+ messages in thread
* [PATCH v4 08/11] iio: amplifiers: ad8366: prepare for device-tree support
2026-02-10 19:42 [PATCH v4 00/11] iio: amplifiers: ad8366: driver update and dt support Rodrigo Alencar via B4 Relay
` (6 preceding siblings ...)
2026-02-10 19:42 ` [PATCH v4 07/11] iio: amplifiers: ad8366: refactor device resource management Rodrigo Alencar via B4 Relay
@ 2026-02-10 19:42 ` Rodrigo Alencar via B4 Relay
2026-02-14 18:56 ` Jonathan Cameron
2026-02-10 19:42 ` [PATCH v4 09/11] iio: amplifiers: ad8366: add device tree support Rodrigo Alencar via B4 Relay
` (2 subsequent siblings)
10 siblings, 1 reply; 32+ messages in thread
From: Rodrigo Alencar via B4 Relay @ 2026-02-10 19:42 UTC (permalink / raw)
To: linux-kernel, linux-iio, devicetree
Cc: Michael Hennerich, Lars-Peter Clausen, Jonathan Cameron,
David Lechner, Andy Shevchenko, Rob Herring, Krzysztof Kozlowski,
Conor Dooley, Rodrigo Alencar
From: Rodrigo Alencar <rodrigo.alencar@analog.com>
Drop switch case on the enum ID in favor of extended chip info table,
containing:
- gain_step, indicating with sign the start of the code range;
- num_channels, to indicate the number IIO channels;
- pack_code() function to describe how SPI buffer is populated;
Which allowed for a simplified read_raw() and write_raw() callbacks.
The probe() function was adjusted accordingly.
Signed-off-by: Rodrigo Alencar <rodrigo.alencar@analog.com>
---
drivers/iio/amplifiers/ad8366.c | 139 +++++++++++++---------------------------
1 file changed, 46 insertions(+), 93 deletions(-)
diff --git a/drivers/iio/amplifiers/ad8366.c b/drivers/iio/amplifiers/ad8366.c
index 343f370eae65..1ae75643e89b 100644
--- a/drivers/iio/amplifiers/ad8366.c
+++ b/drivers/iio/amplifiers/ad8366.c
@@ -19,6 +19,7 @@
#include <linux/regulator/consumer.h>
#include <linux/reset.h>
#include <linux/spi/spi.h>
+#include <linux/unaligned.h>
#include <linux/iio/iio.h>
@@ -30,16 +31,20 @@ enum ad8366_type {
ID_HMC1119,
};
+struct ad8366_state;
+
struct ad8366_info {
int gain_min;
int gain_max;
+ int gain_step;
+ int num_channels;
+ size_t (*pack_code)(struct ad8366_state *st);
};
struct ad8366_state {
struct spi_device *spi;
struct mutex lock; /* protect sensor state */
unsigned char ch[2];
- enum ad8366_type type;
const struct ad8366_info *info;
/*
* DMA (thus cache coherency maintenance) may require the
@@ -48,60 +53,58 @@ struct ad8366_state {
unsigned char data[2] __aligned(IIO_DMA_MINALIGN);
};
+static size_t ad8366_pack_code(struct ad8366_state *st)
+{
+ u8 ch_a = bitrev8(st->ch[0]) >> 2;
+ u8 ch_b = bitrev8(st->ch[1]) >> 2;
+
+ put_unaligned_be16((ch_b << 6) | ch_a, &st->data[0]);
+ return sizeof(__be16);
+}
+
static const struct ad8366_info ad8366_infos[] = {
[ID_AD8366] = {
.gain_min = 4500,
.gain_max = 20500,
+ .gain_step = 253,
+ .num_channels = 2,
+ .pack_code = ad8366_pack_code,
},
[ID_ADA4961] = {
.gain_min = -6000,
.gain_max = 15000,
+ .gain_step = -1000,
+ .num_channels = 1,
},
[ID_ADL5240] = {
.gain_min = -11500,
.gain_max = 20000,
+ .gain_step = 500,
+ .num_channels = 1,
},
[ID_HMC792] = {
.gain_min = -15750,
.gain_max = 0,
+ .gain_step = 250,
+ .num_channels = 1,
},
[ID_HMC1119] = {
.gain_min = -31750,
.gain_max = 0,
+ .gain_step = -250,
+ .num_channels = 1,
},
};
-static int ad8366_write(struct iio_dev *indio_dev,
- unsigned char ch_a, unsigned char ch_b)
+static int ad8366_write_code(struct ad8366_state *st)
{
- struct ad8366_state *st = iio_priv(indio_dev);
- int ret;
+ const struct ad8366_info *inf = st->info;
- switch (st->type) {
- case ID_AD8366:
- ch_a = bitrev8(ch_a & 0x3F);
- ch_b = bitrev8(ch_b & 0x3F);
+ if (inf->pack_code)
+ spi_write(st->spi, st->data, inf->pack_code(st));
- st->data[0] = ch_b >> 4;
- st->data[1] = (ch_b << 4) | (ch_a >> 2);
- break;
- case ID_ADA4961:
- st->data[0] = ch_a & 0x1F;
- break;
- case ID_ADL5240:
- st->data[0] = (ch_a & 0x3F);
- break;
- case ID_HMC792:
- case ID_HMC1119:
- st->data[0] = ch_a;
- break;
- }
-
- ret = spi_write(st->spi, st->data, indio_dev->num_channels);
- if (ret < 0)
- dev_err(&indio_dev->dev, "write failed (%d)", ret);
-
- return ret;
+ st->data[0] = st->ch[0];
+ return spi_write(st->spi, st->data, 1);
}
static int ad8366_read_raw(struct iio_dev *indio_dev,
@@ -111,6 +114,7 @@ static int ad8366_read_raw(struct iio_dev *indio_dev,
long m)
{
struct ad8366_state *st = iio_priv(indio_dev);
+ const struct ad8366_info *inf = st->info;
int ret;
int code, gain = 0;
@@ -118,25 +122,8 @@ static int ad8366_read_raw(struct iio_dev *indio_dev,
switch (m) {
case IIO_CHAN_INFO_HARDWAREGAIN:
code = st->ch[chan->channel];
-
- switch (st->type) {
- case ID_AD8366:
- gain = code * 253 + 4500;
- break;
- case ID_ADA4961:
- gain = 15000 - code * 1000;
- break;
- case ID_ADL5240:
- gain = 20000 - 31500 + code * 500;
- break;
- case ID_HMC792:
- gain = -1 * code * 500;
- break;
- case ID_HMC1119:
- gain = -1 * code * 250;
- break;
- }
-
+ gain = inf->gain_step > 0 ? inf->gain_min : inf->gain_max;
+ gain += inf->gain_step * code;
/* Values in dB */
*val = gain / 1000;
*val2 = (gain % 1000) * 1000;
@@ -171,29 +158,14 @@ static int ad8366_write_raw(struct iio_dev *indio_dev,
if (gain > inf->gain_max || gain < inf->gain_min)
return -EINVAL;
- switch (st->type) {
- case ID_AD8366:
- code = (gain - 4500) / 253;
- break;
- case ID_ADA4961:
- code = (15000 - gain) / 1000;
- break;
- case ID_ADL5240:
- code = ((gain - 500 - 20000) / 500) & 0x3F;
- break;
- case ID_HMC792:
- code = (abs(gain) / 500) & 0x3F;
- break;
- case ID_HMC1119:
- code = (abs(gain) / 250) & 0x7F;
- break;
- }
+ gain -= inf->gain_step > 0 ? inf->gain_min : inf->gain_max;
+ code = DIV_ROUND_CLOSEST(gain, inf->gain_step);
mutex_lock(&st->lock);
switch (mask) {
case IIO_CHAN_INFO_HARDWAREGAIN:
st->ch[chan->channel] = code;
- ret = ad8366_write(indio_dev, st->ch[0], st->ch[1]);
+ ret = ad8366_write_code(st);
break;
default:
ret = -EINVAL;
@@ -234,10 +206,6 @@ static const struct iio_chan_spec ad8366_channels[] = {
AD8366_CHAN(1),
};
-static const struct iio_chan_spec ada4961_channels[] = {
- AD8366_CHAN(0),
-};
-
static int ad8366_probe(struct spi_device *spi)
{
struct device *dev = &spi->dev;
@@ -261,35 +229,20 @@ static int ad8366_probe(struct spi_device *spi)
return dev_err_probe(dev, ret, "Failed to get regulator\n");
st->spi = spi;
- st->type = spi_get_device_id(spi)->driver_data;
+ st->info = &ad8366_infos[spi_get_device_id(spi)->driver_data];
- switch (st->type) {
- case ID_AD8366:
- indio_dev->channels = ad8366_channels;
- indio_dev->num_channels = ARRAY_SIZE(ad8366_channels);
- break;
- case ID_ADA4961:
- case ID_ADL5240:
- case ID_HMC792:
- case ID_HMC1119:
- rstc = devm_reset_control_get_optional_exclusive_deasserted(dev, NULL);
- if (IS_ERR(rstc))
- return dev_err_probe(dev, PTR_ERR(rstc),
- "Failed to get reset controller\n");
+ rstc = devm_reset_control_get_optional_exclusive_deasserted(dev, NULL);
+ if (IS_ERR(rstc))
+ return dev_err_probe(dev, PTR_ERR(rstc),
+ "Failed to get reset controller\n");
- indio_dev->channels = ada4961_channels;
- indio_dev->num_channels = ARRAY_SIZE(ada4961_channels);
- break;
- default:
- return dev_err_probe(dev, -EINVAL, "Invalid device ID\n");
- }
-
- st->info = &ad8366_infos[st->type];
indio_dev->name = spi_get_device_id(spi)->name;
indio_dev->info = &ad8366_info;
indio_dev->modes = INDIO_DIRECT_MODE;
+ indio_dev->channels = ad8366_channels;
+ indio_dev->num_channels = st->info->num_channels;
- ret = ad8366_write(indio_dev, 0, 0);
+ ret = ad8366_write_code(st);
if (ret < 0)
return dev_err_probe(dev, ret, "failed to write initial gain\n");
--
2.43.0
^ permalink raw reply related [flat|nested] 32+ messages in thread* Re: [PATCH v4 08/11] iio: amplifiers: ad8366: prepare for device-tree support
2026-02-10 19:42 ` [PATCH v4 08/11] iio: amplifiers: ad8366: prepare for device-tree support Rodrigo Alencar via B4 Relay
@ 2026-02-14 18:56 ` Jonathan Cameron
0 siblings, 0 replies; 32+ messages in thread
From: Jonathan Cameron @ 2026-02-14 18:56 UTC (permalink / raw)
To: Rodrigo Alencar via B4 Relay
Cc: rodrigo.alencar, linux-kernel, linux-iio, devicetree,
Michael Hennerich, Lars-Peter Clausen, David Lechner,
Andy Shevchenko, Rob Herring, Krzysztof Kozlowski, Conor Dooley
On Tue, 10 Feb 2026 19:42:08 +0000
Rodrigo Alencar via B4 Relay <devnull+rodrigo.alencar.analog.com@kernel.org> wrote:
> From: Rodrigo Alencar <rodrigo.alencar@analog.com>
>
> Drop switch case on the enum ID in favor of extended chip info table,
> containing:
> - gain_step, indicating with sign the start of the code range;
> - num_channels, to indicate the number IIO channels;
> - pack_code() function to describe how SPI buffer is populated;
>
> Which allowed for a simplified read_raw() and write_raw() callbacks.
> The probe() function was adjusted accordingly.
Making the reset call on all devices is a material change (probably fine)
that should be called out here.
>
> Signed-off-by: Rodrigo Alencar <rodrigo.alencar@analog.com>
> @@ -48,60 +53,58 @@ struct ad8366_state {
> unsigned char data[2] __aligned(IIO_DMA_MINALIGN);
> };
>
> +static size_t ad8366_pack_code(struct ad8366_state *st)
See below. To me this is doing too much hidden stuff from point
of view of the caller. I think it needs some more explicit parameters.
> +{
> + u8 ch_a = bitrev8(st->ch[0]) >> 2;
> + u8 ch_b = bitrev8(st->ch[1]) >> 2;
> +
> + put_unaligned_be16((ch_b << 6) | ch_a, &st->data[0]);
> + return sizeof(__be16);
> +}
>
> -static int ad8366_write(struct iio_dev *indio_dev,
> - unsigned char ch_a, unsigned char ch_b)
> +static int ad8366_write_code(struct ad8366_state *st)
> {
> - struct ad8366_state *st = iio_priv(indio_dev);
> - int ret;
> + const struct ad8366_info *inf = st->info;
>
> - switch (st->type) {
> - case ID_AD8366:
> - ch_a = bitrev8(ch_a & 0x3F);
> - ch_b = bitrev8(ch_b & 0x3F);
> + if (inf->pack_code)
> + spi_write(st->spi, st->data, inf->pack_code(st));
Check return value?
I'm also confused that this function now does two writes whereas it only
used to do one.
This is a really confusing call as inf->pack_code() has side effects
that might not be obvious out here. I'd have that callback explicitly
take the inputs and the output array so it's obvious what it can affect.
count = inf->pack_code(st->chan, 2, st->chan_data);
or something along those lines.
>
> - st->data[0] = ch_b >> 4;
> - st->data[1] = (ch_b << 4) | (ch_a >> 2);
> - break;
> - case ID_ADA4961:
> - st->data[0] = ch_a & 0x1F;
> - break;
> - case ID_ADL5240:
> - st->data[0] = (ch_a & 0x3F);
> - break;
> - case ID_HMC792:
> - case ID_HMC1119:
> - st->data[0] = ch_a;
> - break;
> - }
> -
> - ret = spi_write(st->spi, st->data, indio_dev->num_channels);
> - if (ret < 0)
> - dev_err(&indio_dev->dev, "write failed (%d)", ret);
> -
> - return ret;
> + st->data[0] = st->ch[0];
> + return spi_write(st->spi, st->data, 1);
> }
> static int ad8366_probe(struct spi_device *spi)
> {
> struct device *dev = &spi->dev;
> @@ -261,35 +229,20 @@ static int ad8366_probe(struct spi_device *spi)
> return dev_err_probe(dev, ret, "Failed to get regulator\n");
>
> st->spi = spi;
> - st->type = spi_get_device_id(spi)->driver_data;
> + st->info = &ad8366_infos[spi_get_device_id(spi)->driver_data];
>
> - switch (st->type) {
> - case ID_AD8366:
> - indio_dev->channels = ad8366_channels;
> - indio_dev->num_channels = ARRAY_SIZE(ad8366_channels);
> - break;
> - case ID_ADA4961:
> - case ID_ADL5240:
> - case ID_HMC792:
> - case ID_HMC1119:
> - rstc = devm_reset_control_get_optional_exclusive_deasserted(dev, NULL);
> - if (IS_ERR(rstc))
> - return dev_err_probe(dev, PTR_ERR(rstc),
> - "Failed to get reset controller\n");
> + rstc = devm_reset_control_get_optional_exclusive_deasserted(dev, NULL);
I was surprised not to see this change in the patch description.
I guess it's fine because if the chip doesn't have a reset it looks the same
as one that isn't wired? Add a comment to say not all devices have resets or
add a flag to the info structure and go back to calling it only for devices
that at least have a reset pin.
> + if (IS_ERR(rstc))
> + return dev_err_probe(dev, PTR_ERR(rstc),
> + "Failed to get reset controller\n");
>
> - indio_dev->channels = ada4961_channels;
> - indio_dev->num_channels = ARRAY_SIZE(ada4961_channels);
> - break;
> - default:
> - return dev_err_probe(dev, -EINVAL, "Invalid device ID\n");
> - }
> -
> - st->info = &ad8366_infos[st->type];
> indio_dev->name = spi_get_device_id(spi)->name;
> indio_dev->info = &ad8366_info;
> indio_dev->modes = INDIO_DIRECT_MODE;
> + indio_dev->channels = ad8366_channels;
> + indio_dev->num_channels = st->info->num_channels;
>
> - ret = ad8366_write(indio_dev, 0, 0);
> + ret = ad8366_write_code(st);
> if (ret < 0)
> return dev_err_probe(dev, ret, "failed to write initial gain\n");
>
>
^ permalink raw reply [flat|nested] 32+ messages in thread
* [PATCH v4 09/11] iio: amplifiers: ad8366: add device tree support
2026-02-10 19:42 [PATCH v4 00/11] iio: amplifiers: ad8366: driver update and dt support Rodrigo Alencar via B4 Relay
` (7 preceding siblings ...)
2026-02-10 19:42 ` [PATCH v4 08/11] iio: amplifiers: ad8366: prepare for device-tree support Rodrigo Alencar via B4 Relay
@ 2026-02-10 19:42 ` Rodrigo Alencar via B4 Relay
2026-02-14 19:00 ` Jonathan Cameron
2026-02-10 19:42 ` [PATCH v4 10/11] iio: amplifiers: ad8366: consume enable gpio Rodrigo Alencar via B4 Relay
2026-02-10 19:42 ` [PATCH v4 11/11] iio: amplifiers: ad8366: update device support Rodrigo Alencar via B4 Relay
10 siblings, 1 reply; 32+ messages in thread
From: Rodrigo Alencar via B4 Relay @ 2026-02-10 19:42 UTC (permalink / raw)
To: linux-kernel, linux-iio, devicetree
Cc: Michael Hennerich, Lars-Peter Clausen, Jonathan Cameron,
David Lechner, Andy Shevchenko, Rob Herring, Krzysztof Kozlowski,
Conor Dooley, Rodrigo Alencar
From: Rodrigo Alencar <rodrigo.alencar@analog.com>
Drop the enum ID, split chip info table into per-device structs
and add of_match_table.
Signed-off-by: Rodrigo Alencar <rodrigo.alencar@analog.com>
---
drivers/iio/amplifiers/ad8366.c | 100 +++++++++++++++++++++-------------------
1 file changed, 53 insertions(+), 47 deletions(-)
diff --git a/drivers/iio/amplifiers/ad8366.c b/drivers/iio/amplifiers/ad8366.c
index 1ae75643e89b..79fb3119d794 100644
--- a/drivers/iio/amplifiers/ad8366.c
+++ b/drivers/iio/amplifiers/ad8366.c
@@ -14,6 +14,7 @@
#include <linux/bitrev.h>
#include <linux/err.h>
#include <linux/gpio/consumer.h>
+#include <linux/mod_devicetable.h>
#include <linux/module.h>
#include <linux/mutex.h>
#include <linux/regulator/consumer.h>
@@ -23,14 +24,6 @@
#include <linux/iio/iio.h>
-enum ad8366_type {
- ID_AD8366,
- ID_ADA4961,
- ID_ADL5240,
- ID_HMC792,
- ID_HMC1119,
-};
-
struct ad8366_state;
struct ad8366_info {
@@ -62,38 +55,40 @@ static size_t ad8366_pack_code(struct ad8366_state *st)
return sizeof(__be16);
}
-static const struct ad8366_info ad8366_infos[] = {
- [ID_AD8366] = {
- .gain_min = 4500,
- .gain_max = 20500,
- .gain_step = 253,
- .num_channels = 2,
- .pack_code = ad8366_pack_code,
- },
- [ID_ADA4961] = {
- .gain_min = -6000,
- .gain_max = 15000,
- .gain_step = -1000,
- .num_channels = 1,
- },
- [ID_ADL5240] = {
- .gain_min = -11500,
- .gain_max = 20000,
- .gain_step = 500,
- .num_channels = 1,
- },
- [ID_HMC792] = {
- .gain_min = -15750,
- .gain_max = 0,
- .gain_step = 250,
- .num_channels = 1,
- },
- [ID_HMC1119] = {
- .gain_min = -31750,
- .gain_max = 0,
- .gain_step = -250,
- .num_channels = 1,
- },
+static const struct ad8366_info ad8366_chip_info = {
+ .gain_min = 4500,
+ .gain_max = 20500,
+ .gain_step = 253,
+ .num_channels = 2,
+ .pack_code = ad8366_pack_code,
+};
+
+static const struct ad8366_info ada4961_chip_info = {
+ .gain_min = -6000,
+ .gain_max = 15000,
+ .gain_step = -1000,
+ .num_channels = 1,
+};
+
+static const struct ad8366_info adl5240_chip_info = {
+ .gain_min = -11500,
+ .gain_max = 20000,
+ .gain_step = 500,
+ .num_channels = 1,
+};
+
+static const struct ad8366_info hmc792_chip_info = {
+ .gain_min = -15750,
+ .gain_max = 0,
+ .gain_step = 250,
+ .num_channels = 1,
+};
+
+static const struct ad8366_info hmc1119_chip_info = {
+ .gain_min = -31750,
+ .gain_max = 0,
+ .gain_step = -250,
+ .num_channels = 1,
};
static int ad8366_write_code(struct ad8366_state *st)
@@ -229,7 +224,7 @@ static int ad8366_probe(struct spi_device *spi)
return dev_err_probe(dev, ret, "Failed to get regulator\n");
st->spi = spi;
- st->info = &ad8366_infos[spi_get_device_id(spi)->driver_data];
+ st->info = spi_get_device_match_data(spi);
rstc = devm_reset_control_get_optional_exclusive_deasserted(dev, NULL);
if (IS_ERR(rstc))
@@ -250,18 +245,29 @@ static int ad8366_probe(struct spi_device *spi)
}
static const struct spi_device_id ad8366_id[] = {
- {"ad8366", ID_AD8366},
- {"ada4961", ID_ADA4961},
- {"adl5240", ID_ADL5240},
- {"hmc792a", ID_HMC792},
- {"hmc1119", ID_HMC1119},
+ {"ad8366", (kernel_ulong_t)&ad8366_chip_info},
+ {"ada4961", (kernel_ulong_t)&ada4961_chip_info},
+ {"adl5240", (kernel_ulong_t)&adl5240_chip_info},
+ {"hmc792a", (kernel_ulong_t)&hmc792_chip_info},
+ {"hmc1119", (kernel_ulong_t)&hmc1119_chip_info},
{ }
};
MODULE_DEVICE_TABLE(spi, ad8366_id);
+static const struct of_device_id ad8366_of_match[] = {
+ { .compatible = "adi,ad8366", .data = &ad8366_chip_info },
+ { .compatible = "adi,ada4961", .data = &ada4961_chip_info },
+ { .compatible = "adi,adl5240", .data = &adl5240_chip_info },
+ { .compatible = "adi,hmc792a", .data = &hmc792_chip_info },
+ { .compatible = "adi,hmc1119", .data = &hmc1119_chip_info },
+ { }
+};
+MODULE_DEVICE_TABLE(of, ad8366_of_match);
+
static struct spi_driver ad8366_driver = {
.driver = {
- .name = KBUILD_MODNAME,
+ .name = KBUILD_MODNAME,
+ .of_match_table = ad8366_of_match,
},
.probe = ad8366_probe,
.id_table = ad8366_id,
--
2.43.0
^ permalink raw reply related [flat|nested] 32+ messages in thread* Re: [PATCH v4 09/11] iio: amplifiers: ad8366: add device tree support
2026-02-10 19:42 ` [PATCH v4 09/11] iio: amplifiers: ad8366: add device tree support Rodrigo Alencar via B4 Relay
@ 2026-02-14 19:00 ` Jonathan Cameron
0 siblings, 0 replies; 32+ messages in thread
From: Jonathan Cameron @ 2026-02-14 19:00 UTC (permalink / raw)
To: Rodrigo Alencar via B4 Relay
Cc: rodrigo.alencar, linux-kernel, linux-iio, devicetree,
Michael Hennerich, Lars-Peter Clausen, David Lechner,
Andy Shevchenko, Rob Herring, Krzysztof Kozlowski, Conor Dooley
On Tue, 10 Feb 2026 19:42:09 +0000
Rodrigo Alencar via B4 Relay <devnull+rodrigo.alencar.analog.com@kernel.org> wrote:
> From: Rodrigo Alencar <rodrigo.alencar@analog.com>
>
> Drop the enum ID, split chip info table into per-device structs
> and add of_match_table.
>
> Signed-off-by: Rodrigo Alencar <rodrigo.alencar@analog.com>
Hi Rodrigo
A few more related things to update whilst you are doing this.
In general looks good.
Thanks
Jonathan
> +
> +static const struct ad8366_info hmc1119_chip_info = {
> + .gain_min = -31750,
As below. Add
.name = hmc1119,
and similar to all of these.
> + .gain_max = 0,
> + .gain_step = -250,
> + .num_channels = 1,
> };
>
> static int ad8366_write_code(struct ad8366_state *st)
> @@ -229,7 +224,7 @@ static int ad8366_probe(struct spi_device *spi)
> return dev_err_probe(dev, ret, "Failed to get regulator\n");
>
> st->spi = spi;
> - st->info = &ad8366_infos[spi_get_device_id(spi)->driver_data];
> + st->info = spi_get_device_match_data(spi);
Also drop the remaining use of spi_get_device_id() in setting the
name. There are fun issues that arise with using spi_get_device_id() at all
when fallback compatibles are a possibility (which they always are) and
so we are much better off just having the name strings also in the
ad8366_info structures.
>
> rstc = devm_reset_control_get_optional_exclusive_deasserted(dev, NULL);
> if (IS_ERR(rstc))
> @@ -250,18 +245,29 @@ static int ad8366_probe(struct spi_device *spi)
> }
>
> static const struct spi_device_id ad8366_id[] = {
> - {"ad8366", ID_AD8366},
> - {"ada4961", ID_ADA4961},
> - {"adl5240", ID_ADL5240},
> - {"hmc792a", ID_HMC792},
> - {"hmc1119", ID_HMC1119},
> + {"ad8366", (kernel_ulong_t)&ad8366_chip_info},
Given you are touching it anyway can you add space after { and before }
Thanks!
> + {"ada4961", (kernel_ulong_t)&ada4961_chip_info},
> + {"adl5240", (kernel_ulong_t)&adl5240_chip_info},
> + {"hmc792a", (kernel_ulong_t)&hmc792_chip_info},
> + {"hmc1119", (kernel_ulong_t)&hmc1119_chip_info},
> { }
> };
> MODULE_DEVICE_TABLE(spi, ad8366_id);
>
> +static const struct of_device_id ad8366_of_match[] = {
> + { .compatible = "adi,ad8366", .data = &ad8366_chip_info },
> + { .compatible = "adi,ada4961", .data = &ada4961_chip_info },
> + { .compatible = "adi,adl5240", .data = &adl5240_chip_info },
> + { .compatible = "adi,hmc792a", .data = &hmc792_chip_info },
> + { .compatible = "adi,hmc1119", .data = &hmc1119_chip_info },
> + { }
> +};
> +MODULE_DEVICE_TABLE(of, ad8366_of_match);
> +
> static struct spi_driver ad8366_driver = {
> .driver = {
> - .name = KBUILD_MODNAME,
> + .name = KBUILD_MODNAME,
> + .of_match_table = ad8366_of_match,
> },
> .probe = ad8366_probe,
> .id_table = ad8366_id,
>
^ permalink raw reply [flat|nested] 32+ messages in thread
* [PATCH v4 10/11] iio: amplifiers: ad8366: consume enable gpio
2026-02-10 19:42 [PATCH v4 00/11] iio: amplifiers: ad8366: driver update and dt support Rodrigo Alencar via B4 Relay
` (8 preceding siblings ...)
2026-02-10 19:42 ` [PATCH v4 09/11] iio: amplifiers: ad8366: add device tree support Rodrigo Alencar via B4 Relay
@ 2026-02-10 19:42 ` Rodrigo Alencar via B4 Relay
2026-02-10 19:42 ` [PATCH v4 11/11] iio: amplifiers: ad8366: update device support Rodrigo Alencar via B4 Relay
10 siblings, 0 replies; 32+ messages in thread
From: Rodrigo Alencar via B4 Relay @ 2026-02-10 19:42 UTC (permalink / raw)
To: linux-kernel, linux-iio, devicetree
Cc: Michael Hennerich, Lars-Peter Clausen, Jonathan Cameron,
David Lechner, Andy Shevchenko, Rob Herring, Krzysztof Kozlowski,
Conor Dooley, Rodrigo Alencar
From: Rodrigo Alencar <rodrigo.alencar@analog.com>
Some parts may consume enable GPIO to enable serial mode
(HMC1119's and HMC792A P/S pin) or powerup the device
(e.g. ADA4961's PWUP pin).
Signed-off-by: Rodrigo Alencar <rodrigo.alencar@analog.com>
---
drivers/iio/amplifiers/ad8366.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/drivers/iio/amplifiers/ad8366.c b/drivers/iio/amplifiers/ad8366.c
index 79fb3119d794..b828b4be7b6e 100644
--- a/drivers/iio/amplifiers/ad8366.c
+++ b/drivers/iio/amplifiers/ad8366.c
@@ -204,6 +204,7 @@ static const struct iio_chan_spec ad8366_channels[] = {
static int ad8366_probe(struct spi_device *spi)
{
struct device *dev = &spi->dev;
+ struct gpio_desc *enable_gpio;
struct reset_control *rstc;
struct iio_dev *indio_dev;
struct ad8366_state *st;
@@ -231,6 +232,11 @@ static int ad8366_probe(struct spi_device *spi)
return dev_err_probe(dev, PTR_ERR(rstc),
"Failed to get reset controller\n");
+ enable_gpio = devm_gpiod_get_optional(dev, "enable", GPIOD_OUT_HIGH);
+ if (IS_ERR(enable_gpio))
+ return dev_err_probe(dev, PTR_ERR(enable_gpio),
+ "Failed to get enable GPIO\n");
+
indio_dev->name = spi_get_device_id(spi)->name;
indio_dev->info = &ad8366_info;
indio_dev->modes = INDIO_DIRECT_MODE;
--
2.43.0
^ permalink raw reply related [flat|nested] 32+ messages in thread* [PATCH v4 11/11] iio: amplifiers: ad8366: update device support
2026-02-10 19:42 [PATCH v4 00/11] iio: amplifiers: ad8366: driver update and dt support Rodrigo Alencar via B4 Relay
` (9 preceding siblings ...)
2026-02-10 19:42 ` [PATCH v4 10/11] iio: amplifiers: ad8366: consume enable gpio Rodrigo Alencar via B4 Relay
@ 2026-02-10 19:42 ` Rodrigo Alencar via B4 Relay
2026-02-14 19:02 ` Jonathan Cameron
10 siblings, 1 reply; 32+ messages in thread
From: Rodrigo Alencar via B4 Relay @ 2026-02-10 19:42 UTC (permalink / raw)
To: linux-kernel, linux-iio, devicetree
Cc: Michael Hennerich, Lars-Peter Clausen, Jonathan Cameron,
David Lechner, Andy Shevchenko, Rob Herring, Krzysztof Kozlowski,
Conor Dooley, Rodrigo Alencar, Alexandru Ardelean,
Andy Shevchenko
From: Rodrigo Alencar <rodrigo.alencar@analog.com>
Add support for the following digital step attenuators:
- HMC271A: 1dB LSB 5-Bit Digital Attenuator SMT, 0.7 - 3.7 GHz
- ADRF5720: 0.5 dB LSB, 6-Bit, Digital Attenuator, 9 kHz to 40 GHz
- ADRF5730: 0.5 dB LSB, 6-Bit, Digital Attenuator, 100 MHz to 40 GHz
- ADRF5731: 2 dB LSB, 4-Bit, Digital Attenuator, 100 MHz to 40 GHz
- HMC1018A: 1.0 dB LSB GaAs MMIC 5-BIT DIGITAL ATTENUATOR, 0.1 - 30 GHz
- HMC1019A: 0.5 dB LSB GaAs MMIC 5-BIT DIGITAL ATTENUATOR, 0.1 - 30 GHz
Additionally, copyright notice was updated with current year.
Co-developed-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
Co-developed-by: Michael Hennerich <michael.hennerich@analog.com>
Signed-off-by: Michael Hennerich <michael.hennerich@analog.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@intel.com>
Signed-off-by: Rodrigo Alencar <rodrigo.alencar@analog.com>
---
drivers/iio/amplifiers/Kconfig | 6 ++++
drivers/iio/amplifiers/ad8366.c | 69 ++++++++++++++++++++++++++++++++++++++++-
2 files changed, 74 insertions(+), 1 deletion(-)
diff --git a/drivers/iio/amplifiers/Kconfig b/drivers/iio/amplifiers/Kconfig
index a8a604863eed..39d280d4d437 100644
--- a/drivers/iio/amplifiers/Kconfig
+++ b/drivers/iio/amplifiers/Kconfig
@@ -18,7 +18,13 @@ config AD8366
AD8366 Dual-Digital Variable Gain Amplifier (VGA)
ADA4961 BiCMOS RF Digital Gain Amplifier (DGA)
ADL5240 Digitally controlled variable gain amplifier (VGA)
+ ADRF5720: 0.5 dB LSB, 6-Bit, Silicon Digital Attenuator
+ ADRF5730: 0.5 dB LSB, 6-Bit, Silicon Digital Attenuator
+ ADRF5731: 2 dB LSB, 4-Bit, Silicon Digital Attenuator
+ HMC271A: 1dB LSB 5-Bit Digital Attenuator SMT
HMC792A 0.25 dB LSB GaAs MMIC 6-Bit Digital Attenuator
+ HMC1018A: 1.0 dB LSB GaAs MMIC 5-BIT Digital Attenuator
+ HMC1019A: 0.5 dB LSB GaAs MMIC 5-BIT Digital Attenuator
HMC1119 0.25 dB LSB, 7-Bit, Silicon Digital Attenuator
To compile this driver as a module, choose M here: the
diff --git a/drivers/iio/amplifiers/ad8366.c b/drivers/iio/amplifiers/ad8366.c
index b828b4be7b6e..557243497339 100644
--- a/drivers/iio/amplifiers/ad8366.c
+++ b/drivers/iio/amplifiers/ad8366.c
@@ -5,10 +5,16 @@
* AD8366 Dual-Digital Variable Gain Amplifier (VGA)
* ADA4961 BiCMOS RF Digital Gain Amplifier (DGA)
* ADL5240 Digitally controlled variable gain amplifier (VGA)
+ * ADRF5720: 0.5 dB LSB, 6-Bit, Silicon Digital Attenuator, 9 kHz to 40 GHz
+ * ADRF5730: 0.5 dB LSB, 6-Bit, Silicon Digital Attenuator, 100 MHz to 40 GHz
+ * ADRF5731: 2 dB LSB, 4-Bit, Silicon Digital Attenuator, 100 MHz to 40 GHz
+ * HMC271A: 1dB LSB 5-Bit Digital Attenuator SMT, 0.7 - 3.7 GHz
* HMC792A 0.25 dB LSB GaAs MMIC 6-Bit Digital Attenuator
+ * HMC1018A: 1.0 dB LSB GaAs MMIC 5-BIT DIGITAL ATTENUATOR, 0.1 - 30 GHz
+ * HMC1019A: 0.5 dB LSB GaAs MMIC 5-BIT DIGITAL ATTENUATOR, 0.1 - 30 GHz
* HMC1119 0.25 dB LSB, 7-Bit, Silicon Digital Attenuator
*
- * Copyright 2012-2019 Analog Devices Inc.
+ * Copyright 2012-2026 Analog Devices Inc.
*/
#include <linux/bitrev.h>
@@ -55,6 +61,18 @@ static size_t ad8366_pack_code(struct ad8366_state *st)
return sizeof(__be16);
}
+static size_t adrf5731_pack_code(struct ad8366_state *st)
+{
+ st->data[0] = st->ch[0] << 2;
+ return 1;
+}
+
+static size_t hmc271_pack_code(struct ad8366_state *st)
+{
+ st->data[0] = bitrev8(st->ch[0]) >> 3;
+ return 1;
+}
+
static const struct ad8366_info ad8366_chip_info = {
.gain_min = 4500,
.gain_max = 20500,
@@ -77,6 +95,29 @@ static const struct ad8366_info adl5240_chip_info = {
.num_channels = 1,
};
+static const struct ad8366_info adrf57x0_chip_info = {
+ .gain_min = -31500,
+ .gain_max = 0,
+ .gain_step = -500,
+ .num_channels = 1,
+};
+
+static const struct ad8366_info adrf5731_chip_info = {
+ .gain_min = -30000,
+ .gain_max = 0,
+ .gain_step = -2000,
+ .num_channels = 1,
+ .pack_code = adrf5731_pack_code,
+};
+
+static const struct ad8366_info hmc271_chip_info = {
+ .gain_min = -31000,
+ .gain_max = 0,
+ .gain_step = 1000,
+ .num_channels = 1,
+ .pack_code = hmc271_pack_code,
+};
+
static const struct ad8366_info hmc792_chip_info = {
.gain_min = -15750,
.gain_max = 0,
@@ -84,6 +125,20 @@ static const struct ad8366_info hmc792_chip_info = {
.num_channels = 1,
};
+static const struct ad8366_info hmc1018_chip_info = {
+ .gain_min = -31000,
+ .gain_max = 0,
+ .gain_step = 1000,
+ .num_channels = 1,
+};
+
+static const struct ad8366_info hmc1019_chip_info = {
+ .gain_min = -15500,
+ .gain_max = 0,
+ .gain_step = 500,
+ .num_channels = 1,
+};
+
static const struct ad8366_info hmc1119_chip_info = {
.gain_min = -31750,
.gain_max = 0,
@@ -254,7 +309,13 @@ static const struct spi_device_id ad8366_id[] = {
{"ad8366", (kernel_ulong_t)&ad8366_chip_info},
{"ada4961", (kernel_ulong_t)&ada4961_chip_info},
{"adl5240", (kernel_ulong_t)&adl5240_chip_info},
+ {"adrf5720", (kernel_ulong_t)&adrf57x0_chip_info},
+ {"adrf5730", (kernel_ulong_t)&adrf57x0_chip_info},
+ {"adrf5731", (kernel_ulong_t)&adrf5731_chip_info},
+ {"hmc271a", (kernel_ulong_t)&hmc271_chip_info},
{"hmc792a", (kernel_ulong_t)&hmc792_chip_info},
+ {"hmc1018a", (kernel_ulong_t)&hmc1018_chip_info},
+ {"hmc1019a", (kernel_ulong_t)&hmc1019_chip_info},
{"hmc1119", (kernel_ulong_t)&hmc1119_chip_info},
{ }
};
@@ -264,7 +325,13 @@ static const struct of_device_id ad8366_of_match[] = {
{ .compatible = "adi,ad8366", .data = &ad8366_chip_info },
{ .compatible = "adi,ada4961", .data = &ada4961_chip_info },
{ .compatible = "adi,adl5240", .data = &adl5240_chip_info },
+ { .compatible = "adi,adrf5720", .data = &adrf57x0_chip_info },
+ { .compatible = "adi,adrf5730", .data = &adrf57x0_chip_info },
+ { .compatible = "adi,adrf5731", .data = &adrf5731_chip_info },
+ { .compatible = "adi,hmc271a", .data = &hmc271_chip_info },
{ .compatible = "adi,hmc792a", .data = &hmc792_chip_info },
+ { .compatible = "adi,hmc1018a", .data = &hmc1018_chip_info },
+ { .compatible = "adi,hmc1019a", .data = &hmc1019_chip_info },
{ .compatible = "adi,hmc1119", .data = &hmc1119_chip_info },
{ }
};
--
2.43.0
^ permalink raw reply related [flat|nested] 32+ messages in thread* Re: [PATCH v4 11/11] iio: amplifiers: ad8366: update device support
2026-02-10 19:42 ` [PATCH v4 11/11] iio: amplifiers: ad8366: update device support Rodrigo Alencar via B4 Relay
@ 2026-02-14 19:02 ` Jonathan Cameron
0 siblings, 0 replies; 32+ messages in thread
From: Jonathan Cameron @ 2026-02-14 19:02 UTC (permalink / raw)
To: Rodrigo Alencar via B4 Relay
Cc: rodrigo.alencar, linux-kernel, linux-iio, devicetree,
Michael Hennerich, Lars-Peter Clausen, David Lechner,
Andy Shevchenko, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
Alexandru Ardelean, Andy Shevchenko
On Tue, 10 Feb 2026 19:42:11 +0000
Rodrigo Alencar via B4 Relay <devnull+rodrigo.alencar.analog.com@kernel.org> wrote:
> From: Rodrigo Alencar <rodrigo.alencar@analog.com>
>
> Add support for the following digital step attenuators:
> - HMC271A: 1dB LSB 5-Bit Digital Attenuator SMT, 0.7 - 3.7 GHz
> - ADRF5720: 0.5 dB LSB, 6-Bit, Digital Attenuator, 9 kHz to 40 GHz
> - ADRF5730: 0.5 dB LSB, 6-Bit, Digital Attenuator, 100 MHz to 40 GHz
> - ADRF5731: 2 dB LSB, 4-Bit, Digital Attenuator, 100 MHz to 40 GHz
> - HMC1018A: 1.0 dB LSB GaAs MMIC 5-BIT DIGITAL ATTENUATOR, 0.1 - 30 GHz
> - HMC1019A: 0.5 dB LSB GaAs MMIC 5-BIT DIGITAL ATTENUATOR, 0.1 - 30 GHz
>
> Additionally, copyright notice was updated with current year.
>
> Co-developed-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
> Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
> Co-developed-by: Michael Hennerich <michael.hennerich@analog.com>
> Signed-off-by: Michael Hennerich <michael.hennerich@analog.com>
> Reviewed-by: Andy Shevchenko <andriy.shevchenko@intel.com>
> Signed-off-by: Rodrigo Alencar <rodrigo.alencar@analog.com>
Hi Rodrigo.
A few early comments propagate to here but nothing else to add to this
or previous patch.
Thanks,
Jonathan
^ permalink raw reply [flat|nested] 32+ messages in thread