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,
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;
......
......@@ -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);
......
......@@ -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);
}
......@@ -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 */
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