Commit 2532178a authored by Alan Stern's avatar Alan Stern Committed by Greg Kroah-Hartman

[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: default avatarAlan Stern <stern@rowland.harvard.edu>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent 7d35b929
...@@ -634,14 +634,14 @@ static int uhci_start(struct usb_hcd *hcd) ...@@ -634,14 +634,14 @@ static int uhci_start(struct usb_hcd *hcd)
goto err_alloc_root_hub; goto err_alloc_root_hub;
} }
uhci->term_td = uhci_alloc_td(uhci, udev); uhci->term_td = uhci_alloc_td(uhci);
if (!uhci->term_td) { if (!uhci->term_td) {
dev_err(uhci_dev(uhci), "unable to allocate terminating TD\n"); dev_err(uhci_dev(uhci), "unable to allocate terminating TD\n");
goto err_alloc_term_td; goto err_alloc_term_td;
} }
for (i = 0; i < UHCI_NUM_SKELQH; i++) { for (i = 0; i < UHCI_NUM_SKELQH; i++) {
uhci->skelqh[i] = uhci_alloc_qh(uhci, udev); uhci->skelqh[i] = uhci_alloc_qh(uhci);
if (!uhci->skelqh[i]) { if (!uhci->skelqh[i]) {
dev_err(uhci_dev(uhci), "unable to allocate QH\n"); dev_err(uhci_dev(uhci), "unable to allocate QH\n");
goto err_alloc_skelqh; goto err_alloc_skelqh;
......
...@@ -114,7 +114,6 @@ struct uhci_qh { ...@@ -114,7 +114,6 @@ struct uhci_qh {
/* Software fields */ /* Software fields */
dma_addr_t dma_handle; dma_addr_t dma_handle;
struct usb_device *dev;
struct urb_priv *urbp; struct urb_priv *urbp;
struct list_head list; /* P: uhci->frame_list_lock */ struct list_head list; /* P: uhci->frame_list_lock */
...@@ -206,7 +205,6 @@ struct uhci_td { ...@@ -206,7 +205,6 @@ struct uhci_td {
/* Software fields */ /* Software fields */
dma_addr_t dma_handle; dma_addr_t dma_handle;
struct usb_device *dev;
struct urb *urb; struct urb *urb;
struct list_head list; /* P: urb->lock */ struct list_head list; /* P: urb->lock */
......
...@@ -48,7 +48,7 @@ static inline void uhci_moveto_complete(struct uhci_hcd *uhci, ...@@ -48,7 +48,7 @@ static inline void uhci_moveto_complete(struct uhci_hcd *uhci,
list_move_tail(&urbp->urb_list, &uhci->complete_list); list_move_tail(&urbp->urb_list, &uhci->complete_list);
} }
static struct uhci_td *uhci_alloc_td(struct uhci_hcd *uhci, struct usb_device *dev) static struct uhci_td *uhci_alloc_td(struct uhci_hcd *uhci)
{ {
dma_addr_t dma_handle; dma_addr_t dma_handle;
struct uhci_td *td; struct uhci_td *td;
...@@ -63,14 +63,11 @@ static struct uhci_td *uhci_alloc_td(struct uhci_hcd *uhci, struct usb_device *d ...@@ -63,14 +63,11 @@ static struct uhci_td *uhci_alloc_td(struct uhci_hcd *uhci, struct usb_device *d
td->buffer = 0; td->buffer = 0;
td->frame = -1; td->frame = -1;
td->dev = dev;
INIT_LIST_HEAD(&td->list); INIT_LIST_HEAD(&td->list);
INIT_LIST_HEAD(&td->remove_list); INIT_LIST_HEAD(&td->remove_list);
INIT_LIST_HEAD(&td->fl_list); INIT_LIST_HEAD(&td->fl_list);
usb_get_dev(dev);
return td; return td;
} }
...@@ -170,13 +167,10 @@ static void uhci_free_td(struct uhci_hcd *uhci, struct uhci_td *td) ...@@ -170,13 +167,10 @@ static void uhci_free_td(struct uhci_hcd *uhci, struct uhci_td *td)
if (!list_empty(&td->fl_list)) if (!list_empty(&td->fl_list))
dev_warn(uhci_dev(uhci), "td %p still in fl_list!\n", td); dev_warn(uhci_dev(uhci), "td %p still in fl_list!\n", td);
if (td->dev)
usb_put_dev(td->dev);
dma_pool_free(uhci->td_pool, td, td->dma_handle); dma_pool_free(uhci->td_pool, td, td->dma_handle);
} }
static struct uhci_qh *uhci_alloc_qh(struct uhci_hcd *uhci, struct usb_device *dev) static struct uhci_qh *uhci_alloc_qh(struct uhci_hcd *uhci)
{ {
dma_addr_t dma_handle; dma_addr_t dma_handle;
struct uhci_qh *qh; struct uhci_qh *qh;
...@@ -190,14 +184,11 @@ static struct uhci_qh *uhci_alloc_qh(struct uhci_hcd *uhci, struct usb_device *d ...@@ -190,14 +184,11 @@ static struct uhci_qh *uhci_alloc_qh(struct uhci_hcd *uhci, struct usb_device *d
qh->element = UHCI_PTR_TERM; qh->element = UHCI_PTR_TERM;
qh->link = UHCI_PTR_TERM; qh->link = UHCI_PTR_TERM;
qh->dev = dev;
qh->urbp = NULL; qh->urbp = NULL;
INIT_LIST_HEAD(&qh->list); INIT_LIST_HEAD(&qh->list);
INIT_LIST_HEAD(&qh->remove_list); INIT_LIST_HEAD(&qh->remove_list);
usb_get_dev(dev);
return qh; return qh;
} }
...@@ -208,9 +199,6 @@ static void uhci_free_qh(struct uhci_hcd *uhci, struct uhci_qh *qh) ...@@ -208,9 +199,6 @@ static void uhci_free_qh(struct uhci_hcd *uhci, struct uhci_qh *qh)
if (!list_empty(&qh->remove_list)) if (!list_empty(&qh->remove_list))
dev_warn(uhci_dev(uhci), "qh %p still in remove_list!\n", qh); dev_warn(uhci_dev(uhci), "qh %p still in remove_list!\n", qh);
if (qh->dev)
usb_put_dev(qh->dev);
dma_pool_free(uhci->qh_pool, qh, qh->dma_handle); dma_pool_free(uhci->qh_pool, qh, qh->dma_handle);
} }
...@@ -599,7 +587,7 @@ static int uhci_submit_control(struct uhci_hcd *uhci, struct urb *urb, struct ur ...@@ -599,7 +587,7 @@ static int uhci_submit_control(struct uhci_hcd *uhci, struct urb *urb, struct ur
/* /*
* Build the TD for the control request setup packet * Build the TD for the control request setup packet
*/ */
td = uhci_alloc_td(uhci, urb->dev); td = uhci_alloc_td(uhci);
if (!td) if (!td)
return -ENOMEM; return -ENOMEM;
...@@ -628,7 +616,7 @@ static int uhci_submit_control(struct uhci_hcd *uhci, struct urb *urb, struct ur ...@@ -628,7 +616,7 @@ static int uhci_submit_control(struct uhci_hcd *uhci, struct urb *urb, struct ur
if (pktsze > maxsze) if (pktsze > maxsze)
pktsze = maxsze; pktsze = maxsze;
td = uhci_alloc_td(uhci, urb->dev); td = uhci_alloc_td(uhci);
if (!td) if (!td)
return -ENOMEM; return -ENOMEM;
...@@ -646,7 +634,7 @@ static int uhci_submit_control(struct uhci_hcd *uhci, struct urb *urb, struct ur ...@@ -646,7 +634,7 @@ static int uhci_submit_control(struct uhci_hcd *uhci, struct urb *urb, struct ur
/* /*
* Build the final TD for control status * Build the final TD for control status
*/ */
td = uhci_alloc_td(uhci, urb->dev); td = uhci_alloc_td(uhci);
if (!td) if (!td)
return -ENOMEM; return -ENOMEM;
...@@ -668,7 +656,7 @@ static int uhci_submit_control(struct uhci_hcd *uhci, struct urb *urb, struct ur ...@@ -668,7 +656,7 @@ static int uhci_submit_control(struct uhci_hcd *uhci, struct urb *urb, struct ur
uhci_fill_td(td, status | TD_CTRL_IOC, uhci_fill_td(td, status | TD_CTRL_IOC,
destination | uhci_explen(UHCI_NULL_DATA_SIZE), 0); destination | uhci_explen(UHCI_NULL_DATA_SIZE), 0);
qh = uhci_alloc_qh(uhci, urb->dev); qh = uhci_alloc_qh(uhci);
if (!qh) if (!qh)
return -ENOMEM; return -ENOMEM;
...@@ -867,7 +855,7 @@ static int uhci_submit_common(struct uhci_hcd *uhci, struct urb *urb, struct urb ...@@ -867,7 +855,7 @@ static int uhci_submit_common(struct uhci_hcd *uhci, struct urb *urb, struct urb
status &= ~TD_CTRL_SPD; status &= ~TD_CTRL_SPD;
} }
td = uhci_alloc_td(uhci, urb->dev); td = uhci_alloc_td(uhci);
if (!td) if (!td)
return -ENOMEM; return -ENOMEM;
...@@ -893,7 +881,7 @@ static int uhci_submit_common(struct uhci_hcd *uhci, struct urb *urb, struct urb ...@@ -893,7 +881,7 @@ static int uhci_submit_common(struct uhci_hcd *uhci, struct urb *urb, struct urb
*/ */
if (usb_pipeout(urb->pipe) && (urb->transfer_flags & URB_ZERO_PACKET) && if (usb_pipeout(urb->pipe) && (urb->transfer_flags & URB_ZERO_PACKET) &&
!len && urb->transfer_buffer_length) { !len && urb->transfer_buffer_length) {
td = uhci_alloc_td(uhci, urb->dev); td = uhci_alloc_td(uhci);
if (!td) if (!td)
return -ENOMEM; return -ENOMEM;
...@@ -915,7 +903,7 @@ static int uhci_submit_common(struct uhci_hcd *uhci, struct urb *urb, struct urb ...@@ -915,7 +903,7 @@ static int uhci_submit_common(struct uhci_hcd *uhci, struct urb *urb, struct urb
* flag setting. */ * flag setting. */
td->status |= cpu_to_le32(TD_CTRL_IOC); td->status |= cpu_to_le32(TD_CTRL_IOC);
qh = uhci_alloc_qh(uhci, urb->dev); qh = uhci_alloc_qh(uhci);
if (!qh) if (!qh)
return -ENOMEM; return -ENOMEM;
...@@ -1098,7 +1086,7 @@ static int uhci_submit_isochronous(struct uhci_hcd *uhci, struct urb *urb) ...@@ -1098,7 +1086,7 @@ static int uhci_submit_isochronous(struct uhci_hcd *uhci, struct urb *urb)
if (!urb->iso_frame_desc[i].length) if (!urb->iso_frame_desc[i].length)
continue; continue;
td = uhci_alloc_td(uhci, urb->dev); td = uhci_alloc_td(uhci);
if (!td) if (!td)
return -ENOMEM; return -ENOMEM;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment