summaryrefslogtreecommitdiff
path: root/drivers/staging/greybus/operation.c
diff options
context:
space:
mode:
authorJohan Hovold <johan@hovoldconsulting.com>2016-05-27 17:26:34 +0200
committerGreg Kroah-Hartman <gregkh@google.com>2016-05-27 12:21:16 -0700
commit77bbbcf6d36d7ef2054a8b0dc8396cc0f092945e (patch)
tree1421f225d90d84444b716b95dbf76480f3e9e790 /drivers/staging/greybus/operation.c
parent8890f95710d835ba9f843c7dd849858da1d847d8 (diff)
greybus: operation: restructure activation state handling
Restructure the operation activation state handling in preparation for a new disconnecting state. 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.c19
1 files changed, 14 insertions, 5 deletions
diff --git a/drivers/staging/greybus/operation.c b/drivers/staging/greybus/operation.c
index aaa1345b19d9..75d1231cfde5 100644
--- a/drivers/staging/greybus/operation.c
+++ b/drivers/staging/greybus/operation.c
@@ -47,11 +47,15 @@ static int gb_operation_get_active(struct gb_operation *operation)
spin_lock_irqsave(&connection->lock, flags);
- 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;
+ switch (connection->state) {
+ case GB_CONNECTION_STATE_ENABLED:
+ break;
+ case GB_CONNECTION_STATE_ENABLED_TX:
+ if (gb_operation_is_incoming(operation))
+ goto err_unlock;
+ break;
+ default:
+ goto err_unlock;
}
if (operation->active++ == 0)
@@ -62,6 +66,11 @@ static int gb_operation_get_active(struct gb_operation *operation)
spin_unlock_irqrestore(&connection->lock, flags);
return 0;
+
+err_unlock:
+ spin_unlock_irqrestore(&connection->lock, flags);
+
+ return -ENOTCONN;
}
/* Caller holds operation reference. */