diff options
author | Alan Stern <stern@rowland.harvard.edu> | 2007-01-16 11:58:00 -0500 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2007-02-07 18:44:37 -0500 |
commit | e6316565e568b3b5733be10cfca3c27259bef499 (patch) | |
tree | 9c1f90ab4bc0b051bb9f3d052034893fc7d55367 /drivers/usb/host/ehci-hub.c | |
parent | 896fbd7199035958013d106329843d8ae9618753 (diff) |
EHCI: local variable for port status register
This patch (as708) introduces a local variable to hold the port
status-register address in ehci-hub.c. There's not much improvement
in the object code, but it sure is a lot easier to read.
Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Cc: David Brownell <dbrownell@users.sourceforge.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/usb/host/ehci-hub.c')
-rw-r--r-- | drivers/usb/host/ehci-hub.c | 55 |
1 files changed, 24 insertions, 31 deletions
diff --git a/drivers/usb/host/ehci-hub.c b/drivers/usb/host/ehci-hub.c index df00fcbadfbc..12f881ff4b23 100644 --- a/drivers/usb/host/ehci-hub.c +++ b/drivers/usb/host/ehci-hub.c | |||
@@ -193,6 +193,7 @@ static int ehci_bus_resume (struct usb_hcd *hcd) | |||
193 | static int check_reset_complete ( | 193 | static int check_reset_complete ( |
194 | struct ehci_hcd *ehci, | 194 | struct ehci_hcd *ehci, |
195 | int index, | 195 | int index, |
196 | u32 __iomem *status_reg, | ||
196 | int port_status | 197 | int port_status |
197 | ) { | 198 | ) { |
198 | if (!(port_status & PORT_CONNECT)) { | 199 | if (!(port_status & PORT_CONNECT)) { |
@@ -217,8 +218,7 @@ static int check_reset_complete ( | |||
217 | // what happens if HCS_N_CC(params) == 0 ? | 218 | // what happens if HCS_N_CC(params) == 0 ? |
218 | port_status |= PORT_OWNER; | 219 | port_status |= PORT_OWNER; |
219 | port_status &= ~PORT_RWC_BITS; | 220 | port_status &= ~PORT_RWC_BITS; |
220 | ehci_writel(ehci, port_status, | 221 | ehci_writel(ehci, port_status, status_reg); |
221 | &ehci->regs->port_status [index]); | ||
222 | 222 | ||
223 | } else | 223 | } else |
224 | ehci_dbg (ehci, "port %d high speed\n", index + 1); | 224 | ehci_dbg (ehci, "port %d high speed\n", index + 1); |
@@ -347,6 +347,7 @@ static int ehci_hub_control ( | |||
347 | ) { | 347 | ) { |
348 | struct ehci_hcd *ehci = hcd_to_ehci (hcd); | 348 | struct ehci_hcd *ehci = hcd_to_ehci (hcd); |
349 | int ports = HCS_N_PORTS (ehci->hcs_params); | 349 | int ports = HCS_N_PORTS (ehci->hcs_params); |
350 | u32 __iomem *status_reg = &ehci->regs->port_status[wIndex - 1]; | ||
350 | u32 temp, status; | 351 | u32 temp, status; |
351 | unsigned long flags; | 352 | unsigned long flags; |
352 | int retval = 0; | 353 | int retval = 0; |
@@ -375,18 +376,17 @@ static int ehci_hub_control ( | |||
375 | if (!wIndex || wIndex > ports) | 376 | if (!wIndex || wIndex > ports) |
376 | goto error; | 377 | goto error; |
377 | wIndex--; | 378 | wIndex--; |
378 | temp = ehci_readl(ehci, &ehci->regs->port_status [wIndex]); | 379 | temp = ehci_readl(ehci, status_reg); |
379 | if (temp & PORT_OWNER) | 380 | if (temp & PORT_OWNER) |
380 | break; | 381 | break; |
381 | 382 | ||
382 | switch (wValue) { | 383 | switch (wValue) { |
383 | case USB_PORT_FEAT_ENABLE: | 384 | case USB_PORT_FEAT_ENABLE: |
384 | ehci_writel(ehci, temp & ~PORT_PE, | 385 | ehci_writel(ehci, temp & ~PORT_PE, status_reg); |
385 | &ehci->regs->port_status [wIndex]); | ||
386 | break; | 386 | break; |
387 | case USB_PORT_FEAT_C_ENABLE: | 387 | case USB_PORT_FEAT_C_ENABLE: |
388 | ehci_writel(ehci, (temp & ~PORT_RWC_BITS) | PORT_PEC, | 388 | ehci_writel(ehci, (temp & ~PORT_RWC_BITS) | PORT_PEC, |
389 | &ehci->regs->port_status [wIndex]); | 389 | status_reg); |
390 | break; | 390 | break; |
391 | case USB_PORT_FEAT_SUSPEND: | 391 | case USB_PORT_FEAT_SUSPEND: |
392 | if (temp & PORT_RESET) | 392 | if (temp & PORT_RESET) |
@@ -399,7 +399,7 @@ static int ehci_hub_control ( | |||
399 | /* resume signaling for 20 msec */ | 399 | /* resume signaling for 20 msec */ |
400 | temp &= ~(PORT_RWC_BITS | PORT_WAKE_BITS); | 400 | temp &= ~(PORT_RWC_BITS | PORT_WAKE_BITS); |
401 | ehci_writel(ehci, temp | PORT_RESUME, | 401 | ehci_writel(ehci, temp | PORT_RESUME, |
402 | &ehci->regs->port_status [wIndex]); | 402 | status_reg); |
403 | ehci->reset_done [wIndex] = jiffies | 403 | ehci->reset_done [wIndex] = jiffies |
404 | + msecs_to_jiffies (20); | 404 | + msecs_to_jiffies (20); |
405 | } | 405 | } |
@@ -411,15 +411,15 @@ static int ehci_hub_control ( | |||
411 | if (HCS_PPC (ehci->hcs_params)) | 411 | if (HCS_PPC (ehci->hcs_params)) |
412 | ehci_writel(ehci, | 412 | ehci_writel(ehci, |
413 | temp & ~(PORT_RWC_BITS | PORT_POWER), | 413 | temp & ~(PORT_RWC_BITS | PORT_POWER), |
414 | &ehci->regs->port_status [wIndex]); | 414 | status_reg); |
415 | break; | 415 | break; |
416 | case USB_PORT_FEAT_C_CONNECTION: | 416 | case USB_PORT_FEAT_C_CONNECTION: |
417 | ehci_writel(ehci, (temp & ~PORT_RWC_BITS) | PORT_CSC, | 417 | ehci_writel(ehci, (temp & ~PORT_RWC_BITS) | PORT_CSC, |
418 | &ehci->regs->port_status [wIndex]); | 418 | status_reg); |
419 | break; | 419 | break; |
420 | case USB_PORT_FEAT_C_OVER_CURRENT: | 420 | case USB_PORT_FEAT_C_OVER_CURRENT: |
421 | ehci_writel(ehci, (temp & ~PORT_RWC_BITS) | PORT_OCC, | 421 | ehci_writel(ehci, (temp & ~PORT_RWC_BITS) | PORT_OCC, |
422 | &ehci->regs->port_status [wIndex]); | 422 | status_reg); |
423 | break; | 423 | break; |
424 | case USB_PORT_FEAT_C_RESET: | 424 | case USB_PORT_FEAT_C_RESET: |
425 | /* GetPortStatus clears reset */ | 425 | /* GetPortStatus clears reset */ |
@@ -443,7 +443,7 @@ static int ehci_hub_control ( | |||
443 | goto error; | 443 | goto error; |
444 | wIndex--; | 444 | wIndex--; |
445 | status = 0; | 445 | status = 0; |
446 | temp = ehci_readl(ehci, &ehci->regs->port_status [wIndex]); | 446 | temp = ehci_readl(ehci, status_reg); |
447 | 447 | ||
448 | // wPortChange bits | 448 | // wPortChange bits |
449 | if (temp & PORT_CSC) | 449 | if (temp & PORT_CSC) |
@@ -461,13 +461,11 @@ static int ehci_hub_control ( | |||
461 | ehci->reset_done [wIndex] = 0; | 461 | ehci->reset_done [wIndex] = 0; |
462 | 462 | ||
463 | /* stop resume signaling */ | 463 | /* stop resume signaling */ |
464 | temp = ehci_readl(ehci, | 464 | temp = ehci_readl(ehci, status_reg); |
465 | &ehci->regs->port_status [wIndex]); | ||
466 | ehci_writel(ehci, | 465 | ehci_writel(ehci, |
467 | temp & ~(PORT_RWC_BITS | PORT_RESUME), | 466 | temp & ~(PORT_RWC_BITS | PORT_RESUME), |
468 | &ehci->regs->port_status [wIndex]); | 467 | status_reg); |
469 | retval = handshake(ehci, | 468 | retval = handshake(ehci, status_reg, |
470 | &ehci->regs->port_status [wIndex], | ||
471 | PORT_RESUME, 0, 2000 /* 2msec */); | 469 | PORT_RESUME, 0, 2000 /* 2msec */); |
472 | if (retval != 0) { | 470 | if (retval != 0) { |
473 | ehci_err (ehci, "port %d resume error %d\n", | 471 | ehci_err (ehci, "port %d resume error %d\n", |
@@ -486,12 +484,11 @@ static int ehci_hub_control ( | |||
486 | 484 | ||
487 | /* force reset to complete */ | 485 | /* force reset to complete */ |
488 | ehci_writel(ehci, temp & ~(PORT_RWC_BITS | PORT_RESET), | 486 | ehci_writel(ehci, temp & ~(PORT_RWC_BITS | PORT_RESET), |
489 | &ehci->regs->port_status [wIndex]); | 487 | status_reg); |
490 | /* REVISIT: some hardware needs 550+ usec to clear | 488 | /* REVISIT: some hardware needs 550+ usec to clear |
491 | * this bit; seems too long to spin routinely... | 489 | * this bit; seems too long to spin routinely... |
492 | */ | 490 | */ |
493 | retval = handshake(ehci, | 491 | retval = handshake(ehci, status_reg, |
494 | &ehci->regs->port_status [wIndex], | ||
495 | PORT_RESET, 0, 750); | 492 | PORT_RESET, 0, 750); |
496 | if (retval != 0) { | 493 | if (retval != 0) { |
497 | ehci_err (ehci, "port %d reset error %d\n", | 494 | ehci_err (ehci, "port %d reset error %d\n", |
@@ -500,9 +497,8 @@ static int ehci_hub_control ( | |||
500 | } | 497 | } |
501 | 498 | ||
502 | /* see what we found out */ | 499 | /* see what we found out */ |
503 | temp = check_reset_complete (ehci, wIndex, | 500 | temp = check_reset_complete (ehci, wIndex, status_reg, |
504 | ehci_readl(ehci, | 501 | ehci_readl(ehci, status_reg)); |
505 | &ehci->regs->port_status [wIndex])); | ||
506 | } | 502 | } |
507 | 503 | ||
508 | // don't show wPortStatus if it's owned by a companion hc | 504 | // don't show wPortStatus if it's owned by a companion hc |
@@ -547,7 +543,7 @@ static int ehci_hub_control ( | |||
547 | if (!wIndex || wIndex > ports) | 543 | if (!wIndex || wIndex > ports) |
548 | goto error; | 544 | goto error; |
549 | wIndex--; | 545 | wIndex--; |
550 | temp = ehci_readl(ehci, &ehci->regs->port_status [wIndex]); | 546 | temp = ehci_readl(ehci, status_reg); |
551 | if (temp & PORT_OWNER) | 547 | if (temp & PORT_OWNER) |
552 | break; | 548 | break; |
553 | 549 | ||
@@ -561,13 +557,12 @@ static int ehci_hub_control ( | |||
561 | goto error; | 557 | goto error; |
562 | if (device_may_wakeup(&hcd->self.root_hub->dev)) | 558 | if (device_may_wakeup(&hcd->self.root_hub->dev)) |
563 | temp |= PORT_WAKE_BITS; | 559 | temp |= PORT_WAKE_BITS; |
564 | ehci_writel(ehci, temp | PORT_SUSPEND, | 560 | ehci_writel(ehci, temp | PORT_SUSPEND, status_reg); |
565 | &ehci->regs->port_status [wIndex]); | ||
566 | break; | 561 | break; |
567 | case USB_PORT_FEAT_POWER: | 562 | case USB_PORT_FEAT_POWER: |
568 | if (HCS_PPC (ehci->hcs_params)) | 563 | if (HCS_PPC (ehci->hcs_params)) |
569 | ehci_writel(ehci, temp | PORT_POWER, | 564 | ehci_writel(ehci, temp | PORT_POWER, |
570 | &ehci->regs->port_status [wIndex]); | 565 | status_reg); |
571 | break; | 566 | break; |
572 | case USB_PORT_FEAT_RESET: | 567 | case USB_PORT_FEAT_RESET: |
573 | if (temp & PORT_RESUME) | 568 | if (temp & PORT_RESUME) |
@@ -595,8 +590,7 @@ static int ehci_hub_control ( | |||
595 | ehci->reset_done [wIndex] = jiffies | 590 | ehci->reset_done [wIndex] = jiffies |
596 | + msecs_to_jiffies (50); | 591 | + msecs_to_jiffies (50); |
597 | } | 592 | } |
598 | ehci_writel(ehci, temp, | 593 | ehci_writel(ehci, temp, status_reg); |
599 | &ehci->regs->port_status [wIndex]); | ||
600 | break; | 594 | break; |
601 | 595 | ||
602 | /* For downstream facing ports (these): one hub port is put | 596 | /* For downstream facing ports (these): one hub port is put |
@@ -611,8 +605,7 @@ static int ehci_hub_control ( | |||
611 | ehci_quiesce(ehci); | 605 | ehci_quiesce(ehci); |
612 | ehci_halt(ehci); | 606 | ehci_halt(ehci); |
613 | temp |= selector << 16; | 607 | temp |= selector << 16; |
614 | ehci_writel(ehci, temp, | 608 | ehci_writel(ehci, temp, status_reg); |
615 | &ehci->regs->port_status [wIndex]); | ||
616 | break; | 609 | break; |
617 | 610 | ||
618 | default: | 611 | default: |