Commit c41b4f12 authored by Alex Elder's avatar Alex Elder Committed by Greg Kroah-Hartman

greybus: only initialize interfaces when up

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: default avatarAlex Elder <elder@linaro.org>
Signed-off-by: default avatarGreg Kroah-Hartman <greg@kroah.com>
parent 525f1467
...@@ -126,7 +126,7 @@ static void svc_management(struct svc_function_unipro_management *management, ...@@ -126,7 +126,7 @@ static void svc_management(struct svc_function_unipro_management *management,
int payload_length, struct greybus_host_device *hd) int payload_length, struct greybus_host_device *hd)
{ {
struct gb_module *module; struct gb_module *module;
struct gb_interface *interface; int ret;
if (payload_length != sizeof(struct svc_function_unipro_management)) { if (payload_length != sizeof(struct svc_function_unipro_management)) {
dev_err(hd->parent, dev_err(hd->parent,
...@@ -143,15 +143,14 @@ static void svc_management(struct svc_function_unipro_management *management, ...@@ -143,15 +143,14 @@ static void svc_management(struct svc_function_unipro_management *management,
management->link_up.module_id); management->link_up.module_id);
return; return;
} }
interface = gb_interface_find(module, 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); management->link_up.interface_id);
if (!interface) {
dev_err(hd->parent, "Interface ID %d not found\n",
management->link_up.interface_id);
return;
}
interface->device_id = management->link_up.device_id;
(void)svc_set_route_send(interface, hd);
break; break;
case SVC_MANAGEMENT_AP_DEVICE_ID: case SVC_MANAGEMENT_AP_DEVICE_ID:
hd->device_id = management->ap_device_id.device_id; hd->device_id = management->ap_device_id.device_id;
......
...@@ -181,8 +181,6 @@ void gb_add_module(struct greybus_host_device *hd, u8 module_id, ...@@ -181,8 +181,6 @@ void gb_add_module(struct greybus_host_device *hd, u8 module_id,
if (retval) if (retval)
goto err_device; goto err_device;
gb_module_interfaces_init(gmod);
return; return;
err_device: err_device:
put_device(&gmod->dev); put_device(&gmod->dev);
......
...@@ -118,15 +118,25 @@ struct gb_module *gb_module_find(struct greybus_host_device *hd, u8 module_id) ...@@ -118,15 +118,25 @@ struct gb_module *gb_module_find(struct greybus_host_device *hd, u8 module_id)
return NULL; 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; struct gb_interface *interface;
int ret = 0; int ret;
list_for_each_entry(interface, &gmod->interfaces, links) { 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); ret = gb_interface_connections_init(interface);
if (ret) if (ret) {
dev_err(gmod->hd->parent, dev_err(gmod->hd->parent, "module interface init error %d\n",
"module interface init error %d\n", ret); ret);
return ret;
} }
interface->device_id = device_id;
return svc_set_route_send(interface, gmod->hd);
} }
...@@ -55,6 +55,7 @@ void gb_module_destroy(struct gb_module *module); ...@@ -55,6 +55,7 @@ void gb_module_destroy(struct gb_module *module);
struct gb_module *gb_module_find(struct greybus_host_device *hd, struct gb_module *gb_module_find(struct greybus_host_device *hd,
u8 module_id); 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 */ #endif /* __MODULE_H */
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment