From nobody Thu Mar 5 06:32:54 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A1DB52D7392; Mon, 16 Feb 2026 17:10:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771261853; cv=none; b=Ws1oO3llPyMtP40bawqIVjYulrDUQSOlBfU7gXN63C/Q8OjfPdN0P9BkwhR9HF8uRkjIz7K5XI44VOGKJgoZK/ObxVBfkjHPqfOW5QxGhTtS7QpqFjv8XA5u19Y+IDo1ukJfUSm9aYQhXzKWa48IX1rcGH7VzO18NR5gI1wK0iI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771261853; c=relaxed/simple; bh=o3bvt5IVoPOuC7CuBgSGeBwzgK4Z/m9v9mxJ/tknRCE=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=uMFhx/ScKfRO3oFRXv98StNV9sJobOZKCt3xAXcNGXA8rPeQS1V5VwJD2s/8ytR0wGnctOcXcn4668UQvg043/RwGetP06QM1knK7UUHr2JvKzlzJsB70wC2IbxvFNG3X5AhRBQyHONmeMpCnZYk7ZxPHbJFVQKB5+q1ScpD5Fw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=h9o17rhl; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="h9o17rhl" Received: by smtp.kernel.org (Postfix) with ESMTPS id 5CAD3C2BC86; Mon, 16 Feb 2026 17:10:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1771261853; bh=o3bvt5IVoPOuC7CuBgSGeBwzgK4Z/m9v9mxJ/tknRCE=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=h9o17rhl0RKJUJc6euDErpeTgfCLFAcgWpp0fqAwWAYkViHitfOfrM5jwfm5D7ZvN BSKRSl5cwhQNTw7y4v4KwwHqUCgTFoRUKhI7GbbhiPc5kEDP7Jo47+YJikGVzNFzoh EwuT+Zsat4fhj8+YDwXiPSHNcbYuebaDqZgJaSo6EHTT9bh2xBzccYvP+0/yTznrNj RVxicJVnLxpnwhXuYVkUI5JOMWP/5/u58ff5emr2fQC/fKWWTLe0CrzpWnDSoveD93 cJ4XntQ7NWl+ecpA/p1kC0N1i1porRNZKWhO6j+gDnqCtUZQrYob4IPvCBp33iePPM Lb2Cx6tnnq5PA== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 47595E81A56; Mon, 16 Feb 2026 17:10:53 +0000 (UTC) From: Rodrigo Alencar via B4 Relay Date: Mon, 16 Feb 2026 17:10:45 +0000 Subject: [PATCH v5 01/11] MAINTAINERS: Add missing maintainer entry for AD8366 driver Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260216-iio-ad8366-update-v5-1-7e6091357d02@analog.com> References: <20260216-iio-ad8366-update-v5-0-7e6091357d02@analog.com> In-Reply-To: <20260216-iio-ad8366-update-v5-0-7e6091357d02@analog.com> To: linux-kernel@vger.kernel.org, linux-iio@vger.kernel.org, devicetree@vger.kernel.org Cc: Michael Hennerich , Lars-Peter Clausen , Jonathan Cameron , David Lechner , Andy Shevchenko , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Rodrigo Alencar X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1771261851; l=890; i=rodrigo.alencar@analog.com; s=default; h=from:subject:message-id; bh=IB6nsbVkeaHwQfGZNvFxArIH7f6StXcyc8CEVB24Hfs=; b=HhLpF3E0gb1YoVZqodpB9UBVx4v45+g+AF5t2qukrFyQwwTCdPZ9YyN8hPmUkqYZUF4Up4kdH o44MCpfuLhRBBmXv7sa3QnzdvJeB8U7fXsfubKF04UnoOj8zDbeB3O+ X-Developer-Key: i=rodrigo.alencar@analog.com; a=ed25519; pk=ULeHbgU/OYh/PG/4anHDfLgldFItQHAhOktYRVLMFRo= X-Endpoint-Received: by B4 Relay for rodrigo.alencar@analog.com/default with auth_id=561 X-Original-From: Rodrigo Alencar Reply-To: rodrigo.alencar@analog.com From: Rodrigo Alencar Add maintainers entry for drivers/iio/amplifiers/ad8366.c Signed-off-by: Rodrigo Alencar --- 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 =20 +ANALOG DEVICES INC AD8366 DRIVER +M: Michael Hennerich +M: Rodrigo Alencar +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 M: Nuno Sa --=20 2.43.0 From nobody Thu Mar 5 06:32:54 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A1D3F2D6E6C; Mon, 16 Feb 2026 17:10:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771261853; cv=none; b=E+JnE5Qmn4BcokchVs4Hz70UnEzjJaHtSFa7icHZCktJE4Z9Ye21OYRrfggK4d45/N1CYfBP5FoqfXu3+qyr9Edixz8bft0w/p/wKpKqgUbetolyyuE+rHY3KffXyRjOGENL6QZDL9m0XIyMbXREXMF6pvHS2eoiwdl+j3ul4Rs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771261853; c=relaxed/simple; bh=EZj9PEqcMRD9AXu6Ji7mgkwC/I81mfpx66mtqOW1pvk=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=r3d+FK7tCx8Les65gd6r1wFxnJ1WnjxV1ibKi/2RXdW0nhePFZY74R4RB2BboHOtab4KesIomGVdTXUJKmnox0XlTm/bmnRA0cF20jE6LcMVq9S2z8S1813JXKTNxjVxq/NPgicWQW2s0KnK1hjJlLvZVUGymbatDfxYNMV1QgU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=OCRGUBi4; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="OCRGUBi4" Received: by smtp.kernel.org (Postfix) with ESMTPS id 693F5C2BC87; Mon, 16 Feb 2026 17:10:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1771261853; bh=EZj9PEqcMRD9AXu6Ji7mgkwC/I81mfpx66mtqOW1pvk=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=OCRGUBi48DYYOS3tZI9ybh0B2PIKCUIEI/nDtKp9YAY1npGfH7chXT+XhW6mES/Wq jsVo51Id7ZWWz/HkttOYGHbYjYQaeDA7BchitNpcT71C78vLDMi4bVfHdEMc7bsVMN gj2CI4OzGX86q8iJGuqZlsLzKUIrRwCxKMvfPpxXFGw5hTrvBd4e70pZ1kO3zbseZG vT3nohjygW/wOgfoipgPGNdgGYJWNETGxXLqmWJwx6jMWZr+7idipNjiWu9lzrsc/S W2UbvXBnVSy2dcIDo4B4F/RihVhYVDkEJ7Q+3nqsNOmcv3V5k/OmQmeEBRaiHTr2aK aYxpNa4+tJ9uA== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5C30AE81A5A; Mon, 16 Feb 2026 17:10:53 +0000 (UTC) From: Rodrigo Alencar via B4 Relay Date: Mon, 16 Feb 2026 17:10:46 +0000 Subject: [PATCH v5 02/11] dt-bindings: iio: amplifiers: Add AD8366 support Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260216-iio-ad8366-update-v5-2-7e6091357d02@analog.com> References: <20260216-iio-ad8366-update-v5-0-7e6091357d02@analog.com> In-Reply-To: <20260216-iio-ad8366-update-v5-0-7e6091357d02@analog.com> To: linux-kernel@vger.kernel.org, linux-iio@vger.kernel.org, devicetree@vger.kernel.org Cc: Michael Hennerich , Lars-Peter Clausen , Jonathan Cameron , David Lechner , Andy Shevchenko , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Rodrigo Alencar , Conor Dooley X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1771261851; l=3583; i=rodrigo.alencar@analog.com; s=default; h=from:subject:message-id; bh=UNy0X4JXjvK2gtiyKRQ2Bqv9CAzSNJz7qZQMTmwPQ1I=; b=OK8h33nMRSJospAT0GUmWIUjai/GKZVF2PWkT9nSujIDMJUcC02Ds4ACwe3VqxAePJqwRpeI8 QlJxHRESLgXBxlDdRhEiC0PHgVSQ1eij74DieCyPnY0YyPCusj0IOlK X-Developer-Key: i=rodrigo.alencar@analog.com; a=ed25519; pk=ULeHbgU/OYh/PG/4anHDfLgldFItQHAhOktYRVLMFRo= X-Endpoint-Received: by B4 Relay for rodrigo.alencar@analog.com/default with auth_id=561 X-Original-From: Rodrigo Alencar Reply-To: rodrigo.alencar@analog.com From: Rodrigo Alencar 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 Signed-off-by: Rodrigo Alencar --- .../bindings/iio/amplifiers/adi,ad8366.yaml | 97 ++++++++++++++++++= ++++ MAINTAINERS | 1 + 2 files changed, 98 insertions(+) diff --git a/Documentation/devicetree/bindings/iio/amplifiers/adi,ad8366.ya= ml 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 + - Rodrigo Alencar + +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 + spi { + #address-cells =3D <1>; + #size-cells =3D <0>; + + amplifier@0 { + compatible =3D "adi,ad8366"; + reg =3D <0>; + spi-max-frequency =3D <1000000>; + vcc-supply =3D <&vcc_3v3>; + enable-gpios =3D <&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 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 =20 ANALOG DEVICES INC AD9467 DRIVER --=20 2.43.0 From nobody Thu Mar 5 06:32:54 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A69882D73B6; Mon, 16 Feb 2026 17:10:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771261853; cv=none; b=WANRRWTEDuOKTiarJoULtCDtqoshmGWbw2TJlV9XUXq49ZSxrXoDPUhJDAw6tjH4x/ymts7Ma/Pyuqm13mMUrTCGVcx6HU3LG76Yct9xaWLHHT17nfxXFNiadReOPVilQDb7AlsStEteLGy1twJbkzvGJVZlFKcUzonw2LcmY50= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771261853; c=relaxed/simple; bh=GLo3TKV8gFTB9qN1L1dtwn16ZgzOExq0Urh3QlqIRr8=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=G0Drd1wGSjYIaBJYpu/g0OnfR7H1KYtTkR1oosSezoWSSX+gs/85U29Gd6wnJyNYUCMVWabkCW0kVhuNV7s9RzmoNyW1mhGXjPpJvJVysx1bis0GU/WIEj/tVgSue0wEJvJ9D9cyY0XTX2vMXATQQAngon45T2J8EAmwEC5Mr9o= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=IoiBjLwd; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="IoiBjLwd" Received: by smtp.kernel.org (Postfix) with ESMTPS id 7FF44C19425; Mon, 16 Feb 2026 17:10:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1771261853; bh=GLo3TKV8gFTB9qN1L1dtwn16ZgzOExq0Urh3QlqIRr8=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=IoiBjLwdbUhGshcSNowLb78uJKQTHXGCVytrKyOZBGS+ByJE37lQSW2Avp7J1jBrC af5EfAzrSkFc+EcKhwIfSK4CotgKZOLSDioF4W68cjKkuiLdpugyzWbojqhhRrT6W8 JbIpzBCxbQbqcNHLZO9ZE50NEKitGd72Wa4roTRGIZfMcyeQMteMv213x0Z/wzxslr rzZkjfuRTjsSgMqWotqOxwUMqfGumcu01fkPesrLzbQLVo2NW8XOTLcXCmK5yY4T7e xXWwp8o9kvR1BBdhIt5CP1TVI//9awsDFQCWquF00aQDteRYvJOwFC4qLo6OmFDYwn pBRlgVw8mZb7g== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7290FE81A5B; Mon, 16 Feb 2026 17:10:53 +0000 (UTC) From: Rodrigo Alencar via B4 Relay Date: Mon, 16 Feb 2026 17:10:47 +0000 Subject: [PATCH v5 03/11] iio: amplifiers: ad8366: refactor include headers Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260216-iio-ad8366-update-v5-3-7e6091357d02@analog.com> References: <20260216-iio-ad8366-update-v5-0-7e6091357d02@analog.com> In-Reply-To: <20260216-iio-ad8366-update-v5-0-7e6091357d02@analog.com> To: linux-kernel@vger.kernel.org, linux-iio@vger.kernel.org, devicetree@vger.kernel.org Cc: Michael Hennerich , Lars-Peter Clausen , Jonathan Cameron , David Lechner , Andy Shevchenko , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Rodrigo Alencar X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1771261851; l=1982; i=rodrigo.alencar@analog.com; s=default; h=from:subject:message-id; bh=QRIp0tYYyn+DvtgLdXDkjcNw9aoRAB1xYUrQo6x2IZU=; b=kDUXOss1FYOCQTLgt76NE6wZQs9w0kmyBMAHEwlbhL6P8nJLVwnZCKqzs7yVYNesEzUickdMl AggTlzeay1iDAc8U/Y0g1GpDLTWWoolz5rR8WdgQsUAZ5KW/TF9LXdR X-Developer-Key: i=rodrigo.alencar@analog.com; a=ed25519; pk=ULeHbgU/OYh/PG/4anHDfLgldFItQHAhOktYRVLMFRo= X-Endpoint-Received: by B4 Relay for rodrigo.alencar@analog.com/default with auth_id=561 X-Original-From: Rodrigo Alencar Reply-To: rodrigo.alencar@analog.com From: Rodrigo Alencar 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 Adding the following missing headers: + linux/array_size.h: for ARRAY_SIZE + linux/bits.h: for BIT + linux/dev_printk.h: for dev_err + linux/math.h: for abs + linux/mutex.h: for mutex_lock, mutex_unlock + linux/mod_devicetable.h: for spi_device_id + linux/types.h for NULL, __aligned Additionally, those include directives are alphabetically sorted. Signed-off-by: Rodrigo Alencar --- drivers/iio/amplifiers/ad8366.c | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/drivers/iio/amplifiers/ad8366.c b/drivers/iio/amplifiers/ad836= 6.c index d06ac786501c..8dc639d30dbb 100644 --- a/drivers/iio/amplifiers/ad8366.c +++ b/drivers/iio/amplifiers/ad8366.c @@ -11,19 +11,22 @@ * Copyright 2012-2019 Analog Devices Inc. */ =20 -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include #include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include =20 #include -#include =20 enum ad8366_type { ID_AD8366, --=20 2.43.0 From nobody Thu Mar 5 06:32:54 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B9FEB2D77E3; Mon, 16 Feb 2026 17:10:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771261853; cv=none; b=fzta646viVeFNSbLaX2F+MKvEzhPLAn2uENpGcqT/8PfjLe3JK5Gg9pwvG0x1IQ6E8+ppHe5Y3EFuj/e8mGt6zgNrV3zdwCPMKPXZBNmnDmYEegwGK6dOtvn5q260CsSr/FZYMiAeevxSG/KDoxQW2Cc0A06SzH2TRgcwxdWrvI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771261853; c=relaxed/simple; bh=kK87cTU4G81SqasFsmZlFGyid0u7KnD0LcPWzRhX0d8=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=oNy93o0kWI0wlDmMmQXaBCqF6kyUHHOvVyj3MdPsT6ggNzPrtY4966g292X98fv4pnlLXN1DFhGAE9b1VAQgT4fJ+1qNAz3Wf3Suy30upNUhztDzf4cLT34znk4GaHkSmShjIOpRkMxJzP+bEWB7x7QU7DGbch4YlWoqUtnK3oU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=YUVxP8dE; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="YUVxP8dE" Received: by smtp.kernel.org (Postfix) with ESMTPS id 984E3C2BCB2; Mon, 16 Feb 2026 17:10:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1771261853; bh=kK87cTU4G81SqasFsmZlFGyid0u7KnD0LcPWzRhX0d8=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=YUVxP8dE79tlqa8FVf9SdV/GMcH4M+Z0CoIFqNIuSOc0aj+NkvbYDxe5vkOSa9989 JmQpsim4y6bEOHnFIbGu/zbTbK3m1kGB+YftmsTuvWzUOYng0GtPEaN+T6RkjCNYYs I8YSNpsLNyJUaiggkeukYaXF5aAeulDGLcC2EOc0DUOV3NsrWImD5/FcsDpmxvl3oC SYEVMiF2Nzoa+ywiLA8wP2u9ZiaNreWET/rWC0C1SXWm1hlD0pwUlVPbZAGRjd85OJ VYnd10ohMIXkNM1o3e8hfSwDLth/l2/pSYXoA5oUROSjwJRSU2suKQdyuN9tDAAXaa 5q76i6g3QGHtA== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8B0D9E81A32; Mon, 16 Feb 2026 17:10:53 +0000 (UTC) From: Rodrigo Alencar via B4 Relay Date: Mon, 16 Feb 2026 17:10:48 +0000 Subject: [PATCH v5 04/11] iio: amplifiers: ad8366: add local dev pointer to the probe function Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260216-iio-ad8366-update-v5-4-7e6091357d02@analog.com> References: <20260216-iio-ad8366-update-v5-0-7e6091357d02@analog.com> In-Reply-To: <20260216-iio-ad8366-update-v5-0-7e6091357d02@analog.com> To: linux-kernel@vger.kernel.org, linux-iio@vger.kernel.org, devicetree@vger.kernel.org Cc: Michael Hennerich , Lars-Peter Clausen , Jonathan Cameron , David Lechner , Andy Shevchenko , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Rodrigo Alencar X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1771261851; l=1006; i=rodrigo.alencar@analog.com; s=default; h=from:subject:message-id; bh=Ou/8WMhF7+AKa6GUeABGRew50pWjtWQbhob86fa1e1g=; b=AYfam7BpNMyle/XdIo6jM8ZbQWBDr5tpXDxBDpVQNhMfc7ARSj710xAKrc3GSbB+sNNt2uad7 CjnRLEkcfZTB5oncvmpESApnjBCunwsKlBe7xoyEFG6YGyCZa6dXNyf X-Developer-Key: i=rodrigo.alencar@analog.com; a=ed25519; pk=ULeHbgU/OYh/PG/4anHDfLgldFItQHAhOktYRVLMFRo= X-Endpoint-Received: by B4 Relay for rodrigo.alencar@analog.com/default with auth_id=561 X-Original-From: Rodrigo Alencar Reply-To: rodrigo.alencar@analog.com From: Rodrigo Alencar Create local device pointer in the probe function to shorten lines, making the code easier to read. The local device pointer replaces &spi->dev and will be reused across other probe function places in later patches. Signed-off-by: Rodrigo Alencar --- 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/ad836= 6.c index 8dc639d30dbb..677d02f4f075 100644 --- a/drivers/iio/amplifiers/ad8366.c +++ b/drivers/iio/amplifiers/ad8366.c @@ -248,11 +248,12 @@ static const struct iio_chan_spec ada4961_channels[] = =3D { =20 static int ad8366_probe(struct spi_device *spi) { + struct device *dev =3D &spi->dev; struct iio_dev *indio_dev; struct ad8366_state *st; int ret; =20 - indio_dev =3D devm_iio_device_alloc(&spi->dev, sizeof(*st)); + indio_dev =3D devm_iio_device_alloc(dev, sizeof(*st)); if (indio_dev =3D=3D NULL) return -ENOMEM; =20 --=20 2.43.0 From nobody Thu Mar 5 06:32:54 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CE7792D836D; Mon, 16 Feb 2026 17:10:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771261853; cv=none; b=d/Te8aF+2sDKpRoaufgbo8Ix+WzDSNG93c4hMN0prNDb5Rsbj0LqB1nDHOeTPJF6rF5a4HsrdJt0W7ojhFsX5FaFSiHTXUqAdKRu81IS3fCM/1LK+TCHQvWr/I8k/Qb7K9/ekaNUyPc0OuOppFfArIXbKB3GIWXR55GFhe2w3fo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771261853; c=relaxed/simple; bh=WB3uNtPxOXBeyvnMEjIGCj3b9y7bQt14nCNr/5URaso=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=XVM83+jP2niFO1f63vT3rho/4vtOEXMSVMSeLzIpfYITYbi8SGjOZ7qiqM8nGSeIRDZNEr/qBCvRLLth7+J6auR3WjK6ex4CMCzQ3naDBZc47p6ymHty5hyYS+dmCvpSaKiWpBVSMz4AzVbcIKFXc+G1P6S5yP/ML+lVF+71Zs0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Mm006ShV; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Mm006ShV" Received: by smtp.kernel.org (Postfix) with ESMTPS id A93EBC2BCB7; Mon, 16 Feb 2026 17:10:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1771261853; bh=WB3uNtPxOXBeyvnMEjIGCj3b9y7bQt14nCNr/5URaso=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=Mm006ShVeAELIW+YhIssX1l54nR4TQHxWwCNBin7OAUm81mCGKPc707flgZmNB9jE p2GAqTHkerBq6E7ckVzP1j7sXAo91lJwz7eYrfCNdc6V03m3jhgl+DI8ce/PLQoQdl dR4yayIYHyWbNhYEbVGMrqxULAFIsqWqAxrdi+ZirerJtTSTAtN6U9anJFeoLhwZ3F QbXecdZt1WP1LrtnKBc4gGZNUcUXte07ibXFsCyd5OlzqHbf7BTKCxgXM3owOvDIVh x0Al11z/Nszk9etSuKGOVTgO7gwPLZOf/DJ0L/TNKJm7l24rzP+DkTAxZ3d0FLJ9Qv lCDJw6leANCzw== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id A0F1BE81A5B; Mon, 16 Feb 2026 17:10:53 +0000 (UTC) From: Rodrigo Alencar via B4 Relay Date: Mon, 16 Feb 2026 17:10:49 +0000 Subject: [PATCH v5 05/11] iio: amplifiers: ad8366: use devm_mutex_init() and drop mutex_init() Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260216-iio-ad8366-update-v5-5-7e6091357d02@analog.com> References: <20260216-iio-ad8366-update-v5-0-7e6091357d02@analog.com> In-Reply-To: <20260216-iio-ad8366-update-v5-0-7e6091357d02@analog.com> To: linux-kernel@vger.kernel.org, linux-iio@vger.kernel.org, devicetree@vger.kernel.org Cc: Michael Hennerich , Lars-Peter Clausen , Jonathan Cameron , David Lechner , Andy Shevchenko , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Rodrigo Alencar X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1771261851; l=1096; i=rodrigo.alencar@analog.com; s=default; h=from:subject:message-id; bh=Hc2oDziDqm76kntTxzCYZxXGJ8oFjf16eqD+h6jkb6Y=; b=NbSdFlOD0YSqM+1UOH7XzHN/+6UynpQX/NRfeDM/C/2NDF/6kP0lO0zdVqMCVSO67Hew97HPW 2EuuE90K/ALDcCIi4eADmbPLjwTwlP2WJFh4LXuhpRUG5FNWwxFJ0W1 X-Developer-Key: i=rodrigo.alencar@analog.com; a=ed25519; pk=ULeHbgU/OYh/PG/4anHDfLgldFItQHAhOktYRVLMFRo= X-Endpoint-Received: by B4 Relay for rodrigo.alencar@analog.com/default with auth_id=561 X-Original-From: Rodrigo Alencar Reply-To: rodrigo.alencar@analog.com From: Rodrigo Alencar Adopt proper mutex lifecycle with devm_mutex_init(), replacing mutex_init(). Mutex init is moved up (before regulator init), so that goto statement in the error path is avoided (which will be cleaned up later). Signed-off-by: Rodrigo Alencar --- drivers/iio/amplifiers/ad8366.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/iio/amplifiers/ad8366.c b/drivers/iio/amplifiers/ad836= 6.c index 677d02f4f075..6466f3eb6bbc 100644 --- a/drivers/iio/amplifiers/ad8366.c +++ b/drivers/iio/amplifiers/ad8366.c @@ -259,6 +259,10 @@ static int ad8366_probe(struct spi_device *spi) =20 st =3D iio_priv(indio_dev); =20 + ret =3D devm_mutex_init(dev, &st->lock); + if (ret) + return ret; + st->reg =3D devm_regulator_get(&spi->dev, "vcc"); if (!IS_ERR(st->reg)) { ret =3D regulator_enable(st->reg); @@ -267,7 +271,6 @@ static int ad8366_probe(struct spi_device *spi) } =20 spi_set_drvdata(spi, indio_dev); - mutex_init(&st->lock); st->spi =3D spi; st->type =3D spi_get_device_id(spi)->driver_data; =20 --=20 2.43.0 From nobody Thu Mar 5 06:32:54 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DF1082D8793; Mon, 16 Feb 2026 17:10:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771261854; cv=none; b=dN+DGvUCnPZQ0EzYW5BGPEFRJ931B7zoDj7PvYZ/MFs47KTNxtT7Z1wCc2dk7dRo/fufMT7pDKTaxkPRj//3h1v3ZwPo+MVAXDweKQHo8/n77H8AXp+ls83h7Qx88xA2pbMSJRqLZxsC5eLCBixkGI7sKmTN7t4KnocEKQpWXag= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771261854; c=relaxed/simple; bh=VJIxV51qTWBKnBlL0cp3FKxxTxkOycr50HPLDnoxl8Q=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=kzI2l4QG7PHEEYZzKFgrLXsGQl4bE4Zo3YLK0jaeiw2sMXnvoXlx3siY14YSeuNK3MiT2sPylMy0Mlga0xnRoK9rF/i9Ae8O1atuWMx35FVspQShvuyJQLdicDXsKEFOS5U4UdIKF2J4Qbgy5sJmojILOAoogpKH2W0UbZKETsQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=hxb1dk0E; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="hxb1dk0E" Received: by smtp.kernel.org (Postfix) with ESMTPS id BC7A3C19424; Mon, 16 Feb 2026 17:10:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1771261853; bh=VJIxV51qTWBKnBlL0cp3FKxxTxkOycr50HPLDnoxl8Q=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=hxb1dk0ElITDRI6MH3ApbaShbMeLaIQe1wa8Qo/j0EgKFOrvkr4oVYEsDhFL3+2eq 1T4heWs5PRLiRDzop7WhvVa/Sjq1UUliHUs8oKbjPOesLxX1moH1M2LadLanWx60k3 1xIiC1ZfbyjcNXsPSiE4CfXIxc5MfBGj0fMIpp7WCx5MtLlcJcsO8m5gE3jrWYLUiS HUkY5Yx+75E13JhZlRZnbzTrWeGeD58Rn/sd9fBdyxmoLVjKTNDeHmq/H6jVDw3w98 sAHG4OS9p+f4GcM56ymK0vW0cZFgNDktnMpY1rb7Sn5CNST53SGKPOdi1u64yWjCvj XaR07RWIn+xOQ== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id B5533E81A56; Mon, 16 Feb 2026 17:10:53 +0000 (UTC) From: Rodrigo Alencar via B4 Relay Date: Mon, 16 Feb 2026 17:10:50 +0000 Subject: [PATCH v5 06/11] iio: amplifiers: ad8366: refactor device resource management Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260216-iio-ad8366-update-v5-6-7e6091357d02@analog.com> References: <20260216-iio-ad8366-update-v5-0-7e6091357d02@analog.com> In-Reply-To: <20260216-iio-ad8366-update-v5-0-7e6091357d02@analog.com> To: linux-kernel@vger.kernel.org, linux-iio@vger.kernel.org, devicetree@vger.kernel.org Cc: Michael Hennerich , Lars-Peter Clausen , Jonathan Cameron , David Lechner , Andy Shevchenko , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Rodrigo Alencar X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1771261851; l=3284; i=rodrigo.alencar@analog.com; s=default; h=from:subject:message-id; bh=hd/kdztzjkqokqD0/DlRs6C35T+S3wfeCNHmHeep5rY=; b=RBa1W3xX34QtistcDCpL93oZyXPHUmlWaKtpOOvr4beJPTQgDmq99AKSThqdHpR+mSULjFArk aaCQXfRxsw0D3aNPByXMd50i/rNygHKWDFbIqlR3h586+4DhZjaLKxY X-Developer-Key: i=rodrigo.alencar@analog.com; a=ed25519; pk=ULeHbgU/OYh/PG/4anHDfLgldFItQHAhOktYRVLMFRo= X-Endpoint-Received: by B4 Relay for rodrigo.alencar@analog.com/default with auth_id=561 X-Original-From: Rodrigo Alencar Reply-To: rodrigo.alencar@analog.com From: Rodrigo Alencar 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 --- 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/ad836= 6.c index 6466f3eb6bbc..e8c80551d524 100644 --- a/drivers/iio/amplifiers/ad8366.c +++ b/drivers/iio/amplifiers/ad8366.c @@ -43,7 +43,6 @@ struct ad8366_info { =20 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]; @@ -263,14 +262,10 @@ static int ad8366_probe(struct spi_device *spi) if (ret) return ret; =20 - st->reg =3D devm_regulator_get(&spi->dev, "vcc"); - if (!IS_ERR(st->reg)) { - ret =3D regulator_enable(st->reg); - if (ret) - return ret; - } + ret =3D devm_regulator_get_enable(dev, "vcc"); + if (ret) + return dev_err_probe(dev, ret, "Failed to get regulator\n"); =20 - spi_set_drvdata(spi, indio_dev); st->spi =3D spi; st->type =3D spi_get_device_id(spi)->driver_data; =20 @@ -284,17 +279,15 @@ static int ad8366_probe(struct spi_device *spi) case ID_HMC792: case ID_HMC1119: st->reset_gpio =3D devm_gpiod_get_optional(&spi->dev, "reset", GPIOD_OUT= _HIGH); - if (IS_ERR(st->reset_gpio)) { - ret =3D PTR_ERR(st->reset_gpio); - goto error_disable_reg; - } + if (IS_ERR(st->reset_gpio)) + return dev_err_probe(dev, PTR_ERR(st->reset_gpio), + "Failed to get reset gpio\n"); + indio_dev->channels =3D ada4961_channels; indio_dev->num_channels =3D ARRAY_SIZE(ada4961_channels); break; default: - dev_err(&spi->dev, "Invalid device ID\n"); - ret =3D -EINVAL; - goto error_disable_reg; + return dev_err_probe(dev, -EINVAL, "Invalid device ID\n"); } =20 st->info =3D &ad8366_infos[st->type]; @@ -304,31 +297,9 @@ static int ad8366_probe(struct spi_device *spi) =20 ret =3D 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"); =20 - ret =3D 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 =3D spi_get_drvdata(spi); - struct ad8366_state *st =3D iio_priv(indio_dev); - struct regulator *reg =3D st->reg; - - iio_device_unregister(indio_dev); - - if (!IS_ERR(reg)) - regulator_disable(reg); + return devm_iio_device_register(dev, indio_dev); } =20 static const struct spi_device_id ad8366_id[] =3D { @@ -346,7 +317,6 @@ static struct spi_driver ad8366_driver =3D { .name =3D KBUILD_MODNAME, }, .probe =3D ad8366_probe, - .remove =3D ad8366_remove, .id_table =3D ad8366_id, }; =20 --=20 2.43.0 From nobody Thu Mar 5 06:32:54 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id F0ED22D9ED1; Mon, 16 Feb 2026 17:10:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771261854; cv=none; b=kaY2Iae/wL/csvN+3yax2yL15uFsekYv0TibkAsO07dC3KDgy/ZAn296fQo872EKLRQF/iic3KYAmxpaib2925OgpX3UCmmfoyfQSWvYIH3h7sMnD4UnEMTG6y4BC2l3SC63pN3KvT8HElWO1ONH2DnNFcib2h7TbFxWn/5269o= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771261854; c=relaxed/simple; bh=Tuak+ENNzJNCvBEXooP42lleSO+5mhlc56gGGXWb5XQ=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=QgQvawRwoqVRDZV4N+FTzbA7kbaCsf2+VfcIFCGBYrqLl9UoAm4uvQfp0Uu/KZmhJnnYEraQLloPmCbcHlnwOv4B7Cwe6rxI5gxHaVX8Nwyl4kd1F3PZfG63lSvxkKYPL5xxwtI2WySkXhYouLATlZmci2xJczRN2ZC2t6Qw5dw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=uk6gKg8d; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="uk6gKg8d" Received: by smtp.kernel.org (Postfix) with ESMTPS id D1C44C2BC86; Mon, 16 Feb 2026 17:10:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1771261853; bh=Tuak+ENNzJNCvBEXooP42lleSO+5mhlc56gGGXWb5XQ=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=uk6gKg8dmZn6u+leWulrtHcV1J1wXXtEqwjw27VmO7eHAOSAFvAXh6PKDOtHVtgld fP6P4s2veE8xDZsFyoINzv8Tj/3blKoMI/eUT+CVIOiCRPu+1Gdft7dX8uMBcngj3w gK5Xlm8C6SSMvSRAwzXHcgN2uJBUu6OhxYCkU8wukspQoqGXkvYmUmvT337dbhGphe wXQvn6TZILWxjU8TANGQNFzks+eqnlA6taJtlGLuVllMqQjpvJtrRPKMciz6dA7qFx CWy3AwpbvuTXUs95c02Ftv1YG4PUKa0gQwsgJyQOwkzIPaXVTRFp7qJxKefSHhCNJ3 j408hUm3pGBNg== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id C9868E81A5B; Mon, 16 Feb 2026 17:10:53 +0000 (UTC) From: Rodrigo Alencar via B4 Relay Date: Mon, 16 Feb 2026 17:10:51 +0000 Subject: [PATCH v5 07/11] iio: amplifiers: ad8366: replace reset-gpio with reset controller Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260216-iio-ad8366-update-v5-7-7e6091357d02@analog.com> References: <20260216-iio-ad8366-update-v5-0-7e6091357d02@analog.com> In-Reply-To: <20260216-iio-ad8366-update-v5-0-7e6091357d02@analog.com> To: linux-kernel@vger.kernel.org, linux-iio@vger.kernel.org, devicetree@vger.kernel.org Cc: Michael Hennerich , Lars-Peter Clausen , Jonathan Cameron , David Lechner , Andy Shevchenko , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Rodrigo Alencar X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1771261851; l=2412; i=rodrigo.alencar@analog.com; s=default; h=from:subject:message-id; bh=2h/qIlXksRtIPfCMm6MG5JFQw2QvDnxOXehKZUf2GXE=; b=PSHg/AGJgN9vG9M3eQuvL3jFUxI9aLv0if+nBm5XzHiTzwmvwwPpbxbUczUBWOGy6iUAD5JAD PB5aSlFomFaDz7BX7pgjhKiBlxgd709zhp+G4XUiw3XAKFgUcjC1sEL X-Developer-Key: i=rodrigo.alencar@analog.com; a=ed25519; pk=ULeHbgU/OYh/PG/4anHDfLgldFItQHAhOktYRVLMFRo= X-Endpoint-Received: by B4 Relay for rodrigo.alencar@analog.com/default with auth_id=561 X-Original-From: Rodrigo Alencar Reply-To: rodrigo.alencar@analog.com From: Rodrigo Alencar 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. The reset controller init is moved out from the switch case and optionally initialized for every device variant. Although not all devices have a reset pin the code does not need to change if it is not wired. Signed-off-by: Rodrigo Alencar --- drivers/iio/amplifiers/ad8366.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/drivers/iio/amplifiers/ad8366.c b/drivers/iio/amplifiers/ad836= 6.c index e8c80551d524..8b3d6825423e 100644 --- a/drivers/iio/amplifiers/ad8366.c +++ b/drivers/iio/amplifiers/ad8366.c @@ -23,6 +23,7 @@ #include #include #include +#include #include #include =20 @@ -44,7 +45,6 @@ struct ad8366_info { struct ad8366_state { struct spi_device *spi; struct mutex lock; /* protect sensor state */ - struct gpio_desc *reset_gpio; unsigned char ch[2]; enum ad8366_type type; const struct ad8366_info *info; @@ -248,6 +248,7 @@ static const struct iio_chan_spec ada4961_channels[] = =3D { static int ad8366_probe(struct spi_device *spi) { struct device *dev =3D &spi->dev; + struct reset_control *rstc; struct iio_dev *indio_dev; struct ad8366_state *st; int ret; @@ -278,11 +279,6 @@ static int ad8366_probe(struct spi_device *spi) case ID_ADL5240: case ID_HMC792: case ID_HMC1119: - st->reset_gpio =3D devm_gpiod_get_optional(&spi->dev, "reset", GPIOD_OUT= _HIGH); - if (IS_ERR(st->reset_gpio)) - return dev_err_probe(dev, PTR_ERR(st->reset_gpio), - "Failed to get reset gpio\n"); - indio_dev->channels =3D ada4961_channels; indio_dev->num_channels =3D ARRAY_SIZE(ada4961_channels); break; @@ -290,6 +286,11 @@ static int ad8366_probe(struct spi_device *spi) return dev_err_probe(dev, -EINVAL, "Invalid device ID\n"); } =20 + rstc =3D 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"); + st->info =3D &ad8366_infos[st->type]; indio_dev->name =3D spi_get_device_id(spi)->name; indio_dev->info =3D &ad8366_info; --=20 2.43.0 From nobody Thu Mar 5 06:32:54 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 147B02DB7AA; Mon, 16 Feb 2026 17:10:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771261854; cv=none; b=TKuBvs7iZGCdQek1KTJmDV9EhUeyD4zpyeWWV/j4HmQd7Xj+1Ap3OrnUG6J0RNoBnbpxQGRhZ6YU3GD4CJqFGcD3sACyBpdGyAaacNVs8zyDkjWYidVKYpBVrIVkmIRlpnvLRfdzLev7yz7oJDw5j7axbvis6B+QjpA5+zgCSeE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771261854; c=relaxed/simple; bh=Gft/y2lgJMBF0wVW6kCN3YyuV/wW/cUnsAeKbjqhCzY=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=liwNZXqn1QGSNvmiODnwFvJvLCydyLGi0myh8ZnPtxtnfU1Qh/7oYXiIIM1HUHbUbgm3nrtjDxYOlW37XvStB09jZ7+MiEhjnXT4gC24b7KwASB7qjMLVxbWoctYWM7ZlIvG8yYKCcFo58mFxgMVbaYXu/CwuzvCxH7ayNw8t/0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=MpFEqs44; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="MpFEqs44" Received: by smtp.kernel.org (Postfix) with ESMTPS id E36FAC2BC9E; Mon, 16 Feb 2026 17:10:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1771261853; bh=Gft/y2lgJMBF0wVW6kCN3YyuV/wW/cUnsAeKbjqhCzY=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=MpFEqs44DM7j8meDT9EDmnAXJOtQzuitDRhBsowR0++kfcfCIjffVaAdw4sTYQfLu FrctHaAhzRpPt423q05uilIy/Zcu5y5CvzHygHStQ/vn0QC4tDcATOq7TxcxfnOaQ7 MPYQAULxL98Lo56w4FKZ21Ixn23vXsXKoKU8IG06P/xTr70I8z5nKUl2t7AZQFWM29 i62WGSEa43Vyb1u1XKhMEWZpmtPTFJ2SrvfA+K7ah1uRmADJtzQRxAdTdP2S887iUj RN4U0CumMfqrUyEQ6mR4cQdw/1e0sGNbS0eM4XSOEd4CGTkAWLq3Xrhd9ARArapVan ClRgggOafNK+w== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id D9D43E81A5A; Mon, 16 Feb 2026 17:10:53 +0000 (UTC) From: Rodrigo Alencar via B4 Relay Date: Mon, 16 Feb 2026 17:10:52 +0000 Subject: [PATCH v5 08/11] iio: amplifiers: ad8366: prepare for device-tree support Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260216-iio-ad8366-update-v5-8-7e6091357d02@analog.com> References: <20260216-iio-ad8366-update-v5-0-7e6091357d02@analog.com> In-Reply-To: <20260216-iio-ad8366-update-v5-0-7e6091357d02@analog.com> To: linux-kernel@vger.kernel.org, linux-iio@vger.kernel.org, devicetree@vger.kernel.org Cc: Michael Hennerich , Lars-Peter Clausen , Jonathan Cameron , David Lechner , Andy Shevchenko , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Rodrigo Alencar X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1771261851; l=7333; i=rodrigo.alencar@analog.com; s=default; h=from:subject:message-id; bh=hSZQX2mkk9eZiJBBsoEhy14crUmqrrRn00xfVskn5rs=; b=vsxbpm/bMqghD4anjr+u0EE+VOjz65Sqd0blJ91liDTdalvC7DekiOYygbMmWykKCeznh0faA QOLSMs2JJ9ZBV4rvK/xIPFvFAvbRpWl6LO87gzGm/td6Hi473MrhS/i X-Developer-Key: i=rodrigo.alencar@analog.com; a=ed25519; pk=ULeHbgU/OYh/PG/4anHDfLgldFItQHAhOktYRVLMFRo= X-Endpoint-Received: by B4 Relay for rodrigo.alencar@analog.com/default with auth_id=561 X-Original-From: Rodrigo Alencar Reply-To: rodrigo.alencar@analog.com From: Rodrigo Alencar 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. The linux/array_size.h include is removed as number of channels is provided by chip info table. Signed-off-by: Rodrigo Alencar --- drivers/iio/amplifiers/ad8366.c | 134 +++++++++++++-----------------------= ---- 1 file changed, 44 insertions(+), 90 deletions(-) diff --git a/drivers/iio/amplifiers/ad8366.c b/drivers/iio/amplifiers/ad836= 6.c index 8b3d6825423e..22eb6c9bb0f6 100644 --- a/drivers/iio/amplifiers/ad8366.c +++ b/drivers/iio/amplifiers/ad8366.c @@ -11,7 +11,6 @@ * Copyright 2012-2019 Analog Devices Inc. */ =20 -#include #include #include #include @@ -26,6 +25,7 @@ #include #include #include +#include =20 #include =20 @@ -40,13 +40,16 @@ enum ad8366_type { struct ad8366_info { int gain_min; int gain_max; + int gain_step; + size_t num_channels; + size_t (*pack_code)(const unsigned char *code, size_t num_channels, + unsigned char *data); }; =20 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 @@ -55,60 +58,61 @@ struct ad8366_state { unsigned char data[2] __aligned(IIO_DMA_MINALIGN); }; =20 +static size_t ad8366_pack_code(const unsigned char *code, size_t num_chann= els, + unsigned char *data) +{ + u8 ch_a =3D bitrev8(code[0]) >> 2; + u8 ch_b =3D bitrev8(code[1]) >> 2; + + put_unaligned_be16((ch_b << 6) | ch_a, &data[0]); + return sizeof(__be16); +} + static const struct ad8366_info ad8366_infos[] =3D { [ID_AD8366] =3D { .gain_min =3D 4500, .gain_max =3D 20500, + .gain_step =3D 253, + .num_channels =3D 2, + .pack_code =3D ad8366_pack_code, }, [ID_ADA4961] =3D { .gain_min =3D -6000, .gain_max =3D 15000, + .gain_step =3D -1000, + .num_channels =3D 1, }, [ID_ADL5240] =3D { .gain_min =3D -11500, .gain_max =3D 20000, + .gain_step =3D 500, + .num_channels =3D 1, }, [ID_HMC792] =3D { .gain_min =3D -15750, .gain_max =3D 0, + .gain_step =3D 250, + .num_channels =3D 1, }, [ID_HMC1119] =3D { .gain_min =3D -31750, .gain_max =3D 0, + .gain_step =3D -250, + .num_channels =3D 1, }, }; =20 -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 =3D iio_priv(indio_dev); - int ret; + const struct ad8366_info *inf =3D st->info; + size_t len =3D 1; =20 - switch (st->type) { - case ID_AD8366: - ch_a =3D bitrev8(ch_a & 0x3F); - ch_b =3D bitrev8(ch_b & 0x3F); + if (inf->pack_code) + len =3D inf->pack_code(st->ch, inf->num_channels, st->data); + else + st->data[0] =3D st->ch[0]; =20 - st->data[0] =3D ch_b >> 4; - st->data[1] =3D (ch_b << 4) | (ch_a >> 2); - break; - case ID_ADA4961: - st->data[0] =3D ch_a & 0x1F; - break; - case ID_ADL5240: - st->data[0] =3D (ch_a & 0x3F); - break; - case ID_HMC792: - case ID_HMC1119: - st->data[0] =3D ch_a; - break; - } - - ret =3D spi_write(st->spi, st->data, indio_dev->num_channels); - if (ret < 0) - dev_err(&indio_dev->dev, "write failed (%d)", ret); - - return ret; + return spi_write(st->spi, st->data, len); } =20 static int ad8366_read_raw(struct iio_dev *indio_dev, @@ -118,6 +122,7 @@ static int ad8366_read_raw(struct iio_dev *indio_dev, long m) { struct ad8366_state *st =3D iio_priv(indio_dev); + const struct ad8366_info *inf =3D st->info; int ret; int code, gain =3D 0; =20 @@ -125,25 +130,8 @@ static int ad8366_read_raw(struct iio_dev *indio_dev, switch (m) { case IIO_CHAN_INFO_HARDWAREGAIN: code =3D st->ch[chan->channel]; - - switch (st->type) { - case ID_AD8366: - gain =3D code * 253 + 4500; - break; - case ID_ADA4961: - gain =3D 15000 - code * 1000; - break; - case ID_ADL5240: - gain =3D 20000 - 31500 + code * 500; - break; - case ID_HMC792: - gain =3D -1 * code * 500; - break; - case ID_HMC1119: - gain =3D -1 * code * 250; - break; - } - + gain =3D inf->gain_step > 0 ? inf->gain_min : inf->gain_max; + gain +=3D inf->gain_step * code; /* Values in dB */ *val =3D gain / 1000; *val2 =3D (gain % 1000) * 1000; @@ -178,29 +166,14 @@ static int ad8366_write_raw(struct iio_dev *indio_dev, if (gain > inf->gain_max || gain < inf->gain_min) return -EINVAL; =20 - switch (st->type) { - case ID_AD8366: - code =3D (gain - 4500) / 253; - break; - case ID_ADA4961: - code =3D (15000 - gain) / 1000; - break; - case ID_ADL5240: - code =3D ((gain - 500 - 20000) / 500) & 0x3F; - break; - case ID_HMC792: - code =3D (abs(gain) / 500) & 0x3F; - break; - case ID_HMC1119: - code =3D (abs(gain) / 250) & 0x7F; - break; - } + gain -=3D inf->gain_step > 0 ? inf->gain_min : inf->gain_max; + code =3D DIV_ROUND_CLOSEST(gain, inf->gain_step); =20 mutex_lock(&st->lock); switch (mask) { case IIO_CHAN_INFO_HARDWAREGAIN: st->ch[chan->channel] =3D code; - ret =3D ad8366_write(indio_dev, st->ch[0], st->ch[1]); + ret =3D ad8366_write_code(st); break; default: ret =3D -EINVAL; @@ -241,10 +214,6 @@ static const struct iio_chan_spec ad8366_channels[] = =3D { AD8366_CHAN(1), }; =20 -static const struct iio_chan_spec ada4961_channels[] =3D { - AD8366_CHAN(0), -}; - static int ad8366_probe(struct spi_device *spi) { struct device *dev =3D &spi->dev; @@ -268,35 +237,20 @@ static int ad8366_probe(struct spi_device *spi) return dev_err_probe(dev, ret, "Failed to get regulator\n"); =20 st->spi =3D spi; - st->type =3D spi_get_device_id(spi)->driver_data; - - switch (st->type) { - case ID_AD8366: - indio_dev->channels =3D ad8366_channels; - indio_dev->num_channels =3D ARRAY_SIZE(ad8366_channels); - break; - case ID_ADA4961: - case ID_ADL5240: - case ID_HMC792: - case ID_HMC1119: - indio_dev->channels =3D ada4961_channels; - indio_dev->num_channels =3D ARRAY_SIZE(ada4961_channels); - break; - default: - return dev_err_probe(dev, -EINVAL, "Invalid device ID\n"); - } + st->info =3D &ad8366_infos[spi_get_device_id(spi)->driver_data]; =20 rstc =3D 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"); =20 - st->info =3D &ad8366_infos[st->type]; indio_dev->name =3D spi_get_device_id(spi)->name; indio_dev->info =3D &ad8366_info; indio_dev->modes =3D INDIO_DIRECT_MODE; + indio_dev->channels =3D ad8366_channels; + indio_dev->num_channels =3D st->info->num_channels; =20 - ret =3D ad8366_write(indio_dev, 0, 0); + ret =3D ad8366_write_code(st); if (ret < 0) return dev_err_probe(dev, ret, "failed to write initial gain\n"); =20 --=20 2.43.0 From nobody Thu Mar 5 06:32:54 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2EB2B2DC798; Mon, 16 Feb 2026 17:10:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771261854; cv=none; b=i9znnFD1guJKEkHqDvB3V7WYxdxTridFq3LErgYaBKOuOiYw1yd9PvyI/9t4SIPMM3Rbr2e9sorORxTQgEC7vB4TWEdod4cPJkdg3B3WHnVuk43oPnfc1zGDC4L1E5ObdBx+CzIe5N4eehtSAc45XMD0s3h+PU/qnY92SyN5W9w= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771261854; c=relaxed/simple; bh=SGpZmjmJreZtSGcW6F1763DwBbMeVUBQ3LZkIAH4J+A=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=HrTLPuEAdyg6NzDVTeZCFOn8hzYX3m96VjyCcK8iLhfwzmE/AJn6vXpIeRxul1bIAIvjXV1wVvVsyg+/dO3cNxte4LJMs62L4ZtSIzVDcc0K9Y1MZqvz/Y32C5D02GGL7qri7Lz2OQr+PwZF8txtSF4zvRCmnPAi6q77V5QE6k8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=e20q32fW; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="e20q32fW" Received: by smtp.kernel.org (Postfix) with ESMTPS id 0756FC2BCB1; Mon, 16 Feb 2026 17:10:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1771261854; bh=SGpZmjmJreZtSGcW6F1763DwBbMeVUBQ3LZkIAH4J+A=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=e20q32fWVQ2oWgAZWHtVo4g6coWOAyhiQC+6IRasezKd3xCuOqBBRtHBr6nMMPpPA HrIb9ZgvMykT0dvkZGDIDNF/ZSd41z0NH4Pc7W/K7T6zpEAOAjvaBhI2+UwEl70yhX nI609ejTYyqk6VdrNIqJl2QmL/tPYFo8TyiouEbnY9A5SF42CPFqi1YI+ekhyWkKGH grVTvlwlcVp02xsTAVfoRfRhlD0hpat4hbVKcx3vsLPF2DIklkyA4JrnHijftlwns9 OWDIEmyn+WUgdrNWpwEWUNz/r1nNBLMDfPqwZRuN8cyxJ+QMoib4kxSlruS91Cpcrb 4qvlbWE8XBAGg== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id ED64FE81A5B; Mon, 16 Feb 2026 17:10:53 +0000 (UTC) From: Rodrigo Alencar via B4 Relay Date: Mon, 16 Feb 2026 17:10:53 +0000 Subject: [PATCH v5 09/11] iio: amplifiers: ad8366: add device tree support Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260216-iio-ad8366-update-v5-9-7e6091357d02@analog.com> References: <20260216-iio-ad8366-update-v5-0-7e6091357d02@analog.com> In-Reply-To: <20260216-iio-ad8366-update-v5-0-7e6091357d02@analog.com> To: linux-kernel@vger.kernel.org, linux-iio@vger.kernel.org, devicetree@vger.kernel.org Cc: Michael Hennerich , Lars-Peter Clausen , Jonathan Cameron , David Lechner , Andy Shevchenko , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Rodrigo Alencar X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1771261851; l=4519; i=rodrigo.alencar@analog.com; s=default; h=from:subject:message-id; bh=Jiz8Tdwp3Da0KKuGbUooBkSljzJvf+Nn5FFdakciPZM=; b=ZCW/rmjtdHo/Xp/QwaxkHqOSlGmQG9Ddy7TFrLlwD1d2VcBdM1rJjoxWPFd04OF0cGpGFlmRp U/ZE8B0q4lgAPT0ei+KCV0K1qmyYmukdaac2N0ruW0qQpfN9QGXdJoQ X-Developer-Key: i=rodrigo.alencar@analog.com; a=ed25519; pk=ULeHbgU/OYh/PG/4anHDfLgldFItQHAhOktYRVLMFRo= X-Endpoint-Received: by B4 Relay for rodrigo.alencar@analog.com/default with auth_id=561 X-Original-From: Rodrigo Alencar Reply-To: rodrigo.alencar@analog.com From: Rodrigo Alencar Drop the enum ID, split chip info table into per-device structs and add of_match_table. Additionally, add 'name' field into the chip info struct, dropping the usage of spi_get_device_id(). Signed-off-by: Rodrigo Alencar --- drivers/iio/amplifiers/ad8366.c | 107 ++++++++++++++++++++++--------------= ---- 1 file changed, 59 insertions(+), 48 deletions(-) diff --git a/drivers/iio/amplifiers/ad8366.c b/drivers/iio/amplifiers/ad836= 6.c index 22eb6c9bb0f6..fb787a512bff 100644 --- a/drivers/iio/amplifiers/ad8366.c +++ b/drivers/iio/amplifiers/ad8366.c @@ -29,15 +29,8 @@ =20 #include =20 -enum ad8366_type { - ID_AD8366, - ID_ADA4961, - ID_ADL5240, - ID_HMC792, - ID_HMC1119, -}; - struct ad8366_info { + const char *name; int gain_min; int gain_max; int gain_step; @@ -68,38 +61,45 @@ static size_t ad8366_pack_code(const unsigned char *cod= e, size_t num_channels, return sizeof(__be16); } =20 -static const struct ad8366_info ad8366_infos[] =3D { - [ID_AD8366] =3D { - .gain_min =3D 4500, - .gain_max =3D 20500, - .gain_step =3D 253, - .num_channels =3D 2, - .pack_code =3D ad8366_pack_code, - }, - [ID_ADA4961] =3D { - .gain_min =3D -6000, - .gain_max =3D 15000, - .gain_step =3D -1000, - .num_channels =3D 1, - }, - [ID_ADL5240] =3D { - .gain_min =3D -11500, - .gain_max =3D 20000, - .gain_step =3D 500, - .num_channels =3D 1, - }, - [ID_HMC792] =3D { - .gain_min =3D -15750, - .gain_max =3D 0, - .gain_step =3D 250, - .num_channels =3D 1, - }, - [ID_HMC1119] =3D { - .gain_min =3D -31750, - .gain_max =3D 0, - .gain_step =3D -250, - .num_channels =3D 1, - }, +static const struct ad8366_info ad8366_chip_info =3D { + .name =3D "ad8366", + .gain_min =3D 4500, + .gain_max =3D 20500, + .gain_step =3D 253, + .num_channels =3D 2, + .pack_code =3D ad8366_pack_code, +}; + +static const struct ad8366_info ada4961_chip_info =3D { + .name =3D "ada4961", + .gain_min =3D -6000, + .gain_max =3D 15000, + .gain_step =3D -1000, + .num_channels =3D 1, +}; + +static const struct ad8366_info adl5240_chip_info =3D { + .name =3D "adl5240", + .gain_min =3D -11500, + .gain_max =3D 20000, + .gain_step =3D 500, + .num_channels =3D 1, +}; + +static const struct ad8366_info hmc792_chip_info =3D { + .name =3D "hmc792a", + .gain_min =3D -15750, + .gain_max =3D 0, + .gain_step =3D 250, + .num_channels =3D 1, +}; + +static const struct ad8366_info hmc1119_chip_info =3D { + .name =3D "hmc1119", + .gain_min =3D -31750, + .gain_max =3D 0, + .gain_step =3D -250, + .num_channels =3D 1, }; =20 static int ad8366_write_code(struct ad8366_state *st) @@ -237,14 +237,14 @@ static int ad8366_probe(struct spi_device *spi) return dev_err_probe(dev, ret, "Failed to get regulator\n"); =20 st->spi =3D spi; - st->info =3D &ad8366_infos[spi_get_device_id(spi)->driver_data]; + st->info =3D spi_get_device_match_data(spi); =20 rstc =3D 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"); =20 - indio_dev->name =3D spi_get_device_id(spi)->name; + indio_dev->name =3D st->info->name; indio_dev->info =3D &ad8366_info; indio_dev->modes =3D INDIO_DIRECT_MODE; indio_dev->channels =3D ad8366_channels; @@ -258,18 +258,29 @@ static int ad8366_probe(struct spi_device *spi) } =20 static const struct spi_device_id ad8366_id[] =3D { - {"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); =20 +static const struct of_device_id ad8366_of_match[] =3D { + { .compatible =3D "adi,ad8366", .data =3D &ad8366_chip_info }, + { .compatible =3D "adi,ada4961", .data =3D &ada4961_chip_info }, + { .compatible =3D "adi,adl5240", .data =3D &adl5240_chip_info }, + { .compatible =3D "adi,hmc792a", .data =3D &hmc792_chip_info }, + { .compatible =3D "adi,hmc1119", .data =3D &hmc1119_chip_info }, + { } +}; +MODULE_DEVICE_TABLE(of, ad8366_of_match); + static struct spi_driver ad8366_driver =3D { .driver =3D { - .name =3D KBUILD_MODNAME, + .name =3D KBUILD_MODNAME, + .of_match_table =3D ad8366_of_match, }, .probe =3D ad8366_probe, .id_table =3D ad8366_id, --=20 2.43.0 From nobody Thu Mar 5 06:32:54 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5F2BB31076A; Mon, 16 Feb 2026 17:10:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771261854; cv=none; b=fTPJ91zhqfSJJ87bpOOjE/6TlcxBvKhGckIo1M45zkrnumbMLfBQpo96zhexT+eV/1pOroVHQ4Nfd/PJ//3mseYm1gJdtt+LRCrKLLQVVhsjSYhcGCJZjQxy1/hxr1JLpXCpEX4hMXvH3HtwDLs4dGqSLv0h7a5exVMAVEskgNI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771261854; c=relaxed/simple; bh=rGdi/WfzUKG1XZXMbKOthTj36Ehl3dWzjXO/zqT5+Jo=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Jmmtp6kghRXbKNxotLvi1SlNccQv/iLhib28/eQ1hjs3xZ2OWbBAEnAHGP+hJb8az9MIhPvJ5nhH0oBZpdqLVWwrpGymn3rI7zrbPKPoyo9RQmqzAmNLpNkfYO9XHpB+4brwqPbJFeUF/7JimeC8bFpJ9uVdcQld4DhEbNqtyBw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=sflnjk2v; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="sflnjk2v" Received: by smtp.kernel.org (Postfix) with ESMTPS id 273F6C2BCB5; Mon, 16 Feb 2026 17:10:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1771261854; bh=rGdi/WfzUKG1XZXMbKOthTj36Ehl3dWzjXO/zqT5+Jo=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=sflnjk2vg1/9GzaSAd2ilwpFZ/6YfhH/GBTe3Md+JFJzJYVaQyTkWmaSHnP68gARV ABJLNUwUlHPo0kz2cTOB5heyVmAN1rqCohAp0ZOwlSdejdgGCLWGd2xp9+zhmfXHaH S8CqB+vmGVqH3cqWnq6h2DnlSGekjuMQ0agbg0jetsF+gz+b2YSTkH2m8rY3mp5w/H ThKmJ1q/ja49lBCIYH6yduVGLFnhJ3rmPWcgR6FiKi+FyggG9KgdWCWhN5xRkc8eRx v6fraiobCT2i2m655o9Y5fWLGqPkOz3P7Qt9v1t5unQTHYj+wQAbzX6VGspekEvKnU /6Xeta/2u52ww== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 117A5E81A5A; Mon, 16 Feb 2026 17:10:54 +0000 (UTC) From: Rodrigo Alencar via B4 Relay Date: Mon, 16 Feb 2026 17:10:54 +0000 Subject: [PATCH v5 10/11] iio: amplifiers: ad8366: consume enable gpio Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260216-iio-ad8366-update-v5-10-7e6091357d02@analog.com> References: <20260216-iio-ad8366-update-v5-0-7e6091357d02@analog.com> In-Reply-To: <20260216-iio-ad8366-update-v5-0-7e6091357d02@analog.com> To: linux-kernel@vger.kernel.org, linux-iio@vger.kernel.org, devicetree@vger.kernel.org Cc: Michael Hennerich , Lars-Peter Clausen , Jonathan Cameron , David Lechner , Andy Shevchenko , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Rodrigo Alencar X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1771261851; l=1270; i=rodrigo.alencar@analog.com; s=default; h=from:subject:message-id; bh=dDdcU23HlSPG2yMMj26nBGlcwxQIvQ+x8qXHKCHZHlc=; b=2Y8JTqvWh8UqelxNGbz30ENpH9AGUnMeAT3aAwJOTOJ0R8j/8XdxpfiyfbkkTJgbRcP2NWZo/ xJIZFsmAXxGCL8mp/rWGLELLwhFNwrIdkXs5P/UFOWRjHBIjU6Q6uk5 X-Developer-Key: i=rodrigo.alencar@analog.com; a=ed25519; pk=ULeHbgU/OYh/PG/4anHDfLgldFItQHAhOktYRVLMFRo= X-Endpoint-Received: by B4 Relay for rodrigo.alencar@analog.com/default with auth_id=561 X-Original-From: Rodrigo Alencar Reply-To: rodrigo.alencar@analog.com From: Rodrigo Alencar 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 --- drivers/iio/amplifiers/ad8366.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/iio/amplifiers/ad8366.c b/drivers/iio/amplifiers/ad836= 6.c index fb787a512bff..d4499af0518a 100644 --- a/drivers/iio/amplifiers/ad8366.c +++ b/drivers/iio/amplifiers/ad8366.c @@ -217,6 +217,7 @@ static const struct iio_chan_spec ad8366_channels[] =3D= { static int ad8366_probe(struct spi_device *spi) { struct device *dev =3D &spi->dev; + struct gpio_desc *enable_gpio; struct reset_control *rstc; struct iio_dev *indio_dev; struct ad8366_state *st; @@ -239,6 +240,11 @@ static int ad8366_probe(struct spi_device *spi) st->spi =3D spi; st->info =3D spi_get_device_match_data(spi); =20 + enable_gpio =3D 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"); + rstc =3D devm_reset_control_get_optional_exclusive_deasserted(dev, NULL); if (IS_ERR(rstc)) return dev_err_probe(dev, PTR_ERR(rstc), --=20 2.43.0 From nobody Thu Mar 5 06:32:54 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6C6D93164C2; Mon, 16 Feb 2026 17:10:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771261854; cv=none; b=T/x0ebyD27g4HMRJxShmZ/GsBUXkolLf1osnxwd3bUKBs3Ad5c1Jz3KJDkPWGXO4QH7pj6rxYqvDM1ywmJOt/U80wYNF8kK3lCo1iEmE3ykQgzRLUJoCN6mshaHwLXdhf57SlJx756vQCNftKh1GGtDYnvp7jRpK2jZ8JivH9RU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771261854; c=relaxed/simple; bh=e0IeUiRaVin5omBjuJSDZUirOOK2r3E2elE9nOGlE9U=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=BTy0F9jcEz6ZaxHHNao5pYvJZXKAmkugTzEJ6OYKO0QU7wWlZ8imjK3L5xdwpg4eappvhKOXFedfPBRfvbiUOX+QFZSQPJRtLh9HQR57adGmgBBpx3dWWLuG6lSA5VxXrNe/ozEyYclZLQFZVlzwO+lNnVxY6fj5jGewhX2VdwQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=AyxeSNxQ; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="AyxeSNxQ" Received: by smtp.kernel.org (Postfix) with ESMTPS id 3D700C4AF0B; Mon, 16 Feb 2026 17:10:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1771261854; bh=e0IeUiRaVin5omBjuJSDZUirOOK2r3E2elE9nOGlE9U=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=AyxeSNxQ8UwtUoomR9DuReWBnVu1PHUwdI/VpJnG0hfC43ojMUSTPPPr/+9w4ZqRL Mv2NXWsW8Ih2RXsJvBTXXcoghnoIYSW6ehubF+LxFABilgEL3RvVYOaNsOA+UjYgIK PAW9N4uC2/LCzH0kwwqekcCI6IzQglZs3i08+e6sJBCmNXmVHF3stHbqghnoXcbEKi cIj9eJ33XT6Tly1EBXkJ4+J/PojPafvJv/m4TYSCxYlH6/psdp/mvZm7/6C1dcA9fX +VJBHrF7Ej2yYas2ICUsJtpOWOiI5lkxHCJXaThf9aMdJZFV8hOJLuLiIGAEDjZhNc XdTTwTmLZKlsg== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 300EDE81A5B; Mon, 16 Feb 2026 17:10:54 +0000 (UTC) From: Rodrigo Alencar via B4 Relay Date: Mon, 16 Feb 2026 17:10:55 +0000 Subject: [PATCH v5 11/11] iio: amplifiers: ad8366: update device support Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260216-iio-ad8366-update-v5-11-7e6091357d02@analog.com> References: <20260216-iio-ad8366-update-v5-0-7e6091357d02@analog.com> In-Reply-To: <20260216-iio-ad8366-update-v5-0-7e6091357d02@analog.com> To: linux-kernel@vger.kernel.org, linux-iio@vger.kernel.org, devicetree@vger.kernel.org Cc: Michael Hennerich , Lars-Peter Clausen , Jonathan Cameron , David Lechner , Andy Shevchenko , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Rodrigo Alencar , Alexandru Ardelean , Andy Shevchenko X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1771261851; l=6757; i=rodrigo.alencar@analog.com; s=default; h=from:subject:message-id; bh=IP0Q14Wu7q7zwFy9Nj6jg6zOD0UoOhkxtbBst3yVtgM=; b=A3+YY8X4cn13eCtaxB/G4oBGtatXQZylFpHWeG9NWFGhG7LCmYQ50UeE9aHAw0mLNTN7WxDw1 BkghbVjuI7xDTPOvNkskVtrvTx0PywSJB090uvucDemK/QFjDv/u41D X-Developer-Key: i=rodrigo.alencar@analog.com; a=ed25519; pk=ULeHbgU/OYh/PG/4anHDfLgldFItQHAhOktYRVLMFRo= X-Endpoint-Received: by B4 Relay for rodrigo.alencar@analog.com/default with auth_id=561 X-Original-From: Rodrigo Alencar Reply-To: rodrigo.alencar@analog.com From: Rodrigo Alencar 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 Signed-off-by: Alexandru Ardelean Co-developed-by: Michael Hennerich Signed-off-by: Michael Hennerich Reviewed-by: Andy Shevchenko Signed-off-by: Rodrigo Alencar --- drivers/iio/amplifiers/Kconfig | 6 +++ drivers/iio/amplifiers/ad8366.c | 84 +++++++++++++++++++++++++++++++++++++= +++- 2 files changed, 89 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 =20 To compile this driver as a module, choose M here: the diff --git a/drivers/iio/amplifiers/ad8366.c b/drivers/iio/amplifiers/ad836= 6.c index d4499af0518a..334ca91c0f59 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 4= 0 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. */ =20 #include @@ -61,6 +67,20 @@ static size_t ad8366_pack_code(const unsigned char *code= , size_t num_channels, return sizeof(__be16); } =20 +static size_t adrf5731_pack_code(const unsigned char *code, size_t num_cha= nnels, + unsigned char *data) +{ + data[0] =3D code[0] << 2; + return 1; +} + +static size_t hmc271_pack_code(const unsigned char *code, size_t num_chann= els, + unsigned char *data) +{ + data[0] =3D bitrev8(code[0]) >> 3; + return 1; +} + static const struct ad8366_info ad8366_chip_info =3D { .name =3D "ad8366", .gain_min =3D 4500, @@ -86,6 +106,40 @@ static const struct ad8366_info adl5240_chip_info =3D { .num_channels =3D 1, }; =20 +static const struct ad8366_info adrf5720_chip_info =3D { + .name =3D "adrf5720", + .gain_min =3D -31500, + .gain_max =3D 0, + .gain_step =3D -500, + .num_channels =3D 1, +}; + +static const struct ad8366_info adrf5730_chip_info =3D { + .name =3D "adrf5730", + .gain_min =3D -31500, + .gain_max =3D 0, + .gain_step =3D -500, + .num_channels =3D 1, +}; + +static const struct ad8366_info adrf5731_chip_info =3D { + .name =3D "adrf5731", + .gain_min =3D -30000, + .gain_max =3D 0, + .gain_step =3D -2000, + .num_channels =3D 1, + .pack_code =3D adrf5731_pack_code, +}; + +static const struct ad8366_info hmc271_chip_info =3D { + .name =3D "hmc271a", + .gain_min =3D -31000, + .gain_max =3D 0, + .gain_step =3D 1000, + .num_channels =3D 1, + .pack_code =3D hmc271_pack_code, +}; + static const struct ad8366_info hmc792_chip_info =3D { .name =3D "hmc792a", .gain_min =3D -15750, @@ -94,6 +148,22 @@ static const struct ad8366_info hmc792_chip_info =3D { .num_channels =3D 1, }; =20 +static const struct ad8366_info hmc1018_chip_info =3D { + .name =3D "hmc1018a", + .gain_min =3D -31000, + .gain_max =3D 0, + .gain_step =3D 1000, + .num_channels =3D 1, +}; + +static const struct ad8366_info hmc1019_chip_info =3D { + .name =3D "hmc1019a", + .gain_min =3D -15500, + .gain_max =3D 0, + .gain_step =3D 500, + .num_channels =3D 1, +}; + static const struct ad8366_info hmc1119_chip_info =3D { .name =3D "hmc1119", .gain_min =3D -31750, @@ -267,7 +337,13 @@ static const struct spi_device_id ad8366_id[] =3D { { "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)&adrf5720_chip_info }, + { "adrf5730", (kernel_ulong_t)&adrf5730_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 }, { } }; @@ -277,7 +353,13 @@ static const struct of_device_id ad8366_of_match[] =3D= { { .compatible =3D "adi,ad8366", .data =3D &ad8366_chip_info }, { .compatible =3D "adi,ada4961", .data =3D &ada4961_chip_info }, { .compatible =3D "adi,adl5240", .data =3D &adl5240_chip_info }, + { .compatible =3D "adi,adrf5720", .data =3D &adrf5720_chip_info }, + { .compatible =3D "adi,adrf5730", .data =3D &adrf5730_chip_info }, + { .compatible =3D "adi,adrf5731", .data =3D &adrf5731_chip_info }, + { .compatible =3D "adi,hmc271a", .data =3D &hmc271_chip_info }, { .compatible =3D "adi,hmc792a", .data =3D &hmc792_chip_info }, + { .compatible =3D "adi,hmc1018a", .data =3D &hmc1018_chip_info }, + { .compatible =3D "adi,hmc1019a", .data =3D &hmc1019_chip_info }, { .compatible =3D "adi,hmc1119", .data =3D &hmc1119_chip_info }, { } }; --=20 2.43.0