diff options
author | Alan Stern <stern@rowland.harvard.edu> | 2005-04-25 11:14:31 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2005-06-27 17:43:48 -0400 |
commit | 2532178a68b5ce4e421d50ea1b1dcc0a1359f19d (patch) | |
tree | 8ceb32dab2f43431946ef9b09fd02cb07e76e4ed /drivers/usb/host/uhci-q.c | |
parent | 7d35b9298539d2818c51fe9070b08cf9876016f4 (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/host/uhci-q.c')
-rw-r--r-- | drivers/usb/host/uhci-q.c | 32 |
1 files changed, 10 insertions, 22 deletions
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 | ||
51 | static struct uhci_td *uhci_alloc_td(struct uhci_hcd *uhci, struct usb_device *dev) | 51 | static 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 | ||
179 | static struct uhci_qh *uhci_alloc_qh(struct uhci_hcd *uhci, struct usb_device *dev) | 173 | static 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 | ||