[PATCH] usb: gadget: add temporary __uses_feature_flags

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



during the conversion to a new method of finding
proper endpoints, we need to give our users a
grace period until full conversion is finished.

This patch adds a new internal and temporary
__uses_feature_flags flag which will tell gadget
framework that this UDC has been converted to
the new feature flag-based endpoint scheme.

Once all gadget drivers are converted, this
flag will be removed.

Signed-off-by: Felipe Balbi <balbi@xxxxxx>
---
 drivers/usb/dwc3/gadget.c       |  1 +
 drivers/usb/gadget/epautoconf.c | 48 +++++++++++++++++++++--------------------
 drivers/usb/gadget/s3c-hsotg.c  |  1 +
 include/linux/usb/gadget.h      |  2 ++
 4 files changed, 29 insertions(+), 23 deletions(-)

diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c
index eaf8537..54b40ce 100644
--- a/drivers/usb/dwc3/gadget.c
+++ b/drivers/usb/dwc3/gadget.c
@@ -2733,6 +2733,7 @@ int dwc3_gadget_init(struct dwc3 *dwc)
 	dwc->gadget.speed		= USB_SPEED_UNKNOWN;
 	dwc->gadget.sg_supported	= true;
 	dwc->gadget.name		= "dwc3-gadget";
+	dwc->gadget.__uses_feature_flags = true;
 
 	/*
 	 * Per databook, DWC3 needs buffer size to be aligned to MaxPacketSize
diff --git a/drivers/usb/gadget/epautoconf.c b/drivers/usb/gadget/epautoconf.c
index d82ec71..1a71a14 100644
--- a/drivers/usb/gadget/epautoconf.c
+++ b/drivers/usb/gadget/epautoconf.c
@@ -61,31 +61,33 @@ ep_matches (
 	if (USB_ENDPOINT_XFER_CONTROL == type)
 		return 0;
 
-	/* first check feature flags */
-	if (usb_endpoint_dir_in(desc))
-		if (!ep->has_dir_in)
-			return 0;
+	if (gadget->__uses_feature_flags) {
+		/* first check feature flags */
+		if (usb_endpoint_dir_in(desc))
+			if (!ep->has_dir_in)
+				return 0;
 
-	if (usb_endpoint_dir_out(desc))
-		if (!ep->has_dir_out)
-			return 0;
+		if (usb_endpoint_dir_out(desc))
+			if (!ep->has_dir_out)
+				return 0;
 
-	switch (type) {
-	case USB_ENDPOINT_XFER_CONTROL:
-		/* only ep0 */
-		return 0;
-	case USB_ENDPOINT_XFER_BULK:
-		if (ep->has_bulk)
-			goto match;
-		break;
-	case USB_ENDPOINT_XFER_INT:
-		if (ep->has_interrupt)
-			goto match;
-		break;
-	case USB_ENDPOINT_XFER_ISOC:
-		if (ep->has_isochronous)
-			goto match;
-		break;
+		switch (type) {
+		case USB_ENDPOINT_XFER_CONTROL:
+			/* only ep0 */
+			return 0;
+		case USB_ENDPOINT_XFER_BULK:
+			if (ep->has_bulk)
+				goto match;
+			break;
+		case USB_ENDPOINT_XFER_INT:
+			if (ep->has_interrupt)
+				goto match;
+			break;
+		case USB_ENDPOINT_XFER_ISOC:
+			if (ep->has_isochronous)
+				goto match;
+			break;
+		}
 	}
 
 	/* some other naming convention */
diff --git a/drivers/usb/gadget/s3c-hsotg.c b/drivers/usb/gadget/s3c-hsotg.c
index 9f9e2ce..c75576a 100644
--- a/drivers/usb/gadget/s3c-hsotg.c
+++ b/drivers/usb/gadget/s3c-hsotg.c
@@ -3641,6 +3641,7 @@ static int s3c_hsotg_probe(struct platform_device *pdev)
 	hsotg->gadget.max_speed = USB_SPEED_HIGH;
 	hsotg->gadget.ops = &s3c_hsotg_gadget_ops;
 	hsotg->gadget.name = dev_name(dev);
+	hsotg->gadget.__uses_feature_flags = true;
 
 	/* reset the system */
 
diff --git a/include/linux/usb/gadget.h b/include/linux/usb/gadget.h
index abd836e..f52b191 100644
--- a/include/linux/usb/gadget.h
+++ b/include/linux/usb/gadget.h
@@ -536,6 +536,7 @@ struct usb_gadget_ops {
  *	enabled HNP support.
  * @quirk_ep_out_aligned_size: epout requires buffer size to be aligned to
  *	MaxPacketSize.
+ * @__uses_feature_flags: true when UDC uses new feature flags (temporary)
  *
  * Gadgets have a mostly-portable "gadget driver" implementing device
  * functions, handling all usb configurations and interfaces.  Gadget
@@ -576,6 +577,7 @@ struct usb_gadget {
 	unsigned			a_hnp_support:1;
 	unsigned			a_alt_hnp_support:1;
 	unsigned			quirk_ep_out_aligned_size:1;
+	unsigned			__uses_feature_flags:1;
 };
 #define work_to_gadget(w)	(container_of((w), struct usb_gadget, work))
 
-- 
1.9.0

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux