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

greybus: rework receve handling

Rework gb_connection_operation_recv() to be more oriented toward an
operation message, and to no longer use a struct gbuf local variable.
Rename it to be a little more wieldy.
Signed-off-by: default avatarAlex Elder <elder@linaro.org>
Signed-off-by: default avatarGreg Kroah-Hartman <greg@kroah.com>
parent 35b1342b
...@@ -40,7 +40,7 @@ void greybus_cport_in(struct greybus_host_device *hd, u16 cport_id, ...@@ -40,7 +40,7 @@ void greybus_cport_in(struct greybus_host_device *hd, u16 cport_id,
"nonexistent connection (%zu bytes dropped)\n", length); "nonexistent connection (%zu bytes dropped)\n", length);
return; return;
} }
gb_connection_operation_recv(connection, data, length); gb_connection_recv(connection, data, length);
} }
EXPORT_SYMBOL_GPL(greybus_cport_in); EXPORT_SYMBOL_GPL(greybus_cport_in);
......
...@@ -431,12 +431,12 @@ int gb_operation_response_send(struct gb_operation *operation) ...@@ -431,12 +431,12 @@ int gb_operation_response_send(struct gb_operation *operation)
* data into the buffer and do remaining handling via a work queue. * data into the buffer and do remaining handling via a work queue.
* *
*/ */
void gb_connection_operation_recv(struct gb_connection *connection, void gb_connection_recv(struct gb_connection *connection,
void *data, size_t size) void *data, size_t size)
{ {
struct gb_operation_msg_hdr *header; struct gb_operation_msg_hdr *header;
struct gb_operation *operation; struct gb_operation *operation;
struct gbuf *gbuf; struct gb_message *message;
u16 msg_size; u16 msg_size;
if (connection->state != GB_CONNECTION_STATE_ENABLED) if (connection->state != GB_CONNECTION_STATE_ENABLED)
...@@ -459,8 +459,8 @@ void gb_connection_operation_recv(struct gb_connection *connection, ...@@ -459,8 +459,8 @@ void gb_connection_operation_recv(struct gb_connection *connection,
} }
cancel_delayed_work(&operation->timeout_work); cancel_delayed_work(&operation->timeout_work);
gb_pending_operation_remove(operation); gb_pending_operation_remove(operation);
gbuf = &operation->response.gbuf; message = &operation->response;
if (size > gbuf->transfer_buffer_length) { if (size > message->gbuf.transfer_buffer_length) {
operation->result = GB_OP_OVERFLOW; operation->result = GB_OP_OVERFLOW;
gb_connection_err(connection, "recv buffer too small"); gb_connection_err(connection, "recv buffer too small");
return; return;
...@@ -474,10 +474,10 @@ void gb_connection_operation_recv(struct gb_connection *connection, ...@@ -474,10 +474,10 @@ void gb_connection_operation_recv(struct gb_connection *connection,
gb_connection_err(connection, "can't create operation"); gb_connection_err(connection, "can't create operation");
return; return;
} }
gbuf = &operation->request.gbuf; message = &operation->request;
} }
memcpy(gbuf->transfer_buffer, data, msg_size); memcpy(message->gbuf.transfer_buffer, data, msg_size);
/* The rest will be handled in work queue context */ /* The rest will be handled in work queue context */
queue_work(gb_operation_recv_workqueue, &operation->recv_work); queue_work(gb_operation_recv_workqueue, &operation->recv_work);
......
...@@ -87,7 +87,7 @@ struct gb_operation { ...@@ -87,7 +87,7 @@ struct gb_operation {
struct list_head links; /* connection->{operations,pending} */ struct list_head links; /* connection->{operations,pending} */
}; };
void gb_connection_operation_recv(struct gb_connection *connection, void gb_connection_recv(struct gb_connection *connection,
void *data, size_t size); void *data, size_t size);
struct gb_operation *gb_operation_create(struct gb_connection *connection, struct gb_operation *gb_operation_create(struct gb_connection *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