Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Johan Hovold and committed by
Greg Kroah-Hartman
77bbbcf6 8890f957

+14 -5
+14 -5
drivers/staging/greybus/operation.c
··· 47 47 48 48 spin_lock_irqsave(&connection->lock, flags); 49 49 50 - if (connection->state != GB_CONNECTION_STATE_ENABLED && 51 - (connection->state != GB_CONNECTION_STATE_ENABLED_TX || 52 - gb_operation_is_incoming(operation))) { 53 - spin_unlock_irqrestore(&connection->lock, flags); 54 - return -ENOTCONN; 50 + switch (connection->state) { 51 + case GB_CONNECTION_STATE_ENABLED: 52 + break; 53 + case GB_CONNECTION_STATE_ENABLED_TX: 54 + if (gb_operation_is_incoming(operation)) 55 + goto err_unlock; 56 + break; 57 + default: 58 + goto err_unlock; 55 59 } 56 60 57 61 if (operation->active++ == 0) ··· 66 62 spin_unlock_irqrestore(&connection->lock, flags); 67 63 68 64 return 0; 65 + 66 + err_unlock: 67 + spin_unlock_irqrestore(&connection->lock, flags); 68 + 69 + return -ENOTCONN; 69 70 } 70 71 71 72 /* Caller holds operation reference. */