API: Add binding accessors to generic struct mctp_binding
Rather than have every binding include their own wrappers around
binding<->core functions, introduce an accessor to retrieve the struct
mctp_binding from each.
This means we no longer need the binding-specific registration
callbacks. However, we do now need a ->start callback, to allow bindings
to perform post-registration init.
Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
Change-Id: I6cee9e93f37520f85c155a0ca34017cc0675552c
diff --git a/serial.c b/serial.c
index f673a52..781a9c1 100644
--- a/serial.c
+++ b/serial.c
@@ -312,12 +312,15 @@
mctp_rx_consume(serial, buf, len);
}
-void mctp_serial_register_bus(struct mctp_binding_serial *serial,
- struct mctp *mctp, mctp_eid_t eid)
+static int mctp_serial_core_start(struct mctp_binding *binding)
{
- assert(serial->fd >= 0);
- mctp_register_bus(mctp, &serial->binding, eid);
- mctp_binding_set_tx_enabled(&serial->binding, true);
+ mctp_binding_set_tx_enabled(binding, true);
+ return 0;
+}
+
+struct mctp_binding *mctp_binding_serial_core(struct mctp_binding_serial *b)
+{
+ return &b->binding;
}
struct mctp_binding_serial *mctp_serial_init(void)
@@ -334,6 +337,7 @@
serial->binding.pkt_size = MCTP_BMTU;
serial->binding.pkt_pad = 0;
+ serial->binding.start = mctp_serial_core_start;
serial->binding.tx = mctp_binding_serial_tx;
return serial;