greybus: loopback: Wait for all async operations to complete on exit
authorBryan O'Donoghue <bryan.odonoghue@linaro.org>
Fri, 11 Dec 2015 13:46:52 +0000 (13:46 +0000)
committerGreg Kroah-Hartman <gregkh@google.com>
Sat, 12 Dec 2015 00:18:34 +0000 (16:18 -0800)
commit36f241fff4720f205e36bda5900d4ef7b6662bd7
tree3acd4559d588c7da11931ab5747856f24bb310cc
parentc7aae4e613ef471f9f785e4b85de4d46d552c86b
greybus: loopback: Wait for all async operations to complete on exit

On gb_loopback_connection_exit() we should ensure every issued asynchronous
operation completes before exiting connection_exit(). This patch introduces
a waitqueue with a counter which represents the number of incomplete
asynchronous operations. When the counter reaches zero connection_exit()
will complete. At the point which we wait for outstanding operations to
complete the connection-specific loopback thread will have ceased to issue
new operations. Tested with both synchronous and asynchronous operations.

Reviewed-by: Johan Hovold <johan@hovoldconsulting.com>
Suggested-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
drivers/staging/greybus/loopback.c