aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/host
diff options
context:
space:
mode:
authorAlan Stern <stern@rowland.harvard.edu>2005-11-30 11:57:51 -0500
committerGreg Kroah-Hartman <gregkh@suse.de>2006-01-04 16:51:41 -0500
commitfa3465689f93331834a831bbe98e3863701e1068 (patch)
treef8b1186d7ef49289817d54e35cb7cca82fcc3613 /drivers/usb/host
parentf0b80fbf294bc4f6ec179b09fd5b63df25188259 (diff)
[PATCH] USB: UHCI: change uhci_explen macro
This patch (as616) changed the uhci_explen macro in uhci-hcd.h so that it now accepts the desired length, rather than length - 1 with special handling for 0. This also fixes a minor bug that would show up only when a driver submits a 0-length bulk URB. Signed-off-by: Alan Stern <stern@rowland.harvard.edu> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/usb/host')
-rw-r--r--drivers/usb/host/uhci-hcd.c2
-rw-r--r--drivers/usb/host/uhci-hcd.h8
-rw-r--r--drivers/usb/host/uhci-q.c12
3 files changed, 11 insertions, 11 deletions
diff --git a/drivers/usb/host/uhci-hcd.c b/drivers/usb/host/uhci-hcd.c
index 071fab6b6475..120ca64fe3f7 100644
--- a/drivers/usb/host/uhci-hcd.c
+++ b/drivers/usb/host/uhci-hcd.c
@@ -566,7 +566,7 @@ static int uhci_start(struct usb_hcd *hcd)
566 uhci->skel_bulk_qh->link = cpu_to_le32(uhci->skel_term_qh->dma_handle) | UHCI_PTR_QH; 566 uhci->skel_bulk_qh->link = cpu_to_le32(uhci->skel_term_qh->dma_handle) | UHCI_PTR_QH;
567 567
568 /* This dummy TD is to work around a bug in Intel PIIX controllers */ 568 /* This dummy TD is to work around a bug in Intel PIIX controllers */
569 uhci_fill_td(uhci->term_td, 0, (UHCI_NULL_DATA_SIZE << 21) | 569 uhci_fill_td(uhci->term_td, 0, uhci_explen(0) |
570 (0x7f << TD_TOKEN_DEVADDR_SHIFT) | USB_PID_IN, 0); 570 (0x7f << TD_TOKEN_DEVADDR_SHIFT) | USB_PID_IN, 0);
571 uhci->term_td->link = cpu_to_le32(uhci->term_td->dma_handle); 571 uhci->term_td->link = cpu_to_le32(uhci->term_td->dma_handle);
572 572
diff --git a/drivers/usb/host/uhci-hcd.h b/drivers/usb/host/uhci-hcd.h
index e576db57a926..e43282e4e806 100644
--- a/drivers/usb/host/uhci-hcd.h
+++ b/drivers/usb/host/uhci-hcd.h
@@ -71,8 +71,6 @@
71#define USBLEGSUP_RWC 0x8f00 /* the R/WC bits */ 71#define USBLEGSUP_RWC 0x8f00 /* the R/WC bits */
72#define USBLEGSUP_RO 0x5040 /* R/O and reserved bits */ 72#define USBLEGSUP_RO 0x5040 /* R/O and reserved bits */
73 73
74#define UHCI_NULL_DATA_SIZE 0x7FF /* for UHCI controller TD */
75
76#define UHCI_PTR_BITS cpu_to_le32(0x000F) 74#define UHCI_PTR_BITS cpu_to_le32(0x000F)
77#define UHCI_PTR_TERM cpu_to_le32(0x0001) 75#define UHCI_PTR_TERM cpu_to_le32(0x0001)
78#define UHCI_PTR_QH cpu_to_le32(0x0002) 76#define UHCI_PTR_QH cpu_to_le32(0x0002)
@@ -168,9 +166,11 @@ static __le32 inline qh_element(struct uhci_qh *qh) {
168#define TD_TOKEN_EXPLEN_MASK 0x7FF /* expected length, encoded as n - 1 */ 166#define TD_TOKEN_EXPLEN_MASK 0x7FF /* expected length, encoded as n - 1 */
169#define TD_TOKEN_PID_MASK 0xFF 167#define TD_TOKEN_PID_MASK 0xFF
170 168
171#define uhci_explen(len) ((len) << TD_TOKEN_EXPLEN_SHIFT) 169#define uhci_explen(len) ((((len) - 1) & TD_TOKEN_EXPLEN_MASK) << \
170 TD_TOKEN_EXPLEN_SHIFT)
172 171
173#define uhci_expected_length(token) ((((token) >> 21) + 1) & TD_TOKEN_EXPLEN_MASK) 172#define uhci_expected_length(token) ((((token) >> TD_TOKEN_EXPLEN_SHIFT) + \
173 1) & TD_TOKEN_EXPLEN_MASK)
174#define uhci_toggle(token) (((token) >> TD_TOKEN_TOGGLE_SHIFT) & 1) 174#define uhci_toggle(token) (((token) >> TD_TOKEN_TOGGLE_SHIFT) & 1)
175#define uhci_endpoint(token) (((token) >> 15) & 0xf) 175#define uhci_endpoint(token) (((token) >> 15) & 0xf)
176#define uhci_devaddr(token) (((token) >> TD_TOKEN_DEVADDR_SHIFT) & 0x7f) 176#define uhci_devaddr(token) (((token) >> TD_TOKEN_DEVADDR_SHIFT) & 0x7f)
diff --git a/drivers/usb/host/uhci-q.c b/drivers/usb/host/uhci-q.c
index 7e46887d9e12..ace9d15f85d2 100644
--- a/drivers/usb/host/uhci-q.c
+++ b/drivers/usb/host/uhci-q.c
@@ -596,7 +596,7 @@ static int uhci_submit_control(struct uhci_hcd *uhci, struct urb *urb, struct ur
596 return -ENOMEM; 596 return -ENOMEM;
597 597
598 uhci_add_td_to_urb(urb, td); 598 uhci_add_td_to_urb(urb, td);
599 uhci_fill_td(td, status, destination | uhci_explen(7), 599 uhci_fill_td(td, status, destination | uhci_explen(8),
600 urb->setup_dma); 600 urb->setup_dma);
601 601
602 /* 602 /*
@@ -628,7 +628,7 @@ static int uhci_submit_control(struct uhci_hcd *uhci, struct urb *urb, struct ur
628 destination ^= TD_TOKEN_TOGGLE; 628 destination ^= TD_TOKEN_TOGGLE;
629 629
630 uhci_add_td_to_urb(urb, td); 630 uhci_add_td_to_urb(urb, td);
631 uhci_fill_td(td, status, destination | uhci_explen(pktsze - 1), 631 uhci_fill_td(td, status, destination | uhci_explen(pktsze),
632 data); 632 data);
633 633
634 data += pktsze; 634 data += pktsze;
@@ -658,7 +658,7 @@ static int uhci_submit_control(struct uhci_hcd *uhci, struct urb *urb, struct ur
658 658
659 uhci_add_td_to_urb(urb, td); 659 uhci_add_td_to_urb(urb, td);
660 uhci_fill_td(td, status | TD_CTRL_IOC, 660 uhci_fill_td(td, status | TD_CTRL_IOC,
661 destination | uhci_explen(UHCI_NULL_DATA_SIZE), 0); 661 destination | uhci_explen(0), 0);
662 662
663 qh = uhci_alloc_qh(uhci); 663 qh = uhci_alloc_qh(uhci);
664 if (!qh) 664 if (!qh)
@@ -864,7 +864,7 @@ static int uhci_submit_common(struct uhci_hcd *uhci, struct urb *urb, struct urb
864 return -ENOMEM; 864 return -ENOMEM;
865 865
866 uhci_add_td_to_urb(urb, td); 866 uhci_add_td_to_urb(urb, td);
867 uhci_fill_td(td, status, destination | uhci_explen(pktsze - 1) | 867 uhci_fill_td(td, status, destination | uhci_explen(pktsze) |
868 (usb_gettoggle(urb->dev, usb_pipeendpoint(urb->pipe), 868 (usb_gettoggle(urb->dev, usb_pipeendpoint(urb->pipe),
869 usb_pipeout(urb->pipe)) << TD_TOKEN_TOGGLE_SHIFT), 869 usb_pipeout(urb->pipe)) << TD_TOKEN_TOGGLE_SHIFT),
870 data); 870 data);
@@ -890,7 +890,7 @@ static int uhci_submit_common(struct uhci_hcd *uhci, struct urb *urb, struct urb
890 return -ENOMEM; 890 return -ENOMEM;
891 891
892 uhci_add_td_to_urb(urb, td); 892 uhci_add_td_to_urb(urb, td);
893 uhci_fill_td(td, status, destination | uhci_explen(UHCI_NULL_DATA_SIZE) | 893 uhci_fill_td(td, status, destination | uhci_explen(0) |
894 (usb_gettoggle(urb->dev, usb_pipeendpoint(urb->pipe), 894 (usb_gettoggle(urb->dev, usb_pipeendpoint(urb->pipe),
895 usb_pipeout(urb->pipe)) << TD_TOKEN_TOGGLE_SHIFT), 895 usb_pipeout(urb->pipe)) << TD_TOKEN_TOGGLE_SHIFT),
896 data); 896 data);
@@ -1092,7 +1092,7 @@ static int uhci_submit_isochronous(struct uhci_hcd *uhci, struct urb *urb)
1092 return -ENOMEM; 1092 return -ENOMEM;
1093 1093
1094 uhci_add_td_to_urb(urb, td); 1094 uhci_add_td_to_urb(urb, td);
1095 uhci_fill_td(td, status, destination | uhci_explen(urb->iso_frame_desc[i].length - 1), 1095 uhci_fill_td(td, status, destination | uhci_explen(urb->iso_frame_desc[i].length),
1096 urb->transfer_dma + urb->iso_frame_desc[i].offset); 1096 urb->transfer_dma + urb->iso_frame_desc[i].offset);
1097 1097
1098 if (i + 1 >= urb->number_of_packets) 1098 if (i + 1 >= urb->number_of_packets)