[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20251223183142.31897-5-damien.riegel@silabs.com>
Date: Tue, 23 Dec 2025 13:31:38 -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 4/8] greybus: split module creation function
The module creation function is split into two parts; one part for
allocating and initializing the module structure itself, and a second
part to create the interface that belong to this module. This is a
preparatory step before introducing a function to create module in
point-to-point mode.
Signed-off-by: Damien Riégel <damien.riegel@...abs.com>
---
drivers/greybus/module.c | 23 ++++++++++++++++++-----
1 file changed, 18 insertions(+), 5 deletions(-)
diff --git a/drivers/greybus/module.c b/drivers/greybus/module.c
index 4ed68550d32..334aefb46b5 100644
--- a/drivers/greybus/module.c
+++ b/drivers/greybus/module.c
@@ -86,12 +86,12 @@ const struct device_type greybus_module_type = {
.release = gb_module_release,
};
-struct gb_module *gb_module_create(struct gb_host_device *hd, u8 module_id,
- size_t num_interfaces)
+static struct gb_module *__gb_module_create(struct gb_host_device *hd,
+ const struct attribute_group **groups,
+ u8 module_id,
+ size_t num_interfaces)
{
- struct gb_interface *intf;
struct gb_module *module;
- int i;
module = kzalloc(struct_size(module, interfaces, num_interfaces),
GFP_KERNEL);
@@ -105,13 +105,26 @@ struct gb_module *gb_module_create(struct gb_host_device *hd, u8 module_id,
module->dev.parent = &hd->dev;
module->dev.bus = &greybus_bus_type;
module->dev.type = &greybus_module_type;
- module->dev.groups = module_groups;
+ module->dev.groups = groups;
module->dev.dma_mask = hd->dev.dma_mask;
device_initialize(&module->dev);
dev_set_name(&module->dev, "%d-%u", hd->bus_id, module_id);
trace_gb_module_create(module);
+ return module;
+}
+
+struct gb_module *gb_module_create(struct gb_host_device *hd, u8 module_id,
+ size_t num_interfaces)
+{
+ struct gb_module *module = __gb_module_create(hd, module_groups, module_id, num_interfaces);
+ struct gb_interface *intf;
+ int i;
+
+ if (!module)
+ return NULL;
+
for (i = 0; i < num_interfaces; ++i) {
intf = gb_interface_create(module, module_id + i, false);
if (!intf) {
--
2.49.0
Powered by blists - more mailing lists