* [PATCH] usb: gadget: make usb_ep_enable return -EBUSY if ep has already enabled
@ 2015-12-04 7:24 changbin.du
2015-12-10 17:24 ` Felipe Balbi
0 siblings, 1 reply; 4+ messages in thread
From: changbin.du @ 2015-12-04 7:24 UTC (permalink / raw)
To: balbi; +Cc: gregkh, John.Youn, linux-usb, linux-kernel, Du, Changbin
From: "Du, Changbin" <changbin.du@intel.com>
When usb_ep_enable on a enabled ep, the configuration of the ep probably
has changed. In this scenario, the ep configuration in hw should be
reprogrammed by udc driver. Hence, it is better to return an error to
inform the caller.
Signed-off-by: Du, Changbin <changbin.du@intel.com>
---
include/linux/usb/gadget.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/include/linux/usb/gadget.h b/include/linux/usb/gadget.h
index d813bd2..89f9fdd 100644
--- a/include/linux/usb/gadget.h
+++ b/include/linux/usb/gadget.h
@@ -268,7 +268,7 @@ static inline int usb_ep_enable(struct usb_ep *ep)
int ret;
if (ep->enabled)
- return 0;
+ return -EBUSY;
ret = ep->ops->enable(ep, ep->desc);
if (ret)
--
2.5.0
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] usb: gadget: make usb_ep_enable return -EBUSY if ep has already enabled
2015-12-04 7:24 [PATCH] usb: gadget: make usb_ep_enable return -EBUSY if ep has already enabled changbin.du
@ 2015-12-10 17:24 ` Felipe Balbi
2015-12-14 3:16 ` Du, Changbin
2015-12-14 3:40 ` [PATCH v2] " changbin.du
0 siblings, 2 replies; 4+ messages in thread
From: Felipe Balbi @ 2015-12-10 17:24 UTC (permalink / raw)
To: changbin.du; +Cc: gregkh, John.Youn, linux-usb, linux-kernel, Du, Changbin
[-- Attachment #1: Type: text/plain, Size: 939 bytes --]
Hi,
changbin.du@intel.com writes:
> From: "Du, Changbin" <changbin.du@intel.com>
>
> When usb_ep_enable on a enabled ep, the configuration of the ep probably
> has changed. In this scenario, the ep configuration in hw should be
> reprogrammed by udc driver. Hence, it is better to return an error to
> inform the caller.
>
> Signed-off-by: Du, Changbin <changbin.du@intel.com>
> ---
> include/linux/usb/gadget.h | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/include/linux/usb/gadget.h b/include/linux/usb/gadget.h
> index d813bd2..89f9fdd 100644
> --- a/include/linux/usb/gadget.h
> +++ b/include/linux/usb/gadget.h
> @@ -268,7 +268,7 @@ static inline int usb_ep_enable(struct usb_ep *ep)
> int ret;
>
> if (ep->enabled)
> - return 0;
> + return -EBUSY;
While at that, can you add a WARN_ON() as well ?
if (WARN_ON(ep->enabled))
return -EBUSY;
--
balbi
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 818 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread* RE: [PATCH] usb: gadget: make usb_ep_enable return -EBUSY if ep has already enabled
2015-12-10 17:24 ` Felipe Balbi
@ 2015-12-14 3:16 ` Du, Changbin
2015-12-14 3:40 ` [PATCH v2] " changbin.du
1 sibling, 0 replies; 4+ messages in thread
From: Du, Changbin @ 2015-12-14 3:16 UTC (permalink / raw)
To: Felipe Balbi; +Cc: gregkh, John.Youn, linux-usb, linux-kernel
> > When usb_ep_enable on a enabled ep, the configuration of the ep
> probably
> > has changed. In this scenario, the ep configuration in hw should be
> > reprogrammed by udc driver. Hence, it is better to return an error to
> > inform the caller.
> >
> > Signed-off-by: Du, Changbin <changbin.du@intel.com>
> > ---
> > include/linux/usb/gadget.h | 2 +-
> > 1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/include/linux/usb/gadget.h b/include/linux/usb/gadget.h
> > index d813bd2..89f9fdd 100644
> > --- a/include/linux/usb/gadget.h
> > +++ b/include/linux/usb/gadget.h
> > @@ -268,7 +268,7 @@ static inline int usb_ep_enable(struct usb_ep *ep)
> > int ret;
> >
> > if (ep->enabled)
> > - return 0;
> > + return -EBUSY;
>
> While at that, can you add a WARN_ON() as well ?
>
> if (WARN_ON(ep->enabled))
> return -EBUSY;
>
> --
> balbi
I will update the patch, thanks.
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH v2] usb: gadget: make usb_ep_enable return -EBUSY if ep has already enabled
2015-12-10 17:24 ` Felipe Balbi
2015-12-14 3:16 ` Du, Changbin
@ 2015-12-14 3:40 ` changbin.du
1 sibling, 0 replies; 4+ messages in thread
From: changbin.du @ 2015-12-14 3:40 UTC (permalink / raw)
To: balbi; +Cc: gregkh, John.Youn, linux-usb, linux-kernel, Du, Changbin
From: "Du, Changbin" <changbin.du@intel.com>
When usb_ep_enable on a enabled ep, the configuration of the ep probably
has changed. In this scenario, the ep configuration in hw should be
reprogrammed by udc driver. Hence, it is better to return an error to
inform the caller.
Signed-off-by: Du, Changbin <changbin.du@intel.com>
---
change from v1: add WARN_ON_ONCE message.
---
include/linux/usb/gadget.h | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/include/linux/usb/gadget.h b/include/linux/usb/gadget.h
index 3d583a1..b88df2a 100644
--- a/include/linux/usb/gadget.h
+++ b/include/linux/usb/gadget.h
@@ -267,8 +267,12 @@ static inline int usb_ep_enable(struct usb_ep *ep)
{
int ret;
- if (ep->enabled)
- return 0;
+ /**
+ * An enabled ep may has requests in progress, hence shouldn't
+ * reprogram its hw configuration.
+ */
+ if (WARN_ON_ONCE(ep->enabled))
+ return -EBUSY;
ret = ep->ops->enable(ep, ep->desc);
if (ret)
--
2.5.0
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2015-12-14 3:48 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-12-04 7:24 [PATCH] usb: gadget: make usb_ep_enable return -EBUSY if ep has already enabled changbin.du
2015-12-10 17:24 ` Felipe Balbi
2015-12-14 3:16 ` Du, Changbin
2015-12-14 3:40 ` [PATCH v2] " changbin.du
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome