From nobody Sun Feb 8 20:37:55 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 5582F2652B6; Tue, 3 Feb 2026 11:24:19 +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=1770117859; cv=none; b=ADIQmVSNsvcQ06OyObksDJ68j4Q/HUQtvZ1vqUtoDWH5hhYin+O7SKt0Kn5c5MCLjaJ3BCjcCgfScvknksH4uISYrp2JwW9tgIiBa5HFwG7CtYxaHjHKysOlhJI4VLZpJI9WU2fQ5/pRR5VwfXYE4rfNtwJD6mvWFtJ+2BsGHYg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770117859; c=relaxed/simple; bh=o3bvt5IVoPOuC7CuBgSGeBwzgK4Z/m9v9mxJ/tknRCE=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=fT0ad1SMCuHhbOar1lU55Z7p7HGTC7wkEQHAGdh+vrOQNklKi+OT3PCU7WlZcsj4wsmXjeS7mIxStOONI800ZyfqI+nLi9aesv6TPKsgjcMUdNYMlYg79wTXpj/ahK3pnBufcOb6T6znDLvf5AXHLB6NptjLkqM7NntSEHd+LYo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=mFnhsOG2; 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="mFnhsOG2" Received: by smtp.kernel.org (Postfix) with ESMTPS id 2DFF1C19422; Tue, 3 Feb 2026 11:24:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1770117859; bh=o3bvt5IVoPOuC7CuBgSGeBwzgK4Z/m9v9mxJ/tknRCE=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=mFnhsOG2cjRfSBUBPBqR9mCYNj8fOs4ZITMNRiTl7xaMbofIyVKTt3lzxd6U/vm8k KS8nmGkjgMDEZfQm4kLqY6qUveEsWVoGSHcIP5bFZBfxiZ9RfnAiioj9eRUyyHL+V7 jMfybIrm0w9shhxR2Rae6sc/kZCDwaIGh9AyTbSz80FwBFDU2hMr3fUyxTNYC0Zo+7 nGp1R06fbB3/FiOfuSGTn6oQSo8UxUaIEw6YxzqrwDBfEHz28KmUCxhJsVf43x3FqG HE0AW0Aqx44hcxp74J0P5+3ZeKDh2s0HGyX+dEYQiTZhpE1FYuFMBqsdPuO2KDPA+/ B7r/vEtRsjL+g== 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 1A669E6E807; Tue, 3 Feb 2026 11:24:19 +0000 (UTC) From: Rodrigo Alencar via B4 Relay Date: Tue, 03 Feb 2026 11:24:07 +0000 Subject: [PATCH v3 1/9] 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: <20260203-iio-ad8366-update-v3-1-5d5636b5181a@analog.com> References: <20260203-iio-ad8366-update-v3-0-5d5636b5181a@analog.com> In-Reply-To: <20260203-iio-ad8366-update-v3-0-5d5636b5181a@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=1770117857; l=890; i=rodrigo.alencar@analog.com; s=default; h=from:subject:message-id; bh=IB6nsbVkeaHwQfGZNvFxArIH7f6StXcyc8CEVB24Hfs=; b=Np2u20H0RWI9M63yBaqwlqKY5mgZF4mY77FQQ8nqYhbiowkUHpZoBb8llNwUtdE6KmrkuQmzp ZdDinUBGHxzD7O4LDazec5qQojIHu4kn6Vq24/lx4/qpWu8g7A0udUF 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 Sun Feb 8 20:37:55 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 6CF02333451; Tue, 3 Feb 2026 11:24:19 +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=1770117859; cv=none; b=PZ+0IsbQOA//nm8jb54LNEBOZpAtMHMjMZJwUpCewQfTs+OyaSnDS9kLsPvv2LsvDzPmD7zoziurxK91WH9tb6UQ4yWktxc+rbfL/LqU7eG/aBQx/VyD4lQcslxRNjAW5Kxfns3EHXUEVq7pC6zBCoi0q7p7toNhgxLX3T8KuKM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770117859; c=relaxed/simple; bh=aBPIntVD4TEFyPcuBJUSgguCDZx2ov8b6calvONPeKE=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=orbaH8kYR5HFX1duvwwhBqXoIMspZvbmXRFSp7RmvzVw5xJQAXgMvBN5lhTGYp9MU3Rq2VP+CRN+ATIPeABdlg+chn/colZ5yE0cioHmSgom+bi7SvGlrsPgBihus9UijYCPF8SZwIwlhAUjHRCnlJutnhx9It5j+Y4foOCRTBw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=CHnjaSZy; 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="CHnjaSZy" Received: by smtp.kernel.org (Postfix) with ESMTPS id 3C5ACC2BC87; Tue, 3 Feb 2026 11:24:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1770117859; bh=aBPIntVD4TEFyPcuBJUSgguCDZx2ov8b6calvONPeKE=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=CHnjaSZyHTsAftAPy+fPDPIqMvEC7lRE/O0UvSBgmELwKwl8WtZylt0BjeG3u3zZB fkHOU8GxPThIr7LmWb4LChKDpxAgVexjsnTWH1rVLYn7pG7x2rjCS3VauPDR6+XoQf 5Nu5toMXT6mL8G3wpxtFIaq/KNO75sIJPzi5Zm5skeyPD1pgz5Twf5GMAcYKQcTWuh UOArk2xFndoFRrlv8qTVNge2qJEajt7ROFIZev0rMVsD7SUhL2WhOhZjoWSd6z+NA9 gHRhCCaqn+zp8FicfpgwRZ7lhoBNJPdVnCjcXnHBMy9eTSVNPx4gs8fegwC4k4Ydqh 0aBjTNlG5Cvpw== 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 3201BE6E813; Tue, 3 Feb 2026 11:24:19 +0000 (UTC) From: Rodrigo Alencar via B4 Relay Date: Tue, 03 Feb 2026 11:24:08 +0000 Subject: [PATCH v3 2/9] 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: <20260203-iio-ad8366-update-v3-2-5d5636b5181a@analog.com> References: <20260203-iio-ad8366-update-v3-0-5d5636b5181a@analog.com> In-Reply-To: <20260203-iio-ad8366-update-v3-0-5d5636b5181a@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=1770117857; l=3527; i=rodrigo.alencar@analog.com; s=default; h=from:subject:message-id; bh=z+RKl7OEhNSJ75C0Rq25IwQV3k770yUF9OzeepsRMoE=; b=mrY7/uK5urx1izXJEND8WQuaPxLFT3ZAMegqfEtnKKRM9QTdClOFz2ESMOVgPlEs1AchYDWp9 LkG/klQi7F7B+CmKiIsBagi6asLaoX6aTJDRfLizC9mWq/iRXeEtZRZ 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. Signed-off-by: Rodrigo Alencar Reviewed-by: Conor Dooley --- .../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 Sun Feb 8 20:37:55 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 7EE3C3346BB; Tue, 3 Feb 2026 11:24:19 +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=1770117859; cv=none; b=P8+LnQxm2BZHM2/wOEjzx+ZpcqgWPiFllDzX2SrNLNL+9DKhMHIZrTXBDKu+f4zKfv1AHZsbH4RxoRuZSqBtEBRmnce3qhTN7Om1WC2FlHDyYhwfT+DZllp95g5Ez1IPe6INCDyOX/jfN4V4NaJy1l5900J8EF+hTXre3gySEak= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770117859; c=relaxed/simple; bh=o2vrpBmE8UUrNQuSszq90H8TSetzuxSfZT1ZPkryBDI=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=tcvg+Fb0H0qv6hI5xcEvCcRnMlKJoSR+7mi0NX54cJL4/Hp0Dbr60pyxAlFdzZ+uIeu1IEbK6H3R6LHJVyBKwxuCFoKASduOltUl2klG95+g3C2uA1H3ZPXAzdutD4Dh0wch7Hfoe90ZfxghHVsi+vGUVtqpkpmITHPPtbRcQU4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=b2/TUqhn; 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="b2/TUqhn" Received: by smtp.kernel.org (Postfix) with ESMTPS id 555E7C2BC9E; Tue, 3 Feb 2026 11:24:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1770117859; bh=o2vrpBmE8UUrNQuSszq90H8TSetzuxSfZT1ZPkryBDI=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=b2/TUqhnpQHC0D8ucSkXwMOxeMWFEi/dZbBIbn7l4ew+uV79HhKfiCp66Ys4j9qjh fFNUr4BrKgBF6T/filJVM85/SiDn6B8iZoQYhDuIjULtn0tQPXYZzI1mpcOL5XEK6N 9go1B0+GtUK2vkNEzgxzoyM1vEGiuovRkzmnJQNI72Kcc3nYTYg7/sQv71J/K52SFz WxJdaoY1UkaBfW1dG42r4Kx+GESBnBCNl00IgOsTscYNuMeVs0R14lwmJDEVBtQLeN C91y2sYGJbspKrd936NEWG/SCAf8Z+TVrUuVa6IILdfhCavYg9dZlcWHuHv2+fw2C3 I4gkdv/VQm/pA== 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 46662E6E816; Tue, 3 Feb 2026 11:24:19 +0000 (UTC) From: Rodrigo Alencar via B4 Relay Date: Tue, 03 Feb 2026 11:24:09 +0000 Subject: [PATCH v3 3/9] 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: <20260203-iio-ad8366-update-v3-3-5d5636b5181a@analog.com> References: <20260203-iio-ad8366-update-v3-0-5d5636b5181a@analog.com> In-Reply-To: <20260203-iio-ad8366-update-v3-0-5d5636b5181a@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=1770117857; l=966; i=rodrigo.alencar@analog.com; s=default; h=from:subject:message-id; bh=i1uZPY/+9TFsjqSIU1LFXWflhkq05R0JInppwz60DI0=; b=XEQOgfJvTdu75yedpZWp7uhgPEHCuQp7kFnG45x0KqJp1Rz9hi0+ZlbTLkwVALJ1fsMzVuyj/ 08Z8XVNkGD3BYcjYh9P6ksLh/l8uN4/F1PJDkKgTdLU9VY5I3BOv4xW 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(). 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 d06ac786501c..f0d44f2769ca 100644 --- a/drivers/iio/amplifiers/ad8366.c +++ b/drivers/iio/amplifiers/ad8366.c @@ -255,6 +255,10 @@ static int ad8366_probe(struct spi_device *spi) =20 st =3D iio_priv(indio_dev); =20 + ret =3D devm_mutex_init(&spi->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); @@ -263,7 +267,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 Sun Feb 8 20:37:55 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 A2A81336EC1; Tue, 3 Feb 2026 11:24:19 +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=1770117859; cv=none; b=GZr4lvEVMoh9SCgY1oIkYQxSdgLH90SuqHjzmkFgjIAJbPcDUXbCwZoOjSLWQCv6ruDbY4tq0NzmVEe4BOwkFC5aSz8RYAZWtMOl1HUjM8L7TZK1OCsr+zOLt/l7HMt2szisSYrSl/91NOl+dML9u9GKSTZcswo08twB0RagTAs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770117859; c=relaxed/simple; bh=4TpjQU7RKnPyWX86KGp8TKTM6hGi4/wBYH7Z+MEZlEI=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=FJy92SbX01fwOBmWE5aNDYavBBPQhXTcqy2mb+IRbzugvxzqaQNT1VU78WkbM5eJBm7gKq4guNyMzdIdeKFfbjmdm1Srk+3pvvNGlRauAP01RmOuBl3m47NvVFfSroi+7AtclIXCG9iI0DfWaGNctfC/kjj6NAcDDRc6D9C+c9g= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=oxOq34Z+; 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="oxOq34Z+" Received: by smtp.kernel.org (Postfix) with ESMTPS id 80B43C19425; Tue, 3 Feb 2026 11:24:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1770117859; bh=4TpjQU7RKnPyWX86KGp8TKTM6hGi4/wBYH7Z+MEZlEI=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=oxOq34Z+oy3D0z+4zyAeQKP1bsgyhBBHp1DAYviAK16UGUN1vT5s/zMjobpqZ+z/C ucvoaexh91OtTD3dsB+dhi2NSMYzZ9/kxGqE9TDmR1xhlxEqr2djEMdKFoOyC4k5bV 10I9pLfJsaSwN1mOql1WETG/KG97PhRLeDzeL6tb6VYDm6nXPiIPjr0u9tYQgh4cxp MdQn8bTZ0CGd06CDFx3p/R+rDnL7xpbBmdrbnZVh5hVCEXJ99QlmsxJp8Ca/23k7fC 3Fo74qr9rXFJ/GHoUUcJcP1aVp198eempDwFlLNe30/0BG39cA+3/Xz09PZC77oPYR 2mu8MT82VXZZQ== 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 77F06E6E814; Tue, 3 Feb 2026 11:24:19 +0000 (UTC) From: Rodrigo Alencar via B4 Relay Date: Tue, 03 Feb 2026 11:24:10 +0000 Subject: [PATCH v3 4/9] iio: amplifiers: ad8366: drop reset_gpio from private struct 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: <20260203-iio-ad8366-update-v3-4-5d5636b5181a@analog.com> References: <20260203-iio-ad8366-update-v3-0-5d5636b5181a@analog.com> In-Reply-To: <20260203-iio-ad8366-update-v3-0-5d5636b5181a@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=1770117857; l=1514; i=rodrigo.alencar@analog.com; s=default; h=from:subject:message-id; bh=7IwKgsiwuYgVI5syKodj5406ItZPM82hCN9tX04mYFY=; b=i15+QkMb3ey0jb7qHzqL41jsRwkIBTZZPa6FPCCPautCrcfENc09gcuKI8Tzvrri6MBRTsYV5 2BBjchX6bsqAQidMDp/bQKMKEJzBIsrvwet+mcb+x1aZ7AxYHSzDK6f 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 turn it into a local variable, as it is not being used anywhere else. Signed-off-by: Rodrigo Alencar --- drivers/iio/amplifiers/ad8366.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/iio/amplifiers/ad8366.c b/drivers/iio/amplifiers/ad836= 6.c index f0d44f2769ca..d6e18eb71bc8 100644 --- a/drivers/iio/amplifiers/ad8366.c +++ b/drivers/iio/amplifiers/ad8366.c @@ -42,7 +42,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; @@ -245,6 +244,7 @@ static const struct iio_chan_spec ada4961_channels[] = =3D { =20 static int ad8366_probe(struct spi_device *spi) { + struct gpio_desc *reset_gpio; struct iio_dev *indio_dev; struct ad8366_state *st; int ret; @@ -279,9 +279,9 @@ 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)) { - ret =3D PTR_ERR(st->reset_gpio); + reset_gpio =3D devm_gpiod_get_optional(&spi->dev, "reset", GPIOD_OUT_HIG= H); + if (IS_ERR(reset_gpio)) { + ret =3D PTR_ERR(reset_gpio); goto error_disable_reg; } indio_dev->channels =3D ada4961_channels; --=20 2.43.0 From nobody Sun Feb 8 20:37:55 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 B44F43382E4; Tue, 3 Feb 2026 11:24:19 +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=1770117859; cv=none; b=XXf3Xo7a6WKSCcHY0B0WLqRz4Uq8VeYtnVnUdTmxZmExGj87cbUtw2uydBxeo+nJM+6REgwPIiafkn9ubD+v8DQXPrMrcRa5S7UmiYjX+yl3+eIN/jgKbNXqqaqhV5trGnFD4H+Ws1o/pT1J2NfhjlzEbtzN3g9ofaCz8mQUPek= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770117859; c=relaxed/simple; bh=OkrRjjRXZ14XH3hepKiVh+rGbuFi8EYTlqqCt8mD1+g=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=eJWRSGCyK+TBIlVPovzKNP1Qzfe/4S2eSBt03Ojr2ZNYc45Oi3J4Rgq8uZBkiCZHlC0aUXBL6DftKAp/XfJK2wVt6WZ8SCg0gjIPyos29vWtX453qhhr7sBynDK4wnTJ0I++MhrT8H8Sbl6800mT5Rz7NvIfNuS/TO7Zwcq86Po= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=eBCZZ/T3; 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="eBCZZ/T3" Received: by smtp.kernel.org (Postfix) with ESMTPS id 96FA5C116D0; Tue, 3 Feb 2026 11:24:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1770117859; bh=OkrRjjRXZ14XH3hepKiVh+rGbuFi8EYTlqqCt8mD1+g=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=eBCZZ/T3rcTrsZynR9AVzcHtCPaoKEgamUZ/vjbsxc1ll+DLJrwAGUJjf7QCdfkaU n2wzPPA79FFsn6WDOcgQK78yPJKcSUFtXIAgQV1D8RqzlKtw/RGrYW3rrWkRipLuR8 aGymbdDNLCKw64+Dl4xkEAaO6Rq+o3+gkF2bhzwMSlKbqW+4XTJtpytcLT2B5vkPpM OMOE6VwYFrmf9CkDcQsU9gyJE/g4cJ7asKRrfGNg/Y6rNWKVTvcjJLBXgP9v1PpXeI FOX4t93q3WoaZA2dTgAziUr3smearDveK24w9LJvi+Ae0DNIshk0hbejqG5fM+bz0z BTJN0FhUx3azw== 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 8E02AE6E813; Tue, 3 Feb 2026 11:24:19 +0000 (UTC) From: Rodrigo Alencar via B4 Relay Date: Tue, 03 Feb 2026 11:24:11 +0000 Subject: [PATCH v3 5/9] 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: <20260203-iio-ad8366-update-v3-5-5d5636b5181a@analog.com> References: <20260203-iio-ad8366-update-v3-0-5d5636b5181a@analog.com> In-Reply-To: <20260203-iio-ad8366-update-v3-0-5d5636b5181a@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=1770117857; l=3293; i=rodrigo.alencar@analog.com; s=default; h=from:subject:message-id; bh=f+kMNCcEGZUSXT8GVTgbBGh2m45pMNgPC1EpKanwlWg=; b=QNUN9HjLyrpZeTAjssfmUhl9ReViIORKF/ARDaupDTw072/+Xik5ksSJHsb8b7p9IJckuEGnj /tSnt4l+Qc/AyG5Nf7bysVSf4xJ//MsC7qqaVwxzbu4h6IIkI7/1yBX 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 d6e18eb71bc8..2da10c748362 100644 --- a/drivers/iio/amplifiers/ad8366.c +++ b/drivers/iio/amplifiers/ad8366.c @@ -40,7 +40,6 @@ struct ad8366_info { =20 struct ad8366_state { struct spi_device *spi; - struct regulator *reg; struct mutex lock; /* protect sensor state */ unsigned char ch[2]; enum ad8366_type type; @@ -259,14 +258,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(&spi->dev, "vcc"); + if (ret) + return dev_err_probe(&spi->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 @@ -280,17 +275,15 @@ static int ad8366_probe(struct spi_device *spi) case ID_HMC792: case ID_HMC1119: reset_gpio =3D devm_gpiod_get_optional(&spi->dev, "reset", GPIOD_OUT_HIG= H); - if (IS_ERR(reset_gpio)) { - ret =3D PTR_ERR(reset_gpio); - goto error_disable_reg; - } + if (IS_ERR(reset_gpio)) + return dev_err_probe(&spi->dev, PTR_ERR(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(&spi->dev, -EINVAL, "Invalid device ID\n"); } =20 st->info =3D &ad8366_infos[st->type]; @@ -300,31 +293,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(&spi->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(&spi->dev, indio_dev); } =20 static const struct spi_device_id ad8366_id[] =3D { @@ -342,7 +313,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 Sun Feb 8 20:37:55 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 EEB1A33A9CD; Tue, 3 Feb 2026 11:24:19 +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=1770117860; cv=none; b=B6wsVqaYxuXv025mVeTikf65i/DqKc+IBQnYk3dF8KQ6Ht/9yQE0iS0fSamx4OF891C8UotL9AuYHacMF4ixkL3UwS7bLPJiqXOEoUHi9xNi7U0yTj4+7Wvtdih5w/ruz7W7WORrR+UkTBDro1x1IyLdx2NijlAxQPwxGw1zBa8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770117860; c=relaxed/simple; bh=ZEudIFOMkZH+LXKC81DG++ePZDeFIx28avMwVNLYPO4=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=M5fHcqRC8zE1p5lFgQEpnV1iVGq3tPLvX/h8caEREilQoR97dHm1F8ok3NdXysxb5NOjarQHKalHjQ1IHwzOSc4Bj7/Z1DjjgS01W41xpFBXRfkuh5rLlaZ1s70pYNqdKCzSysqvht5zU6E15v9FNmjNLjJ00/Ulq0TLo7OiTbo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=HSUEvto7; 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="HSUEvto7" Received: by smtp.kernel.org (Postfix) with ESMTPS id C5742C2BCAF; Tue, 3 Feb 2026 11:24:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1770117859; bh=ZEudIFOMkZH+LXKC81DG++ePZDeFIx28avMwVNLYPO4=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=HSUEvto7lfcPnDF1WWwo4GvznIEeyCqGn1z+LudgiNGZYDz05o5/qLVt88L1zjMiX 12/t47dvqKFj41J3+OAf+NLEoEWzedHiKYnKoF3Z+TSXgvlYvZOw1Ktc+3a+LdCX/A wyq8q6fAZwv2aQYR5kJYFR34bluvzooUDZfCcrJ4oJkFHNPRVqn6yncXAZrIcUs4bQ 7Xfu0VOTizC6VghPsxEqNapWMhDd+u/H36+WzYGvwS5b7/TRJXH5ASp/mL5XaU8hLP PaFPMs7GQjLTEQC9Da7hV6fAPT0el7CsG1ABoX/EenIKwEQwArwBUuxAFkuKTSo8YF EM72alkKEejdQ== 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 B9724E6E814; Tue, 3 Feb 2026 11:24:19 +0000 (UTC) From: Rodrigo Alencar via B4 Relay Date: Tue, 03 Feb 2026 11:24:12 +0000 Subject: [PATCH v3 6/9] iio: amplifiers: ad8366: sort header includes 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: <20260203-iio-ad8366-update-v3-6-5d5636b5181a@analog.com> References: <20260203-iio-ad8366-update-v3-0-5d5636b5181a@analog.com> In-Reply-To: <20260203-iio-ad8366-update-v3-0-5d5636b5181a@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=1770117857; l=1177; i=rodrigo.alencar@analog.com; s=default; h=from:subject:message-id; bh=s8rA3b2H1BNCIQuGiHV+VZ+q0tCGOGK7fNQac9O3/2A=; b=6nC3fXTKZ6yKd6LIm5kdhd1WpXb+6nc/95oKvrPcHm5ISsHtbPa1K5gWxYdl8ecEO9Og96D8X pgEXHp8iuFZD5YaPCqylqB8QTeiObfXzBpxgdk014ZMYv5aFWG4Lhhn 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 Alphabetically sort include directives and drop include of linux/kernel.h. Signed-off-by: Rodrigo Alencar --- drivers/iio/amplifiers/ad8366.c | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/drivers/iio/amplifiers/ad8366.c b/drivers/iio/amplifiers/ad836= 6.c index 2da10c748362..40b03e417be8 100644 --- a/drivers/iio/amplifiers/ad8366.c +++ b/drivers/iio/amplifiers/ad8366.c @@ -11,19 +11,17 @@ * 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 =20 enum ad8366_type { ID_AD8366, --=20 2.43.0 From nobody Sun Feb 8 20:37:55 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 3C93433B97B; Tue, 3 Feb 2026 11:24:20 +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=1770117860; cv=none; b=tGfAhwX3wRSSaagCQS1HT5VH5AMrAMzrWexLt3KLc7DTL/6NY2eVZJMErplCJWfgsYTuxEQWuCgJhN9Rnd0lA6Ze1PSUPgNddKLrEhcXMCIv/aXOJLm8pn2ohIfXoKPjORu8YVDWUDlic++7k5cqsExKQzwP9xmgvIJILCAv/Fc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770117860; c=relaxed/simple; bh=mPm/ZXkLgijvX5BqaOJpIPMrDmYb6nV9d+WBghP1oaA=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=UDPj7Mjt1ejgLlikc/J0OxGOLEy3uaYqSx+cLljZ7cVdwHd5ohZw2X3oJ5QeJkxz/qgfJ8d93iLq71jscuJExAIm0O+kx+yKVyXA0/W9dCyhR2M+Q8a9aiUqMYZdxZK2Bwz873QN5s0qbASm0R5rJO4j6Tdw6Ba3Rc7rftUskc4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=G9cb5MIE; 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="G9cb5MIE" Received: by smtp.kernel.org (Postfix) with ESMTPS id DCE8CC4AF09; Tue, 3 Feb 2026 11:24:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1770117859; bh=mPm/ZXkLgijvX5BqaOJpIPMrDmYb6nV9d+WBghP1oaA=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=G9cb5MIEv9K2Rdtt8Jtjbp/11D1vN7NKRpq41UiDgfn1WOcUDSeI58GnPZSVwnBc4 JRrXQPncrwmrN2yy2d/GWwnjB/N/VUbAMlmKtdetvoNQ8OqwZhIVXaVbVdnqaJdayX /4DLKWQ+PbpOvioXoOqzNqQhmPCcTanO4g81FpSPYlJ2F052iTly/ywqwupGWpTzPT AD7wN5eoTZq+ue54dw1w/Nnb0woPVfhQ2LxbchIT+zFBWQwKEOvfX56JA6ft91puBD DawOOyFdE10e5T6ebuERIVsyg3niOkT8Dk8LFwAAvHl7v7v+qHEEVjvpcW1U5wW76B Es0S5yjeF/mYg== 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 D2164E6E807; Tue, 3 Feb 2026 11:24:19 +0000 (UTC) From: Rodrigo Alencar via B4 Relay Date: Tue, 03 Feb 2026 11:24:13 +0000 Subject: [PATCH v3 7/9] 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: <20260203-iio-ad8366-update-v3-7-5d5636b5181a@analog.com> References: <20260203-iio-ad8366-update-v3-0-5d5636b5181a@analog.com> In-Reply-To: <20260203-iio-ad8366-update-v3-0-5d5636b5181a@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=1770117857; l=9094; i=rodrigo.alencar@analog.com; s=default; h=from:subject:message-id; bh=GjtGW1A1Fw9w2PC4dNzs8JDF0ld3ALoDYy8sRQJrqR0=; b=6RkSVPRBxqGkSiCW1ypzKM3bPa4mIDX9WRWgkIhI4B8KlXpDBQKKmufmaeUk30UHWHnf4sqmZ 4ZSxUi0ZcyHDPGs/h1QsIL4iBlaHPFYc30iz8Ut4B+gHVJQ861389Hs 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 support by dropping 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; With this, switch cases on the device type were dropped: - probe() function adjusted accordingly; - Simplified read_raw() and write_raw() callbacks; Signed-off-by: Rodrigo Alencar --- drivers/iio/amplifiers/ad8366.c | 217 ++++++++++++++++--------------------= ---- 1 file changed, 88 insertions(+), 129 deletions(-) diff --git a/drivers/iio/amplifiers/ad8366.c b/drivers/iio/amplifiers/ad836= 6.c index 40b03e417be8..dc2fe94c53cd 100644 --- a/drivers/iio/amplifiers/ad8366.c +++ b/drivers/iio/amplifiers/ad8366.c @@ -18,29 +18,27 @@ #include #include #include +#include #include #include #include #include +#include =20 -enum ad8366_type { - ID_AD8366, - ID_ADA4961, - ID_ADL5240, - ID_HMC792, - ID_HMC1119, -}; +struct ad8366_state; =20 struct ad8366_info { int gain_min; int gain_max; + int gain_step; + int num_channels; + size_t (*pack_code)(struct ad8366_state *st); }; =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 @@ -49,60 +47,62 @@ struct ad8366_state { unsigned char data[2] __aligned(IIO_DMA_MINALIGN); }; =20 -static const struct ad8366_info ad8366_infos[] =3D { - [ID_AD8366] =3D { - .gain_min =3D 4500, - .gain_max =3D 20500, - }, - [ID_ADA4961] =3D { - .gain_min =3D -6000, - .gain_max =3D 15000, - }, - [ID_ADL5240] =3D { - .gain_min =3D -11500, - .gain_max =3D 20000, - }, - [ID_HMC792] =3D { - .gain_min =3D -15750, - .gain_max =3D 0, - }, - [ID_HMC1119] =3D { - .gain_min =3D -31750, - .gain_max =3D 0, - }, +static size_t ad8366_pack_code(struct ad8366_state *st) +{ + u8 ch_a =3D bitrev8(st->ch[0]) >> 2; + u8 ch_b =3D bitrev8(st->ch[1]) >> 2; + + put_unaligned_be16((ch_b << 6) | ch_a, &st->data[0]); + return 2; +} + +static const struct ad8366_info ad8366_chip_info =3D { + .gain_min =3D 4500, + .gain_max =3D 20500, + .gain_step =3D 253, + .num_channels =3D 2, + .pack_code =3D ad8366_pack_code, }; =20 -static int ad8366_write(struct iio_dev *indio_dev, - unsigned char ch_a, unsigned char ch_b) +static const struct ad8366_info ada4961_chip_info =3D { + .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 { + .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 { + .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 { + .gain_min =3D -31750, + .gain_max =3D 0, + .gain_step =3D -250, + .num_channels =3D 1, +}; + +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); + 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, @@ -112,32 +112,14 @@ 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; + int gain =3D inf->gain_step > 0 ? inf->gain_min : inf->gain_max; =20 mutex_lock(&st->lock); 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 * st->ch[chan->channel]; /* Values in dB */ *val =3D gain / 1000; *val2 =3D (gain % 1000) * 1000; @@ -172,29 +154,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; @@ -235,10 +202,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 gpio_desc *reset_gpio; @@ -261,35 +224,20 @@ static int ad8366_probe(struct spi_device *spi) return dev_err_probe(&spi->dev, ret, "Failed to get regulator\n"); =20 st->spi =3D spi; - st->type =3D spi_get_device_id(spi)->driver_data; + st->info =3D spi_get_device_match_data(spi); =20 - 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: - reset_gpio =3D devm_gpiod_get_optional(&spi->dev, "reset", GPIOD_OUT_HIG= H); - if (IS_ERR(reset_gpio)) - return dev_err_probe(&spi->dev, PTR_ERR(reset_gpio), - "Failed to get reset GPIO\n"); + reset_gpio =3D devm_gpiod_get_optional(&spi->dev, "reset", GPIOD_OUT_HIGH= ); + if (IS_ERR(reset_gpio)) + return dev_err_probe(&spi->dev, PTR_ERR(reset_gpio), + "Failed to get reset GPIO\n"); =20 - indio_dev->channels =3D ada4961_channels; - indio_dev->num_channels =3D ARRAY_SIZE(ada4961_channels); - break; - default: - return dev_err_probe(&spi->dev, -EINVAL, "Invalid device ID\n"); - } - - 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(&spi->dev, ret, "failed to write initial gain\n"); =20 @@ -297,18 +245,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 Sun Feb 8 20:37:55 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 34A1633B961; Tue, 3 Feb 2026 11:24:20 +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=1770117860; cv=none; b=ixDkdQdHlWLHsPnEU9BBNMHT7UlFXGWoRXkqTV5Nz4JjY9MdT4FQmJX6YR1Osi8AksDa5xaToMQaOQnSwi/gSQpq32fGuuKAalhl4RNvnui3ehPuH+KbQVnBMs5Fr4dp8GAeu2Nc78fgBbBRkPVc3/5uMXp9vfTb8FfIGszKh6Y= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770117860; c=relaxed/simple; bh=JvqRvi/KRBjYNMnk26SO2KrpKQDhXOhrqtEVadrdH3Y=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=gMKOocfTOW6H0pYA6GSof3sdyZsL6ltNkuiwWgUh3ENDHgJe6kEAa6gEOjkSlguLtcqPdd8J0rPdPWi99XyjWBCuffUS+GI1hlOK+m8UohTrtxj34m4RSkLS2ySJwKiaMPpi9nSPQr+J113yMl03ABnJP9+1ebCoFDOFuFk3JfY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=rqUsNAZu; 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="rqUsNAZu" Received: by smtp.kernel.org (Postfix) with ESMTPS id 08372C4AF0B; Tue, 3 Feb 2026 11:24:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1770117860; bh=JvqRvi/KRBjYNMnk26SO2KrpKQDhXOhrqtEVadrdH3Y=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=rqUsNAZuYOspCotY7SXlu/kxEEOa2/tEHTJdC3BiV5i6KFVq1pX8nWYysP8FQjDO4 JlhgjWh2hJn6RRuZkClyBgUFUrFwLOfr7XQHYPIXh6L5AxZuTpGayg2O3uUER++OXI u+z9Bn2w26yrXI8/hkd/n/2I37DyeeKathhj/VQTekqvM8f5Im2LrMrPw4qdHOLXdI kuRvFUXTbWM5BEkpr/L4ZADH/gXABWBHKkti8v5MHs+DLbokzOWubJ3xsa33iyzdO2 5WN3ihyW/FQdDS6REC45EI70/1i14tRWrf/KpLgbWGQ53YbZ5gPN8f4zDd9iR5iTmk rEF+ojP4nImQw== 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 ECAC7E6E813; Tue, 3 Feb 2026 11:24:19 +0000 (UTC) From: Rodrigo Alencar via B4 Relay Date: Tue, 03 Feb 2026 11:24:14 +0000 Subject: [PATCH v3 8/9] 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: <20260203-iio-ad8366-update-v3-8-5d5636b5181a@analog.com> References: <20260203-iio-ad8366-update-v3-0-5d5636b5181a@analog.com> In-Reply-To: <20260203-iio-ad8366-update-v3-0-5d5636b5181a@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=1770117857; l=2016; i=rodrigo.alencar@analog.com; s=default; h=from:subject:message-id; bh=NI6Xmsw6qw3e0XQ9ey2GDgpNHtC2qQOpsDhpudcrNSs=; b=ZER9ogdVMM1LC5NtTAY6EUzYEivRrdqa9Z7JDK8lrB2+9ayvCpIvxFYbFnrfBO9qWiV9YtaMV WU8YXCibjV5BnBBKUU2aTvOAu0vFUDlB8gHQ3ZyiIFv8fmlsueHNL0u 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). Also, add a comment explaining that even though chips like HMC271A has a reset gpio, this driver previously considered the reset pin for parts that don't actually have a reset gpio, so it might have been used to enable/power the device. Signed-off-by: Rodrigo Alencar --- drivers/iio/amplifiers/ad8366.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/drivers/iio/amplifiers/ad8366.c b/drivers/iio/amplifiers/ad836= 6.c index dc2fe94c53cd..92865ab96ade 100644 --- a/drivers/iio/amplifiers/ad8366.c +++ b/drivers/iio/amplifiers/ad8366.c @@ -204,7 +204,7 @@ static const struct iio_chan_spec ad8366_channels[] =3D= { =20 static int ad8366_probe(struct spi_device *spi) { - struct gpio_desc *reset_gpio; + struct gpio_desc *reset_gpio, *enable_gpio; struct iio_dev *indio_dev; struct ad8366_state *st; int ret; @@ -226,11 +226,22 @@ static int ad8366_probe(struct spi_device *spi) st->spi =3D spi; st->info =3D spi_get_device_match_data(spi); =20 + /* + * Previously, this driver considered the reset gpio for some devices + * that don't actually have a reset pin, which could have been wired + * up to the enable pin instead, so some users might be relying on this + * to turn the chip on rather than reset it. + */ reset_gpio =3D devm_gpiod_get_optional(&spi->dev, "reset", GPIOD_OUT_HIGH= ); if (IS_ERR(reset_gpio)) return dev_err_probe(&spi->dev, PTR_ERR(reset_gpio), "Failed to get reset GPIO\n"); =20 + enable_gpio =3D devm_gpiod_get_optional(&spi->dev, "enable", GPIOD_OUT_HI= GH); + if (IS_ERR(enable_gpio)) + return dev_err_probe(&spi->dev, PTR_ERR(enable_gpio), + "Failed to get enable GPIO\n"); + indio_dev->name =3D spi_get_device_id(spi)->name; indio_dev->info =3D &ad8366_info; indio_dev->modes =3D INDIO_DIRECT_MODE; --=20 2.43.0 From nobody Sun Feb 8 20:37:55 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 3DDE933B97E; Tue, 3 Feb 2026 11:24:20 +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=1770117860; cv=none; b=DPtxSa3sjVp+byq7FI7YsxAMpE0Xs1s67c9iXAwJlTg2r1K11amD+x8e6ba0PEIs9Jf7JR4fMJzG7SfYeHB3QU+Jbz6eJVmfVtB9ydGoLZmLIxLbFd1T79pilUZTLZG7nAeAMVFz4xXkkbPEXuT/ewZdAkXdTKZ4zVzwNn3XQNY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770117860; c=relaxed/simple; bh=FIxM5V8+JQAKRcYhGX479j5LikG1/Ho6CmiPz3v8nQQ=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=IKquQXZYNnDze4C06inpgFfTEpyAIH2+ll2ANH0rWWH/HTDunB08belI/whBsWnJWLV/czjJtPa4tMiABf+uRC6WIhVNUAVrmJce8e9j9HFZmXozvOEb56HxPaPuKGo4hffyYw4c9EVVgWaxc29EFe54uq+4JflVlPcTW9FiDk8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=l7XVQFfX; 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="l7XVQFfX" Received: by smtp.kernel.org (Postfix) with ESMTPS id 1D9D5C116D0; Tue, 3 Feb 2026 11:24:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1770117860; bh=FIxM5V8+JQAKRcYhGX479j5LikG1/Ho6CmiPz3v8nQQ=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=l7XVQFfXX3ruPx2iB6en/m0XVqhyXkrHFCz67LV99Iy7YpPfXPZVJq0NFRdNb6YxJ oiDxfCO0nNKNgxmvP02LtGxnlqkWxp5oy7WAIsSQHmNfzgwkjHrtNCqftdUPmMRHyn S36nCOsatkWmExSjUHVnK8MYrftxfzh2ihzQitUjYA95GMLTY4tbNlz63Z+WEoaDZN BFVfyFEs1BUvRxXB5so0qFSfuANVNUJCk93X+Aq68BF+82W/okLtb7lgbFivSrI/vy AuWWafaTcy4uZuArd3RD6YtrPVNJESNtiy+EHCPWXoxKkCXBkh7s2/IWq6xOlJDILQ OwOk5iEnfMpKg== 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 10216E6E814; Tue, 3 Feb 2026 11:24:20 +0000 (UTC) From: Rodrigo Alencar via B4 Relay Date: Tue, 03 Feb 2026 11:24:15 +0000 Subject: [PATCH v3 9/9] 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: <20260203-iio-ad8366-update-v3-9-5d5636b5181a@analog.com> References: <20260203-iio-ad8366-update-v3-0-5d5636b5181a@analog.com> In-Reply-To: <20260203-iio-ad8366-update-v3-0-5d5636b5181a@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 X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1770117857; l=6250; i=rodrigo.alencar@analog.com; s=default; h=from:subject:message-id; bh=VWX2rYjoJLQFKSpmfPi56ddhqrjyXurza45bIv8KGCc=; b=7P6icB4MiuTdlRZsIx83DFXErvmLxITPgRiKTKRf7+JPhC8glSfxh4T9hhXVd0/zwouFmDaPf h+TyAPhupfYAi5SsOZPIRRtLgcGoB8ehT36MzW0c699fYqGGRGRGP1+ 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 Signed-off-by: Rodrigo Alencar Reviewed-by: Andy Shevchenko --- 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 =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 92865ab96ade..42b89fef761a 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 @@ -56,6 +62,18 @@ static size_t ad8366_pack_code(struct ad8366_state *st) return 2; } =20 +static size_t adrf5731_pack_code(struct ad8366_state *st) +{ + st->data[0] =3D st->ch[0] << 2; + return 1; +} + +static size_t hmc271_pack_code(struct ad8366_state *st) +{ + st->data[0] =3D bitrev8(st->ch[0]) >> 3; + return 1; +} + static const struct ad8366_info ad8366_chip_info =3D { .gain_min =3D 4500, .gain_max =3D 20500, @@ -78,6 +96,29 @@ static const struct ad8366_info adl5240_chip_info =3D { .num_channels =3D 1, }; =20 +static const struct ad8366_info adrf57x0_chip_info =3D { + .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 { + .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 { + .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 { .gain_min =3D -15750, .gain_max =3D 0, @@ -85,6 +126,20 @@ static const struct ad8366_info hmc792_chip_info =3D { .num_channels =3D 1, }; =20 +static const struct ad8366_info hmc1018_chip_info =3D { + .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 { + .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 { .gain_min =3D -31750, .gain_max =3D 0, @@ -259,7 +314,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)&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}, { } }; @@ -269,7 +330,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 &adrf57x0_chip_info }, + { .compatible =3D "adi,adrf5730", .data =3D &adrf57x0_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