1
0
Fork 0

greybus: move copy of incoming request data

Currently incoming request data is copied into a request message
buffer in gb_connection_recv_request().  Move that--along with the
assignment of the message id--into gb_operation_create_incoming().

Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
hifive-unleashed-5.1
Alex Elder 2014-12-02 08:30:28 -06:00 committed by Greg Kroah-Hartman
parent 85a0442893
commit 34db1f91e6
1 changed files with 14 additions and 7 deletions

View File

@ -465,11 +465,19 @@ struct gb_operation *gb_operation_create(struct gb_connection *connection,
static struct gb_operation * static struct gb_operation *
gb_operation_create_incoming(struct gb_connection *connection, gb_operation_create_incoming(struct gb_connection *connection,
u8 type, size_t request_size, u16 operation_id, u8 type,
size_t response_size) void *data, size_t request_size)
{ {
return gb_operation_create_common(connection, false, type, struct gb_operation *operation;
request_size, response_size);
operation = gb_operation_create_common(connection, false, type,
request_size, 0);
if (operation) {
operation->id = operation_id;
memcpy(operation->request->header, data, request_size);
}
return operation;
} }
/* /*
@ -622,13 +630,12 @@ static void gb_connection_recv_request(struct gb_connection *connection,
{ {
struct gb_operation *operation; struct gb_operation *operation;
operation = gb_operation_create_incoming(connection, type, size, 0); operation = gb_operation_create_incoming(connection, operation_id,
type, data, size);
if (!operation) { if (!operation) {
gb_connection_err(connection, "can't create operation"); gb_connection_err(connection, "can't create operation");
return; /* XXX Respond with pre-allocated ENOMEM */ return; /* XXX Respond with pre-allocated ENOMEM */
} }
operation->id = operation_id;
memcpy(operation->request->header, data, size);
/* XXX Right now this will just complete the operation */ /* XXX Right now this will just complete the operation */
if (gb_operation_result_set(operation, -ENOSYS)) if (gb_operation_result_set(operation, -ENOSYS))