Commit 81fba249 authored by Johan Hovold's avatar Johan Hovold Committed by Greg Kroah-Hartman

greybus: connection: always cancel operations on connection disable

Always cancel all operations on connection disable and remove the now
unused DESTROYING state.
Reviewed-by: default avatarViresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: default avatarJohan Hovold <johan@hovoldconsulting.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@google.com>
parent bfa9a5e2
...@@ -426,12 +426,17 @@ EXPORT_SYMBOL_GPL(gb_connection_enable); ...@@ -426,12 +426,17 @@ EXPORT_SYMBOL_GPL(gb_connection_enable);
void gb_connection_disable(struct gb_connection *connection) void gb_connection_disable(struct gb_connection *connection)
{ {
if (connection->state == GB_CONNECTION_STATE_DISABLED)
return;
gb_connection_control_disconnected(connection); gb_connection_control_disconnected(connection);
spin_lock_irq(&connection->lock); spin_lock_irq(&connection->lock);
connection->state = GB_CONNECTION_STATE_DISABLED; connection->state = GB_CONNECTION_STATE_DISABLED;
spin_unlock_irq(&connection->lock); spin_unlock_irq(&connection->lock);
gb_connection_cancel_operations(connection, -ESHUTDOWN);
gb_connection_svc_connection_destroy(connection); gb_connection_svc_connection_destroy(connection);
gb_connection_hd_cport_disable(connection); gb_connection_hd_cport_disable(connection);
} }
...@@ -483,19 +488,13 @@ EXPORT_SYMBOL_GPL(gb_connection_legacy_init); ...@@ -483,19 +488,13 @@ EXPORT_SYMBOL_GPL(gb_connection_legacy_init);
void gb_connection_legacy_exit(struct gb_connection *connection) void gb_connection_legacy_exit(struct gb_connection *connection)
{ {
spin_lock_irq(&connection->lock); if (connection->state == GB_CONNECTION_STATE_DISABLED)
if (connection->state != GB_CONNECTION_STATE_ENABLED) {
spin_unlock_irq(&connection->lock);
return; return;
}
connection->state = GB_CONNECTION_STATE_DESTROYING;
spin_unlock_irq(&connection->lock);
gb_connection_cancel_operations(connection, -ESHUTDOWN);
connection->protocol->connection_exit(connection);
gb_connection_disable(connection); gb_connection_disable(connection);
connection->protocol->connection_exit(connection);
gb_connection_unbind_protocol(connection); gb_connection_unbind_protocol(connection);
} }
EXPORT_SYMBOL_GPL(gb_connection_legacy_exit); EXPORT_SYMBOL_GPL(gb_connection_legacy_exit);
......
...@@ -17,7 +17,6 @@ enum gb_connection_state { ...@@ -17,7 +17,6 @@ enum gb_connection_state {
GB_CONNECTION_STATE_INVALID = 0, GB_CONNECTION_STATE_INVALID = 0,
GB_CONNECTION_STATE_DISABLED = 1, GB_CONNECTION_STATE_DISABLED = 1,
GB_CONNECTION_STATE_ENABLED = 2, GB_CONNECTION_STATE_ENABLED = 2,
GB_CONNECTION_STATE_DESTROYING = 3,
}; };
struct gb_operation; struct gb_operation;
......
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