greybus: define connection state
Define the state of a connection. A connection will not be
enabled until it has been successfully set up. Once it starts
getting torn down its state will move to "being destroyed".
Don't send any operation request messages unless the connection is
enabled. And drop any incoming messages if if the connection is
not enabled.
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 b5901a1..a16e52a 100644
--- a/drivers/staging/greybus/connection.h
+++ b/drivers/staging/greybus/connection.h
@@ -13,6 +13,14 @@
#include "greybus.h"
+enum gb_connection_state {
+ GB_CONNECTION_STATE_INVALID = 0,
+ GB_CONNECTION_STATE_DISABLED = 1,
+ GB_CONNECTION_STATE_ENABLED = 2,
+ GB_CONNECTION_STATE_ERROR = 3,
+ GB_CONNECTION_STATE_DESTROYING = 4,
+};
+
struct gb_connection {
struct greybus_host_device *hd;
struct gb_interface *interface;
@@ -22,6 +30,7 @@
struct rb_node hd_node;
struct list_head interface_links;
enum greybus_protocol protocol;
+ enum gb_connection_state state;
struct list_head operations;
struct rb_root pending; /* awaiting reponse */