Commit 738599c0 authored by Viresh Kumar's avatar Viresh Kumar Committed by Greg Kroah-Hartman

greybus: protocol: Create request structure from within gb_protocol_get_version()

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: default avatarViresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@google.com>
parent 3944a454
...@@ -421,7 +421,7 @@ int gb_connection_init(struct gb_connection *connection) ...@@ -421,7 +421,7 @@ int gb_connection_init(struct gb_connection *connection)
* this for SVC as that is initiated by the SVC. * this for SVC as that is initiated by the SVC.
*/ */
if (connection->hd_cport_id != GB_SVC_CPORT_ID) { 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) { if (ret) {
dev_err(&connection->dev, dev_err(&connection->dev,
"Failed to get version CPort-%d (%d)\n", "Failed to get version CPort-%d (%d)\n",
......
...@@ -163,12 +163,20 @@ struct gb_protocol *gb_protocol_get(u8 id, u8 major, u8 minor) ...@@ -163,12 +163,20 @@ struct gb_protocol *gb_protocol_get(u8 id, u8 major, u8 minor)
return protocol; return protocol;
} }
int gb_protocol_get_version(struct gb_connection *connection, void *request, int gb_protocol_get_version(struct gb_connection *connection, bool send_request)
int request_size)
{ {
struct gb_protocol_version_response response; struct gb_protocol_version_response response;
struct gb_protocol_version_response *request = NULL;
int request_size = 0;
int retval; 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, retval = gb_operation_sync(connection, GB_REQUEST_TYPE_PROTOCOL_VERSION,
request, request_size, &response, request, request_size, &response,
sizeof(response)); sizeof(response));
......
...@@ -44,8 +44,7 @@ int gb_protocol_deregister(struct gb_protocol *protocol); ...@@ -44,8 +44,7 @@ int gb_protocol_deregister(struct gb_protocol *protocol);
__gb_protocol_register(protocol, THIS_MODULE) __gb_protocol_register(protocol, THIS_MODULE)
struct gb_protocol *gb_protocol_get(u8 id, u8 major, u8 minor); struct gb_protocol *gb_protocol_get(u8 id, u8 major, u8 minor);
int gb_protocol_get_version(struct gb_connection *connection, void *request, int gb_protocol_get_version(struct gb_connection *connection, bool send_request);
int request_size);
void gb_protocol_put(struct gb_protocol *protocol); void gb_protocol_put(struct gb_protocol *protocol);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment