Commit 67c93ae6 authored by Viresh Kumar's avatar Viresh Kumar Committed by Greg Kroah-Hartman

greybus: svc: fully initialize the partially initialized connection

SVC hello message is received now and we should fully initialize the
partially initialized connection. This can be done by removing and
re-adding the device corresponding to the connection.
Signed-off-by: default avatarViresh Kumar <viresh.kumar@linaro.org>
Tested-by: default avatarPerry Hung <perry@leaflabs.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@google.com>
parent 3dfe8aaa
......@@ -111,6 +111,30 @@ struct device_type greybus_connection_type = {
};
int svc_update_connection(struct gb_interface *intf,
struct gb_connection *connection)
{
struct gb_bundle *bundle;
bundle = gb_bundle_create(intf, GB_SVC_BUNDLE_ID, GREYBUS_CLASS_SVC);
if (!bundle)
return -EINVAL;
device_del(&connection->dev);
connection->bundle = bundle;
connection->dev.parent = &bundle->dev;
dev_set_name(&connection->dev, "%s:%d", dev_name(&bundle->dev),
GB_SVC_CPORT_ID);
WARN_ON(device_add(&connection->dev));
spin_lock_irq(&gb_connections_lock);
list_add(&connection->bundle_links, &bundle->connections);
spin_unlock_irq(&gb_connections_lock);
return 0;
}
void gb_connection_bind_protocol(struct gb_connection *connection)
{
struct gb_protocol *protocol;
......
......@@ -47,6 +47,8 @@ struct gb_connection {
};
#define to_gb_connection(d) container_of(d, struct gb_connection, dev)
int svc_update_connection(struct gb_interface *intf,
struct gb_connection *connection);
struct gb_connection *gb_connection_create(struct gb_bundle *bundle,
u16 cport_id, u8 protocol_id);
struct gb_connection *gb_connection_create_range(struct greybus_host_device *hd,
......
......@@ -43,7 +43,6 @@ gb_ap_interface_create(struct greybus_host_device *hd,
{
struct gb_interface *intf;
struct device *dev = &hd->endo->dev;
int ret;
intf = gb_interface_create(hd, interface_id);
if (!intf) {
......@@ -53,20 +52,7 @@ gb_ap_interface_create(struct greybus_host_device *hd,
}
intf->device_id = GB_DEVICE_ID_AP;
/*
* XXX: Disable the initial svc connection here, but don't destroy it
* yet. We do need to send a response of 'svc-hello message' on that.
*/
/* Establish new control CPort connection */
ret = gb_create_bundle_connection(intf, GREYBUS_CLASS_SVC);
if (ret) {
dev_err(&intf->dev, "%s: Failed to create svc connection (%d %d)\n",
__func__, interface_id, ret);
gb_interface_destroy(intf);
intf = NULL;
}
svc_update_connection(intf, connection);
return intf;
}
......
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