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