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/operation.c b/drivers/staging/greybus/operation.c
index afb42d5..5d23d19 100644
--- a/drivers/staging/greybus/operation.c
+++ b/drivers/staging/greybus/operation.c
@@ -417,6 +417,9 @@
 {
 	int ret;
 
+	if (operation->connection->state != GB_CONNECTION_STATE_ENABLED)
+		return -ENOTCONN;
+
 	/*
 	 * XXX
 	 * I think the order of operations is going to be
@@ -461,6 +464,9 @@
 	struct gbuf *gbuf;
 	u16 msg_size;
 
+	if (connection->state != GB_CONNECTION_STATE_ENABLED)
+		return;
+
 	if (size > GB_OPERATION_MESSAGE_SIZE_MAX) {
 		gb_connection_err(connection, "message too big");
 		return;