greybus: interface: separate initialisation and registration
Separate interface initialisation from registration of the interface and its bundles. This is a step towards registering also interfaces that failed to initialise (e.g. a dummy interface). Signed-off-by: Johan Hovold <johan@hovoldconsulting.com> Reviewed-by: Jeffrey Carlyle <jcarlyle@google.com> Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org> Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>hifive-unleashed-5.1
parent
39495a2bea
commit
7a137fb290
|
@ -179,16 +179,12 @@ void gb_interfaces_remove(struct gb_host_device *hd)
|
||||||
gb_interface_remove(intf);
|
gb_interface_remove(intf);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/*
|
||||||
* gb_interface_init
|
* Intialise an interface by enabling the control connection and fetching the
|
||||||
*
|
* manifest and other information over it.
|
||||||
* Create connection for control CPort and then request/parse manifest.
|
|
||||||
* Finally initialize all the bundles to set routes via SVC and initialize all
|
|
||||||
* connections.
|
|
||||||
*/
|
*/
|
||||||
int gb_interface_init(struct gb_interface *intf)
|
int gb_interface_init(struct gb_interface *intf)
|
||||||
{
|
{
|
||||||
struct gb_bundle *bundle, *tmp;
|
|
||||||
int ret, size;
|
int ret, size;
|
||||||
void *manifest;
|
void *manifest;
|
||||||
|
|
||||||
|
@ -236,11 +232,22 @@ int gb_interface_init(struct gb_interface *intf)
|
||||||
if (ret)
|
if (ret)
|
||||||
goto free_manifest;
|
goto free_manifest;
|
||||||
|
|
||||||
/* Register the interface and its bundles. */
|
free_manifest:
|
||||||
|
kfree(manifest);
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Register an interface and its bundles. */
|
||||||
|
int gb_interface_add(struct gb_interface *intf)
|
||||||
|
{
|
||||||
|
struct gb_bundle *bundle, *tmp;
|
||||||
|
int ret;
|
||||||
|
|
||||||
ret = device_add(&intf->dev);
|
ret = device_add(&intf->dev);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
dev_err(&intf->dev, "failed to register interface: %d\n", ret);
|
dev_err(&intf->dev, "failed to register interface: %d\n", ret);
|
||||||
goto free_manifest;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
dev_info(&intf->dev, "Interface added: VID=0x%08x, PID=0x%08x\n",
|
dev_info(&intf->dev, "Interface added: VID=0x%08x, PID=0x%08x\n",
|
||||||
|
@ -256,9 +263,5 @@ int gb_interface_init(struct gb_interface *intf)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = 0;
|
return 0;
|
||||||
|
|
||||||
free_manifest:
|
|
||||||
kfree(manifest);
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,6 +48,7 @@ struct gb_interface *gb_interface_find(struct gb_host_device *hd,
|
||||||
struct gb_interface *gb_interface_create(struct gb_host_device *hd,
|
struct gb_interface *gb_interface_create(struct gb_host_device *hd,
|
||||||
u8 interface_id);
|
u8 interface_id);
|
||||||
int gb_interface_init(struct gb_interface *intf);
|
int gb_interface_init(struct gb_interface *intf);
|
||||||
|
int gb_interface_add(struct gb_interface *intf);
|
||||||
void gb_interface_remove(struct gb_interface *intf);
|
void gb_interface_remove(struct gb_interface *intf);
|
||||||
void gb_interfaces_remove(struct gb_host_device *hd);
|
void gb_interfaces_remove(struct gb_host_device *hd);
|
||||||
|
|
||||||
|
|
|
@ -629,6 +629,10 @@ static void gb_svc_process_intf_hotplug(struct gb_operation *operation)
|
||||||
goto destroy_route;
|
goto destroy_route;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ret = gb_interface_add(intf);
|
||||||
|
if (ret)
|
||||||
|
goto destroy_route;
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
destroy_route:
|
destroy_route:
|
||||||
|
|
Loading…
Reference in New Issue