summaryrefslogtreecommitdiffstats
path: root/drivers/usb/gadget/udc/core.c
diff options
context:
space:
mode:
authorElson Roy Serrao <quic_eserrao@quicinc.com>2023-03-24 14:47:57 -0700
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2023-03-29 10:27:00 +0200
commitb93c2a68f3d9dc98ec30dcb342ae47c1c8d09d18 (patch)
tree0ab2f0fef04383c702f06f478ba36e0ce964fc18 /drivers/usb/gadget/udc/core.c
parent79e94aa19736ec8f38ec02880eeec37cc5900bd8 (diff)
downloadlinux-stable-b93c2a68f3d9dc98ec30dcb342ae47c1c8d09d18.tar.gz
linux-stable-b93c2a68f3d9dc98ec30dcb342ae47c1c8d09d18.tar.bz2
linux-stable-b93c2a68f3d9dc98ec30dcb342ae47c1c8d09d18.zip
usb: gadget: Properly configure the device for remote wakeup
The wakeup bit in the bmAttributes field indicates whether the device is configured for remote wakeup. But this field should be allowed to set only if the UDC supports such wakeup mechanism. So configure this field based on UDC capability. Also inform the UDC whether the device is configured for remote wakeup by implementing a gadget op. Reviewed-by: Thinh Nguyen <Thinh.Nguyen@synopsys.com> Signed-off-by: Elson Roy Serrao <quic_eserrao@quicinc.com> Link: https://lore.kernel.org/r/1679694482-16430-2-git-send-email-quic_eserrao@quicinc.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/usb/gadget/udc/core.c')
-rw-r--r--drivers/usb/gadget/udc/core.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/drivers/usb/gadget/udc/core.c b/drivers/usb/gadget/udc/core.c
index 23b0629a8774..3dcbba739db6 100644
--- a/drivers/usb/gadget/udc/core.c
+++ b/drivers/usb/gadget/udc/core.c
@@ -514,6 +514,33 @@ out:
EXPORT_SYMBOL_GPL(usb_gadget_wakeup);
/**
+ * usb_gadget_set_remote_wakeup - configures the device remote wakeup feature.
+ * @gadget:the device being configured for remote wakeup
+ * @set:value to be configured.
+ *
+ * set to one to enable remote wakeup feature and zero to disable it.
+ *
+ * returns zero on success, else negative errno.
+ */
+int usb_gadget_set_remote_wakeup(struct usb_gadget *gadget, int set)
+{
+ int ret = 0;
+
+ if (!gadget->ops->set_remote_wakeup) {
+ ret = -EOPNOTSUPP;
+ goto out;
+ }
+
+ ret = gadget->ops->set_remote_wakeup(gadget, set);
+
+out:
+ trace_usb_gadget_set_remote_wakeup(gadget, ret);
+
+ return ret;
+}
+EXPORT_SYMBOL_GPL(usb_gadget_set_remote_wakeup);
+
+/**
* usb_gadget_set_selfpowered - sets the device selfpowered feature.
* @gadget:the device being declared as self-powered
*