[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20251223183142.31897-6-damien.riegel@silabs.com>
Date: Tue, 23 Dec 2025 13:31:39 -0500
From: Damien Riégel <damien.riegel@...abs.com>
To: greybus-dev@...ts.linaro.org
Cc: linux-kernel@...r.kernel.org, Johan Hovold <johan@...nel.org>,
Alex Elder <elder@...nel.org>,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
linux-devel@...abs.com,
Damien Riégel <damien.riegel@...abs.com>
Subject: [PATCH 5/8] greybus: add function create module in P2P mode
Add a new function to a create a module in point-to-point mode. The
number of interfaces is normally reported by the SVC in a "Module
Inserted".
As there's no SVC in point-to-point mode, this function hardcodes the
number of interface to 1. The "eject" attribute is also hidden, as
"Module Eject" is an operation issued by the AP to the SVC to eject
module with the given primary interface and doesn't make sense if SVC is
absent.
Signed-off-by: Damien Riégel <damien.riegel@...abs.com>
---
drivers/greybus/module.c | 30 ++++++++++++++++++++++++++++++
include/linux/greybus/module.h | 1 +
2 files changed, 31 insertions(+)
diff --git a/drivers/greybus/module.c b/drivers/greybus/module.c
index 334aefb46b5..e628dc81b9a 100644
--- a/drivers/greybus/module.c
+++ b/drivers/greybus/module.c
@@ -72,6 +72,13 @@ static struct attribute *module_attrs[] = {
};
ATTRIBUTE_GROUPS(module);
+static struct attribute *module_p2p_attrs[] = {
+ &dev_attr_module_id.attr,
+ &dev_attr_num_interfaces.attr,
+ NULL,
+};
+ATTRIBUTE_GROUPS(module_p2p);
+
static void gb_module_release(struct device *dev)
{
struct gb_module *module = to_gb_module(dev);
@@ -115,6 +122,29 @@ static struct gb_module *__gb_module_create(struct gb_host_device *hd,
return module;
}
+struct gb_module *gb_module_create_p2p(struct gb_host_device *hd)
+{
+ struct gb_module *module = __gb_module_create(hd, module_p2p_groups, 0, 1);
+ struct gb_interface *intf;
+
+ if (!module)
+ return NULL;
+
+ intf = gb_interface_create(module, 0, true);
+ if (!intf) {
+ dev_err(&module->dev, "failed to create P2P interface\n");
+ put_device(&module->dev);
+
+ module = NULL;
+ goto exit;
+ }
+
+ module->interfaces[0] = intf;
+
+exit:
+ return module;
+}
+
struct gb_module *gb_module_create(struct gb_host_device *hd, u8 module_id,
size_t num_interfaces)
{
diff --git a/include/linux/greybus/module.h b/include/linux/greybus/module.h
index 3efe2133acf..8fec21d6abf 100644
--- a/include/linux/greybus/module.h
+++ b/include/linux/greybus/module.h
@@ -27,6 +27,7 @@ struct gb_module {
};
#define to_gb_module(d) container_of(d, struct gb_module, dev)
+struct gb_module *gb_module_create_p2p(struct gb_host_device *hd);
struct gb_module *gb_module_create(struct gb_host_device *hd, u8 module_id,
size_t num_interfaces);
int gb_module_add(struct gb_module *module);
--
2.49.0
Powered by blists - more mailing lists