Commit 2206ea9c authored by Viresh Kumar's avatar Viresh Kumar Committed by Greg Kroah-Hartman

greybus: interface: move gb_module_interface_init() to interface.c

That's where it belong to. Also rename it in a similar way to:
gb_interface_create() and gb_interface_destroy().
Signed-off-by: default avatarViresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: default avatarGreg Kroah-Hartman <greg@kroah.com>
parent 676daaf4
......@@ -146,7 +146,7 @@ static void svc_management(struct svc_function_unipro_management *management,
management->link_up.module_id);
return;
}
ret = gb_module_interface_init(module,
ret = gb_interface_init(module,
management->link_up.interface_id,
management->link_up.device_id);
if (ret)
......
......@@ -111,6 +111,36 @@ void gb_interface_destroy(struct gb_module *gmod)
spin_unlock_irq(&gb_interfaces_lock);
}
int gb_interface_init(struct gb_module *gmod, u8 interface_id, u8 device_id)
{
struct gb_interface *interface;
int ret;
interface = gb_interface_find(gmod, interface_id);
if (!interface) {
dev_err(gmod->hd->parent, "module %hhu not found\n",
interface_id);
return -ENOENT;
}
interface->device_id = device_id;
ret = svc_set_route_send(interface, gmod->hd);
if (ret) {
dev_err(gmod->hd->parent, "failed to set route (%d)\n", ret);
return ret;
}
ret = gb_interface_connections_init(interface);
if (ret) {
dev_err(gmod->hd->parent, "module interface init error %d\n",
ret);
/* XXX clear route */
return ret;
}
return 0;
}
struct gb_interface *gb_interface_find(struct gb_module *module,
u8 interface_id)
{
......
......@@ -24,6 +24,7 @@ struct gb_interface {
struct gb_interface *gb_interface_create(struct gb_module *gmod, u8 module_id);
void gb_interface_destroy(struct gb_module *gmod);
int gb_interface_init(struct gb_module *gmod, u8 module_id, u8 device_id);
struct gb_interface *gb_interface_find(struct gb_module *gmod, u8 interface_id);
......
......@@ -201,34 +201,3 @@ void gb_remove_modules(struct greybus_host_device *hd)
list_for_each_entry_safe(gmod, temp, &hd->modules, links)
gb_module_destroy(gmod);
}
int
gb_module_interface_init(struct gb_module *gmod, u8 interface_id, u8 device_id)
{
struct gb_interface *interface;
int ret;
interface = gb_interface_find(gmod, interface_id);
if (!interface) {
dev_err(gmod->hd->parent, "module %hhu not found\n",
interface_id);
return -ENOENT;
}
interface->device_id = device_id;
ret = svc_set_route_send(interface, gmod->hd);
if (ret) {
dev_err(gmod->hd->parent, "failed to set route (%d)\n", ret);
return ret;
}
ret = gb_interface_connections_init(interface);
if (ret) {
dev_err(gmod->hd->parent, "module interface init error %d\n",
ret);
/* XXX clear route */
return ret;
}
return 0;
}
......@@ -55,7 +55,4 @@ void gb_module_destroy(struct gb_module *module);
struct gb_module *gb_module_find(struct greybus_host_device *hd,
u8 module_id);
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