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

greybus: connection: send [dis]connected events over control CPort

The AP needs to send connected and disconnection events to all
interfaces, before a CPort (other than control CPort) can be used.

For now do it which we initialize the connection, but it should be moved
to operations code later.
Reviewed-by: default avatarAlex Elder <elder@linaro.org>
Signed-off-by: default avatarViresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@google.com>
parent 87c8eb8d
......@@ -248,6 +248,7 @@ void gb_connection_destroy(struct gb_connection *connection)
int gb_connection_init(struct gb_connection *connection)
{
int cport_id = connection->intf_cport_id;
int ret;
if (!connection->protocol) {
......@@ -255,6 +256,22 @@ int gb_connection_init(struct gb_connection *connection)
return 0;
}
/*
* Inform Interface about Active CPorts. We don't need to do this
* operation for control cport.
*/
if (cport_id != GB_CONTROL_CPORT_ID) {
struct gb_control *control = connection->bundle->intf->control;
ret = gb_control_connected_operation(control, cport_id);
if (ret) {
dev_warn(&connection->dev,
"Failed to connect CPort-%d (%d)\n",
cport_id, ret);
return 0;
}
}
/* Need to enable the connection to initialize it */
connection->state = GB_CONNECTION_STATE_ENABLED;
ret = connection->protocol->connection_init(connection);
......@@ -266,6 +283,8 @@ int gb_connection_init(struct gb_connection *connection)
void gb_connection_exit(struct gb_connection *connection)
{
int cport_id = connection->intf_cport_id;
if (!connection->protocol) {
dev_warn(&connection->dev, "exit without protocol.\n");
return;
......@@ -276,4 +295,19 @@ void gb_connection_exit(struct gb_connection *connection)
connection->state = GB_CONNECTION_STATE_DESTROYING;
connection->protocol->connection_exit(connection);
/*
* Inform Interface about In-active CPorts. We don't need to do this
* operation for control cport.
*/
if (cport_id != GB_CONTROL_CPORT_ID) {
struct gb_control *control = connection->bundle->intf->control;
int ret;
ret = gb_control_disconnected_operation(control, cport_id);
if (ret)
dev_warn(&connection->dev,
"Failed to disconnect CPort-%d (%d)\n",
cport_id, ret);
}
}
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