OSDN Git Service

greybus: protocol: Create request structure from within gb_protocol_get_version()
authorViresh Kumar <viresh.kumar@linaro.org>
Wed, 12 Aug 2015 03:49:32 +0000 (09:19 +0530)
committerGreg Kroah-Hartman <gregkh@google.com>
Wed, 12 Aug 2015 04:57:12 +0000 (21:57 -0700)
The version request can only send the version of protocol for which it
is initiated and gb_protocol_get_version() has all the information to
create the request structure.

Replace the 'request' and 'request_size' arguments to
gb_protocol_get_version() with a bool to know if the version information
of the protocol should be sent or not.

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 0ec5b0d..2b2be3f 100644 (file)
@@ -421,7 +421,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) {
-               ret = gb_protocol_get_version(connection, NULL, 0);
+               ret = gb_protocol_get_version(connection, false);
                if (ret) {
                        dev_err(&connection->dev,
                                "Failed to get version CPort-%d (%d)\n",
index b63e28c..5bdc2c0 100644 (file)
@@ -163,12 +163,20 @@ struct gb_protocol *gb_protocol_get(u8 id, u8 major, u8 minor)
        return protocol;
 }
 
-int gb_protocol_get_version(struct gb_connection *connection, void *request,
-                           int request_size)
+int gb_protocol_get_version(struct gb_connection *connection, bool send_request)
 {
        struct gb_protocol_version_response response;
+       struct gb_protocol_version_response *request = NULL;
+       int request_size = 0;
        int retval;
 
+       if (send_request) {
+               response.major = connection->protocol->major;
+               response.minor = connection->protocol->minor;
+               request = &response;
+               request_size = sizeof(*request);
+       }
+
        retval = gb_operation_sync(connection, GB_REQUEST_TYPE_PROTOCOL_VERSION,
                                   request, request_size, &response,
                                   sizeof(response));
index 34a7f18..87b5a10 100644 (file)
@@ -44,8 +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, void *request,
-                           int request_size);
+int gb_protocol_get_version(struct gb_connection *connection, bool send_request);
 
 void gb_protocol_put(struct gb_protocol *protocol);