greybus: protocol: send own protocol version while requesting it
authorViresh Kumar <viresh.kumar@linaro.org>
Wed, 12 Aug 2015 05:34:06 +0000 (11:04 +0530)
committerGreg Kroah-Hartman <gregkh@google.com>
Thu, 13 Aug 2015 03:55:01 +0000 (20:55 -0700)
The greybus specifications clearly say (for all protocols) that the
sender is responsible for sending the highest version of protocol it
supports, while it requests the same from the receiver.

But the greybus code never followed that.

Fix, this by always sending AP's version of the protocol, while
requesting the same from svc/module.

This also renames 'response' to 'version' in gb_protocol_get_version()
as it is used for both request/response.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
drivers/staging/greybus/connection.c
drivers/staging/greybus/protocol.c
drivers/staging/greybus/protocol.h

index eae6ad1..27b64d6 100644 (file)
@@ -428,19 +428,7 @@ int gb_connection_init(struct gb_connection *connection)
         * this for SVC as that is initiated by the SVC.
         */
        if (connection->hd_cport_id != GB_SVC_CPORT_ID) {
-               bool send_request = false;
-
-               /*
-                * We need to send the protocol version of the firmware protocol
-                * supported by AP and so this special case.
-                */
-               if (connection->protocol->id == GREYBUS_PROTOCOL_FIRMWARE)
-                       send_request = true;
-
-               // FIXME: Should we always send the protocol version AP can
-               // support ?
-
-               ret = gb_protocol_get_version(connection, send_request);
+               ret = gb_protocol_get_version(connection);
                if (ret) {
                        dev_err(&connection->dev,
                                "Failed to get version CPort-%d (%d)\n",
index 5bdc2c0..1c74659 100644 (file)
@@ -163,38 +163,32 @@ struct gb_protocol *gb_protocol_get(u8 id, u8 major, u8 minor)
        return protocol;
 }
 
-int gb_protocol_get_version(struct gb_connection *connection, bool send_request)
+int gb_protocol_get_version(struct gb_connection *connection)
 {
-       struct gb_protocol_version_response response;
-       struct gb_protocol_version_response *request = NULL;
-       int request_size = 0;
+       struct gb_protocol_version_response version;
        int retval;
 
-       if (send_request) {
-               response.major = connection->protocol->major;
-               response.minor = connection->protocol->minor;
-               request = &response;
-               request_size = sizeof(*request);
-       }
+       version.major = connection->protocol->major;
+       version.minor = connection->protocol->minor;
 
        retval = gb_operation_sync(connection, GB_REQUEST_TYPE_PROTOCOL_VERSION,
-                                  request, request_size, &response,
-                                  sizeof(response));
+                                  &version, sizeof(version), &version,
+                                  sizeof(version));
        if (retval)
                return retval;
 
-       if (response.major > connection->protocol->major) {
+       if (version.major > connection->protocol->major) {
                dev_err(&connection->dev,
                        "unsupported major version (%hhu > %hhu)\n",
-                       response.major, connection->protocol->major);
+                       version.major, connection->protocol->major);
                return -ENOTSUPP;
        }
 
-       connection->module_major = response.major;
-       connection->module_minor = response.minor;
+       connection->module_major = version.major;
+       connection->module_minor = version.minor;
 
        dev_dbg(&connection->dev, "version_major = %u version_minor = %u\n",
-               response.major, response.minor);
+               version.major, version.minor);
 
        return 0;
 }
index 87b5a10..8d55a4a 100644 (file)
@@ -44,7 +44,7 @@ int gb_protocol_deregister(struct gb_protocol *protocol);
        __gb_protocol_register(protocol, THIS_MODULE)
 
 struct gb_protocol *gb_protocol_get(u8 id, u8 major, u8 minor);
-int gb_protocol_get_version(struct gb_connection *connection, bool send_request);
+int gb_protocol_get_version(struct gb_connection *connection);
 
 void gb_protocol_put(struct gb_protocol *protocol);