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 6/8] greybus: make host API work without SVC
Date: Tue, 23 Dec 2025 13:31:40 -0500	[thread overview]
Message-ID: <20251223183142.31897-7-damien.riegel@silabs.com> (raw)
In-Reply-To: <20251223183142.31897-1-damien.riegel@silabs.com>

In preparation for an SVC-less topology, make host device API behaves
nicely if an SVC is not allocated.

Signed-off-by: Damien Riégel <damien.riegel@silabs.com>
---
 drivers/greybus/hd.c | 27 +++++++++++++++++++++------
 1 file changed, 21 insertions(+), 6 deletions(-)

diff --git a/drivers/greybus/hd.c b/drivers/greybus/hd.c
index 5de98d9177f..1e2f1f3a65f 100644
--- a/drivers/greybus/hd.c
+++ b/drivers/greybus/hd.c
@@ -45,11 +45,19 @@ static struct attribute *bus_attrs[] = {
 };
 ATTRIBUTE_GROUPS(bus);
 
+static bool gb_hd_is_p2p(struct gb_host_device *hd)
+{
+	return !hd->svc;
+}
+
 int gb_hd_cport_reserve(struct gb_host_device *hd, u16 cport_id)
 {
 	struct ida *id_map = &hd->cport_id_map;
 	int ret;
 
+	if (gb_hd_is_p2p(hd))
+		return -EPERM;
+
 	ret = ida_alloc_range(id_map, cport_id, cport_id, GFP_KERNEL);
 	if (ret < 0) {
 		dev_err(&hd->dev, "failed to reserve cport %u\n", cport_id);
@@ -64,6 +72,9 @@ void gb_hd_cport_release_reserved(struct gb_host_device *hd, u16 cport_id)
 {
 	struct ida *id_map = &hd->cport_id_map;
 
+	if (gb_hd_is_p2p(hd))
+		return;
+
 	ida_free(id_map, cport_id);
 }
 EXPORT_SYMBOL_GPL(gb_hd_cport_release_reserved);
@@ -205,10 +216,12 @@ int gb_hd_add(struct gb_host_device *hd)
 	if (ret)
 		return ret;
 
-	ret = gb_svc_add(hd->svc);
-	if (ret) {
-		device_del(&hd->dev);
-		return ret;
+	if (!gb_hd_is_p2p(hd)) {
+		ret = gb_svc_add(hd->svc);
+		if (ret) {
+			device_del(&hd->dev);
+			return ret;
+		}
 	}
 
 	trace_gb_hd_add(hd);
@@ -225,7 +238,8 @@ void gb_hd_del(struct gb_host_device *hd)
 	 * Tear down the svc and flush any on-going hotplug processing before
 	 * removing the remaining interfaces.
 	 */
-	gb_svc_del(hd->svc);
+	if (!gb_hd_is_p2p(hd))
+		gb_svc_del(hd->svc);
 
 	device_del(&hd->dev);
 }
@@ -233,7 +247,8 @@ EXPORT_SYMBOL_GPL(gb_hd_del);
 
 void gb_hd_shutdown(struct gb_host_device *hd)
 {
-	gb_svc_del(hd->svc);
+	if (!gb_hd_is_p2p(hd))
+		gb_svc_del(hd->svc);
 }
 EXPORT_SYMBOL_GPL(gb_hd_shutdown);
 
-- 
2.49.0


  parent reply	other threads:[~2025-12-23 19:01 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 ` [PATCH 2/8] greybus: let gb_interface_create take additional p2p argument Damien Riégel
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 ` Damien Riégel [this message]
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-7-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®