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)
 {