Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

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

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
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -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",
+10 −2
Original line number Diff line number Diff line
@@ -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));
+1 −2
Original line number Diff line number Diff line
@@ -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);