greybus: interface: Pass interface pointer to gb_interface_remove()
authorViresh Kumar <viresh.kumar@linaro.org>
Wed, 23 Sep 2015 23:48:10 +0000 (16:48 -0700)
committerGreg Kroah-Hartman <gregkh@google.com>
Thu, 24 Sep 2015 22:25:03 +0000 (15:25 -0700)
The callers already have a valid interface pointer and there is no need
for gb_interface_remove() to find the interface again.

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

index c38fb8b31c2b5efbfacc3b25ab506e64166166ae..b0253ce8e864baea568286af0b6ab1b29b3ad6de 100644 (file)
@@ -183,7 +183,7 @@ put_module:
 /*
  * Tear down a previously set up module.
  */
-static void interface_destroy(struct gb_interface *intf)
+void gb_interface_remove(struct gb_interface *intf)
 {
        struct gb_module *module;
        struct gb_bundle *bundle;
@@ -207,6 +207,14 @@ static void interface_destroy(struct gb_interface *intf)
        put_device(&module->dev);
 }
 
+void gb_interfaces_remove(struct greybus_host_device *hd)
+{
+       struct gb_interface *intf, *temp;
+
+       list_for_each_entry_safe(intf, temp, &hd->interfaces, links)
+               gb_interface_remove(intf);
+}
+
 /**
  * gb_interface_init
  *
@@ -273,22 +281,3 @@ free_manifest:
        kfree(manifest);
        return ret;
 }
-
-void gb_interface_remove(struct greybus_host_device *hd, u8 interface_id)
-{
-       struct gb_interface *intf = gb_interface_find(hd, interface_id);
-
-       if (intf)
-               interface_destroy(intf);
-       else
-               dev_err(hd->parent, "interface id %d not found\n",
-                       interface_id);
-}
-
-void gb_interfaces_remove(struct greybus_host_device *hd)
-{
-       struct gb_interface *intf, *temp;
-
-       list_for_each_entry_safe(intf, temp, &hd->interfaces, links)
-               interface_destroy(intf);
-}
index 38210ad4e631f78e52be323689d68d6defa5a4db..42b5d0156cdc8c60df0086555431c144e27cb091 100644 (file)
@@ -59,7 +59,7 @@ struct gb_interface *gb_interface_create(struct greybus_host_device *hd,
                                         u8 interface_id);
 void gb_interface_destroy(struct gb_interface *intf);
 int gb_interface_init(struct gb_interface *intf, u8 device_id);
-void gb_interface_remove(struct greybus_host_device *hd, u8 interface_id);
+void gb_interface_remove(struct gb_interface *intf);
 void gb_interfaces_remove(struct greybus_host_device *hd);
 
 int gb_create_bundle_connection(struct gb_interface *intf, u8 class);
index b59d76fcc40581020f4a39d6b269f20228f8476f..da2ffd655122684d3123e07070451aa97ca5dba2 100644 (file)
@@ -374,7 +374,7 @@ static void svc_intf_remove(struct gb_connection *connection,
        u8 device_id;
 
        device_id = intf->device_id;
-       gb_interface_remove(hd, intf_id);
+       gb_interface_remove(intf);
 
        /*
         * Destroy the two-way route between the AP and the interface.
@@ -497,7 +497,7 @@ svc_id_free:
 ida_put:
        ida_simple_remove(&svc->device_id_map, device_id);
 destroy_interface:
-       gb_interface_remove(hd, intf_id);
+       gb_interface_remove(intf);
 free_svc_hotplug:
        kfree(svc_hotplug);
 }