greybus: interface: move interface-removal helper

Move helper to remove all interfaces of a host-device to the svc code
and call it when removing the svc device as this needs to be coordinated
with flushing the SVC work queue.

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Reviewed-by: Jeffrey Carlyle <jcarlyle@google.com>
Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
diff --git a/drivers/staging/greybus/svc.c b/drivers/staging/greybus/svc.c
index 572ed0e..446cb25 100644
--- a/drivers/staging/greybus/svc.c
+++ b/drivers/staging/greybus/svc.c
@@ -997,6 +997,14 @@
 	return 0;
 }
 
+static void gb_svc_remove_interfaces(struct gb_svc *svc)
+{
+	struct gb_interface *intf, *tmp;
+
+	list_for_each_entry_safe(intf, tmp, &svc->hd->interfaces, links)
+		gb_interface_remove(intf);
+}
+
 void gb_svc_del(struct gb_svc *svc)
 {
 	gb_connection_disable(svc->connection);
@@ -1012,6 +1020,8 @@
 	}
 
 	flush_workqueue(svc->wq);
+
+	gb_svc_remove_interfaces(svc);
 }
 
 void gb_svc_put(struct gb_svc *svc)