greybus: improve module cleanup code

When a module gets destroyed all of its state and the state of its
interfaces and connections (etc.) need to be torn down.  This is
not now being done properly.  Add this teardown code.

Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
diff --git a/drivers/staging/greybus/interface.c b/drivers/staging/greybus/interface.c
index 0c2fdd3..645f05b 100644
--- a/drivers/staging/greybus/interface.c
+++ b/drivers/staging/greybus/interface.c
@@ -54,6 +54,8 @@
 	list_del(&interface->links);
 	spin_unlock_irq(&gb_interfaces_lock);
 
+	gb_interface_connections_exit(interface);
+
 	/* kref_put(gmod); */
 	kfree(interface);
 }
@@ -72,3 +74,15 @@
 
 	return ret;
 }
+
+void gb_interface_connections_exit(struct gb_interface *interface)
+{
+	struct gb_connection *connection;
+	struct gb_connection *next;
+
+	list_for_each_entry_safe(connection, next, &interface->connections,
+			interface_links) {
+		gb_connection_exit(connection);
+		gb_connection_destroy(connection);
+	}
+}