Commit 1cb5fa47 authored by Viresh Kumar's avatar Viresh Kumar Committed by Greg Kroah-Hartman

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: default avatarViresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@google.com>
parent d706ef8f
......@@ -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",
......
......@@ -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;
}
......
......@@ -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);
......
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