When host sends GET_STATUS to ECM interface, handle the request
from the function driver. Since the interface is wakeup capable,
set the corresponding bit, and set RW bit if the function is
already armed for wakeup by the host.
Cc: stable@kernel.org
Fixes: 481c225c4802 ("usb: gadget: Handle function suspend feature selector")
Signed-off-by: Prashanth K <prashanth.k@oss.qualcomm.com>
---
drivers/usb/gadget/function/f_ecm.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/drivers/usb/gadget/function/f_ecm.c b/drivers/usb/gadget/function/f_ecm.c
index 80841de845b0..027226325039 100644
--- a/drivers/usb/gadget/function/f_ecm.c
+++ b/drivers/usb/gadget/function/f_ecm.c
@@ -892,6 +892,12 @@ static void ecm_resume(struct usb_function *f)
gether_resume(&ecm->port);
}
+static int ecm_get_status(struct usb_function *f)
+{
+ return (f->func_wakeup_armed ? USB_INTRF_STAT_FUNC_RW : 0) |
+ USB_INTRF_STAT_FUNC_RW_CAP;
+}
+
static void ecm_free(struct usb_function *f)
{
struct f_ecm *ecm;
@@ -960,6 +966,7 @@ static struct usb_function *ecm_alloc(struct usb_function_instance *fi)
ecm->port.func.disable = ecm_disable;
ecm->port.func.free_func = ecm_free;
ecm->port.func.suspend = ecm_suspend;
+ ecm->port.func.get_status = ecm_get_status;
ecm->port.func.resume = ecm_resume;
return &ecm->port.func;
--
2.25.1
On Thu, Apr 03, 2025, Prashanth K wrote: > When host sends GET_STATUS to ECM interface, handle the request > from the function driver. Since the interface is wakeup capable, > set the corresponding bit, and set RW bit if the function is > already armed for wakeup by the host. > > Cc: stable@kernel.org > Fixes: 481c225c4802 ("usb: gadget: Handle function suspend feature selector") > Signed-off-by: Prashanth K <prashanth.k@oss.qualcomm.com> > --- > drivers/usb/gadget/function/f_ecm.c | 7 +++++++ > 1 file changed, 7 insertions(+) > > diff --git a/drivers/usb/gadget/function/f_ecm.c b/drivers/usb/gadget/function/f_ecm.c > index 80841de845b0..027226325039 100644 > --- a/drivers/usb/gadget/function/f_ecm.c > +++ b/drivers/usb/gadget/function/f_ecm.c > @@ -892,6 +892,12 @@ static void ecm_resume(struct usb_function *f) > gether_resume(&ecm->port); > } > > +static int ecm_get_status(struct usb_function *f) > +{ > + return (f->func_wakeup_armed ? USB_INTRF_STAT_FUNC_RW : 0) | > + USB_INTRF_STAT_FUNC_RW_CAP; > +} > + Why does USB_INTRF_STAT_FUNC_RW_CAP is set regardless of USB_CONFIG_ATT_WAKEUP? BR, Thinh > static void ecm_free(struct usb_function *f) > { > struct f_ecm *ecm; > @@ -960,6 +966,7 @@ static struct usb_function *ecm_alloc(struct usb_function_instance *fi) > ecm->port.func.disable = ecm_disable; > ecm->port.func.free_func = ecm_free; > ecm->port.func.suspend = ecm_suspend; > + ecm->port.func.get_status = ecm_get_status; > ecm->port.func.resume = ecm_resume; > > return &ecm->port.func; > -- > 2.25.1 >
On 08-04-25 06:38 am, Thinh Nguyen wrote: > On Thu, Apr 03, 2025, Prashanth K wrote: >> When host sends GET_STATUS to ECM interface, handle the request >> from the function driver. Since the interface is wakeup capable, >> set the corresponding bit, and set RW bit if the function is >> already armed for wakeup by the host. >> >> Cc: stable@kernel.org >> Fixes: 481c225c4802 ("usb: gadget: Handle function suspend feature selector") >> Signed-off-by: Prashanth K <prashanth.k@oss.qualcomm.com> >> --- >> drivers/usb/gadget/function/f_ecm.c | 7 +++++++ >> 1 file changed, 7 insertions(+) >> >> diff --git a/drivers/usb/gadget/function/f_ecm.c b/drivers/usb/gadget/function/f_ecm.c >> index 80841de845b0..027226325039 100644 >> --- a/drivers/usb/gadget/function/f_ecm.c >> +++ b/drivers/usb/gadget/function/f_ecm.c >> @@ -892,6 +892,12 @@ static void ecm_resume(struct usb_function *f) >> gether_resume(&ecm->port); >> } >> >> +static int ecm_get_status(struct usb_function *f) >> +{ >> + return (f->func_wakeup_armed ? USB_INTRF_STAT_FUNC_RW : 0) | >> + USB_INTRF_STAT_FUNC_RW_CAP; >> +} >> + > > Why does USB_INTRF_STAT_FUNC_RW_CAP is set regardless of > USB_CONFIG_ATT_WAKEUP? > We check that in composite.c before calling get_status(). Have added some comments there [Patch v1 2/3] regarding same. Thanks, Prashanth K
On Tue, Apr 08, 2025, Prashanth K wrote: > > > On 08-04-25 06:38 am, Thinh Nguyen wrote: > > On Thu, Apr 03, 2025, Prashanth K wrote: > >> When host sends GET_STATUS to ECM interface, handle the request > >> from the function driver. Since the interface is wakeup capable, > >> set the corresponding bit, and set RW bit if the function is > >> already armed for wakeup by the host. > >> > >> Cc: stable@kernel.org > >> Fixes: 481c225c4802 ("usb: gadget: Handle function suspend feature selector") > >> Signed-off-by: Prashanth K <prashanth.k@oss.qualcomm.com> > >> --- > >> drivers/usb/gadget/function/f_ecm.c | 7 +++++++ > >> 1 file changed, 7 insertions(+) > >> > >> diff --git a/drivers/usb/gadget/function/f_ecm.c b/drivers/usb/gadget/function/f_ecm.c > >> index 80841de845b0..027226325039 100644 > >> --- a/drivers/usb/gadget/function/f_ecm.c > >> +++ b/drivers/usb/gadget/function/f_ecm.c > >> @@ -892,6 +892,12 @@ static void ecm_resume(struct usb_function *f) > >> gether_resume(&ecm->port); > >> } > >> > >> +static int ecm_get_status(struct usb_function *f) > >> +{ > >> + return (f->func_wakeup_armed ? USB_INTRF_STAT_FUNC_RW : 0) | > >> + USB_INTRF_STAT_FUNC_RW_CAP; > >> +} > >> + > > > > Why does USB_INTRF_STAT_FUNC_RW_CAP is set regardless of > > USB_CONFIG_ATT_WAKEUP? > > > We check that in composite.c before calling get_status(). > Have added some comments there [Patch v1 2/3] regarding same. > Ok, let's discuss on the other thread. Thanks, Thinh
© 2016 - 2025 Red Hat, Inc.