diff options
author | David Lin <dtwlin@google.com> | 2016-07-07 22:07:00 -0500 |
---|---|---|
committer | Alex Elder <elder@linaro.org> | 2016-07-08 14:56:28 -0500 |
commit | f53be0eaf0603324ea90eb352df0ffa18dde646a (patch) | |
tree | 67b25ae38bf642fd40b09a60fe8dde52b7fb17ff /drivers/staging/greybus/control.c | |
parent | f61908f94a9fc550d4619224263fff16cddcc830 (diff) | |
download | op-kernel-dev-f53be0eaf0603324ea90eb352df0ffa18dde646a.zip op-kernel-dev-f53be0eaf0603324ea90eb352df0ffa18dde646a.tar.gz |
greybus: control: add interface suspend prepare operation
Add the AP implementation for the Greybus Control Interface Suspend
Prepare Operation. AP uses this Operation during the Suspend transition
to request the Interface to enter a low-power mode after it detects a
subsequent UniPro link hibernation.
Signed-off-by: David Lin <dtwlin@google.com>
Reviewed-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Alex Elder <elder@linaro.org>
Diffstat (limited to 'drivers/staging/greybus/control.c')
-rw-r--r-- | drivers/staging/greybus/control.c | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/drivers/staging/greybus/control.c b/drivers/staging/greybus/control.c index a53fa3d..252352ce 100644 --- a/drivers/staging/greybus/control.c +++ b/drivers/staging/greybus/control.c @@ -348,6 +348,41 @@ int gb_control_bundle_activate(struct gb_control *control, u8 bundle_id) return 0; } +static int gb_control_interface_pm_status_map(u8 status) +{ + switch (status) { + case GB_CONTROL_INTF_PM_BUSY: + return -EBUSY; + case GB_CONTROL_INTF_PM_NA: + return -ENOMSG; + default: + return -EREMOTEIO; + } +} + +int gb_control_interface_suspend_prepare(struct gb_control *control) +{ + struct gb_control_intf_pm_response response; + int ret; + + ret = gb_operation_sync(control->connection, + GB_CONTROL_TYPE_INTF_SUSPEND_PREPARE, NULL, 0, + &response, sizeof(response)); + if (ret) { + dev_err(&control->dev, + "failed to send interface suspend prepare: %d\n", ret); + return ret; + } + + if (response.status != GB_CONTROL_INTF_PM_OK) { + dev_err(&control->dev, "interface error while preparing suspend: %d\n", + response.status); + return gb_control_interface_pm_status_map(response.status); + } + + return 0; +} + static ssize_t vendor_string_show(struct device *dev, struct device_attribute *attr, char *buf) { |