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: <20230623140944.2613002-2-olivier.moysan@foss.st.com>
Date:   Fri, 23 Jun 2023 16:09:37 +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-kernel@...r.kernel.org>, <linux-iio@...r.kernel.org>
Subject: [RFC PATCH 1/7] iio: introduce iio backend device

Add a new device type in IIO framework.
This backend device does not compute channel attributes and does not expose
them through sysfs, as done typically in iio-rescale frontend device.
Instead, it allows to report information applying to channel
attributes through callbacks. These backend devices can be cascaded
to represent chained components.
An IIO device configured as a consumer of a backend device can compute
the channel attributes of the whole chain.

Signed-off-by: Olivier Moysan <olivier.moysan@...s.st.com>
---
 drivers/iio/Makefile               |  2 +
 drivers/iio/industrialio-backend.c | 59 ++++++++++++++++++++++++++++++
 include/linux/iio/backend.h        | 29 +++++++++++++++
 3 files changed, 90 insertions(+)
 create mode 100644 drivers/iio/industrialio-backend.c
 create mode 100644 include/linux/iio/backend.h

diff --git a/drivers/iio/Makefile b/drivers/iio/Makefile
index 9622347a1c1b..b747fcef611d 100644
--- a/drivers/iio/Makefile
+++ b/drivers/iio/Makefile
@@ -8,6 +8,8 @@ industrialio-y := industrialio-core.o industrialio-event.o inkern.o
 industrialio-$(CONFIG_IIO_BUFFER) += industrialio-buffer.o
 industrialio-$(CONFIG_IIO_TRIGGER) += industrialio-trigger.o
 
+industrialio-$(CONFIG_IIO_BACKEND) += industrialio-backend.o
+
 obj-$(CONFIG_IIO_CONFIGFS) += industrialio-configfs.o
 obj-$(CONFIG_IIO_GTS_HELPER) += industrialio-gts-helper.o
 obj-$(CONFIG_IIO_SW_DEVICE) += industrialio-sw-device.o
diff --git a/drivers/iio/industrialio-backend.c b/drivers/iio/industrialio-backend.c
new file mode 100644
index 000000000000..6a0f071f8682
--- /dev/null
+++ b/drivers/iio/industrialio-backend.c
@@ -0,0 +1,59 @@
+// SPDX-License-Identifier: GPL-2.0
+/* The industrial I/O core, backend handling functions
+ *
+ */
+
+#include <linux/kernel.h>
+#include <linux/device.h>
+#include <linux/list.h>
+#include <linux/iio/backend.h>
+
+struct iio_backend *iio_backend_alloc(struct device *parent)
+{
+	struct iio_backend *backend;
+
+	/*
+	 * Allocate backend struct
+	 * Init backend device & struct
+	 */
+
+	return backend;
+};
+EXPORT_SYMBOL(iio_backend_alloc);
+
+int iio_backend_register(struct iio_backend *backend)
+{
+	/*
+	 * Add device to device hierarchy
+	 * (Call device_add())
+	 */
+
+	return 0;
+};
+EXPORT_SYMBOL(iio_backend_register);
+
+void iio_backend_unregister(struct iio_backend *backend)
+{
+	/*
+	 * Free backend struct and delete device
+	 * (Call device_del())
+	 */
+};
+EXPORT_SYMBOL(iio_backend_unregister);
+
+struct iio_backend *iio_backend_get(struct device *dev)
+{
+	struct iio_backend *backend;
+
+	/*
+	 * Get backend in from device node
+	 * (call fwnode_property_get_reference_args() with io-backends prop)
+	 * Allocate backend
+	 * Find backend device from phandle
+	 * (call bus_find_device_by_fwnode())
+	 * Return backend
+	 */
+
+	return backend;
+};
+EXPORT_SYMBOL(iio_backend_get);
diff --git a/include/linux/iio/backend.h b/include/linux/iio/backend.h
new file mode 100644
index 000000000000..e089e5e6cef0
--- /dev/null
+++ b/include/linux/iio/backend.h
@@ -0,0 +1,29 @@
+/* SPDX-License-Identifier: GPL-2.0-or-later */
+/*
+ * The industrial I/O core, backend handling functions
+ *
+ * Author: Olivier Moysan <olivier.moysan@...s.st.com>.
+ */
+
+struct iio_backend_ops;
+
+struct iio_backend {
+	const struct iio_backend_ops	*ops;
+	struct module			*owner;
+	int				id;
+	const char			*name;
+	struct device			dev;
+	struct list_head		list;
+	void				*priv;
+};
+
+struct iio_backend_ops {
+	int (*enable)(struct iio_backend *backend);
+	int (*disable)(struct iio_backend *backend);
+	int (*read_raw)(struct iio_backend *backend, int *val, int *val2, long mask);
+};
+
+struct iio_backend *iio_backend_alloc(struct device *parent);
+int iio_backend_register(struct iio_backend *backend);
+void iio_backend_unregister(struct iio_backend *backend);
+struct iio_backend *iio_backend_get(struct device *dev);
-- 
2.25.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ