lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20251216-b4-ad9467-optional-backend-v1-2-83e61531ef4d@vaisala.com>
Date: Tue, 16 Dec 2025 11:40:06 +0000
From: Tomas Melin <tomas.melin@...sala.com>
To: Michael Hennerich <Michael.Hennerich@...log.com>, 
 Nuno Sa <nuno.sa@...log.com>, Lars-Peter Clausen <lars@...afoo.de>, 
 Jonathan Cameron <jic23@...nel.org>, David Lechner <dlechner@...libre.com>, 
 Andy Shevchenko <andy@...nel.org>
Cc: linux-iio@...r.kernel.org, linux-kernel@...r.kernel.org, 
 Tomas Melin <tomas.melin@...sala.com>
Subject: [PATCH 2/2] iio: adc: ad9467: make iio backend optional

Not all users can or want to use the device with an iio-backend.
For these users, let the driver work in standalone mode, not coupled
to the backend or the services it provides.

Signed-off-by: Tomas Melin <tomas.melin@...sala.com>
---
 drivers/iio/adc/ad9467.c | 37 +++++++++++++++++++++++++------------
 1 file changed, 25 insertions(+), 12 deletions(-)

diff --git a/drivers/iio/adc/ad9467.c b/drivers/iio/adc/ad9467.c
index 60fc3361b2689a4c38287c613ef93fe00338e5fa..37b8f88da6681d44f3fbbb6c8c171ae7117b9090 100644
--- a/drivers/iio/adc/ad9467.c
+++ b/drivers/iio/adc/ad9467.c
@@ -1000,6 +1000,9 @@ static int ad9467_update_scan_mode(struct iio_dev *indio_dev,
 	unsigned int c;
 	int ret;
 
+	if (!st->back)
+		return -EOPNOTSUPP;
+
 	for (c = 0; c < st->info->num_channels; c++) {
 		if (test_bit(c, scan_mask))
 			ret = iio_backend_chan_enable(st->back, c);
@@ -1066,6 +1069,7 @@ static int ad9467_iio_backend_get(struct ad9467_state *st)
 {
 	struct device *dev = &st->spi->dev;
 	struct device_node *__back;
+	unsigned int nr_nodes = 0;
 
 	st->back = devm_iio_backend_get(dev, NULL);
 	if (!IS_ERR(st->back))
@@ -1084,6 +1088,7 @@ static int ad9467_iio_backend_get(struct ad9467_state *st)
 	for_each_node_with_property(__back, "adi,adc-dev") {
 		struct device_node *__me;
 
+		nr_nodes++;
 		__me = of_parse_phandle(__back, "adi,adc-dev", 0);
 		if (!__me)
 			continue;
@@ -1100,6 +1105,10 @@ static int ad9467_iio_backend_get(struct ad9467_state *st)
 		return PTR_ERR_OR_ZERO(st->back);
 	}
 
+	st->back = NULL;
+	if (!nr_nodes)
+		return -ENOENT;
+
 	return -ENODEV;
 }
 
@@ -1294,8 +1303,8 @@ static void ad9467_debugfs_init(struct iio_dev *indio_dev)
 
 	debugfs_create_file("in_voltage_test_mode_available", 0400, d, st,
 			    &ad9467_test_mode_available_fops);
-
-	iio_backend_debugfs_add(st->back, indio_dev);
+	if (st->back)
+		iio_backend_debugfs_add(st->back, indio_dev);
 }
 
 static int ad9467_probe(struct spi_device *spi)
@@ -1352,21 +1361,25 @@ static int ad9467_probe(struct spi_device *spi)
 	indio_dev->channels = st->info->channels;
 	indio_dev->num_channels = st->info->num_channels;
 
+	/* Using a backend is optional */
 	ret = ad9467_iio_backend_get(st);
-	if (ret)
+	if (ret && ret != -ENOENT)
 		return ret;
 
-	ret = devm_iio_backend_request_buffer(&spi->dev, st->back, indio_dev);
-	if (ret)
-		return ret;
+	if (!ret) {
+		ret = devm_iio_backend_request_buffer(&spi->dev, st->back,
+						      indio_dev);
+		if (ret)
+			return ret;
 
-	ret = devm_iio_backend_enable(&spi->dev, st->back);
-	if (ret)
-		return ret;
+		ret = devm_iio_backend_enable(&spi->dev, st->back);
+		if (ret)
+			return ret;
 
-	ret = ad9467_calibrate(st);
-	if (ret)
-		return ret;
+		ret = ad9467_calibrate(st);
+		if (ret)
+			return ret;
+	}
 
 	ret = devm_iio_device_register(&spi->dev, indio_dev);
 	if (ret)

-- 
2.47.3


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ