From nobody Mon Feb 9 10:30:14 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 441A2329E50; Mon, 19 Jan 2026 14:37:30 +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=1768833450; cv=none; b=O+rUXUc4CfYcddG83b6MWjZqCyohS0GyoOSgY54EEut8mPNgW+u0VuskzXp28nPCRhPgjrZ59dqtp3dudPNLPzQ2euFMVp5JtMxC2XV3WnzPgEl4RwvGhTj0HCY3J/W3WoxewIkseiY3ApCx+5sFd9EW68zCXt1GFv9ox+7B0KU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768833450; c=relaxed/simple; bh=UyScQ2ACRZSy/lz8cbYQAzpkus17hqeQlMYDqY0q6pg=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=bdbv+imzNDfE9rUP7c/ukeQbUbLqKhXAmaqQxZl3W7oNnJXyAPOsDi+R52z+famcxavSlW0hfDsGz2cqXcgQaoPp/22FDOMQiEDNfU+/NA3+15UfJolo7bU42QH8sHSqPEyrK5+BETbGpUGeVxwWwXumE5k2hUm5THebtGSPUrQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=TAd/aon/; 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="TAd/aon/" Received: by smtp.kernel.org (Postfix) with ESMTPS id F2168C19425; Mon, 19 Jan 2026 14:37:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1768833450; bh=UyScQ2ACRZSy/lz8cbYQAzpkus17hqeQlMYDqY0q6pg=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=TAd/aon/ysL1iXYiHwSlRLNBkjyuEyhdx+a/QupGtTU3xmA8ccRtCn1mgzFdPNh18 DjC4cRRQOf1uM/h9a0IhTDHsJVjny3uJCESBSbQW92XbZ6M+WpINqUlPsJQJ4Rn/Md lkNnZCGj2+BfJodt1Wp+pb7TVrwcVQihsSxagJ9XEOrX3QPP1JYYTuZN0ZpTzo/DpC bB8Urn7qnbBzCuTcg2D/vbK+IhfftKFiFdfqjajApuk+Mv7WQ+YK9innVsTNL56Qi9 PFqZBKjNkrb9apnadaa6l7gJfiJubab4CEXM6UMLRoZXyJlxx8Kk3C9PqmWPGzd0T1 9recPb0VwAIKA== 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 E3962D29C31; Mon, 19 Jan 2026 14:37:29 +0000 (UTC) From: Rodrigo Alencar via B4 Relay Date: Mon, 19 Jan 2026 14:36:55 +0000 Subject: [PATCH 1/7] 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: <20260119-iio-ad8366-update-v1-1-8044e23e964a@analog.com> References: <20260119-iio-ad8366-update-v1-0-8044e23e964a@analog.com> In-Reply-To: <20260119-iio-ad8366-update-v1-0-8044e23e964a@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=1768833448; l=890; i=rodrigo.alencar@analog.com; s=default; h=from:subject:message-id; bh=rob+NAZkHfCiMJf8OmO/3rqHiaqTB4rC3m2DW61I/hw=; b=6hPObne3IZwi5e5qhPoH2SIEVRDnrUBNyf3hrhYjWzrS+d76rkW3+SJ6J67va/4rz/A4OkX+4 T2Vqevb6abRBwDg1690Dxrw5HmSeU6FpjqSfmY5/Jf2fCA8hJJrv6/Q 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 4dd9f758a871..9c8e83470464 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 Mon Feb 9 10:30:14 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 3BB6F27E07E; Mon, 19 Jan 2026 14:37:30 +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=1768833450; cv=none; b=RGN60wtZ2lKitYqtcNzj/8gcyjWtmcn0e4FLmpYCSl2HvzXf4M5cOWkMFOPtafV7k3A29oZpWPSCDdl01mU49t8Zssx2s4E44y3zmYs8nn7bRtQStDYVg5bNXtIOtPlyZcqHHm1g0Qf+WKXfRrne1JZQbEZN0JZAclJzr/8cs8s= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768833450; c=relaxed/simple; bh=d/8RMpsl29Y8TYdguvIdcsQnNBPTICFlLMW095KZ3Uc=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=SO6AXy0DpOetOUHShm7tfSp8BYPADUAZGqjpXzPXZzWjA4Ftk2O/XgNgMfrBrPGAKoya5pg5054JMTv3HyIQo301nuQq71DJvUzB7BGMIRj4iP+GXKokRy33VCUos+sFVPx+fjWuN8JB1l19zP55mOsG77mugnIgtc7cA0ax9d8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=EsqGTelL; 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="EsqGTelL" Received: by smtp.kernel.org (Postfix) with ESMTPS id 0CE65C19423; Mon, 19 Jan 2026 14:37:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1768833450; bh=d/8RMpsl29Y8TYdguvIdcsQnNBPTICFlLMW095KZ3Uc=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=EsqGTelLaLd7E5ajbh78dPbDs64COBrxc1rHcd4PvxMW3hOMD9PYprRKZpuXI3vJS IxX1bMJl+wFDvBPV2aGVl02Vrf/fxibUrlvTPGcdvaQejCq9nXQe17cXy8sNVmY62J 1ykG7QQ0L9+huc5ljeWpePQ1i0oZKzbjw0fvJnhvBW3IVt0cnHcwDNyscGir+4eqk+ sL73vzdbiaaLOoszEIMjCoOoWT9hP1Ui8AFpuMcocOI+6h3WqiP8Oec3K2qLXiVZ6s 9Mn8K3PAOmUyMciEOBKBteAw0lgLq9Dut74ex42RaPNrO7apWunWgu+xXX/PUU26px rH9o7ZapYMeBw== 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 F260FD29C33; Mon, 19 Jan 2026 14:37:29 +0000 (UTC) From: Rodrigo Alencar via B4 Relay Date: Mon, 19 Jan 2026 14:36:56 +0000 Subject: [PATCH 2/7] 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: <20260119-iio-ad8366-update-v1-2-8044e23e964a@analog.com> References: <20260119-iio-ad8366-update-v1-0-8044e23e964a@analog.com> In-Reply-To: <20260119-iio-ad8366-update-v1-0-8044e23e964a@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=1768833448; l=3034; i=rodrigo.alencar@analog.com; s=default; h=from:subject:message-id; bh=MBEdUYu8R67rthes6ey0a6hT+KutZfNFQEm2s4twTzs=; b=2jvQufCxxYEUOOUxTv/fGM9g28FrsoPfcUranF/D1M2D1HEEl6yJ7XDkcUfc87aRU5Wuw3DGa 1E+Hw9QHvhoBCuMU/Xgtovg96uqeJsvqgRq7oLtfWfuQSXa7fV98So9 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. Signed-off-by: Rodrigo Alencar --- .../bindings/iio/amplifiers/adi,ad8366.yaml | 85 ++++++++++++++++++= ++++ MAINTAINERS | 1 + 2 files changed, 86 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..7477bb9b5071 --- /dev/null +++ b/Documentation/devicetree/bindings/iio/amplifiers/adi,ad8366.yaml @@ -0,0 +1,85 @@ +# 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, 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 + description: + GPIO pin used to reset the device. + + enable-gpios: + maxItems: 1 + description: + GPIO pin used to enable the device. + +required: + - compatible + - reg + - vcc-supply + +allOf: + - $ref: /schemas/spi/spi-peripheral-props.yaml# + +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>; + }; + }; + - | + #include + spi { + #address-cells =3D <1>; + #size-cells =3D <0>; + + attenuator@1 { + compatible =3D "adi,adrf5730"; + reg =3D <1>; + spi-max-frequency =3D <1000000>; + vcc-supply =3D <&vcc_3v3>; + }; + }; +... diff --git a/MAINTAINERS b/MAINTAINERS index 9c8e83470464..0bbeea028cc0 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 Mon Feb 9 10:30:14 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 44120327783; Mon, 19 Jan 2026 14:37:30 +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=1768833450; cv=none; b=CkSLJyNe4KZrnaKANbE8tzgm+RChCBOK+K+r0bB77QiZHXZcBIMkQ3OOf9ij4JOz4WVNJnQlaiULNuIq9b62GOABqpHp89CSwyi6jeKefBlMOomKdrdCEa1gEXtcK2dDb3PF5sxwDodNdBOXihV76eXj6jIDbSMgyREz7/zqRh4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768833450; c=relaxed/simple; bh=xPOhEhJe2siRPjS/kJC/6NA/KZx23W+i1g4sCUKpoFY=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=qHr27tcNbssPPJNELuG13JEhSg+HBP27UZ/MJDdQzKDfSCG5ZOgWaMmbm/zMCJ1vo6xu+YTkEY+A1DbJSHGShvGWtgYW5QO/YH3GHrXSgSpPcWya2eNXtg3rrtIWaFYNQ1lAvLf3s2Db/UT9YH7Sb7Kasx5doTPfRdwUmYbp29A= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=efAt2KMr; 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="efAt2KMr" Received: by smtp.kernel.org (Postfix) with ESMTPS id 1394FC2BC9E; Mon, 19 Jan 2026 14:37:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1768833450; bh=xPOhEhJe2siRPjS/kJC/6NA/KZx23W+i1g4sCUKpoFY=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=efAt2KMrMLppYw+4RUV62Ws4oUbimR8M1+HGWZZT0FMDaiHWxdH9R0nvd4qBDbwtm 61xUCKOOWiaOE91qqRt9jLvg04PVIESJK+vNj2B24TE0ksPeNIRCpGta5cLRCZbGBb ITAAOm1ooevK5rPvaRBBs3MF+0oNpUeOR3U6HDeX1lP72DFRam545WxLAqjPzaIObo DZqKf0JWVzqcML0vIUkZzyRPMNB2kIirSsq0yDRhx5FVaNNwdjjZ15nGXiAW9+2eNs lCP9TUeaYG2c/NElbQemZ7l68FpcrJIfyL0MhWis6I+b/kpETlXzy+6RNT9qrPwdeb A6OhTq8QNDMvw== 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 0CC9CD29C30; Mon, 19 Jan 2026 14:37:30 +0000 (UTC) From: Rodrigo Alencar via B4 Relay Date: Mon, 19 Jan 2026 14:36:57 +0000 Subject: [PATCH 3/7] iio: amplifiers: ad8366: consume enable gpio for applicable parts 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: <20260119-iio-ad8366-update-v1-3-8044e23e964a@analog.com> References: <20260119-iio-ad8366-update-v1-0-8044e23e964a@analog.com> In-Reply-To: <20260119-iio-ad8366-update-v1-0-8044e23e964a@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=1768833448; l=1344; i=rodrigo.alencar@analog.com; s=default; h=from:subject:message-id; bh=72lAxpPNNVQiH2FXV5I3I6t6Jbf3Jb9inxis9HKayGg=; b=ucKmp4HZErTKFi9sJh+JIsoCqsY/QGNLqSVg7QQSl32tUv5zhJtJfI4iCycjsyP6+xhAmBpXc FiUEq/SJwoOCRtUjswdfirRTeW4ZDJdyst3bWb6gfYCsq7yFgtfS5bm 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 set serial mode (PS pin) or powerup the device (e.g. ADA4961's PWUP pin). Co-developed-by: Michael Hennerich Signed-off-by: Michael Hennerich Signed-off-by: Rodrigo Alencar --- drivers/iio/amplifiers/ad8366.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/drivers/iio/amplifiers/ad8366.c b/drivers/iio/amplifiers/ad836= 6.c index d06ac786501c..63bb9f0179eb 100644 --- a/drivers/iio/amplifiers/ad8366.c +++ b/drivers/iio/amplifiers/ad8366.c @@ -43,6 +43,7 @@ struct ad8366_state { struct regulator *reg; struct mutex lock; /* protect sensor state */ struct gpio_desc *reset_gpio; + struct gpio_desc *enable_gpio; unsigned char ch[2]; enum ad8366_type type; const struct ad8366_info *info; @@ -281,6 +282,13 @@ static int ad8366_probe(struct spi_device *spi) ret =3D PTR_ERR(st->reset_gpio); goto error_disable_reg; } + + st->enable_gpio =3D devm_gpiod_get_optional(&spi->dev, "enable", GPIOD_O= UT_HIGH); + if (IS_ERR(st->enable_gpio)) { + ret =3D PTR_ERR(st->enable_gpio); + goto error_disable_reg; + } + indio_dev->channels =3D ada4961_channels; indio_dev->num_channels =3D ARRAY_SIZE(ada4961_channels); break; --=20 2.43.0 From nobody Mon Feb 9 10:30:14 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 665E7379983; Mon, 19 Jan 2026 14:37:30 +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=1768833450; cv=none; b=HqBmTJH34quv1fs9H6LCRRksToh65om5UW+lYLhTquJNhEx+4V0gsRIo9xec/2H6HpGxO1/nX9gN0V4P7SKtlBYXrQ9nkNko0bbrb4/nHY+9P4+yw4COFvRu26Bl+GEWAAt3OWQpdicRHeNjq5nCQku9k6GvKovoduzeATIWE5c= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768833450; c=relaxed/simple; bh=tdrnZlnqOpUIGcLhTATBc1Qu8gJqQvY8iwv4Gcft5ow=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=fpjh6QLIYa3B1ig5K/U2avbk6eblR/kLnmkGPhuL/xv3UNYF1pDy1JBTL8w4PcaBq/7VFivyflKLxEe1aHDmWKIKvqMANavcWJiwdDskdQOVScEU4MVPKOGIGfb4eWGEWRpfBE5ln6UoJUfKkKIFrp2zDy8xLMVyd/kIaB8+WIo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=fOTJ9sOQ; 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="fOTJ9sOQ" Received: by smtp.kernel.org (Postfix) with ESMTPS id 2EACCC4AF10; Mon, 19 Jan 2026 14:37:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1768833450; bh=tdrnZlnqOpUIGcLhTATBc1Qu8gJqQvY8iwv4Gcft5ow=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=fOTJ9sOQjyOZkd2+vlKtd+qWZO3QoPOATFUizFtsyapY0g+eS0DRGq4bKL4JicBhr L9uUA66TwIPjXbEpJCpXWbVOuXay0WuYsFqH5xQoz1YNdUEqVbzcBF9SK5qxPqcZNg P5E16tiLZlXwAxVGRqX6lFOkeBXxPiynxoK/+uPdwLmsECoY3BDbvpz1lpD3m3a4bj /7KBfkUdoCqhSV6jo9FUjH4A/ToA7pB1pIFLbWmld8iCvW5RFx27WD38bwBdrAAiJH D5akyAlmIcFXNHTPIei5LDdooIPln4n1uDmdTwP/uCiP9Bh2C1lq1b+7pR9pHrqqJj 52OuUDUgRN14g== 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 1ECADD29C35; Mon, 19 Jan 2026 14:37:30 +0000 (UTC) From: Rodrigo Alencar via B4 Relay Date: Mon, 19 Jan 2026 14:36:58 +0000 Subject: [PATCH 4/7] 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: <20260119-iio-ad8366-update-v1-4-8044e23e964a@analog.com> References: <20260119-iio-ad8366-update-v1-0-8044e23e964a@analog.com> In-Reply-To: <20260119-iio-ad8366-update-v1-0-8044e23e964a@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=1768833448; l=6539; i=rodrigo.alencar@analog.com; s=default; h=from:subject:message-id; bh=bc9805wahSZeSu7sbk0f/V65J9GCdQoD3kGvDyhbmiE=; b=mM5gnwgmIG1mRWhg45TAPvPbCbDH9PqlezzOtKP13TkZ4XWUhU2DOA3LArVxdW1Ay5BPmoD6F MvDNxivUAfDDJs7q99Rs7YEyaE3qSWERD4xPbmIyL4Jj9v84aSmk+U7 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 This patch adds support for 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 --- drivers/iio/amplifiers/Kconfig | 6 +++ drivers/iio/amplifiers/ad8366.c | 86 +++++++++++++++++++++++++++++++++++++= +++- 2 files changed, 91 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 63bb9f0179eb..160a8ab0c2ee 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 @@ -29,7 +35,13 @@ enum ad8366_type { ID_AD8366, ID_ADA4961, ID_ADL5240, + ID_ADRF5720, + ID_ADRF5730, + ID_ADRF5731, + ID_HMC271, ID_HMC792, + ID_HMC1018, + ID_HMC1019, ID_HMC1119, }; =20 @@ -67,10 +79,34 @@ static const struct ad8366_info ad8366_infos[] =3D { .gain_min =3D -11500, .gain_max =3D 20000, }, + [ID_ADRF5720] =3D { + .gain_min =3D -31500, + .gain_max =3D 0, + }, + [ID_ADRF5730] =3D { + .gain_min =3D -31500, + .gain_max =3D 0, + }, + [ID_ADRF5731] =3D { + .gain_min =3D -30000, + .gain_max =3D 0, + }, + [ID_HMC271] =3D { + .gain_min =3D -31000, + .gain_max =3D 0, + }, [ID_HMC792] =3D { .gain_min =3D -15750, .gain_max =3D 0, }, + [ID_HMC1018] =3D { + .gain_min =3D -31000, + .gain_max =3D 0, + }, + [ID_HMC1019] =3D { + .gain_min =3D -15500, + .gain_max =3D 0, + }, [ID_HMC1119] =3D { .gain_min =3D -31750, .gain_max =3D 0, @@ -95,9 +131,17 @@ static int ad8366_write(struct iio_dev *indio_dev, st->data[0] =3D ch_a & 0x1F; break; case ID_ADL5240: + case ID_ADRF5720: + case ID_ADRF5730: + case ID_ADRF5731: st->data[0] =3D (ch_a & 0x3F); break; + case ID_HMC271: + st->data[0] =3D bitrev8(ch_a & 0x1F) >> 3; + break; case ID_HMC792: + case ID_HMC1018: + case ID_HMC1019: case ID_HMC1119: st->data[0] =3D ch_a; break; @@ -135,9 +179,23 @@ static int ad8366_read_raw(struct iio_dev *indio_dev, case ID_ADL5240: gain =3D 20000 - 31500 + code * 500; break; + case ID_ADRF5720: + case ID_ADRF5730: + gain =3D -1 * code * 500; + break; + case ID_ADRF5731: + gain =3D -1 * code * 500; + break; case ID_HMC792: gain =3D -1 * code * 500; break; + case ID_HMC271: + case ID_HMC1018: + gain =3D -31000 + code * 1000; + break; + case ID_HMC1019: + gain =3D -15500 + code * 500; + break; case ID_HMC1119: gain =3D -1 * code * 250; break; @@ -187,9 +245,23 @@ static int ad8366_write_raw(struct iio_dev *indio_dev, case ID_ADL5240: code =3D ((gain - 500 - 20000) / 500) & 0x3F; break; + case ID_ADRF5720: + case ID_ADRF5730: + code =3D (abs(gain) / 500) & 0x3F; + break; + case ID_ADRF5731: + code =3D (abs(gain) / 500) & 0x3C; + break; case ID_HMC792: code =3D (abs(gain) / 500) & 0x3F; break; + case ID_HMC271: + case ID_HMC1018: + code =3D ((gain - 1000) / 1000) & 0x1F; + break; + case ID_HMC1019: + code =3D ((gain - 500) / 500) & 0x1F; + break; case ID_HMC1119: code =3D (abs(gain) / 250) & 0x7F; break; @@ -275,8 +347,14 @@ static int ad8366_probe(struct spi_device *spi) break; case ID_ADA4961: case ID_ADL5240: + case ID_HMC271: case ID_HMC792: case ID_HMC1119: + case ID_ADRF5720: + case ID_ADRF5730: + case ID_ADRF5731: + case ID_HMC1018: + case ID_HMC1019: 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); @@ -335,8 +413,14 @@ static void ad8366_remove(struct spi_device *spi) static const struct spi_device_id ad8366_id[] =3D { {"ad8366", ID_AD8366}, {"ada4961", ID_ADA4961}, + {"adrf5720", ID_ADRF5720}, + {"adrf5730", ID_ADRF5730}, + {"adrf5731", ID_ADRF5731}, {"adl5240", ID_ADL5240}, + {"hmc271a", ID_HMC271}, {"hmc792a", ID_HMC792}, + {"hmc1018a", ID_HMC1018}, + {"hmc1019a", ID_HMC1019}, {"hmc1119", ID_HMC1119}, { } }; --=20 2.43.0 From nobody Mon Feb 9 10:30:14 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 689C537BE62; Mon, 19 Jan 2026 14:37:30 +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=1768833450; cv=none; b=ANwhNrdeM48PjfYOgCTyIwj+n8+alJ/rgY9I2bWghjkzU8KvOUyq7b8kYg88fq8fm1mf5Qh/NUvufiRGJlbvqDHknabmQ6ZD5ybqgJVyUMtW/sTVJVuOhqz4/rxeRhS8OzyP1Ey3UjfM8eCJaKFUDyaqofw4UTXLFHhr1qVcZwY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768833450; c=relaxed/simple; bh=y1m1SiLaohoC5eNbpZldUkqlDCAqPqNXgONSe2+u36Y=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=TFT9zcxwA45oAAAqEght2twNzjCR7J2dkOLeMIlFMREt5a0RKgnXRBCCluW263Cyuzfwxba7Pi6jelMtzjTWr4Qox4gsQ40LkWZT014uybk2AdrHX+STw7UTvdQFOUABGuJic8R8ZxF7wtytr95YAmA2c61eNQOm7Ey4KoMbmw0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=WIe3xOwj; 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="WIe3xOwj" Received: by smtp.kernel.org (Postfix) with ESMTPS id 3949AC2BC87; Mon, 19 Jan 2026 14:37:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1768833450; bh=y1m1SiLaohoC5eNbpZldUkqlDCAqPqNXgONSe2+u36Y=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=WIe3xOwjeU0V/1UChjxVWu1BT3a69bVar6MVjawm9GJjUT1vkpNgK3aWVSVLBBlar jO4QQJzrgDVXjwPM3M4uyMXTR7AeeCH8B+JXfzZ2AzUeQvoQpiyI7jmp/0NWlhC4B0 Hcubw76y6+u/W8lyLkPfXgDlhjj7GDrzhPPhWeBZCBN6UDPcrupm6G7KqBI2qaA3Sm /aoho/1/Pmm3XjfM3WW4l8Q0w5lSUNxuIADJ1PbEh3kq4qOW9EiWxeApMlZBYEpJcc 2zSnjmjb2pOt8EFhR8+nJ9XqAGn9IKiOmgZrD4FYl8Q44bLSzT/wpNJwwVMm75mjME 6dY7XIEHsIdAg== 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 2FB0DD29C30; Mon, 19 Jan 2026 14:37:30 +0000 (UTC) From: Rodrigo Alencar via B4 Relay Date: Mon, 19 Jan 2026 14:36:59 +0000 Subject: [PATCH 5/7] iio: amplifiers: ad8366: use cleanup.h mutex guard 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: <20260119-iio-ad8366-update-v1-5-8044e23e964a@analog.com> References: <20260119-iio-ad8366-update-v1-0-8044e23e964a@analog.com> In-Reply-To: <20260119-iio-ad8366-update-v1-0-8044e23e964a@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=1768833448; l=1898; i=rodrigo.alencar@analog.com; s=default; h=from:subject:message-id; bh=YAYuOUTweoFKOoWx+os6umUAifv0dwftAt5d8TlJqJM=; b=XO9ZOAiOXRraSPnBYDMJ92vscFlv6RXnUB1srGcO5GKbPh/9atl/9cKD5LVevvB4MJtc5/IhN zfcLQaRgzWQB153uBkHdfmqCo/RgQq41EGJrnzH+zdwQcjWIwq29kC5 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 Changes related to mutex handling: - use guard() from cleanup for mutex locking - replace mutex_init() for devm_mutex_init() Signed-off-by: Rodrigo Alencar --- drivers/iio/amplifiers/ad8366.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/drivers/iio/amplifiers/ad8366.c b/drivers/iio/amplifiers/ad836= 6.c index 160a8ab0c2ee..26856cb4216e 100644 --- a/drivers/iio/amplifiers/ad8366.c +++ b/drivers/iio/amplifiers/ad8366.c @@ -17,6 +17,7 @@ * Copyright 2012-2026 Analog Devices Inc. */ =20 +#include #include #include #include @@ -164,7 +165,8 @@ static int ad8366_read_raw(struct iio_dev *indio_dev, int ret; int code, gain =3D 0; =20 - mutex_lock(&st->lock); + guard(mutex)(&st->lock); + switch (m) { case IIO_CHAN_INFO_HARDWAREGAIN: code =3D st->ch[chan->channel]; @@ -210,7 +212,6 @@ static int ad8366_read_raw(struct iio_dev *indio_dev, default: ret =3D -EINVAL; } - mutex_unlock(&st->lock); =20 return ret; }; @@ -267,7 +268,8 @@ static int ad8366_write_raw(struct iio_dev *indio_dev, break; } =20 - mutex_lock(&st->lock); + guard(mutex)(&st->lock); + switch (mask) { case IIO_CHAN_INFO_HARDWAREGAIN: st->ch[chan->channel] =3D code; @@ -276,7 +278,6 @@ static int ad8366_write_raw(struct iio_dev *indio_dev, default: ret =3D -EINVAL; } - mutex_unlock(&st->lock); =20 return ret; } @@ -336,10 +337,13 @@ 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 + ret =3D devm_mutex_init(&spi->dev, &st->lock); + if (ret) + return ret; + switch (st->type) { case ID_AD8366: indio_dev->channels =3D ad8366_channels; --=20 2.43.0 From nobody Mon Feb 9 10:30:14 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 72AE737C0FB; Mon, 19 Jan 2026 14:37:30 +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=1768833450; cv=none; b=d/4JG/bB1AkIgyuBThR3yqUgSSH0Nl8gF5CmBdSvetZw5AGMxbKzMF9zhwwBvPAkIcnxNiW5hCEHPvL08uLtpnCNG6KNaaB+Ga6x8POHjI7Jp1FOtE/j4ak4jWuv3AL9HmI7LS1/zuoGPwBBEsIgdWfHLsKFQ2zYhylSrkLM7/0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768833450; c=relaxed/simple; bh=giJ6/VLbcxnk735dSuxazPN3skX6nOEAm+AhScCb89c=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=iKYMfK6gOPymT1iN2UK6JVKRBwF7zNVKOuCsNpaTlQrRDnMp2JldM+JKMVRo9W89pEJR648Ch3QkyUsN11xl9iub0M9dL/SUwR007RR1EAWmN0fp6E/luV0+P9omiBYrRwCXfk/uVkWrqchZH6RUBe9+XvAsD9voKqfode57XI4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=fcKDXOT+; 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="fcKDXOT+" Received: by smtp.kernel.org (Postfix) with ESMTPS id 46B79C19424; Mon, 19 Jan 2026 14:37:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1768833450; bh=giJ6/VLbcxnk735dSuxazPN3skX6nOEAm+AhScCb89c=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=fcKDXOT+XnsT17tUEjDfneiZgYtm6N7V6nc4rgjLTQrf3pHE/BDt6nVFyMZRmG4jv XhKwTEdLX5MlyRB0QbInyYtPWtqnxHzr8KM79CCPzK1+wzZviBWtfYZV0S/KTybKeL rXQCX1oK2zNkVFW+UIbV6ZatuHXqe1QWmYXufW8r3mL4PeqG27gMFPkp7o+7yuZ1M9 W5EqkYFSzkoOSoRkXj8i6vbDrLRcdIu9bMtzme2+wdX0FZD0w6/miorEmbbxDTowjI NFFzUyGU/Vt9IT9GytDLkwTMUz2/3uXtmkHY+CW0QgXGMANPtOUxvPOEK9hKsfMRVW RhmPkEkBGnvyQ== 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 3F5F9D29C33; Mon, 19 Jan 2026 14:37:30 +0000 (UTC) From: Rodrigo Alencar via B4 Relay Date: Mon, 19 Jan 2026 14:37:00 +0000 Subject: [PATCH 6/7] iio: amplifiers: ad8366: simplify 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: <20260119-iio-ad8366-update-v1-6-8044e23e964a@analog.com> References: <20260119-iio-ad8366-update-v1-0-8044e23e964a@analog.com> In-Reply-To: <20260119-iio-ad8366-update-v1-0-8044e23e964a@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=1768833448; l=4200; i=rodrigo.alencar@analog.com; s=default; h=from:subject:message-id; bh=9nMXwNgzXAopfdZluBjtYQNwc5lWj5QsLZXeSBRFTdk=; b=vUrAZJY0pjyhVmyviKaCRDU9w7phrJqDGahvMW4OAaA4iUXYlgQbCSKcHPbtWl6rxStJCxVk0 kRGOfcfO1HGAgC5cyfUJMTaqFbYYwDkQeC2/7wkfKgB/lKRsbZA9TK5 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 Device resource managed simplified with: - voltage regulator managed internally by the device. - 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. Also, dev_err_probe() is used to report probe errors with created local device pointer. Signed-off-by: Rodrigo Alencar --- drivers/iio/amplifiers/ad8366.c | 68 +++++++++++--------------------------= ---- 1 file changed, 18 insertions(+), 50 deletions(-) diff --git a/drivers/iio/amplifiers/ad8366.c b/drivers/iio/amplifiers/ad836= 6.c index 26856cb4216e..d3fd8d44eae7 100644 --- a/drivers/iio/amplifiers/ad8366.c +++ b/drivers/iio/amplifiers/ad8366.c @@ -53,7 +53,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; struct gpio_desc *enable_gpio; @@ -321,26 +320,22 @@ static int ad8366_probe(struct spi_device *spi) { struct iio_dev *indio_dev; struct ad8366_state *st; + struct device *dev =3D &spi->dev; 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 st =3D iio_priv(indio_dev); - - st->reg =3D devm_regulator_get(&spi->dev, "vcc"); - if (!IS_ERR(st->reg)) { - ret =3D regulator_enable(st->reg); - if (ret) - return ret; - } - - spi_set_drvdata(spi, indio_dev); st->spi =3D spi; st->type =3D spi_get_device_id(spi)->driver_data; =20 - ret =3D devm_mutex_init(&spi->dev, &st->lock); + ret =3D devm_regulator_get_enable(dev, "vcc"); + if (ret) + return dev_err_probe(dev, ret, "Failed to get regulator\n"); + + ret =3D devm_mutex_init(dev, &st->lock); if (ret) return ret; =20 @@ -359,25 +354,21 @@ static int ad8366_probe(struct spi_device *spi) case ID_ADRF5731: case ID_HMC1018: case ID_HMC1019: - 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; - } + st->reset_gpio =3D devm_gpiod_get_optional(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"); =20 - st->enable_gpio =3D devm_gpiod_get_optional(&spi->dev, "enable", GPIOD_O= UT_HIGH); - if (IS_ERR(st->enable_gpio)) { - ret =3D PTR_ERR(st->enable_gpio); - goto error_disable_reg; - } + st->enable_gpio =3D devm_gpiod_get_optional(dev, "enable", GPIOD_OUT_HIG= H); + if (IS_ERR(st->enable_gpio)) + return dev_err_probe(dev, PTR_ERR(st->enable_gpio), + "Failed to get enable GPIO\n"); =20 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]; @@ -387,31 +378,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 { @@ -435,7 +404,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 Mon Feb 9 10:30:14 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 87ED637F0E4; Mon, 19 Jan 2026 14:37:30 +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=1768833450; cv=none; b=TDsO8iaVE2vON7TbYF6ZalWx01fGa7WUj1IrEmkcQfurCiCngZY0u8aehEcDhXA7ojSgKuJs4bfpYR3Xr9D/24gSuT5Ah7z1ackKG63N4mcw+1kRk6gpq2QPRVlpr1LPJIvYxl5R3XtfyxuHLGkxeoMneS7pIM4OwjewcHjvGFw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768833450; c=relaxed/simple; bh=HcN7gZXwRIuh+bGj1eRaqviXm4njZCLh8953XUGFkX8=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=ioiEs9OPSVvTZASj9oznrvtOrox/vclC0jbjSPvwI8NTsn/hlt7+VG56SmGS39b2ef2irViiVnQApzhrqduXC+8yEalq3HaRO5tTrb5qHABUVgW8uIAiblB4beiCqTOVK85WCJHdYlVWh8WlJ8KWMaoVSkP/CXqyjbeMoqGWSw0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=lSv55gNY; 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="lSv55gNY" Received: by smtp.kernel.org (Postfix) with ESMTPS id 58C93C2BCB5; Mon, 19 Jan 2026 14:37:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1768833450; bh=HcN7gZXwRIuh+bGj1eRaqviXm4njZCLh8953XUGFkX8=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=lSv55gNYrLoQa1gcWrYZQP4DkyWfjpFZEr9jy31a0iNr//831mi4PqzzeW6ZpzEeW qRLmrLwLl1uc4dv5ea44yWM+/97L4RjDBKJG6/oxwJAkBj2gD86g1lJKuTcEuECUJb 7tdbdwYsvLPdLKCGWas0OZT1bNj8fIIdB8P5RaVF8dyiz6H9Fr5d4NqfQeK5w7bS9x J7YMIlvDGI5P1HKUgUYk1PLiTHuVuqG3t4BjN1XQ9bZwphoaIoP7fucXUaUxEStKRn dflB63jALEXUrXsr/tn9fTBtUpZ9HlZESekYivcLXsGVEQaKzYuxP9uchxeG+zfL/g xdzIrZu3QR3XQ== 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 4FEAFD29C35; Mon, 19 Jan 2026 14:37:30 +0000 (UTC) From: Rodrigo Alencar via B4 Relay Date: Mon, 19 Jan 2026 14:37:01 +0000 Subject: [PATCH 7/7] 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: <20260119-iio-ad8366-update-v1-7-8044e23e964a@analog.com> References: <20260119-iio-ad8366-update-v1-0-8044e23e964a@analog.com> In-Reply-To: <20260119-iio-ad8366-update-v1-0-8044e23e964a@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=1768833448; l=12768; i=rodrigo.alencar@analog.com; s=default; h=from:subject:message-id; bh=67Y4OSTw7ChBFBUHIGLRt2epU3S1rrY4JV+HtSrHjes=; b=ZqhL2dzr6U3CVOo5V95jN2ttiEnrPnbSIEvCppMlRB6EALHfUoTZmzRnB4HAxrirWfAB7fMbd Ty9AUNhE+XkDM4vflyQkc2xeeYYofSPNSppuNeE3Fk6+2+qxwzh0rvw 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 Device-tree support achieved dropping the enum ID in favor of an extended chip info table: - gain step and number of channels moved to chip info - pack_code function added to describe how SPI buffer is populated With this, switch cases on the device type were dropped: - simplified read_raw and write_raw callbacks - number of channels retrieved from chip info in probe function Signed-off-by: Rodrigo Alencar --- drivers/iio/amplifiers/ad8366.c | 303 +++++++++++++++++-------------------= ---- 1 file changed, 129 insertions(+), 174 deletions(-) diff --git a/drivers/iio/amplifiers/ad8366.c b/drivers/iio/amplifiers/ad836= 6.c index d3fd8d44eae7..484ab2b6196c 100644 --- a/drivers/iio/amplifiers/ad8366.c +++ b/drivers/iio/amplifiers/ad8366.c @@ -27,6 +27,7 @@ #include #include #include +#include #include =20 #include @@ -46,9 +47,14 @@ enum ad8366_type { ID_HMC1119, }; =20 +struct ad8366_state; + struct ad8366_info { int gain_min; int gain_max; + int gain_step; + int num_channels; + size_t (*pack_code)(struct ad8366_state *st); }; =20 struct ad8366_state { @@ -66,153 +72,142 @@ struct ad8366_state { unsigned char data[2] __aligned(IIO_DMA_MINALIGN); }; =20 +static int ad8366_write_code(struct ad8366_state *st) +{ + const struct ad8366_info *inf =3D st->info; + + return spi_write(st->spi, st->data, inf->pack_code(st)); +} + +static size_t ad8366_pack_code(struct ad8366_state *st) +{ + u8 ch_a =3D bitrev8(st->ch[0] & 0x3F); + u8 ch_b =3D bitrev8(st->ch[1] & 0x3F); + + st->data[0] =3D ch_b >> 4; + st->data[1] =3D (ch_b << 4) | (ch_a >> 2); + return 2; +} + +static size_t simple_pack_code(struct ad8366_state *st) +{ + st->data[0] =3D st->ch[0]; + return 1; +} + +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] & 0x1F) >> 3; + return 1; +} + 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, + .pack_code =3D simple_pack_code, }, [ID_ADL5240] =3D { .gain_min =3D -11500, .gain_max =3D 20000, + .gain_step =3D 500, + .num_channels =3D 1, + .pack_code =3D simple_pack_code, }, [ID_ADRF5720] =3D { .gain_min =3D -31500, .gain_max =3D 0, + .gain_step =3D -500, + .num_channels =3D 1, + .pack_code =3D simple_pack_code, }, [ID_ADRF5730] =3D { .gain_min =3D -31500, .gain_max =3D 0, + .gain_step =3D -500, + .num_channels =3D 1, + .pack_code =3D simple_pack_code, }, [ID_ADRF5731] =3D { .gain_min =3D -30000, .gain_max =3D 0, + .gain_step =3D -2000, + .num_channels =3D 1, + .pack_code =3D adrf5731_pack_code, }, [ID_HMC271] =3D { .gain_min =3D -31000, .gain_max =3D 0, + .gain_step =3D 1000, + .num_channels =3D 1, + .pack_code =3D hmc271_pack_code, }, [ID_HMC792] =3D { .gain_min =3D -15750, .gain_max =3D 0, + .gain_step =3D 250, + .num_channels =3D 1, + .pack_code =3D simple_pack_code, }, [ID_HMC1018] =3D { .gain_min =3D -31000, .gain_max =3D 0, + .gain_step =3D 1000, + .num_channels =3D 1, + .pack_code =3D simple_pack_code, }, [ID_HMC1019] =3D { .gain_min =3D -15500, .gain_max =3D 0, + .gain_step =3D 500, + .num_channels =3D 1, + .pack_code =3D simple_pack_code, }, [ID_HMC1119] =3D { .gain_min =3D -31750, .gain_max =3D 0, + .gain_step =3D -250, + .num_channels =3D 1, + .pack_code =3D simple_pack_code, }, }; =20 -static int ad8366_write(struct iio_dev *indio_dev, - unsigned char ch_a, unsigned char ch_b) -{ - struct ad8366_state *st =3D iio_priv(indio_dev); - int ret; - - switch (st->type) { - case ID_AD8366: - ch_a =3D bitrev8(ch_a & 0x3F); - ch_b =3D bitrev8(ch_b & 0x3F); - - 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: - case ID_ADRF5720: - case ID_ADRF5730: - case ID_ADRF5731: - st->data[0] =3D (ch_a & 0x3F); - break; - case ID_HMC271: - st->data[0] =3D bitrev8(ch_a & 0x1F) >> 3; - break; - case ID_HMC792: - case ID_HMC1018: - case ID_HMC1019: - 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; -} - static int ad8366_read_raw(struct iio_dev *indio_dev, struct iio_chan_spec const *chan, int *val, int *val2, - long m) + long mask) { struct ad8366_state *st =3D iio_priv(indio_dev); - int ret; - int code, gain =3D 0; + const struct ad8366_info *inf =3D st->info; + int gain =3D inf->gain_step > 0 ? inf->gain_min : inf->gain_max; =20 guard(mutex)(&st->lock); =20 - switch (m) { + switch (mask) { 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_ADRF5720: - case ID_ADRF5730: - gain =3D -1 * code * 500; - break; - case ID_ADRF5731: - gain =3D -1 * code * 500; - break; - case ID_HMC792: - gain =3D -1 * code * 500; - break; - case ID_HMC271: - case ID_HMC1018: - gain =3D -31000 + code * 1000; - break; - case ID_HMC1019: - gain =3D -15500 + code * 500; - break; - case ID_HMC1119: - gain =3D -1 * code * 250; - break; - } - - /* Values in dB */ + gain +=3D inf->gain_step * st->ch[chan->channel]; *val =3D gain / 1000; *val2 =3D (gain % 1000) * 1000; - - ret =3D IIO_VAL_INT_PLUS_MICRO_DB; - break; + return IIO_VAL_INT_PLUS_MICRO_DB; default: - ret =3D -EINVAL; + return -EINVAL; } - - return ret; }; =20 static int ad8366_write_raw(struct iio_dev *indio_dev, @@ -223,10 +218,8 @@ static int ad8366_write_raw(struct iio_dev *indio_dev, { struct ad8366_state *st =3D iio_priv(indio_dev); const struct ad8366_info *inf =3D st->info; - int code =3D 0, gain; - int ret; + int code, gain, gain_base; =20 - /* Values in dB */ if (val < 0) gain =3D (val * 1000) - (val2 / 1000); else @@ -235,50 +228,18 @@ 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_ADRF5720: - case ID_ADRF5730: - code =3D (abs(gain) / 500) & 0x3F; - break; - case ID_ADRF5731: - code =3D (abs(gain) / 500) & 0x3C; - break; - case ID_HMC792: - code =3D (abs(gain) / 500) & 0x3F; - break; - case ID_HMC271: - case ID_HMC1018: - code =3D ((gain - 1000) / 1000) & 0x1F; - break; - case ID_HMC1019: - code =3D ((gain - 500) / 500) & 0x1F; - break; - case ID_HMC1119: - code =3D (abs(gain) / 250) & 0x7F; - break; - } + gain_base =3D inf->gain_step > 0 ? inf->gain_min : inf->gain_max; + code =3D DIV_ROUND_CLOSEST(gain - gain_base, inf->gain_step); =20 guard(mutex)(&st->lock); =20 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]); - break; + return ad8366_write_code(st); default: - ret =3D -EINVAL; + return -EINVAL; } - - return ret; } =20 static int ad8366_write_raw_get_fmt(struct iio_dev *indio_dev, @@ -312,10 +273,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 iio_dev *indio_dev; @@ -329,7 +286,9 @@ static int ad8366_probe(struct spi_device *spi) =20 st =3D iio_priv(indio_dev); st->spi =3D spi; - st->type =3D spi_get_device_id(spi)->driver_data; + st->info =3D spi_get_device_match_data(spi); + if (!st->info) + return -EINVAL; =20 ret =3D devm_regulator_get_enable(dev, "vcc"); if (ret) @@ -339,44 +298,23 @@ static int ad8366_probe(struct spi_device *spi) if (ret) return ret; =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_HMC271: - case ID_HMC792: - case ID_HMC1119: - case ID_ADRF5720: - case ID_ADRF5730: - case ID_ADRF5731: - case ID_HMC1018: - case ID_HMC1019: - st->reset_gpio =3D devm_gpiod_get_optional(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"); + st->reset_gpio =3D devm_gpiod_get_optional(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"); =20 - st->enable_gpio =3D devm_gpiod_get_optional(dev, "enable", GPIOD_OUT_HIG= H); - if (IS_ERR(st->enable_gpio)) - return dev_err_probe(dev, PTR_ERR(st->enable_gpio), - "Failed to get enable GPIO\n"); + st->enable_gpio =3D devm_gpiod_get_optional(dev, "enable", GPIOD_OUT_HIGH= ); + if (IS_ERR(st->enable_gpio)) + return dev_err_probe(dev, PTR_ERR(st->enable_gpio), + "Failed to get enable GPIO\n"); =20 - 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[st->type]; indio_dev->name =3D spi_get_device_id(spi)->name; indio_dev->info =3D &ad8366_info; + indio_dev->channels =3D ad8366_channels; + indio_dev->num_channels =3D st->info->num_channels; indio_dev->modes =3D INDIO_DIRECT_MODE; =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 @@ -384,24 +322,41 @@ static int ad8366_probe(struct spi_device *spi) } =20 static const struct spi_device_id ad8366_id[] =3D { - {"ad8366", ID_AD8366}, - {"ada4961", ID_ADA4961}, - {"adrf5720", ID_ADRF5720}, - {"adrf5730", ID_ADRF5730}, - {"adrf5731", ID_ADRF5731}, - {"adl5240", ID_ADL5240}, - {"hmc271a", ID_HMC271}, - {"hmc792a", ID_HMC792}, - {"hmc1018a", ID_HMC1018}, - {"hmc1019a", ID_HMC1019}, - {"hmc1119", ID_HMC1119}, + {"ad8366", (kernel_ulong_t)&ad8366_infos[ID_AD8366]}, + {"ada4961", (kernel_ulong_t)&ad8366_infos[ID_ADA4961]}, + {"adrf5720", (kernel_ulong_t)&ad8366_infos[ID_ADRF5720]}, + {"adrf5730", (kernel_ulong_t)&ad8366_infos[ID_ADRF5730]}, + {"adrf5731", (kernel_ulong_t)&ad8366_infos[ID_ADRF5731]}, + {"adl5240", (kernel_ulong_t)&ad8366_infos[ID_ADL5240]}, + {"hmc271a", (kernel_ulong_t)&ad8366_infos[ID_HMC271]}, + {"hmc792a", (kernel_ulong_t)&ad8366_infos[ID_HMC792]}, + {"hmc1018a", (kernel_ulong_t)&ad8366_infos[ID_HMC1018]}, + {"hmc1019a", (kernel_ulong_t)&ad8366_infos[ID_HMC1019]}, + {"hmc1119", (kernel_ulong_t)&ad8366_infos[ID_HMC1119]}, { } }; MODULE_DEVICE_TABLE(spi, ad8366_id); =20 +static const struct of_device_id ad8366_of_match[] =3D { + { .compatible =3D "adi,ad8366", .data =3D &ad8366_infos[ID_AD8366] }, + { .compatible =3D "adi,ada4961", .data =3D &ad8366_infos[ID_ADA4961] }, + { .compatible =3D "adi,adrf5720", .data =3D &ad8366_infos[ID_ADRF5720] }, + { .compatible =3D "adi,adrf5730", .data =3D &ad8366_infos[ID_ADRF5730] }, + { .compatible =3D "adi,adrf5731", .data =3D &ad8366_infos[ID_ADRF5731] }, + { .compatible =3D "adi,adl5240", .data =3D &ad8366_infos[ID_ADL5240] }, + { .compatible =3D "adi,hmc271a", .data =3D &ad8366_infos[ID_HMC271] }, + { .compatible =3D "adi,hmc792a", .data =3D &ad8366_infos[ID_HMC792] }, + { .compatible =3D "adi,hmc1018a", .data =3D &ad8366_infos[ID_HMC1018] }, + { .compatible =3D "adi,hmc1019a", .data =3D &ad8366_infos[ID_HMC1019] }, + { .compatible =3D "adi,hmc1119", .data =3D &ad8366_infos[ID_HMC1119] }, + { } +}; +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