greybus: connection: destroy workqueue at unregister
authorJohan Hovold <johan@hovoldconsulting.com>
Tue, 19 Jan 2016 11:51:23 +0000 (12:51 +0100)
committerGreg Kroah-Hartman <gregkh@google.com>
Tue, 19 Jan 2016 20:17:13 +0000 (12:17 -0800)
commitc3681f6c92df6c4ec834fc8e3fa1905e73952630
treea10e6735badd6039c729bc69eb894a14ec5cae5b
parent2edbf5ffbf5ef8b92518e57687e96a7d34ddd3c4
greybus: connection: destroy workqueue at unregister

Destroy the work queue when the connection is destroyed/deregistered
instead of when the last reference is dropped.

The work queue is not needed once the connection has been deregistered,
and no operations will ever be added to it again (handled by checking
connection->state) even if the connection object may not be deallocated
until the final reference is dropped.

The work-queue name is set based on the host-device name and host-device
cport id, something which guarantees a unique name. This would no longer
be true if the work queue was not destroyed at connection deregistration
as a new connection could then be created for that very same host cport.

This is not necessarily a problem unless some work queue features are
used that require unique work-queue names, but let's try to be well
behaved.

Also update an obsolete comment and make explicit that a connection must
be disabled before being destroyed.

Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
drivers/staging/greybus/connection.c