From nobody Thu Apr 2 17:18:17 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 433F6331226; Tue, 10 Feb 2026 19:42:18 +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=1770752538; cv=none; b=jg/vnu5LZV0ouzMqcJHnqskjCZqFBeBKmwgGAcGswHa+zPGl8slCla29M/QnK/QWtF/Sh1nL5vTm9He7rfDNmCziTzGYlPDM+Bp8hDnr84TCTL7/wWZgg0tM8QLLjYzBk7jyZBRxXJGp/2f9SIGUZVoOsHZ870Ishtdr0XShaio= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770752538; c=relaxed/simple; bh=dBAEJKtc96dEneGGru/3QqhRhpSnPrGxCr2yV8h6zZY=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=aLUbCVMGnDxFP+W+Gr42qe7mhiroH5tke8QwxOnQ4wMuMiqI4coA1v4m+PSMvXpyvUm2SQEvV/EcqAtQTuP7WSgqk08gIfpM8p/hryyMOlWxqBDq1Zn3+Fslcbly/M8B3/3K1r85rRhxQr0gm3WozNGK2OsVJhdkX45G4pYx+OM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Eof9XVRo; 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="Eof9XVRo" Received: by smtp.kernel.org (Postfix) with ESMTPS id 04310C19421; Tue, 10 Feb 2026 19:42:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1770752538; bh=dBAEJKtc96dEneGGru/3QqhRhpSnPrGxCr2yV8h6zZY=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=Eof9XVRoHwuuW8HmMPYXo+AkWQDdGhMLqqYlC3dJAll+Gy1OWXjsm4eevLEsvh+Kb U3+78eUBLadoIaCmUQ55+N9QXbBuzEHd6XYjjcp+giBiLPsWiJq+L16yuj9PLNnobN ejh6l2BxDEpunTVXylGPzP5Q3ondn+Y6+wExaKR5n78+kSKUEx/DrKK09EGYAOrq78 Irq7WrJb835sIKDwMB3aTAR+TUhBg8yc8FtCsKOeR2cyM9tu0rhmyu00fWeDRmAlN3 tXqjY6h10IlYsyroSK+UM8EUJDoOql3gb9B3bddI448kUoxC9AIn8o/e1bJAHzrHfe 5guI9XL74uq2A== 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 ECB69EB2700; Tue, 10 Feb 2026 19:42:17 +0000 (UTC) From: Rodrigo Alencar via B4 Relay Date: Tue, 10 Feb 2026 19:42:09 +0000 Subject: [PATCH v4 09/11] iio: amplifiers: ad8366: add device tree support Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260210-iio-ad8366-update-v4-9-15505f7b15b4@analog.com> References: <20260210-iio-ad8366-update-v4-0-15505f7b15b4@analog.com> In-Reply-To: <20260210-iio-ad8366-update-v4-0-15505f7b15b4@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=1770752535; l=4163; i=rodrigo.alencar@analog.com; s=default; h=from:subject:message-id; bh=Q1eL1soBzt5LHgD1qOKJM+53k4PYKZ8/z9tudKqluIA=; b=eQQfhs+zD2dD7LvlR2kiKOJhcwb2MjmslXaewcKN79vRzr8nzAplH+G9TLC97gT1X/JtJSTuS Wa3bZtwwPeoAhiMWpRNdHW9xZOdolbXPvnHVKgQ6d3CVbmRp4k5S1i3 X-Developer-Key: i=rodrigo.alencar@analog.com; a=ed25519; pk=ULeHbgU/OYh/PG/4anHDfLgldFItQHAhOktYRVLMFRo= X-Endpoint-Received: by B4 Relay for rodrigo.alencar@analog.com/default with auth_id=561 X-Original-From: Rodrigo Alencar Reply-To: rodrigo.alencar@analog.com From: Rodrigo Alencar Drop the enum ID, split chip info table into per-device structs and add of_match_table. Signed-off-by: Rodrigo Alencar --- drivers/iio/amplifiers/ad8366.c | 100 +++++++++++++++++++++---------------= ---- 1 file changed, 53 insertions(+), 47 deletions(-) diff --git a/drivers/iio/amplifiers/ad8366.c b/drivers/iio/amplifiers/ad836= 6.c index 1ae75643e89b..79fb3119d794 100644 --- a/drivers/iio/amplifiers/ad8366.c +++ b/drivers/iio/amplifiers/ad8366.c @@ -14,6 +14,7 @@ #include #include #include +#include #include #include #include @@ -23,14 +24,6 @@ =20 #include =20 -enum ad8366_type { - ID_AD8366, - ID_ADA4961, - ID_ADL5240, - ID_HMC792, - ID_HMC1119, -}; - struct ad8366_state; =20 struct ad8366_info { @@ -62,38 +55,40 @@ static size_t ad8366_pack_code(struct ad8366_state *st) return sizeof(__be16); } =20 -static const struct ad8366_info ad8366_infos[] =3D { - [ID_AD8366] =3D { - .gain_min =3D 4500, - .gain_max =3D 20500, - .gain_step =3D 253, - .num_channels =3D 2, - .pack_code =3D ad8366_pack_code, - }, - [ID_ADA4961] =3D { - .gain_min =3D -6000, - .gain_max =3D 15000, - .gain_step =3D -1000, - .num_channels =3D 1, - }, - [ID_ADL5240] =3D { - .gain_min =3D -11500, - .gain_max =3D 20000, - .gain_step =3D 500, - .num_channels =3D 1, - }, - [ID_HMC792] =3D { - .gain_min =3D -15750, - .gain_max =3D 0, - .gain_step =3D 250, - .num_channels =3D 1, - }, - [ID_HMC1119] =3D { - .gain_min =3D -31750, - .gain_max =3D 0, - .gain_step =3D -250, - .num_channels =3D 1, - }, +static const struct ad8366_info ad8366_chip_info =3D { + .gain_min =3D 4500, + .gain_max =3D 20500, + .gain_step =3D 253, + .num_channels =3D 2, + .pack_code =3D ad8366_pack_code, +}; + +static const struct ad8366_info ada4961_chip_info =3D { + .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, }; =20 static int ad8366_write_code(struct ad8366_state *st) @@ -229,7 +224,7 @@ static int ad8366_probe(struct spi_device *spi) return dev_err_probe(dev, ret, "Failed to get regulator\n"); =20 st->spi =3D spi; - st->info =3D &ad8366_infos[spi_get_device_id(spi)->driver_data]; + st->info =3D spi_get_device_match_data(spi); =20 rstc =3D devm_reset_control_get_optional_exclusive_deasserted(dev, NULL); if (IS_ERR(rstc)) @@ -250,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