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]
Date:   Fri, 23 Jun 2023 16:09:41 +0200
From:   Olivier Moysan <olivier.moysan@...s.st.com>
To:     Jonathan Cameron <jic23@...nel.org>,
        Lars-Peter Clausen <lars@...afoo.de>
CC:     Olivier Moysan <olivier.moysan@...s.st.com>,
        <linux-iio@...r.kernel.org>, <linux-kernel@...r.kernel.org>
Subject: [RFC PATCH 5/7] iio: adc: sd_adc_modulator: change to iio backend device

Register the SD modulator as an IIO backend device instead of
a standard IIO device.

Signed-off-by: Olivier Moysan <olivier.moysan@...s.st.com>
---
 drivers/iio/adc/sd_adc_modulator.c | 65 ++++++++++++++++++++----------
 1 file changed, 44 insertions(+), 21 deletions(-)

diff --git a/drivers/iio/adc/sd_adc_modulator.c b/drivers/iio/adc/sd_adc_modulator.c
index 327cc2097f6c..61246a52dc79 100644
--- a/drivers/iio/adc/sd_adc_modulator.c
+++ b/drivers/iio/adc/sd_adc_modulator.c
@@ -7,42 +7,65 @@
  */
 
 #include <linux/iio/iio.h>
+#include <linux/iio/backend.h>
 #include <linux/iio/triggered_buffer.h>
 #include <linux/module.h>
 #include <linux/mod_devicetable.h>
 #include <linux/platform_device.h>
 
-static const struct iio_info iio_sd_mod_iio_info;
+struct iio_sd_mod_priv {
+};
 
-static const struct iio_chan_spec iio_sd_mod_ch = {
-	.type = IIO_VOLTAGE,
-	.indexed = 1,
-	.scan_type = {
-		.sign = 'u',
-		.realbits = 1,
-		.shift = 0,
-	},
+static int sd_mod_enable(struct iio_backend *backend)
+{
+	struct iio_sd_mod_priv *priv = backend->priv;
+
+	/* PM resume */
+
+	return 0;
+};
+
+static int sd_mod_disable(struct iio_backend *backend)
+{
+	struct iio_sd_mod_priv *priv = backend->priv;
+
+	/* PM suspend */
+
+	return 0;
+};
+
+static int sd_mod_read(struct iio_backend *backend, int *val, int *val2, long mask)
+{
+	struct iio_sd_mod_priv *priv = backend->priv;
+
+	switch (mask) {
+		/* Process channel info */
+	}
+
+	return -EINVAL;
+};
+
+static const struct iio_backend_ops sd_mod_ops = {
+	.enable = sd_mod_enable,
+	.disable = sd_mod_disable,
+	.read_raw = sd_mod_read,
 };
 
 static int iio_sd_mod_probe(struct platform_device *pdev)
 {
 	struct device *dev = &pdev->dev;
-	struct iio_dev *iio;
-
-	iio = devm_iio_device_alloc(dev, 0);
-	if (!iio)
-		return -ENOMEM;
+	struct iio_backend *backend;
+	struct iio_sd_mod_priv *priv;
+	int ret;
 
-	iio->name = dev_name(dev);
-	iio->info = &iio_sd_mod_iio_info;
-	iio->modes = INDIO_BUFFER_HARDWARE;
+	priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
 
-	iio->num_channels = 1;
-	iio->channels = &iio_sd_mod_ch;
+	backend = iio_backend_alloc(dev);
 
-	platform_set_drvdata(pdev, iio);
+	backend->priv = priv;
+	backend->ops = &sd_mod_ops;
 
-	return devm_iio_device_register(&pdev->dev, iio);
+	return iio_backend_register(backend);
 }
 
 static const struct of_device_id sd_adc_of_match[] = {
-- 
2.25.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ