}
int gb_connection_init(struct gb_connection *connection);
+void gb_connection_exit(struct gb_connection *connection);
void greybus_data_rcvd(struct gb_host_device *hd, u16 cport_id,
u8 *data, size_t length);
{
struct gb_host_device *hd = to_gb_host_device(dev);
+ if (hd->svc_connection)
+ gb_connection_destroy(hd->svc_connection);
ida_simple_remove(&gb_hd_bus_id_map, hd->bus_id);
ida_destroy(&hd->cport_id_map);
kfree(hd);
device_initialize(&hd->dev);
dev_set_name(&hd->dev, "greybus%d", hd->bus_id);
- return hd;
-}
-EXPORT_SYMBOL_GPL(gb_hd_create);
-
-static int gb_hd_create_svc_connection(struct gb_host_device *hd)
-{
hd->svc_connection = gb_connection_create_static(hd, GB_SVC_CPORT_ID,
GREYBUS_PROTOCOL_SVC);
if (!hd->svc_connection) {
dev_err(&hd->dev, "failed to create svc connection\n");
- return -ENOMEM;
+ put_device(&hd->dev);
+ return ERR_PTR(-ENOMEM);
}
- return 0;
+ return hd;
}
+EXPORT_SYMBOL_GPL(gb_hd_create);
int gb_hd_add(struct gb_host_device *hd)
{
if (ret)
return ret;
- ret = gb_hd_create_svc_connection(hd);
- if (ret) {
- device_del(&hd->dev);
- return ret;
- }
-
ret = gb_connection_init(hd->svc_connection);
if (ret) {
- gb_connection_destroy(hd->svc_connection);
device_del(&hd->dev);
return ret;
}
{
gb_interfaces_remove(hd);
- gb_connection_destroy(hd->svc_connection);
+ gb_connection_exit(hd->svc_connection);
device_del(&hd->dev);
}