aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb
diff options
context:
space:
mode:
authorAlan Stern <stern@rowland.harvard.edu>2005-04-25 11:14:31 -0400
committerGreg Kroah-Hartman <gregkh@suse.de>2005-06-27 17:43:48 -0400
commit2532178a68b5ce4e421d50ea1b1dcc0a1359f19d (patch)
tree8ceb32dab2f43431946ef9b09fd02cb07e76e4ed /drivers/usb
parent7d35b9298539d2818c51fe9070b08cf9876016f4 (diff)
[PATCH] UHCI: Don't store device pointer in QH or TD
This patch simplifies the uhci-hcd driver by removing the device pointer currently stored in the QH and TD structures. Those pointers weren't being used for anything other than to increment the device's reference count, which is unnecessary since the device is used only when an URB completes, and outstanding URBs take their own reference to the device. As a useful side effect, this change means that uhci-hcd no longer needs to have the root-hub device available in the start routine. Signed-off-by: Alan Stern <stern@rowland.harvard.edu> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/usb')
-rw-r--r--drivers/usb/host/uhci-hcd.c4
-rw-r--r--drivers/usb/host/uhci-hcd.h2
-rw-r--r--drivers/usb/host/uhci-q.c32
3 files changed, 12 insertions, 26 deletions
diff --git a/drivers/usb/host/uhci-hcd.c b/drivers/usb/host/uhci-hcd.c
index 53ba8a56592e..6b87bd74b046 100644
--- a/drivers/usb/host/uhci-hcd.c
+++ b/drivers/usb/host/uhci-hcd.c
@@ -634,14 +634,14 @@ static int uhci_start(struct usb_hcd *hcd)
634 goto err_alloc_root_hub; 634 goto err_alloc_root_hub;
635 } 635 }
636 636
637 uhci->term_td = uhci_alloc_td(uhci, udev); 637 uhci->term_td = uhci_alloc_td(uhci);
638 if (!uhci->term_td) { 638 if (!uhci->term_td) {
639 dev_err(uhci_dev(uhci), "unable to allocate terminating TD\n"); 639 dev_err(uhci_dev(uhci), "unable to allocate terminating TD\n");
640 goto err_alloc_term_td; 640 goto err_alloc_term_td;
641 } 641 }
642 642
643 for (i = 0; i < UHCI_NUM_SKELQH; i++) { 643 for (i = 0; i < UHCI_NUM_SKELQH; i++) {
644 uhci->skelqh[i] = uhci_alloc_qh(uhci, udev); 644 uhci->skelqh[i] = uhci_alloc_qh(uhci);
645 if (!uhci->skelqh[i]) { 645 if (!uhci->skelqh[i]) {
646 dev_err(uhci_dev(uhci), "unable to allocate QH\n"); 646 dev_err(uhci_dev(uhci), "unable to allocate QH\n");
647 goto err_alloc_skelqh; 647 goto err_alloc_skelqh;
diff --git a/drivers/usb/host/uhci-hcd.h b/drivers/usb/host/uhci-hcd.h
index d7c67b73eb7a..bf9c5f9b508b 100644
--- a/drivers/usb/host/uhci-hcd.h
+++ b/drivers/usb/host/uhci-hcd.h
@@ -114,7 +114,6 @@ struct uhci_qh {
114 /* Software fields */ 114 /* Software fields */
115 dma_addr_t dma_handle; 115 dma_addr_t dma_handle;
116 116
117 struct usb_device *dev;
118 struct urb_priv *urbp; 117 struct urb_priv *urbp;
119 118
120 struct list_head list; /* P: uhci->frame_list_lock */ 119 struct list_head list; /* P: uhci->frame_list_lock */
@@ -206,7 +205,6 @@ struct uhci_td {
206 /* Software fields */ 205 /* Software fields */
207 dma_addr_t dma_handle; 206 dma_addr_t dma_handle;
208 207
209 struct usb_device *dev;
210 struct urb *urb; 208 struct urb *urb;
211 209
212 struct list_head list; /* P: urb->lock */ 210 struct list_head list; /* P: urb->lock */
diff --git a/drivers/usb/host/uhci-q.c b/drivers/usb/host/uhci-q.c
index 77f264851e98..5f18084a116d 100644
--- a/drivers/usb/host/uhci-q.c
+++ b/drivers/usb/host/uhci-q.c
@@ -48,7 +48,7 @@ static inline void uhci_moveto_complete(struct uhci_hcd *uhci,
48 list_move_tail(&urbp->urb_list, &uhci->complete_list); 48 list_move_tail(&urbp->urb_list, &uhci->complete_list);
49} 49}
50 50
51static struct uhci_td *uhci_alloc_td(struct uhci_hcd *uhci, struct usb_device *dev) 51static struct uhci_td *uhci_alloc_td(struct uhci_hcd *uhci)
52{ 52{
53 dma_addr_t dma_handle; 53 dma_addr_t dma_handle;
54 struct uhci_td *td; 54 struct uhci_td *td;
@@ -63,14 +63,11 @@ static struct uhci_td *uhci_alloc_td(struct uhci_hcd *uhci, struct usb_device *d
63 td->buffer = 0; 63 td->buffer = 0;
64 64
65 td->frame = -1; 65 td->frame = -1;
66 td->dev = dev;
67 66
68 INIT_LIST_HEAD(&td->list); 67 INIT_LIST_HEAD(&td->list);
69 INIT_LIST_HEAD(&td->remove_list); 68 INIT_LIST_HEAD(&td->remove_list);
70 INIT_LIST_HEAD(&td->fl_list); 69 INIT_LIST_HEAD(&td->fl_list);
71 70
72 usb_get_dev(dev);
73
74 return td; 71 return td;
75} 72}
76 73
@@ -170,13 +167,10 @@ static void uhci_free_td(struct uhci_hcd *uhci, struct uhci_td *td)
170 if (!list_empty(&td->fl_list)) 167 if (!list_empty(&td->fl_list))
171 dev_warn(uhci_dev(uhci), "td %p still in fl_list!\n", td); 168 dev_warn(uhci_dev(uhci), "td %p still in fl_list!\n", td);
172 169
173 if (td->dev)
174 usb_put_dev(td->dev);
175
176 dma_pool_free(uhci->td_pool, td, td->dma_handle); 170 dma_pool_free(uhci->td_pool, td, td->dma_handle);
177} 171}
178 172
179static struct uhci_qh *uhci_alloc_qh(struct uhci_hcd *uhci, struct usb_device *dev) 173static struct uhci_qh *uhci_alloc_qh(struct uhci_hcd *uhci)
180{ 174{
181 dma_addr_t dma_handle; 175 dma_addr_t dma_handle;
182 struct uhci_qh *qh; 176 struct uhci_qh *qh;
@@ -190,14 +184,11 @@ static struct uhci_qh *uhci_alloc_qh(struct uhci_hcd *uhci, struct usb_device *d
190 qh->element = UHCI_PTR_TERM; 184 qh->element = UHCI_PTR_TERM;
191 qh->link = UHCI_PTR_TERM; 185 qh->link = UHCI_PTR_TERM;
192 186
193 qh->dev = dev;
194 qh->urbp = NULL; 187 qh->urbp = NULL;
195 188
196 INIT_LIST_HEAD(&qh->list); 189 INIT_LIST_HEAD(&qh->list);
197 INIT_LIST_HEAD(&qh->remove_list); 190 INIT_LIST_HEAD(&qh->remove_list);
198 191
199 usb_get_dev(dev);
200
201 return qh; 192 return qh;
202} 193}
203 194
@@ -208,9 +199,6 @@ static void uhci_free_qh(struct uhci_hcd *uhci, struct uhci_qh *qh)
208 if (!list_empty(&qh->remove_list)) 199 if (!list_empty(&qh->remove_list))
209 dev_warn(uhci_dev(uhci), "qh %p still in remove_list!\n", qh); 200 dev_warn(uhci_dev(uhci), "qh %p still in remove_list!\n", qh);
210 201
211 if (qh->dev)
212 usb_put_dev(qh->dev);
213
214 dma_pool_free(uhci->qh_pool, qh, qh->dma_handle); 202 dma_pool_free(uhci->qh_pool, qh, qh->dma_handle);
215} 203}
216 204
@@ -599,7 +587,7 @@ static int uhci_submit_control(struct uhci_hcd *uhci, struct urb *urb, struct ur
599 /* 587 /*
600 * Build the TD for the control request setup packet 588 * Build the TD for the control request setup packet
601 */ 589 */
602 td = uhci_alloc_td(uhci, urb->dev); 590 td = uhci_alloc_td(uhci);
603 if (!td) 591 if (!td)
604 return -ENOMEM; 592 return -ENOMEM;
605 593
@@ -628,7 +616,7 @@ static int uhci_submit_control(struct uhci_hcd *uhci, struct urb *urb, struct ur
628 if (pktsze > maxsze) 616 if (pktsze > maxsze)
629 pktsze = maxsze; 617 pktsze = maxsze;
630 618
631 td = uhci_alloc_td(uhci, urb->dev); 619 td = uhci_alloc_td(uhci);
632 if (!td) 620 if (!td)
633 return -ENOMEM; 621 return -ENOMEM;
634 622
@@ -646,7 +634,7 @@ static int uhci_submit_control(struct uhci_hcd *uhci, struct urb *urb, struct ur
646 /* 634 /*
647 * Build the final TD for control status 635 * Build the final TD for control status
648 */ 636 */
649 td = uhci_alloc_td(uhci, urb->dev); 637 td = uhci_alloc_td(uhci);
650 if (!td) 638 if (!td)
651 return -ENOMEM; 639 return -ENOMEM;
652 640
@@ -668,7 +656,7 @@ static int uhci_submit_control(struct uhci_hcd *uhci, struct urb *urb, struct ur
668 uhci_fill_td(td, status | TD_CTRL_IOC, 656 uhci_fill_td(td, status | TD_CTRL_IOC,
669 destination | uhci_explen(UHCI_NULL_DATA_SIZE), 0); 657 destination | uhci_explen(UHCI_NULL_DATA_SIZE), 0);
670 658
671 qh = uhci_alloc_qh(uhci, urb->dev); 659 qh = uhci_alloc_qh(uhci);
672 if (!qh) 660 if (!qh)
673 return -ENOMEM; 661 return -ENOMEM;
674 662
@@ -867,7 +855,7 @@ static int uhci_submit_common(struct uhci_hcd *uhci, struct urb *urb, struct urb
867 status &= ~TD_CTRL_SPD; 855 status &= ~TD_CTRL_SPD;
868 } 856 }
869 857
870 td = uhci_alloc_td(uhci, urb->dev); 858 td = uhci_alloc_td(uhci);
871 if (!td) 859 if (!td)
872 return -ENOMEM; 860 return -ENOMEM;
873 861
@@ -893,7 +881,7 @@ static int uhci_submit_common(struct uhci_hcd *uhci, struct urb *urb, struct urb
893 */ 881 */
894 if (usb_pipeout(urb->pipe) && (urb->transfer_flags & URB_ZERO_PACKET) && 882 if (usb_pipeout(urb->pipe) && (urb->transfer_flags & URB_ZERO_PACKET) &&
895 !len && urb->transfer_buffer_length) { 883 !len && urb->transfer_buffer_length) {
896 td = uhci_alloc_td(uhci, urb->dev); 884 td = uhci_alloc_td(uhci);
897 if (!td) 885 if (!td)
898 return -ENOMEM; 886 return -ENOMEM;
899 887
@@ -915,7 +903,7 @@ static int uhci_submit_common(struct uhci_hcd *uhci, struct urb *urb, struct urb
915 * flag setting. */ 903 * flag setting. */
916 td->status |= cpu_to_le32(TD_CTRL_IOC); 904 td->status |= cpu_to_le32(TD_CTRL_IOC);
917 905
918 qh = uhci_alloc_qh(uhci, urb->dev); 906 qh = uhci_alloc_qh(uhci);
919 if (!qh) 907 if (!qh)
920 return -ENOMEM; 908 return -ENOMEM;
921 909
@@ -1098,7 +1086,7 @@ static int uhci_submit_isochronous(struct uhci_hcd *uhci, struct urb *urb)
1098 if (!urb->iso_frame_desc[i].length) 1086 if (!urb->iso_frame_desc[i].length)
1099 continue; 1087 continue;
1100 1088
1101 td = uhci_alloc_td(uhci, urb->dev); 1089 td = uhci_alloc_td(uhci);
1102 if (!td) 1090 if (!td)
1103 return -ENOMEM; 1091 return -ENOMEM;
1104 1092