diff options
author | Johan Hovold <johan@hovoldconsulting.com> | 2016-01-08 20:13:45 +0100 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@google.com> | 2016-01-12 18:17:35 -0800 |
commit | 4d0bee11253ba98c4a9c9ebb6df19c3185fe1fd8 (patch) | |
tree | fb6c3e55805f450a15225834ae683b05c93d774a | |
parent | 2c92bd5235ac72aa659150ebac309dd4f1c01079 (diff) | |
download | linux-stable-4d0bee11253ba98c4a9c9ebb6df19c3185fe1fd8.tar.gz linux-stable-4d0bee11253ba98c4a9c9ebb6df19c3185fe1fd8.tar.bz2 linux-stable-4d0bee11253ba98c4a9c9ebb6df19c3185fe1fd8.zip |
greybus: connection: fix connection-state handling
Set connection state to ENABLE before sending the control connected
message, and set state DISABLE after sending the control disconnected
event.
Remove the now unused ERROR connection state.
Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
-rw-r--r-- | drivers/staging/greybus/connection.c | 21 | ||||
-rw-r--r-- | drivers/staging/greybus/connection.h | 3 |
2 files changed, 14 insertions, 10 deletions
diff --git a/drivers/staging/greybus/connection.c b/drivers/staging/greybus/connection.c index b356ee0575e2..1cb33147aa00 100644 --- a/drivers/staging/greybus/connection.c +++ b/drivers/staging/greybus/connection.c @@ -403,15 +403,14 @@ int gb_connection_init(struct gb_connection *connection) if (ret) goto err_hd_cport_disable; - ret = gb_connection_control_connected(connection); - if (ret) - goto err_svc_destroy; - - /* Need to enable the connection to initialize it */ spin_lock_irq(&connection->lock); connection->state = GB_CONNECTION_STATE_ENABLED; spin_unlock_irq(&connection->lock); + ret = gb_connection_control_connected(connection); + if (ret) + goto err_svc_destroy; + ret = gb_connection_protocol_get_version(connection); if (ret) goto err_disconnect; @@ -423,11 +422,11 @@ int gb_connection_init(struct gb_connection *connection) return 0; err_disconnect: + gb_connection_control_disconnected(connection); + spin_lock_irq(&connection->lock); - connection->state = GB_CONNECTION_STATE_ERROR; + connection->state = GB_CONNECTION_STATE_DISABLED; spin_unlock_irq(&connection->lock); - - gb_connection_control_disconnected(connection); err_svc_destroy: gb_connection_svc_connection_destroy(connection); err_hd_cport_disable: @@ -451,7 +450,13 @@ void gb_connection_exit(struct gb_connection *connection) gb_connection_cancel_operations(connection, -ESHUTDOWN); connection->protocol->connection_exit(connection); + gb_connection_control_disconnected(connection); + + spin_lock_irq(&connection->lock); + connection->state = GB_CONNECTION_STATE_DISABLED; + spin_unlock_irq(&connection->lock); + gb_connection_svc_connection_destroy(connection); gb_connection_hd_cport_disable(connection); gb_connection_unbind_protocol(connection); diff --git a/drivers/staging/greybus/connection.h b/drivers/staging/greybus/connection.h index b795b44c1859..ef31c8d6dfe0 100644 --- a/drivers/staging/greybus/connection.h +++ b/drivers/staging/greybus/connection.h @@ -17,8 +17,7 @@ enum gb_connection_state { GB_CONNECTION_STATE_INVALID = 0, GB_CONNECTION_STATE_DISABLED = 1, GB_CONNECTION_STATE_ENABLED = 2, - GB_CONNECTION_STATE_ERROR = 3, - GB_CONNECTION_STATE_DESTROYING = 4, + GB_CONNECTION_STATE_DESTROYING = 3, }; struct gb_connection { |