greybus: connection: remove broken protocol-version handling
authorJohan Hovold <johan@hovoldconsulting.com>
Tue, 19 Jan 2016 11:51:20 +0000 (12:51 +0100)
committerGreg Kroah-Hartman <gregkh@google.com>
Tue, 19 Jan 2016 20:17:13 +0000 (12:17 -0800)
Remove the broken legacy protocol-version handling from core and move it
to the legacy driver instead.

Note that version handling has always been broken as legacy protocols
were looked up and bound to connections before the connections were
enabled and version negotiation could take place (over that very
connection). Document that in the legacy driver as well.

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/connection.c
drivers/staging/greybus/connection.h
drivers/staging/greybus/legacy.c

index 7a967befc89734b40e17e427994d0fa9f58af3a3..ebd038ea6e8a9692c0a934b687b91d55f11fb08e 100644 (file)
@@ -120,8 +120,6 @@ gb_connection_create(struct gb_host_device *hd, int hd_cport_id,
        struct gb_connection *connection;
        struct ida *id_map = &hd->cport_id_map;
        int ida_start, ida_end;
-       u8 major = 0;
-       u8 minor = 1;
 
        /*
         * If a manifest tries to reuse a cport, reject it.  We
@@ -159,8 +157,6 @@ gb_connection_create(struct gb_host_device *hd, int hd_cport_id,
        connection->intf = intf;
 
        connection->protocol_id = protocol_id;
-       connection->major = major;
-       connection->minor = minor;
 
        connection->bundle = bundle;
        connection->state = GB_CONNECTION_STATE_DISABLED;
index 33deeb64dd29e002e4804965f74e46e10e2b468d..66f37b2f4a388c097d53c93f8c05478e033caad1 100644 (file)
@@ -39,8 +39,6 @@ struct gb_connection {
 
        struct gb_protocol              *protocol;
        u8                              protocol_id;
-       u8                              major;
-       u8                              minor;
        u8                              module_major;
        u8                              module_minor;
 
index a2c0b9bed9a9c8af3af99031cdb78556b5b3a98b..186482300682ff193f648d05bc1418a56009dc17 100644 (file)
@@ -30,15 +30,25 @@ static int legacy_connection_get_version(struct gb_connection *connection)
 static int legacy_connection_bind_protocol(struct gb_connection *connection)
 {
        struct gb_protocol *protocol;
+       u8 major, minor;
+
+       /*
+        * The legacy protocols have always been looked up using a hard-coded
+        * version of 0.1, despite (or perhaps rather, due to) the fact that
+        * module version negotiation could not take place until after the
+        * protocol was bound.
+        */
+       major = 0;
+       minor = 1;
 
        protocol = gb_protocol_get(connection->protocol_id,
-                                  connection->major,
-                                  connection->minor);
+                                  major,
+                                  minor);
        if (!protocol) {
                dev_err(&connection->hd->dev,
                                "protocol 0x%02x version %u.%u not found\n",
                                connection->protocol_id,
-                               connection->major, connection->minor);
+                               major, minor);
                return -EPROTONOSUPPORT;
        }
        connection->protocol = protocol;