From: Viresh Kumar Date: Mon, 22 Jun 2015 11:12:29 +0000 (+0530) Subject: greybus: connection: send [dis]connected events over control CPort X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=f18327e8ebf4738140e9b33a2de99bb8e526a269;p=GitHub%2FLineageOS%2Fandroid_kernel_motorola_exynos9610.git 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: Alex Elder Signed-off-by: Viresh Kumar Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/staging/greybus/connection.c b/drivers/staging/greybus/connection.c index 9467aaba2b32..564011ac7894 100644 --- a/drivers/staging/greybus/connection.c +++ b/drivers/staging/greybus/connection.c @@ -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); + } }