aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb
diff options
context:
space:
mode:
authorJulia Lawall <julia@diku.dk>2008-12-29 05:22:14 -0500
committerGreg Kroah-Hartman <gregkh@suse.de>2009-03-24 19:20:28 -0400
commit2e0fe709687470637a0709b930ccc9e993d2dad5 (patch)
tree97bd47eee757905185ac8341fe350e046d027aa3 /drivers/usb
parent00185a60c37549531b9eee562d3eba19020875d5 (diff)
USB: drivers: use USB API functions rather than constants
This set of patches introduces calls to the following set of functions: usb_endpoint_dir_in(epd) usb_endpoint_dir_out(epd) usb_endpoint_is_bulk_in(epd) usb_endpoint_is_bulk_out(epd) usb_endpoint_is_int_in(epd) usb_endpoint_is_int_out(epd) usb_endpoint_num(epd) usb_endpoint_type(epd) usb_endpoint_xfer_bulk(epd) usb_endpoint_xfer_control(epd) usb_endpoint_xfer_int(epd) usb_endpoint_xfer_isoc(epd) In some cases, introducing one of these functions is not possible, and it just replaces an explicit integer value by one of the following constants: USB_ENDPOINT_XFER_BULK USB_ENDPOINT_XFER_CONTROL USB_ENDPOINT_XFER_INT USB_ENDPOINT_XFER_ISOC An extract of the semantic patch that makes these changes is as follows: (http://www.emn.fr/x-info/coccinelle/) // <smpl> @r1@ struct usb_endpoint_descriptor *epd; @@ - ((epd->bmAttributes & \(USB_ENDPOINT_XFERTYPE_MASK\|3\)) == - \(USB_ENDPOINT_XFER_CONTROL\|0\)) + usb_endpoint_xfer_control(epd) @r5@ struct usb_endpoint_descriptor *epd; @@ - ((epd->bEndpointAddress & \(USB_ENDPOINT_DIR_MASK\|0x80\)) == - \(USB_DIR_IN\|0x80\)) + usb_endpoint_dir_in(epd) @inc@ @@ #include <linux/usb.h> @depends on !inc && (r1||r5)@ @@ + #include <linux/usb.h> #include <linux/usb/...> // </smpl> Signed-off-by: Julia Lawall <julia@diku.dk> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/usb')
-rw-r--r--drivers/usb/core/devices.c2
-rw-r--r--drivers/usb/core/endpoint.c9
-rw-r--r--drivers/usb/host/r8a66597-hcd.c15
-rw-r--r--drivers/usb/serial/keyspan.c2
-rw-r--r--drivers/usb/storage/usb.c6
5 files changed, 16 insertions, 18 deletions
diff --git a/drivers/usb/core/devices.c b/drivers/usb/core/devices.c
index 6ec38175a817..73c108d117b4 100644
--- a/drivers/usb/core/devices.c
+++ b/drivers/usb/core/devices.c
@@ -187,7 +187,7 @@ static char *usb_dump_endpoint_descriptor(int speed, char *start, char *end,
187 } 187 }
188 188
189 /* this isn't checking for illegal values */ 189 /* this isn't checking for illegal values */
190 switch (desc->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) { 190 switch (usb_endpoint_type(desc)) {
191 case USB_ENDPOINT_XFER_CONTROL: 191 case USB_ENDPOINT_XFER_CONTROL:
192 type = "Ctrl"; 192 type = "Ctrl";
193 if (speed == USB_SPEED_HIGH) /* uframes per NAK */ 193 if (speed == USB_SPEED_HIGH) /* uframes per NAK */
diff --git a/drivers/usb/core/endpoint.c b/drivers/usb/core/endpoint.c
index e1710f260b4f..40dee2ac0133 100644
--- a/drivers/usb/core/endpoint.c
+++ b/drivers/usb/core/endpoint.c
@@ -66,7 +66,7 @@ static ssize_t show_ep_type(struct device *dev, struct device_attribute *attr,
66 struct ep_device *ep = to_ep_device(dev); 66 struct ep_device *ep = to_ep_device(dev);
67 char *type = "unknown"; 67 char *type = "unknown";
68 68
69 switch (ep->desc->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) { 69 switch (usb_endpoint_type(ep->desc)) {
70 case USB_ENDPOINT_XFER_CONTROL: 70 case USB_ENDPOINT_XFER_CONTROL:
71 type = "Control"; 71 type = "Control";
72 break; 72 break;
@@ -94,7 +94,7 @@ static ssize_t show_ep_interval(struct device *dev,
94 94
95 in = (ep->desc->bEndpointAddress & USB_DIR_IN); 95 in = (ep->desc->bEndpointAddress & USB_DIR_IN);
96 96
97 switch (ep->desc->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) { 97 switch (usb_endpoint_type(ep->desc)) {
98 case USB_ENDPOINT_XFER_CONTROL: 98 case USB_ENDPOINT_XFER_CONTROL:
99 if (ep->udev->speed == USB_SPEED_HIGH) /* uframes per NAK */ 99 if (ep->udev->speed == USB_SPEED_HIGH) /* uframes per NAK */
100 interval = ep->desc->bInterval; 100 interval = ep->desc->bInterval;
@@ -131,10 +131,9 @@ static ssize_t show_ep_direction(struct device *dev,
131 struct ep_device *ep = to_ep_device(dev); 131 struct ep_device *ep = to_ep_device(dev);
132 char *direction; 132 char *direction;
133 133
134 if ((ep->desc->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) == 134 if (usb_endpoint_xfer_control(ep->desc))
135 USB_ENDPOINT_XFER_CONTROL)
136 direction = "both"; 135 direction = "both";
137 else if (ep->desc->bEndpointAddress & USB_DIR_IN) 136 else if (usb_endpoint_dir_in(ep->desc))
138 direction = "in"; 137 direction = "in";
139 else 138 else
140 direction = "out"; 139 direction = "out";
diff --git a/drivers/usb/host/r8a66597-hcd.c b/drivers/usb/host/r8a66597-hcd.c
index 319041205b57..5e942d94aebe 100644
--- a/drivers/usb/host/r8a66597-hcd.c
+++ b/drivers/usb/host/r8a66597-hcd.c
@@ -660,9 +660,9 @@ static u16 get_empty_pipenum(struct r8a66597 *r8a66597,
660 u16 array[R8A66597_MAX_NUM_PIPE], i = 0, min; 660 u16 array[R8A66597_MAX_NUM_PIPE], i = 0, min;
661 661
662 memset(array, 0, sizeof(array)); 662 memset(array, 0, sizeof(array));
663 switch (ep->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) { 663 switch (usb_endpoint_type(ep)) {
664 case USB_ENDPOINT_XFER_BULK: 664 case USB_ENDPOINT_XFER_BULK:
665 if (ep->bEndpointAddress & USB_ENDPOINT_DIR_MASK) 665 if (usb_endpoint_dir_in(ep))
666 array[i++] = 4; 666 array[i++] = 4;
667 else { 667 else {
668 array[i++] = 3; 668 array[i++] = 3;
@@ -670,7 +670,7 @@ static u16 get_empty_pipenum(struct r8a66597 *r8a66597,
670 } 670 }
671 break; 671 break;
672 case USB_ENDPOINT_XFER_INT: 672 case USB_ENDPOINT_XFER_INT:
673 if (ep->bEndpointAddress & USB_ENDPOINT_DIR_MASK) { 673 if (usb_endpoint_dir_in(ep)) {
674 array[i++] = 6; 674 array[i++] = 6;
675 array[i++] = 7; 675 array[i++] = 7;
676 array[i++] = 8; 676 array[i++] = 8;
@@ -678,7 +678,7 @@ static u16 get_empty_pipenum(struct r8a66597 *r8a66597,
678 array[i++] = 9; 678 array[i++] = 9;
679 break; 679 break;
680 case USB_ENDPOINT_XFER_ISOC: 680 case USB_ENDPOINT_XFER_ISOC:
681 if (ep->bEndpointAddress & USB_ENDPOINT_DIR_MASK) 681 if (usb_endpoint_dir_in(ep))
682 array[i++] = 2; 682 array[i++] = 2;
683 else 683 else
684 array[i++] = 1; 684 array[i++] = 1;
@@ -928,10 +928,9 @@ static void init_pipe_info(struct r8a66597 *r8a66597, struct urb *urb,
928 928
929 info.pipenum = get_empty_pipenum(r8a66597, ep); 929 info.pipenum = get_empty_pipenum(r8a66597, ep);
930 info.address = get_urb_to_r8a66597_addr(r8a66597, urb); 930 info.address = get_urb_to_r8a66597_addr(r8a66597, urb);
931 info.epnum = ep->bEndpointAddress & USB_ENDPOINT_NUMBER_MASK; 931 info.epnum = usb_endpoint_num(ep);
932 info.maxpacket = le16_to_cpu(ep->wMaxPacketSize); 932 info.maxpacket = le16_to_cpu(ep->wMaxPacketSize);
933 info.type = get_r8a66597_type(ep->bmAttributes 933 info.type = get_r8a66597_type(usb_endpoint_type(ep));
934 & USB_ENDPOINT_XFERTYPE_MASK);
935 info.bufnum = get_bufnum(info.pipenum); 934 info.bufnum = get_bufnum(info.pipenum);
936 info.buf_bsize = get_buf_bsize(info.pipenum); 935 info.buf_bsize = get_buf_bsize(info.pipenum);
937 if (info.type == R8A66597_BULK) { 936 if (info.type == R8A66597_BULK) {
@@ -941,7 +940,7 @@ static void init_pipe_info(struct r8a66597 *r8a66597, struct urb *urb,
941 info.interval = get_interval(urb, ep->bInterval); 940 info.interval = get_interval(urb, ep->bInterval);
942 info.timer_interval = get_timer_interval(urb, ep->bInterval); 941 info.timer_interval = get_timer_interval(urb, ep->bInterval);
943 } 942 }
944 if (ep->bEndpointAddress & USB_ENDPOINT_DIR_MASK) 943 if (usb_endpoint_dir_in(ep))
945 info.dir_in = 1; 944 info.dir_in = 1;
946 else 945 else
947 info.dir_in = 0; 946 info.dir_in = 0;
diff --git a/drivers/usb/serial/keyspan.c b/drivers/usb/serial/keyspan.c
index 9878c0fb3859..00daa8f7759a 100644
--- a/drivers/usb/serial/keyspan.c
+++ b/drivers/usb/serial/keyspan.c
@@ -1507,7 +1507,7 @@ static struct urb *keyspan_setup_urb(struct usb_serial *serial, int endpoint,
1507 } else { 1507 } else {
1508 dev_warn(&serial->interface->dev, 1508 dev_warn(&serial->interface->dev,
1509 "unsupported endpoint type %x\n", 1509 "unsupported endpoint type %x\n",
1510 ep_desc->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK); 1510 usb_endpoint_type(ep_desc));
1511 usb_free_urb(urb); 1511 usb_free_urb(urb);
1512 return NULL; 1512 return NULL;
1513 } 1513 }
diff --git a/drivers/usb/storage/usb.c b/drivers/usb/storage/usb.c
index 4becf495ca2d..b01dade63cb3 100644
--- a/drivers/usb/storage/usb.c
+++ b/drivers/usb/storage/usb.c
@@ -846,12 +846,12 @@ static int get_pipes(struct us_data *us)
846 us->send_ctrl_pipe = usb_sndctrlpipe(us->pusb_dev, 0); 846 us->send_ctrl_pipe = usb_sndctrlpipe(us->pusb_dev, 0);
847 us->recv_ctrl_pipe = usb_rcvctrlpipe(us->pusb_dev, 0); 847 us->recv_ctrl_pipe = usb_rcvctrlpipe(us->pusb_dev, 0);
848 us->send_bulk_pipe = usb_sndbulkpipe(us->pusb_dev, 848 us->send_bulk_pipe = usb_sndbulkpipe(us->pusb_dev,
849 ep_out->bEndpointAddress & USB_ENDPOINT_NUMBER_MASK); 849 usb_endpoint_num(ep_out));
850 us->recv_bulk_pipe = usb_rcvbulkpipe(us->pusb_dev, 850 us->recv_bulk_pipe = usb_rcvbulkpipe(us->pusb_dev,
851 ep_in->bEndpointAddress & USB_ENDPOINT_NUMBER_MASK); 851 usb_endpoint_num(ep_in));
852 if (ep_int) { 852 if (ep_int) {
853 us->recv_intr_pipe = usb_rcvintpipe(us->pusb_dev, 853 us->recv_intr_pipe = usb_rcvintpipe(us->pusb_dev,
854 ep_int->bEndpointAddress & USB_ENDPOINT_NUMBER_MASK); 854 usb_endpoint_num(ep_int));
855 us->ep_bInterval = ep_int->bInterval; 855 us->ep_bInterval = ep_int->bInterval;
856 } 856 }
857 return 0; 857 return 0;