mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Damien Riégel" <damien.riegel@silabs.com>
To: greybus-dev@lists.linaro.org
Cc: linux-kernel@vger.kernel.org, "Johan Hovold" <johan@kernel.org>,
	"Alex Elder" <elder@kernel.org>,
	"Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
	linux-devel@silabs.com,
	"Damien Riégel" <damien.riegel@silabs.com>
Subject: [PATCH 2/8] greybus: let gb_interface_create take additional p2p argument
Date: Tue, 23 Dec 2025 13:31:36 -0500	[thread overview]
Message-ID: <20251223183142.31897-3-damien.riegel@silabs.com> (raw)
In-Reply-To: <20251223183142.31897-1-damien.riegel@silabs.com>

Update the function that creates an interface to take an additional
boolean argument to indicate if the interface is point to point or not.

If this argument is true, interface's type and ID are immediately set,
and a different group of attributes is set on the interface device, as
there is no way to fetch greybus attributes (vendor ID, product ID,
serial number) or Unipro attributes (ddbl1 manufacturer and product ID)
when SVC is absent, and so it doesn't make sense to expose them.

Signed-off-by: Damien Riégel <damien.riegel@silabs.com>
---
 drivers/greybus/interface.c       | 20 ++++++++++++++++----
 drivers/greybus/module.c          |  2 +-
 include/linux/greybus/interface.h |  3 ++-
 3 files changed, 19 insertions(+), 6 deletions(-)

diff --git a/drivers/greybus/interface.c b/drivers/greybus/interface.c
index e96b58b211b..aa2bd841977 100644
--- a/drivers/greybus/interface.c
+++ b/drivers/greybus/interface.c
@@ -687,6 +687,12 @@ static const struct attribute_group *interface_groups[] = {
 	NULL
 };
 
+static const struct attribute_group *interface_groups_p2p[] = {
+	&interface_greybus_group,
+	&interface_common_group,
+	NULL
+};
+
 static void gb_interface_release(struct device *dev)
 {
 	struct gb_interface *intf = to_gb_interface(dev);
@@ -790,7 +796,8 @@ const struct device_type greybus_interface_type = {
  * failure occurs due to memory exhaustion.
  */
 struct gb_interface *gb_interface_create(struct gb_module *module,
-					 u8 interface_id)
+					 u8 interface_id,
+					 bool p2p)
 {
 	struct gb_host_device *hd = module->hd;
 	struct gb_interface *intf;
@@ -808,13 +815,18 @@ struct gb_interface *gb_interface_create(struct gb_module *module,
 	INIT_WORK(&intf->mode_switch_work, gb_interface_mode_switch_work);
 	init_completion(&intf->mode_switch_completion);
 
-	/* Invalid device id to start with */
-	intf->device_id = GB_INTERFACE_DEVICE_ID_BAD;
+	if (p2p) {
+		intf->device_id = GB_SVC_DEVICE_ID_MIN;
+		intf->type = GB_INTERFACE_TYPE_P2P;
+	} else {
+		/* Invalid device id to start with */
+		intf->device_id = GB_INTERFACE_DEVICE_ID_BAD;
+	}
 
 	intf->dev.parent = &module->dev;
 	intf->dev.bus = &greybus_bus_type;
 	intf->dev.type = &greybus_interface_type;
-	intf->dev.groups = interface_groups;
+	intf->dev.groups = p2p ? interface_groups_p2p : interface_groups;
 	intf->dev.dma_mask = module->dev.dma_mask;
 	device_initialize(&intf->dev);
 	dev_set_name(&intf->dev, "%s.%u", dev_name(&module->dev),
diff --git a/drivers/greybus/module.c b/drivers/greybus/module.c
index 7f7153a1dd6..4ed68550d32 100644
--- a/drivers/greybus/module.c
+++ b/drivers/greybus/module.c
@@ -113,7 +113,7 @@ struct gb_module *gb_module_create(struct gb_host_device *hd, u8 module_id,
 	trace_gb_module_create(module);
 
 	for (i = 0; i < num_interfaces; ++i) {
-		intf = gb_interface_create(module, module_id + i);
+		intf = gb_interface_create(module, module_id + i, false);
 		if (!intf) {
 			dev_err(&module->dev, "failed to create interface %u\n",
 				module_id + i);
diff --git a/include/linux/greybus/interface.h b/include/linux/greybus/interface.h
index fed6356eb13..dee42859ebe 100644
--- a/include/linux/greybus/interface.h
+++ b/include/linux/greybus/interface.h
@@ -70,7 +70,8 @@ struct gb_interface {
 #define to_gb_interface(d) container_of(d, struct gb_interface, dev)
 
 struct gb_interface *gb_interface_create(struct gb_module *module,
-					 u8 interface_id);
+					 u8 interface_id,
+					 bool p2p);
 int gb_interface_activate(struct gb_interface *intf);
 void gb_interface_deactivate(struct gb_interface *intf);
 int gb_interface_enable(struct gb_interface *intf);
-- 
2.49.0


  parent reply	other threads:[~2025-12-23 19:07 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-12-23 18:31 [PATCH 0/8] greybus: support point-to-point topology Damien Riégel
2025-12-23 18:31 ` [PATCH 1/8] greybus: add P2P interface type Damien Riégel
2025-12-23 18:31 ` Damien Riégel [this message]
2025-12-23 18:31 ` [PATCH 3/8] greybus: force CPort ID allocation in P2P mode Damien Riégel
2025-12-23 18:31 ` [PATCH 4/8] greybus: split module creation function Damien Riégel
2025-12-23 18:31 ` [PATCH 5/8] greybus: add function create module in P2P mode Damien Riégel
2025-12-23 18:31 ` [PATCH 6/8] greybus: make host API work without SVC Damien Riégel
2025-12-23 18:31 ` [PATCH 7/8] greybus: add function to create SVC-less host device Damien Riégel
2025-12-23 18:31 ` [PATCH 8/8] greybus: add function to probe p2p module Damien Riégel
2026-01-16 15:09 ` [PATCH 0/8] greybus: support point-to-point topology Greg Kroah-Hartman
2026-01-27 20:23   ` Damien Riégel
2026-01-28  6:04     ` Greg Kroah-Hartman
2026-01-28 15:39       ` Damien Riégel

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20251223183142.31897-3-damien.riegel@silabs.com \
    --to=damien.riegel@silabs.com \
    --cc=elder@kernel.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=greybus-dev@lists.linaro.org \
    --cc=johan@kernel.org \
    --cc=linux-devel@silabs.com \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®