diff options
author | Johan Hovold <johan@hovoldconsulting.com> | 2016-01-19 12:51:14 +0100 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@google.com> | 2016-01-19 12:17:13 -0800 |
commit | e217ae762bccb0ba0109887cefec3e20e5549a48 (patch) | |
tree | fac7fea51714f8eb5ec281812e75b333f4f3c27d /drivers/staging/greybus/control.c | |
parent | 6bd6e148930b6f6dff7a6d664b37ba76d6d2c75e (diff) | |
download | op-kernel-dev-e217ae762bccb0ba0109887cefec3e20e5549a48.zip op-kernel-dev-e217ae762bccb0ba0109887cefec3e20e5549a48.tar.gz |
greybus: control: drop legacy-protocol dependency
Drop dependency on the legacy protocol abstraction.
Instead implement the protocol-specific version request directly, and
use the new interface for managing the control connection.
Note that the version request is being removed from most protocols, but
we need to keep the current request for the control protocol as-is
indefinitely to maintain backwards compatibility (e.g. with the ES2/ES3
bootrom).
Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Diffstat (limited to 'drivers/staging/greybus/control.c')
-rw-r--r-- | drivers/staging/greybus/control.c | 72 |
1 files changed, 48 insertions, 24 deletions
diff --git a/drivers/staging/greybus/control.c b/drivers/staging/greybus/control.c index d79807c..3077940 100644 --- a/drivers/staging/greybus/control.c +++ b/drivers/staging/greybus/control.c @@ -17,6 +17,43 @@ #define GB_CONTROL_VERSION_MINOR 1 +int gb_control_get_version(struct gb_control *control) +{ + struct gb_interface *intf = control->connection->intf; + struct gb_control_version_request request; + struct gb_control_version_response response; + int ret; + + request.major = GB_CONTROL_VERSION_MAJOR; + request.minor = GB_CONTROL_VERSION_MINOR; + + ret = gb_operation_sync(control->connection, + GB_CONTROL_TYPE_VERSION, + &request, sizeof(request), &response, + sizeof(response)); + if (ret) { + dev_err(&intf->dev, + "failed to get control-protocol version: %d\n", + ret); + return ret; + } + + if (response.major > request.major) { + dev_err(&intf->dev, + "unsupported major control-protocol version (%u > %u)\n", + response.major, request.major); + return -ENOTSUPP; + } + + control->protocol_major = response.major; + control->protocol_minor = response.minor; + + dev_dbg(&intf->dev, "%s - %u.%u\n", __func__, response.major, + response.minor); + + return 0; +} + /* Get Manifest's size from the interface */ int gb_control_get_manifest_size_operation(struct gb_interface *intf) { @@ -121,7 +158,7 @@ int gb_control_enable(struct gb_control *control) dev_dbg(&control->connection->intf->dev, "%s\n", __func__); - ret = gb_connection_legacy_init(control->connection); + ret = gb_connection_enable_tx(control->connection); if (ret) { dev_err(&control->connection->intf->dev, "failed to enable control connection: %d\n", @@ -129,14 +166,23 @@ int gb_control_enable(struct gb_control *control) return ret; } + ret = gb_control_get_version(control); + if (ret) + goto err_disable_connection; + return 0; + +err_disable_connection: + gb_connection_disable(control->connection); + + return ret; } void gb_control_disable(struct gb_control *control) { dev_dbg(&control->connection->intf->dev, "%s\n", __func__); - gb_connection_legacy_exit(control->connection); + gb_connection_disable(control->connection); } void gb_control_destroy(struct gb_control *control) @@ -144,25 +190,3 @@ void gb_control_destroy(struct gb_control *control) gb_connection_destroy(control->connection); kfree(control); } - -static int gb_control_connection_init(struct gb_connection *connection) -{ - dev_dbg(&connection->intf->dev, "%s\n", __func__); - - return 0; -} - -static void gb_control_connection_exit(struct gb_connection *connection) -{ - dev_dbg(&connection->intf->dev, "%s\n", __func__); -} - -static struct gb_protocol control_protocol = { - .name = "control", - .id = GREYBUS_PROTOCOL_CONTROL, - .major = GB_CONTROL_VERSION_MAJOR, - .minor = GB_CONTROL_VERSION_MINOR, - .connection_init = gb_control_connection_init, - .connection_exit = gb_control_connection_exit, -}; -gb_builtin_protocol_driver(control_protocol); |