aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/host/ehci-q.c
diff options
context:
space:
mode:
authorAlan Stern <stern@rowland.harvard.edu>2011-08-18 16:31:30 -0400
committerGreg Kroah-Hartman <gregkh@suse.de>2011-08-22 18:57:01 -0400
commite8799906045302776b35b66b16495c575db3b69c (patch)
treee6b5a76bd13ef0a9df24f7a7c8c1e924c0efcedb /drivers/usb/host/ehci-q.c
parentdfd8c81fd1c09c740140a2334669994d5c6edcaa (diff)
USB: EHCI: remove usages of hcd->state
This patch (as1483) improves the ehci-hcd driver family by getting rid of the reliance on the hcd->state variable. It has no clear owner and it isn't protected by the usual HCD locks. In its place, the patch adds a new, private ehci->rh_state field to record the state of the root hub. Along the way, the patch removes a couple of lines containing redundant assignments to the state variable. Also, the QUIESCING state simply gets changed to the RUNNING state, because the driver doesn't make any distinction between them. Signed-off-by: Alan Stern <stern@rowland.harvard.edu> Acked-by: Jingoo Han <jg1.han@samsung.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/usb/host/ehci-q.c')
-rw-r--r--drivers/usb/host/ehci-q.c22
1 files changed, 10 insertions, 12 deletions
diff --git a/drivers/usb/host/ehci-q.c b/drivers/usb/host/ehci-q.c
index 0917e3a32465..6ce0b3a9a0f9 100644
--- a/drivers/usb/host/ehci-q.c
+++ b/drivers/usb/host/ehci-q.c
@@ -153,7 +153,7 @@ static void ehci_clear_tt_buffer_complete(struct usb_hcd *hcd,
153 spin_lock_irqsave(&ehci->lock, flags); 153 spin_lock_irqsave(&ehci->lock, flags);
154 qh->clearing_tt = 0; 154 qh->clearing_tt = 0;
155 if (qh->qh_state == QH_STATE_IDLE && !list_empty(&qh->qtd_list) 155 if (qh->qh_state == QH_STATE_IDLE && !list_empty(&qh->qtd_list)
156 && HC_IS_RUNNING(hcd->state)) 156 && ehci->rh_state == EHCI_RH_RUNNING)
157 qh_link_async(ehci, qh); 157 qh_link_async(ehci, qh);
158 spin_unlock_irqrestore(&ehci->lock, flags); 158 spin_unlock_irqrestore(&ehci->lock, flags);
159} 159}
@@ -425,7 +425,7 @@ qh_completions (struct ehci_hcd *ehci, struct ehci_qh *qh)
425 425
426 /* stop scanning when we reach qtds the hc is using */ 426 /* stop scanning when we reach qtds the hc is using */
427 } else if (likely (!stopped 427 } else if (likely (!stopped
428 && HC_IS_RUNNING (ehci_to_hcd(ehci)->state))) { 428 && ehci->rh_state == EHCI_RH_RUNNING)) {
429 break; 429 break;
430 430
431 /* scan the whole queue for unlinks whenever it stops */ 431 /* scan the whole queue for unlinks whenever it stops */
@@ -433,7 +433,7 @@ qh_completions (struct ehci_hcd *ehci, struct ehci_qh *qh)
433 stopped = 1; 433 stopped = 1;
434 434
435 /* cancel everything if we halt, suspend, etc */ 435 /* cancel everything if we halt, suspend, etc */
436 if (!HC_IS_RUNNING(ehci_to_hcd(ehci)->state)) 436 if (ehci->rh_state != EHCI_RH_RUNNING)
437 last_status = -ESHUTDOWN; 437 last_status = -ESHUTDOWN;
438 438
439 /* this qtd is active; skip it unless a previous qtd 439 /* this qtd is active; skip it unless a previous qtd
@@ -977,9 +977,8 @@ static void qh_link_async (struct ehci_hcd *ehci, struct ehci_qh *qh)
977 /* in case a clear of CMD_ASE didn't take yet */ 977 /* in case a clear of CMD_ASE didn't take yet */
978 (void)handshake(ehci, &ehci->regs->status, 978 (void)handshake(ehci, &ehci->regs->status,
979 STS_ASS, 0, 150); 979 STS_ASS, 0, 150);
980 cmd |= CMD_ASE | CMD_RUN; 980 cmd |= CMD_ASE;
981 ehci_writel(ehci, cmd, &ehci->regs->command); 981 ehci_writel(ehci, cmd, &ehci->regs->command);
982 ehci_to_hcd(ehci)->state = HC_STATE_RUNNING;
983 /* posted write need not be known to HC yet ... */ 982 /* posted write need not be known to HC yet ... */
984 } 983 }
985 } 984 }
@@ -1168,14 +1167,13 @@ static void end_unlink_async (struct ehci_hcd *ehci)
1168 1167
1169 qh_completions (ehci, qh); 1168 qh_completions (ehci, qh);
1170 1169
1171 if (!list_empty (&qh->qtd_list) 1170 if (!list_empty(&qh->qtd_list) && ehci->rh_state == EHCI_RH_RUNNING) {
1172 && HC_IS_RUNNING (ehci_to_hcd(ehci)->state))
1173 qh_link_async (ehci, qh); 1171 qh_link_async (ehci, qh);
1174 else { 1172 } else {
1175 /* it's not free to turn the async schedule on/off; leave it 1173 /* it's not free to turn the async schedule on/off; leave it
1176 * active but idle for a while once it empties. 1174 * active but idle for a while once it empties.
1177 */ 1175 */
1178 if (HC_IS_RUNNING (ehci_to_hcd(ehci)->state) 1176 if (ehci->rh_state == EHCI_RH_RUNNING
1179 && ehci->async->qh_next.qh == NULL) 1177 && ehci->async->qh_next.qh == NULL)
1180 timer_action (ehci, TIMER_ASYNC_OFF); 1178 timer_action (ehci, TIMER_ASYNC_OFF);
1181 } 1179 }
@@ -1211,7 +1209,7 @@ static void start_unlink_async (struct ehci_hcd *ehci, struct ehci_qh *qh)
1211 /* stop async schedule right now? */ 1209 /* stop async schedule right now? */
1212 if (unlikely (qh == ehci->async)) { 1210 if (unlikely (qh == ehci->async)) {
1213 /* can't get here without STS_ASS set */ 1211 /* can't get here without STS_ASS set */
1214 if (ehci_to_hcd(ehci)->state != HC_STATE_HALT 1212 if (ehci->rh_state != EHCI_RH_HALTED
1215 && !ehci->reclaim) { 1213 && !ehci->reclaim) {
1216 /* ... and CMD_IAAD clear */ 1214 /* ... and CMD_IAAD clear */
1217 ehci_writel(ehci, cmd & ~CMD_ASE, 1215 ehci_writel(ehci, cmd & ~CMD_ASE,
@@ -1237,7 +1235,7 @@ static void start_unlink_async (struct ehci_hcd *ehci, struct ehci_qh *qh)
1237 wmb (); 1235 wmb ();
1238 1236
1239 /* If the controller isn't running, we don't have to wait for it */ 1237 /* If the controller isn't running, we don't have to wait for it */
1240 if (unlikely(!HC_IS_RUNNING(ehci_to_hcd(ehci)->state))) { 1238 if (unlikely(ehci->rh_state != EHCI_RH_RUNNING)) {
1241 /* if (unlikely (qh->reclaim != 0)) 1239 /* if (unlikely (qh->reclaim != 0))
1242 * this will recurse, probably not much 1240 * this will recurse, probably not much
1243 */ 1241 */
@@ -1260,7 +1258,7 @@ static void scan_async (struct ehci_hcd *ehci)
1260 enum ehci_timer_action action = TIMER_IO_WATCHDOG; 1258 enum ehci_timer_action action = TIMER_IO_WATCHDOG;
1261 1259
1262 timer_action_done (ehci, TIMER_ASYNC_SHRINK); 1260 timer_action_done (ehci, TIMER_ASYNC_SHRINK);
1263 stopped = !HC_IS_RUNNING(ehci_to_hcd(ehci)->state); 1261 stopped = (ehci->rh_state != EHCI_RH_RUNNING);
1264 1262
1265 ehci->qh_scan_next = ehci->async->qh_next.qh; 1263 ehci->qh_scan_next = ehci->async->qh_next.qh;
1266 while (ehci->qh_scan_next) { 1264 while (ehci->qh_scan_next) {