greybus: legacy: add initialized flag
authorJohan Hovold <johan@hovoldconsulting.com>
Thu, 21 Jan 2016 16:34:18 +0000 (17:34 +0100)
committerGreg Kroah-Hartman <gregkh@google.com>
Fri, 22 Jan 2016 06:46:38 +0000 (22:46 -0800)
Add initialized flag and use instead of the connection protocol pointer
to determine when the legacy connection has been initialised.

This is a step in moving legacy connection binding to
connection-creation time.

Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
drivers/staging/greybus/legacy.c

index 37c42124861155d417846441775cc60b3e35567e..c7f59e4f5b8eeb7ef098241274d9f350a9c2ba13 100644 (file)
@@ -14,6 +14,7 @@
 
 struct legacy_connection {
        struct gb_connection *connection;
+       bool initialized;
 };
 
 struct legacy_data {
@@ -112,6 +113,8 @@ static int legacy_connection_init(struct legacy_connection *lc)
        if (ret)
                goto err_disable;
 
+       lc->initialized = true;
+
        return 0;
 
 err_disable:
@@ -126,7 +129,7 @@ static void legacy_connection_exit(struct legacy_connection *lc)
 {
        struct gb_connection *connection = lc->connection;
 
-       if (!connection->protocol)
+       if (!lc->initialized)
                return;
 
        gb_connection_disable(connection);
@@ -134,6 +137,8 @@ static void legacy_connection_exit(struct legacy_connection *lc)
        connection->protocol->connection_exit(connection);
 
        legacy_connection_unbind_protocol(connection);
+
+       lc->initialized = false;
 }
 
 static int legacy_connection_create(struct legacy_connection *lc,