[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20251223183142.31897-7-damien.riegel@silabs.com>
Date: Tue, 23 Dec 2025 13:31:40 -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 6/8] greybus: make host API work without SVC
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@...abs.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
Powered by blists - more mailing lists