libmctp: Add mctp_unregister_bus()
Allow for safe cleanup of busses associated with bindings when the
binding has work to do in the tear-down path.
Signed-off-by: Andrew Jeffery <andrew@aj.id.au>
Change-Id: I7cc45e30d778554cfa33c49a47fe237b23fe5431
diff --git a/core.c b/core.c
index 4d945db..0b75cb9 100644
--- a/core.c
+++ b/core.c
@@ -372,6 +372,18 @@
return rc;
}
+void mctp_unregister_bus(struct mctp *mctp, struct mctp_binding *binding)
+{
+ /*
+ * We only support one bus right now; once the call completes we will
+ * have no more busses
+ */
+ mctp->n_busses = 0;
+ binding->mctp = NULL;
+ binding->bus = NULL;
+ free(mctp->busses);
+}
+
int mctp_bridge_busses(struct mctp *mctp,
struct mctp_binding *b1, struct mctp_binding *b2)
{
diff --git a/libmctp.h b/libmctp.h
index 09672ac..bc0cb5b 100644
--- a/libmctp.h
+++ b/libmctp.h
@@ -82,6 +82,8 @@
struct mctp_binding *binding,
mctp_eid_t eid);
+void mctp_unregister_bus(struct mctp *mctp, struct mctp_binding *binding);
+
/* Create a simple bidirectional bridge between busses.
*
* In this mode, the MCTP stack is initialised as a bridge. There is no EID