greybus: introduce protocol abstraction
Define a protocol structure that will allow protocols to be
registered dynamically. For now we just introduce a bookkeeping
data structure. Upcoming patches will move protocol-related methods
into the protocol structure, and will start registering protocol
handlers dynamically.
A list of connections using a given protocol is maintained so we can
tell when a protocol is no longer in use. This may not be necessary
(we could use a kref instead) but it may turn out to be a good way
to clean things up.
The interface is gb_protocol_get() and gb_protocol_put() for a
connection, allowing the protocol to be looked up and the connection
structure to be inserted into its list.
Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
diff --git a/drivers/staging/greybus/connection.h b/drivers/staging/greybus/connection.h
index 830abe7..8056993 100644
--- a/drivers/staging/greybus/connection.h
+++ b/drivers/staging/greybus/connection.h
@@ -39,7 +39,9 @@
struct rb_node hd_node;
struct list_head interface_links;
- u8 protocol_id;
+
+ struct gb_protocol *protocol;
+ struct list_head protocol_links;
enum gb_connection_state state;