On Thu, Jan 19, 2023, Elson Serrao wrote: > > > On 1/18/2023 5:44 PM, Thinh Nguyen wrote: > > On Tue, Jan 17, 2023, Elson Roy Serrao wrote: > > > Add a flag to indicate whether the gadget is capable > > > of sending remote wakeup to the host. > > > > > > Signed-off-by: Elson Roy Serrao <quic_eserrao@xxxxxxxxxxx> > > > --- > > > drivers/usb/gadget/composite.c | 3 +++ > > > include/linux/usb/gadget.h | 2 ++ > > > 2 files changed, 5 insertions(+) > > > > > > diff --git a/drivers/usb/gadget/composite.c b/drivers/usb/gadget/composite.c > > > index 403563c..b83963a 100644 > > > --- a/drivers/usb/gadget/composite.c > > > +++ b/drivers/usb/gadget/composite.c > > > @@ -965,6 +965,9 @@ static int set_config(struct usb_composite_dev *cdev, > > > else > > > usb_gadget_clear_selfpowered(gadget); > > > + if (USB_CONFIG_ATT_WAKEUP & c->bmAttributes) > > > + gadget->rw_capable = 1; > > > > Some device may not support remote wakeup. gadget->rw_capable should be > > set and reported by the UDC. May need a gadget ops to enable remote > > wakeup here. > > > > Thanks, > > Thinh > > > Not exactly clear on which parameter in UDC decides whether a device > supports remote wakeup. Here I have this flag just to indicate whether the > connected device is rw capable based on the bmAttributes populated in the > config descriptor. If the UDC doesnt have a callback for remote wakeup we > have that check when calling the gadget op in udc/core.c (have added a > similar check in usb_func_wakeup() also ). That flag describes the gadget's capability, not the device configuration. However, it's being used as a configuration flag. Thanks, Thinh > > int usb_gadget_wakeup(struct usb_gadget *gadget) > { > int ret = 0; > > if (!gadget->ops->wakeup) { > ret = -EOPNOTSUPP; > goto out; > > Thanks > Elson > > > > + > > > usb_gadget_vbus_draw(gadget, power); > > > if (result >= 0 && cdev->delayed_status) > > > result = USB_GADGET_DELAYED_STATUS; > > > diff --git a/include/linux/usb/gadget.h b/include/linux/usb/gadget.h > > > index dc3092c..15785f8 100644 > > > --- a/include/linux/usb/gadget.h > > > +++ b/include/linux/usb/gadget.h > > > @@ -385,6 +385,7 @@ struct usb_gadget_ops { > > > * indicates that it supports LPM as per the LPM ECN & errata. > > > * @irq: the interrupt number for device controller. > > > * @id_number: a unique ID number for ensuring that gadget names are distinct > > > + * @rw_capable: True if the gadget is capable of sending remote wakeup. > > > *