[OPW,kernel,3/3] staging: emxx_udc: use USB API functions rather than constants
diff mbox

Message ID 41cf36bf7039cd29d2fc9331fd6f9c8d395a7f18.1414686497.git.tapaswenipathak@gmail.com
State New, archived
Headers show

Commit Message

Tapasweni Pathak Oct. 30, 2014, 4:33 p.m. UTC
This patch introduces the use of the functions usb_endpoint_type and
usb_endpoint_num.

The Coccinelle semantic patch that makes these changes is as follows:

@@ struct usb_endpoint_descriptor *epd; @@

- (epd->bEndpointAddress & \(USB_ENDPOINT_NUMBER_MASK\|0x0f\))
+ usb_endpoint_num(epd)

@@ struct usb_endpoint_descriptor *epd; @@

- (epd->bmAttributes & \(USB_ENDPOINT_XFERTYPE_MASK\|3\))
+ usb_endpoint_type(epd)

Build Tested it.

Signed-off-by: Tapasweni Pathak <tapaswenipathak@gmail.com>
---
 drivers/staging/emxx_udc/emxx_udc.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

--
1.7.9.5

Comments

Julia Lawall Oct. 30, 2014, 4:35 p.m. UTC | #1
On Thu, 30 Oct 2014, Tapasweni Pathak wrote:

> This patch introduces the use of the functions usb_endpoint_type and
> usb_endpoint_num.
>
> The Coccinelle semantic patch that makes these changes is as follows:
>
> @@ struct usb_endpoint_descriptor *epd; @@
>
> - (epd->bEndpointAddress & \(USB_ENDPOINT_NUMBER_MASK\|0x0f\))
> + usb_endpoint_num(epd)
>
> @@ struct usb_endpoint_descriptor *epd; @@
>
> - (epd->bmAttributes & \(USB_ENDPOINT_XFERTYPE_MASK\|3\))
> + usb_endpoint_type(epd)
>
> Build Tested it.
>
> Signed-off-by: Tapasweni Pathak <tapaswenipathak@gmail.com>
> ---
>  drivers/staging/emxx_udc/emxx_udc.c |    4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/staging/emxx_udc/emxx_udc.c b/drivers/staging/emxx_udc/emxx_udc.c
> index 77e4aee..0261d0b 100644
> --- a/drivers/staging/emxx_udc/emxx_udc.c
> +++ b/drivers/staging/emxx_udc/emxx_udc.c
> @@ -2622,7 +2622,7 @@ static int nbu2ss_ep_enable(
>  		return -EINVAL;
>  	}
>
> -	ep_type = desc->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK;
> +	ep_type = usb_endpoint_type(desc);
>  	if ((ep_type == USB_ENDPOINT_XFER_CONTROL)
>  		|| (ep_type == USB_ENDPOINT_XFER_ISOC)) {
>
> @@ -2644,7 +2644,7 @@ static int nbu2ss_ep_enable(
>  	spin_lock_irqsave(&udc->lock, flags);
>
>  	ep->desc = desc;
> -	ep->epnum = desc->bEndpointAddress & USB_ENDPOINT_NUMBER_MASK;
> +	ep->epnum = usb_endpoint_num(desc);
>  	ep->direct = desc->bEndpointAddress & USB_ENDPOINT_DIR_MASK;

There is nothing to do for this one?

julia

>  	ep->ep_type = ep_type;
>  	ep->wedged = 0;
> --
> 1.7.9.5
>
> --
> You received this message because you are subscribed to the Google Groups "opw-kernel" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to opw-kernel+unsubscribe@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>
Greg KH Oct. 30, 2014, 7:17 p.m. UTC | #2
On Thu, Oct 30, 2014 at 05:35:34PM +0100, Julia Lawall wrote:
> 
> 
> On Thu, 30 Oct 2014, Tapasweni Pathak wrote:
> 
> > This patch introduces the use of the functions usb_endpoint_type and
> > usb_endpoint_num.
> >
> > The Coccinelle semantic patch that makes these changes is as follows:
> >
> > @@ struct usb_endpoint_descriptor *epd; @@
> >
> > - (epd->bEndpointAddress & \(USB_ENDPOINT_NUMBER_MASK\|0x0f\))
> > + usb_endpoint_num(epd)
> >
> > @@ struct usb_endpoint_descriptor *epd; @@
> >
> > - (epd->bmAttributes & \(USB_ENDPOINT_XFERTYPE_MASK\|3\))
> > + usb_endpoint_type(epd)
> >
> > Build Tested it.
> >
> > Signed-off-by: Tapasweni Pathak <tapaswenipathak@gmail.com>
> > ---
> >  drivers/staging/emxx_udc/emxx_udc.c |    4 ++--
> >  1 file changed, 2 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/staging/emxx_udc/emxx_udc.c b/drivers/staging/emxx_udc/emxx_udc.c
> > index 77e4aee..0261d0b 100644
> > --- a/drivers/staging/emxx_udc/emxx_udc.c
> > +++ b/drivers/staging/emxx_udc/emxx_udc.c
> > @@ -2622,7 +2622,7 @@ static int nbu2ss_ep_enable(
> >  		return -EINVAL;
> >  	}
> >
> > -	ep_type = desc->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK;
> > +	ep_type = usb_endpoint_type(desc);
> >  	if ((ep_type == USB_ENDPOINT_XFER_CONTROL)
> >  		|| (ep_type == USB_ENDPOINT_XFER_ISOC)) {
> >
> > @@ -2644,7 +2644,7 @@ static int nbu2ss_ep_enable(
> >  	spin_lock_irqsave(&udc->lock, flags);
> >
> >  	ep->desc = desc;
> > -	ep->epnum = desc->bEndpointAddress & USB_ENDPOINT_NUMBER_MASK;
> > +	ep->epnum = usb_endpoint_num(desc);
> >  	ep->direct = desc->bEndpointAddress & USB_ENDPOINT_DIR_MASK;
> 
> There is nothing to do for this one?

You can use usb_endpoint_dir_in() or usb_endpoint_dir_out(), but that
doesn't really work here.  This driver is pretty crazy in this handling
of USB endpoints, so for now, it needs to stay as-is, but ideally, this
whole logic should be rewritten to be more "standard" and simple with
regards to how endpoints are handled.

thanks,

greg k-h

Patch
diff mbox

diff --git a/drivers/staging/emxx_udc/emxx_udc.c b/drivers/staging/emxx_udc/emxx_udc.c
index 77e4aee..0261d0b 100644
--- a/drivers/staging/emxx_udc/emxx_udc.c
+++ b/drivers/staging/emxx_udc/emxx_udc.c
@@ -2622,7 +2622,7 @@  static int nbu2ss_ep_enable(
 		return -EINVAL;
 	}

-	ep_type = desc->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK;
+	ep_type = usb_endpoint_type(desc);
 	if ((ep_type == USB_ENDPOINT_XFER_CONTROL)
 		|| (ep_type == USB_ENDPOINT_XFER_ISOC)) {

@@ -2644,7 +2644,7 @@  static int nbu2ss_ep_enable(
 	spin_lock_irqsave(&udc->lock, flags);

 	ep->desc = desc;
-	ep->epnum = desc->bEndpointAddress & USB_ENDPOINT_NUMBER_MASK;
+	ep->epnum = usb_endpoint_num(desc);
 	ep->direct = desc->bEndpointAddress & USB_ENDPOINT_DIR_MASK;
 	ep->ep_type = ep_type;
 	ep->wedged = 0;