diff options
author | Johan Hovold <johan@hovoldconsulting.com> | 2015-09-17 13:17:24 +0200 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@google.com> | 2015-09-17 14:33:47 -0700 |
commit | 9d7fc25b3c05a3330002560c19f0dfbfe83ea8a0 (patch) | |
tree | c4c77d3aefe142d558d06d24e1a66b9e46768f83 /drivers/staging/greybus/connection.c | |
parent | 72d748226379979e4a2e3e1ebf5379fa57f6f3fe (diff) | |
download | linux-stable-9d7fc25b3c05a3330002560c19f0dfbfe83ea8a0.tar.gz linux-stable-9d7fc25b3c05a3330002560c19f0dfbfe83ea8a0.tar.bz2 linux-stable-9d7fc25b3c05a3330002560c19f0dfbfe83ea8a0.zip |
greybus: connection: add control-connected helper
Add control-connected helper to improve readability.
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.c | 38 |
1 files changed, 26 insertions, 12 deletions
diff --git a/drivers/staging/greybus/connection.c b/drivers/staging/greybus/connection.c index ac787923b2d7..de5581267fce 100644 --- a/drivers/staging/greybus/connection.c +++ b/drivers/staging/greybus/connection.c @@ -368,6 +368,29 @@ gb_connection_svc_connection_destroy(struct gb_connection *connection) connection->intf_cport_id); } +/* Inform Interface about active CPorts */ +static int gb_connection_control_connected(struct gb_connection *connection) +{ + struct gb_protocol *protocol = connection->protocol; + struct gb_control *control; + u16 cport_id = connection->intf_cport_id; + int ret; + + if (protocol->flags & GB_PROTOCOL_SKIP_CONTROL_CONNECTED) + return 0; + + control = connection->bundle->intf->control; + + ret = gb_control_connected_operation(control, cport_id); + if (ret) { + dev_err(&connection->dev, + "failed to connect cport: %d\n", ret); + return ret; + } + + return 0; +} + /* Inform Interface about inactive CPorts */ static void gb_connection_control_disconnected(struct gb_connection *connection) @@ -399,18 +422,9 @@ static int gb_connection_init(struct gb_connection *connection) if (ret) return ret; - /* Inform Interface about active CPorts */ - if (!(protocol->flags & GB_PROTOCOL_SKIP_CONTROL_CONNECTED)) { - struct gb_control *control = connection->bundle->intf->control; - - ret = gb_control_connected_operation(control, cport_id); - if (ret) { - dev_err(&connection->dev, - "Failed to connect CPort-%d (%d)\n", - cport_id, ret); - goto err_svc_destroy; - } - } + ret = gb_connection_control_connected(connection); + if (ret) + goto err_svc_destroy; /* Need to enable the connection to initialize it */ spin_lock_irq(&connection->lock); |