Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1290819 > unrolled thread

[PATCH v2] usb: gadget: make usb_ep_enable return -EBUSY if ep has already enabled

Started bychangbin.du@intel.com
First post2015-12-14 04:50 +0100
Last post2015-12-14 04:50 +0100
Articles 1 — 1 participant

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  [PATCH v2] usb: gadget: make usb_ep_enable return -EBUSY if ep has already enabled changbin.du@intel.com - 2015-12-14 04:50 +0100

#1290819 — [PATCH v2] usb: gadget: make usb_ep_enable return -EBUSY if ep has already enabled

Fromchangbin.du@intel.com
Date2015-12-14 04:50 +0100
Subject[PATCH v2] usb: gadget: make usb_ep_enable return -EBUSY if ep has already enabled
Message-ID<qFsj7-ED-7@gated-at.bofh.it>
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

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [standalone]


Back to top | Article view | linux.kernel


csiph-web