summaryrefslogtreecommitdiff
path: root/drivers/staging/greybus/operation.c
diff options
context:
space:
mode:
authorJohan Hovold <johan@hovoldconsulting.com>2016-01-19 12:51:07 +0100
committerGreg Kroah-Hartman <gregkh@google.com>2016-01-19 12:12:40 -0800
commit570dfa7c55a76258b03a2d93f9db12dacc2ad3c6 (patch)
treeb4b4f11f9c7b0e86577909d615baa8256959eb28 /drivers/staging/greybus/operation.c
parent23268785b288c25ab5ee2ec523982546b5353880 (diff)
greybus: connection: add unidirectional enabled state
Add a new connection state ENABLED_TX in which only outgoing operations are allowed. This allows drivers to query the device during probe before allocating their state containers without having to worry about racing incoming requests. Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org> Signed-off-by: Johan Hovold <johan@hovoldconsulting.com> Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Diffstat (limited to 'drivers/staging/greybus/operation.c')
-rw-r--r--drivers/staging/greybus/operation.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/drivers/staging/greybus/operation.c b/drivers/staging/greybus/operation.c
index 4dc79cb12397..d6b3d1f22b28 100644
--- a/drivers/staging/greybus/operation.c
+++ b/drivers/staging/greybus/operation.c
@@ -47,7 +47,9 @@ static int gb_operation_get_active(struct gb_operation *operation)
spin_lock_irqsave(&connection->lock, flags);
- if (connection->state != GB_CONNECTION_STATE_ENABLED) {
+ if (connection->state != GB_CONNECTION_STATE_ENABLED &&
+ connection->state != GB_CONNECTION_STATE_ENABLED_TX &&
+ !gb_operation_is_incoming(operation)) {
spin_unlock_irqrestore(&connection->lock, flags);
return -ENOTCONN;
}
@@ -906,7 +908,8 @@ void gb_connection_recv(struct gb_connection *connection,
size_t msg_size;
u16 operation_id;
- if (connection->state != GB_CONNECTION_STATE_ENABLED) {
+ if (connection->state != GB_CONNECTION_STATE_ENABLED &&
+ connection->state != GB_CONNECTION_STATE_ENABLED_TX) {
dev_warn(dev, "%s: dropping %zu received bytes\n",
connection->name, size);
return;