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

greybus: distinguish incoming from outgoing requests

When we remove the mandatory status byte from response messages we
will no longer be able to use a zero-sized response to indicate
an operation is to be used for an incoming request.

Define a new function gb_operation_create_incoming() to be used
for incoming operations.  Change (and rename) gb_operation_create()
to be a helper that takes a Boolean to indicate which type is to be
created, and use a simple wrapper to expose the outgoing operation
creation routine.
Signed-off-by: default avatarAlex Elder <elder@linaro.org>
Signed-off-by: default avatarGreg Kroah-Hartman <greg@kroah.com>
parent dcec19fb
...@@ -294,13 +294,13 @@ static void gb_operation_message_exit(struct gb_message *message) ...@@ -294,13 +294,13 @@ static void gb_operation_message_exit(struct gb_message *message)
* Returns a pointer to the new operation or a null pointer if an * Returns a pointer to the new operation or a null pointer if an
* error occurs. * error occurs.
*/ */
struct gb_operation *gb_operation_create(struct gb_connection *connection, static struct gb_operation *
u8 type, size_t request_size, gb_operation_create_common(struct gb_connection *connection, bool outgoing,
size_t response_size) u8 type, size_t request_size,
size_t response_size)
{ {
struct gb_operation *operation; struct gb_operation *operation;
gfp_t gfp_flags = response_size ? GFP_KERNEL : GFP_ATOMIC; gfp_t gfp_flags = response_size ? GFP_KERNEL : GFP_ATOMIC;
bool outgoing = response_size != 0;
int ret; int ret;
operation = kmem_cache_zalloc(gb_operation_cache, gfp_flags); operation = kmem_cache_zalloc(gb_operation_cache, gfp_flags);
...@@ -340,6 +340,23 @@ struct gb_operation *gb_operation_create(struct gb_connection *connection, ...@@ -340,6 +340,23 @@ struct gb_operation *gb_operation_create(struct gb_connection *connection,
return NULL; return NULL;
} }
struct gb_operation *gb_operation_create(struct gb_connection *connection,
u8 type, size_t request_size,
size_t response_size)
{
return gb_operation_create_common(connection, true, type,
request_size, response_size);
}
static struct gb_operation *
gb_operation_create_incoming(struct gb_connection *connection,
u8 type, size_t request_size,
size_t response_size)
{
return gb_operation_create_common(connection, false, type,
request_size, response_size);
}
/* /*
* Destroy a previously created operation. * Destroy a previously created operation.
*/ */
...@@ -427,7 +444,7 @@ void gb_connection_recv_request(struct gb_connection *connection, ...@@ -427,7 +444,7 @@ void gb_connection_recv_request(struct gb_connection *connection,
{ {
struct gb_operation *operation; struct gb_operation *operation;
operation = gb_operation_create(connection, type, size, 0); operation = gb_operation_create_incoming(connection, type, size, 0);
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 */
......
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