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

greybus: svc: connection is created only once now

We no longer create a fresh connection on receiving svc-hello message,
but rather update the initial one.

Update 'initial_svc_connection' after the connection is fully
initialized. Look for the partially initialized connection while
removing hd, as hd might be removed before getting svc-hello requests
from svc.

Also update gb_svc_connection_init() to initialize id_map on the first
(and the only) call to connection-init function.

We also can't update connection->bundle->intf->svc, as its a bundle-less
connection. Lets stop updating intf->svc as its not really used.
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 67c93ae6
......@@ -236,6 +236,12 @@ void greybus_remove_hd(struct greybus_host_device *hd)
gb_interfaces_remove(hd);
gb_endo_remove(hd->endo);
/* Is the SVC still using the partially uninitialized connection ? */
if (hd->initial_svc_connection) {
gb_connection_exit(hd->initial_svc_connection);
gb_connection_destroy(hd->initial_svc_connection);
}
/*
* Make sure there are no leftovers that can potentially corrupt sysfs.
*/
......
......@@ -54,6 +54,9 @@ gb_ap_interface_create(struct greybus_host_device *hd,
intf->device_id = GB_DEVICE_ID_AP;
svc_update_connection(intf, connection);
/* Its no longer a partially initialized connection */
hd->initial_svc_connection = NULL;
return intf;
}
......@@ -384,24 +387,11 @@ static int gb_svc_connection_init(struct gb_connection *connection)
svc->connection = connection;
connection->private = svc;
/*
* SVC connection is created twice:
* - before the interface-id of the AP and the endo type is known.
* - after receiving endo type and interface-id of the AP from the SVC.
*
* We should do light-weight initialization for the first case.
*/
if (!connection->bundle) {
WARN_ON(connection->hd->initial_svc_connection);
connection->hd->initial_svc_connection = connection;
return 0;
}
ida_init(&greybus_svc_device_id_map);
/* Set interface's svc connection */
connection->bundle->intf->svc = svc;
return 0;
}
......@@ -409,14 +399,6 @@ static void gb_svc_connection_exit(struct gb_connection *connection)
{
struct gb_svc *svc = connection->private;
if (connection->hd->initial_svc_connection == connection) {
connection->hd->initial_svc_connection = NULL;
} else {
if (WARN_ON(connection->bundle->intf->svc != svc))
return;
connection->bundle->intf->svc = NULL;
}
connection->private = NULL;
kfree(svc);
}
......
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