Commit dcec19fb authored by Alex Elder's avatar Alex Elder Committed by Greg Kroah-Hartman

greybus: get rid of uart request_operation()

In "uart-gb.c", request_operation() function is only used by
get_version().  Since it's not reused, it probably subtracts
rather than adds value.  So just incorporate what it does
into get_version() and get rid of request_operation().
Signed-off-by: default avatarAlex Elder <elder@linaro.org>
Signed-off-by: default avatarGreg Kroah-Hartman <greg@kroah.com>
parent 980c7c50
...@@ -136,15 +136,19 @@ static DEFINE_IDR(tty_minors); ...@@ -136,15 +136,19 @@ static DEFINE_IDR(tty_minors);
static DEFINE_MUTEX(table_lock); static DEFINE_MUTEX(table_lock);
static atomic_t reference_count = ATOMIC_INIT(0); static atomic_t reference_count = ATOMIC_INIT(0);
/*
static int request_operation(struct gb_connection *connection, int type, * This request only uses the connection field, and if successful,
void *response, int response_size) * fills in the major and minor protocol version of the target.
*/
static int get_version(struct gb_tty *tty)
{ {
struct gb_operation *operation; struct gb_operation *operation;
struct gb_uart_simple_response *fake_response; struct gb_uart_proto_version_response *response;
int ret; int ret;
operation = gb_operation_create(connection, type, 0, response_size); operation = gb_operation_create(tty->connection,
GB_UART_REQ_PROTOCOL_VERSION,
0, sizeof(*response));
if (!operation) if (!operation)
return -ENOMEM; return -ENOMEM;
...@@ -155,20 +159,23 @@ static int request_operation(struct gb_connection *connection, int type, ...@@ -155,20 +159,23 @@ static int request_operation(struct gb_connection *connection, int type,
goto out; goto out;
} }
/* response = operation->response.payload;
* We only want to look at the status, and all requests have the same if (response->status) {
* layout for where the status is, so cast this to a random request so gb_connection_err(tty->connection, "response %hhu",
* we can see the status easier. response->status);
*/
fake_response = operation->response.payload;
if (fake_response->status) {
gb_connection_err(connection, "response %hhu",
fake_response->status);
ret = -EIO; ret = -EIO;
} else { } else {
/* Good request, so copy to the caller's buffer */ if (response->major > GB_UART_VERSION_MAJOR) {
if (response_size && response) pr_err("unsupported major version (%hhu > %hhu)\n",
memcpy(response, fake_response, response_size); response->major, GB_UART_VERSION_MAJOR);
ret = -ENOTSUPP;
goto out;
}
tty->version_major = response->major;
tty->version_minor = response->minor;
pr_debug("%s: version_major = %u version_minor = %u\n",
__func__, tty->version_major, tty->version_minor);
} }
out: out:
gb_operation_destroy(operation); gb_operation_destroy(operation);
...@@ -176,32 +183,6 @@ static int request_operation(struct gb_connection *connection, int type, ...@@ -176,32 +183,6 @@ static int request_operation(struct gb_connection *connection, int type,
return ret; return ret;
} }
/*
* This request only uses the connection field, and if successful,
* fills in the major and minor protocol version of the target.
*/
static int get_version(struct gb_tty *tty)
{
struct gb_uart_proto_version_response version_response;
int retval;
retval = request_operation(tty->connection,
GB_UART_REQ_PROTOCOL_VERSION,
&version_response, sizeof(version_response));
if (retval)
return retval;
if (version_response.major > GB_UART_VERSION_MAJOR) {
pr_err("unsupported major version (%hhu > %hhu)\n",
version_response.major, GB_UART_VERSION_MAJOR);
return -ENOTSUPP;
}
tty->version_major = version_response.major;
tty->version_minor = version_response.minor;
return 0;
}
static int send_data(struct gb_tty *tty, u16 size, const u8 *data) static int send_data(struct gb_tty *tty, u16 size, const u8 *data)
{ {
struct gb_connection *connection = tty->connection; struct gb_connection *connection = tty->connection;
......
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