summaryrefslogtreecommitdiffstats
path: root/drivers/staging/greybus/connection.c
diff options
context:
space:
mode:
authorJohan Hovold2015-09-17 13:17:26 +0200
committerGreg Kroah-Hartman2015-09-17 23:35:47 +0200
commitd7ea30a57145d13a6e74c90e4f7277cb8705bcc1 (patch)
treec3e886cd571f61c95f945d9947c82fc2db1c01e0 /drivers/staging/greybus/connection.c
parentgreybus: connection: add protocol-version helper (diff)
downloadkernel-qcow2-linux-d7ea30a57145d13a6e74c90e4f7277cb8705bcc1.tar.gz
kernel-qcow2-linux-d7ea30a57145d13a6e74c90e4f7277cb8705bcc1.tar.xz
kernel-qcow2-linux-d7ea30a57145d13a6e74c90e4f7277cb8705bcc1.zip
greybus: hd: add optional cport enable and disable callbacks
Add optional cport enable and disable callbacks to the greybus host drivers, that can be used to initialise and allocate/release resources associated with a cport during connection setup/teardown (e.g. software queues and hardware state). Signed-off-by: Johan Hovold <johan@hovoldconsulting.com> Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Diffstat (limited to 'drivers/staging/greybus/connection.c')
-rw-r--r--drivers/staging/greybus/connection.c37
1 files changed, 36 insertions, 1 deletions
diff --git a/drivers/staging/greybus/connection.c b/drivers/staging/greybus/connection.c
index 91d1e477a6b6..b4947f01d22b 100644
--- a/drivers/staging/greybus/connection.c
+++ b/drivers/staging/greybus/connection.c
@@ -284,6 +284,34 @@ err_remove_ida:
return NULL;
}
+static int gb_connection_hd_cport_enable(struct gb_connection *connection)
+{
+ struct greybus_host_device *hd = connection->hd;
+ int ret;
+
+ if (!hd->driver->cport_enable)
+ return 0;
+
+ ret = hd->driver->cport_enable(hd, connection->hd_cport_id);
+ if (ret) {
+ dev_err(&connection->dev,
+ "failed to enable host cport: %d\n", ret);
+ return ret;
+ }
+
+ return 0;
+}
+
+static void gb_connection_hd_cport_disable(struct gb_connection *connection)
+{
+ struct greybus_host_device *hd = connection->hd;
+
+ if (!hd->driver->cport_disable)
+ return;
+
+ hd->driver->cport_disable(hd, connection->hd_cport_id);
+}
+
struct gb_connection *gb_connection_create(struct gb_bundle *bundle,
u16 cport_id, u8 protocol_id)
{
@@ -439,10 +467,14 @@ static int gb_connection_init(struct gb_connection *connection)
struct gb_protocol *protocol = connection->protocol;
int ret;
- ret = gb_connection_svc_connection_create(connection);
+ ret = gb_connection_hd_cport_enable(connection);
if (ret)
return ret;
+ ret = gb_connection_svc_connection_create(connection);
+ if (ret)
+ goto err_hd_cport_disable;
+
ret = gb_connection_control_connected(connection);
if (ret)
goto err_svc_destroy;
@@ -470,6 +502,8 @@ err_disconnect:
gb_connection_control_disconnected(connection);
err_svc_destroy:
gb_connection_svc_connection_destroy(connection);
+err_hd_cport_disable:
+ gb_connection_hd_cport_disable(connection);
return ret;
}
@@ -492,6 +526,7 @@ static void gb_connection_exit(struct gb_connection *connection)
connection->protocol->connection_exit(connection);
gb_connection_control_disconnected(connection);
gb_connection_svc_connection_destroy(connection);
+ gb_connection_hd_cport_disable(connection);
}
/*