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

Message ID 8f90947353d33148e4de8b566a8947f281f418ca.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.

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/media/lirc/lirc_igorplugusb.c |    2 +-
 drivers/staging/media/lirc/lirc_imon.c        |    2 +-
 drivers/staging/media/lirc/lirc_sasem.c       |    2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

--
1.7.9.5

Comments

Greg KH Oct. 30, 2014, 8:16 p.m. UTC | #1
On Thu, Oct 30, 2014 at 10:03:09PM +0530, Tapasweni Pathak wrote:
> This patch introduces the use of the functions usb_endpoint_type.
> 
> 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/media/lirc/lirc_igorplugusb.c |    2 +-
>  drivers/staging/media/lirc/lirc_imon.c        |    2 +-
>  drivers/staging/media/lirc/lirc_sasem.c       |    2 +-
>  3 files changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/staging/media/lirc/lirc_igorplugusb.c b/drivers/staging/media/lirc/lirc_igorplugusb.c
> index fd5d3d2..c0bad43 100644
> --- a/drivers/staging/media/lirc/lirc_igorplugusb.c
> +++ b/drivers/staging/media/lirc/lirc_igorplugusb.c
> @@ -378,7 +378,7 @@ static int igorplugusb_remote_probe(struct usb_interface *intf,
>  	ep = &idesc->endpoint->desc;
>  	if (((ep->bEndpointAddress & USB_ENDPOINT_DIR_MASK)
>  	    != USB_DIR_IN)
> -	    || (ep->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK)
> +	    || usb_endpoint_type(ep)
>  	    != USB_ENDPOINT_XFER_CONTROL)

What about using usb_endpoint_xfer_control() instead?  And testing for a
direction of a control endpoint makes no sense, by definition it is
bidirectional.

>  		return -ENODEV;
> 
> diff --git a/drivers/staging/media/lirc/lirc_imon.c b/drivers/staging/media/lirc/lirc_imon.c
> index 387dc4b..fc761c0 100644
> --- a/drivers/staging/media/lirc/lirc_imon.c
> +++ b/drivers/staging/media/lirc/lirc_imon.c
> @@ -751,7 +751,7 @@ static int imon_probe(struct usb_interface *interface,
> 
>  		ep = &iface_desc->endpoint[i].desc;
>  		ep_dir = ep->bEndpointAddress & USB_ENDPOINT_DIR_MASK;
> -		ep_type = ep->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK;
> +		ep_type = usb_endpoint_type(ep);
> 
>  		if (!ir_ep_found &&
>  			ep_dir == USB_DIR_IN &&

Can you use other usb functions here as well?  What happens to ep_dir?


> diff --git a/drivers/staging/media/lirc/lirc_sasem.c b/drivers/staging/media/lirc/lirc_sasem.c
> index 3836c42..3212354 100644
> --- a/drivers/staging/media/lirc/lirc_sasem.c
> +++ b/drivers/staging/media/lirc/lirc_sasem.c
> @@ -711,7 +711,7 @@ static int sasem_probe(struct usb_interface *interface,
> 
>  		ep = &iface_desc->endpoint [i].desc;
>  		ep_dir = ep->bEndpointAddress & USB_ENDPOINT_DIR_MASK;
> -		ep_type = ep->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK;
> +		ep_type = usb_endpoint_type(ep);
> 
>  		if (!ir_ep_found &&
>  			ep_dir == USB_DIR_IN &&

Same here as above.

thanks,

greg k-h

Patch
diff mbox

diff --git a/drivers/staging/media/lirc/lirc_igorplugusb.c b/drivers/staging/media/lirc/lirc_igorplugusb.c
index fd5d3d2..c0bad43 100644
--- a/drivers/staging/media/lirc/lirc_igorplugusb.c
+++ b/drivers/staging/media/lirc/lirc_igorplugusb.c
@@ -378,7 +378,7 @@  static int igorplugusb_remote_probe(struct usb_interface *intf,
 	ep = &idesc->endpoint->desc;
 	if (((ep->bEndpointAddress & USB_ENDPOINT_DIR_MASK)
 	    != USB_DIR_IN)
-	    || (ep->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK)
+	    || usb_endpoint_type(ep)
 	    != USB_ENDPOINT_XFER_CONTROL)
 		return -ENODEV;

diff --git a/drivers/staging/media/lirc/lirc_imon.c b/drivers/staging/media/lirc/lirc_imon.c
index 387dc4b..fc761c0 100644
--- a/drivers/staging/media/lirc/lirc_imon.c
+++ b/drivers/staging/media/lirc/lirc_imon.c
@@ -751,7 +751,7 @@  static int imon_probe(struct usb_interface *interface,

 		ep = &iface_desc->endpoint[i].desc;
 		ep_dir = ep->bEndpointAddress & USB_ENDPOINT_DIR_MASK;
-		ep_type = ep->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK;
+		ep_type = usb_endpoint_type(ep);

 		if (!ir_ep_found &&
 			ep_dir == USB_DIR_IN &&
diff --git a/drivers/staging/media/lirc/lirc_sasem.c b/drivers/staging/media/lirc/lirc_sasem.c
index 3836c42..3212354 100644
--- a/drivers/staging/media/lirc/lirc_sasem.c
+++ b/drivers/staging/media/lirc/lirc_sasem.c
@@ -711,7 +711,7 @@  static int sasem_probe(struct usb_interface *interface,

 		ep = &iface_desc->endpoint [i].desc;
 		ep_dir = ep->bEndpointAddress & USB_ENDPOINT_DIR_MASK;
-		ep_type = ep->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK;
+		ep_type = usb_endpoint_type(ep);

 		if (!ir_ep_found &&
 			ep_dir == USB_DIR_IN &&