From 1cb5fa47c54ba045593c4dfede72338107ba2133 Mon Sep 17 00:00:00 2001 From: Viresh Kumar Date: Wed, 12 Aug 2015 11:04:06 +0530 Subject: [PATCH] greybus: protocol: send own protocol version while requesting it 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 Signed-off-by: Greg Kroah-Hartman --- drivers/staging/greybus/connection.c | 14 +------------- drivers/staging/greybus/protocol.c | 28 +++++++++++----------------- drivers/staging/greybus/protocol.h | 2 +- 3 files changed, 13 insertions(+), 31 deletions(-) diff --git a/drivers/staging/greybus/connection.c b/drivers/staging/greybus/connection.c index eae6ad143d0b..27b64d6c8f2e 100644 --- a/drivers/staging/greybus/connection.c +++ b/drivers/staging/greybus/connection.c @@ -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", diff --git a/drivers/staging/greybus/protocol.c b/drivers/staging/greybus/protocol.c index 5bdc2c026efd..1c746597f016 100644 --- a/drivers/staging/greybus/protocol.c +++ b/drivers/staging/greybus/protocol.c @@ -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; } diff --git a/drivers/staging/greybus/protocol.h b/drivers/staging/greybus/protocol.h index 87b5a1010de0..8d55a4a2f06e 100644 --- a/drivers/staging/greybus/protocol.h +++ b/drivers/staging/greybus/protocol.h @@ -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); -- 2.20.1