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: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
This commit is contained in:
Viresh Kumar 2014-11-14 17:25:08 +05:30 committed by Greg Kroah-Hartman
parent 676daaf458
commit 2206ea9cf8
5 changed files with 32 additions and 35 deletions

View File

@ -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)

View File

@ -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)
{

View File

@ -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);

View File

@ -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;
}

View File

@ -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 */