Commit 77bbbcf6 authored by Johan Hovold's avatar Johan Hovold Committed by Greg Kroah-Hartman

greybus: operation: restructure activation state handling

Restructure the operation activation state handling in preparation for a
new disconnecting state.
Signed-off-by: default avatarJohan Hovold <johan@hovoldconsulting.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@google.com>
parent 8890f957
...@@ -47,11 +47,15 @@ static int gb_operation_get_active(struct gb_operation *operation) ...@@ -47,11 +47,15 @@ static int gb_operation_get_active(struct gb_operation *operation)
spin_lock_irqsave(&connection->lock, flags); spin_lock_irqsave(&connection->lock, flags);
if (connection->state != GB_CONNECTION_STATE_ENABLED && switch (connection->state) {
(connection->state != GB_CONNECTION_STATE_ENABLED_TX || case GB_CONNECTION_STATE_ENABLED:
gb_operation_is_incoming(operation))) { break;
spin_unlock_irqrestore(&connection->lock, flags); case GB_CONNECTION_STATE_ENABLED_TX:
return -ENOTCONN; if (gb_operation_is_incoming(operation))
goto err_unlock;
break;
default:
goto err_unlock;
} }
if (operation->active++ == 0) if (operation->active++ == 0)
...@@ -62,6 +66,11 @@ static int gb_operation_get_active(struct gb_operation *operation) ...@@ -62,6 +66,11 @@ static int gb_operation_get_active(struct gb_operation *operation)
spin_unlock_irqrestore(&connection->lock, flags); spin_unlock_irqrestore(&connection->lock, flags);
return 0; return 0;
err_unlock:
spin_unlock_irqrestore(&connection->lock, flags);
return -ENOTCONN;
} }
/* Caller holds operation reference. */ /* Caller holds operation reference. */
......
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