usb: gadget: add temporary __uses_feature_flags

Message ID 1393866242-14132-1-git-send-email-balbi@ti.com
State New
Headers show

Commit Message

Felipe Balbi March 3, 2014, 5:04 p.m.
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@ti.com>
---
 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(-)

Comments

Felipe Balbi March 3, 2014, 10:52 p.m. | #1
On Mon, Mar 03, 2014 at 02:46:32PM -0800, Greg KH wrote:
> On Mon, Mar 03, 2014 at 11:04:02AM -0600, Felipe Balbi wrote:
> > 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.
> 
> Who are these "users"?  kernel developers?  Or end-users?

kernel developers.

> > 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@ti.com>
> > ---
> >  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;
> 
> I don't really understand what this is doing for anyone.  Can't we just
> fix up all in-kernel users of the flags properly?

I can try to do that, yes, but for v3.15 might be quite a bit of work.
Anyway, I guess we still have a few days left.

cheers
Felipe Balbi March 5, 2014, 3:45 p.m. | #2
On Mon, Mar 03, 2014 at 04:52:27PM -0600, Felipe Balbi wrote:
> On Mon, Mar 03, 2014 at 02:46:32PM -0800, Greg KH wrote:
> > On Mon, Mar 03, 2014 at 11:04:02AM -0600, Felipe Balbi wrote:
> > > 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.
> > 
> > Who are these "users"?  kernel developers?  Or end-users?
> 
> kernel developers.
> 
> > > 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@ti.com>
> > > ---
> > >  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;
> > 
> > I don't really understand what this is doing for anyone.  Can't we just
> > fix up all in-kernel users of the flags properly?
> 
> I can try to do that, yes, but for v3.15 might be quite a bit of work.
> Anyway, I guess we still have a few days left.

I have dropped those patches from my "next" branch, it'll give me more
time to make this right for v3.16.
Greg KH March 5, 2014, 6:17 p.m. | #3
On Wed, Mar 05, 2014 at 09:45:22AM -0600, Felipe Balbi wrote:
> On Mon, Mar 03, 2014 at 04:52:27PM -0600, Felipe Balbi wrote:
> > On Mon, Mar 03, 2014 at 02:46:32PM -0800, Greg KH wrote:
> > > On Mon, Mar 03, 2014 at 11:04:02AM -0600, Felipe Balbi wrote:
> > > > 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.
> > > 
> > > Who are these "users"?  kernel developers?  Or end-users?
> > 
> > kernel developers.
> > 
> > > > 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@ti.com>
> > > > ---
> > > >  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;
> > > 
> > > I don't really understand what this is doing for anyone.  Can't we just
> > > fix up all in-kernel users of the flags properly?
> > 
> > I can try to do that, yes, but for v3.15 might be quite a bit of work.
> > Anyway, I guess we still have a few days left.
> 
> I have dropped those patches from my "next" branch, it'll give me more
> time to make this right for v3.16.

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

Patch

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))