greybus: only initialize interfaces when up
authorAlex Elder <elder@linaro.org>
Wed, 22 Oct 2014 07:04:32 +0000 (02:04 -0500)
committerGreg Kroah-Hartman <greg@kroah.com>
Wed, 22 Oct 2014 09:22:22 +0000 (17:22 +0800)
Rather than bringing up all interfaces described in the manifest,
wait until we get a link up message, and at that time go initialize
the link.

Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
drivers/staging/greybus/ap.c
drivers/staging/greybus/core.c
drivers/staging/greybus/module.c
drivers/staging/greybus/module.h

index 7ea329cfa1eb1b1a6bbc4a4612c94f4fe18f68a0..1a9112a21bbba208fd5b2210242d6a9e5aa876fd 100644 (file)
@@ -126,7 +126,7 @@ static void svc_management(struct svc_function_unipro_management *management,
                           int payload_length, struct greybus_host_device *hd)
 {
        struct gb_module *module;
-       struct gb_interface *interface;
+       int ret;
 
        if (payload_length != sizeof(struct svc_function_unipro_management)) {
                dev_err(hd->parent,
@@ -143,15 +143,14 @@ static void svc_management(struct svc_function_unipro_management *management,
                                management->link_up.module_id);
                        return;
                }
-               interface = gb_interface_find(module,
-                                             management->link_up.interface_id);
-               if (!interface) {
-                       dev_err(hd->parent, "Interface ID %d not found\n",
+               ret = gb_module_interface_init(module,
+                               management->link_up.interface_id,
+                               management->link_up.device_id);
+               if (ret)
+                       dev_err(hd->parent, "error %d initializing"
+                               "module %hhu interface %hhu\n",
+                               ret, management->link_up.module_id,
                                management->link_up.interface_id);
-                       return;
-               }
-               interface->device_id = management->link_up.device_id;
-               (void)svc_set_route_send(interface, hd);
                break;
        case SVC_MANAGEMENT_AP_DEVICE_ID:
                hd->device_id = management->ap_device_id.device_id;
index 480e12bac84a9f1b0bdf267242bfa41db5ab3521..9f4ae1c63fa0426eeceae656a193707b6f2dbf18 100644 (file)
@@ -181,8 +181,6 @@ void gb_add_module(struct greybus_host_device *hd, u8 module_id,
        if (retval)
                goto err_device;
 
-       gb_module_interfaces_init(gmod);
-
        return;
 err_device:
        put_device(&gmod->dev);
index 50139f41fe208c70dca923b40e5b801c87c125c2..bcb0ff0981645aa86a78c297e46121987a64c58b 100644 (file)
@@ -118,15 +118,25 @@ struct gb_module *gb_module_find(struct greybus_host_device *hd, u8 module_id)
        return NULL;
 }
 
-void gb_module_interfaces_init(struct gb_module *gmod)
+int
+gb_module_interface_init(struct gb_module *gmod, u8 interface_id, u8 device_id)
 {
        struct gb_interface *interface;
-       int ret = 0;
+       int ret;
 
-       list_for_each_entry(interface, &gmod->interfaces, links) {
-               ret = gb_interface_connections_init(interface);
-               if (ret)
-                       dev_err(gmod->hd->parent,
-                               "module interface init error %d\n", ret);
+       interface = gb_interface_find(gmod, interface_id);
+       if (!interface) {
+               dev_err(gmod->hd->parent, "module %hhu not found\n",
+                       interface_id);
+               return -ENOENT;
        }
+       ret = gb_interface_connections_init(interface);
+       if (ret) {
+               dev_err(gmod->hd->parent, "module interface init error %d\n",
+                       ret);
+               return ret;
+       }
+       interface->device_id = device_id;
+
+       return svc_set_route_send(interface, gmod->hd);
 }
index 82def46e5ab14bffb50d8af1fc1cfb9eba027001..74ac4fdd3c83045627d7dcc6664f85ae4040c9e2 100644 (file)
@@ -55,6 +55,7 @@ void gb_module_destroy(struct gb_module *module);
 struct gb_module *gb_module_find(struct greybus_host_device *hd,
                                u8 module_id);
 
-void gb_module_interfaces_init(struct gb_module *gmod);
+int gb_module_interface_init(struct gb_module *gmod, u8 module_id,
+                               u8 device_id);
 
 #endif /* __MODULE_H */