USB: EHCI: Refactor "if (handshake()) state = HC_STATE_HALT"
Refactor the EHCI "if (handshake()) state = HC_STATE_HALT" idiom, which appears 4 times, by replacing it with calls to a new function called handshake_on_error_set_halt(). Saves a few bytes too. Signed-off-by: Karsten Wiese <fzu@wemgehoertderstaat.de> Signed-off-by: David Brownell <dbrownell@users.sourceforge.net> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
This commit is contained in:
parent
96f9bc373c
commit
c765d4cad9
|
@ -145,6 +145,16 @@ static int handshake (struct ehci_hcd *ehci, void __iomem *ptr,
|
||||||
return -ETIMEDOUT;
|
return -ETIMEDOUT;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int handshake_on_error_set_halt(struct ehci_hcd *ehci, void __iomem *ptr,
|
||||||
|
u32 mask, u32 done, int usec)
|
||||||
|
{
|
||||||
|
int error = handshake(ehci, ptr, mask, done, usec);
|
||||||
|
if (error)
|
||||||
|
ehci_to_hcd(ehci)->state = HC_STATE_HALT;
|
||||||
|
|
||||||
|
return error;
|
||||||
|
}
|
||||||
|
|
||||||
/* force HC to halt state from unknown (EHCI spec section 2.3) */
|
/* force HC to halt state from unknown (EHCI spec section 2.3) */
|
||||||
static int ehci_halt (struct ehci_hcd *ehci)
|
static int ehci_halt (struct ehci_hcd *ehci)
|
||||||
{
|
{
|
||||||
|
@ -217,11 +227,9 @@ static void ehci_quiesce (struct ehci_hcd *ehci)
|
||||||
/* wait for any schedule enables/disables to take effect */
|
/* wait for any schedule enables/disables to take effect */
|
||||||
temp = ehci_readl(ehci, &ehci->regs->command) << 10;
|
temp = ehci_readl(ehci, &ehci->regs->command) << 10;
|
||||||
temp &= STS_ASS | STS_PSS;
|
temp &= STS_ASS | STS_PSS;
|
||||||
if (handshake (ehci, &ehci->regs->status, STS_ASS | STS_PSS,
|
if (handshake_on_error_set_halt(ehci, &ehci->regs->status,
|
||||||
temp, 16 * 125) != 0) {
|
STS_ASS | STS_PSS, temp, 16 * 125))
|
||||||
ehci_to_hcd(ehci)->state = HC_STATE_HALT;
|
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
/* then disable anything that's still active */
|
/* then disable anything that's still active */
|
||||||
temp = ehci_readl(ehci, &ehci->regs->command);
|
temp = ehci_readl(ehci, &ehci->regs->command);
|
||||||
|
@ -229,11 +237,8 @@ static void ehci_quiesce (struct ehci_hcd *ehci)
|
||||||
ehci_writel(ehci, temp, &ehci->regs->command);
|
ehci_writel(ehci, temp, &ehci->regs->command);
|
||||||
|
|
||||||
/* hardware can take 16 microframes to turn off ... */
|
/* hardware can take 16 microframes to turn off ... */
|
||||||
if (handshake (ehci, &ehci->regs->status, STS_ASS | STS_PSS,
|
handshake_on_error_set_halt(ehci, &ehci->regs->status,
|
||||||
0, 16 * 125) != 0) {
|
STS_ASS | STS_PSS, 0, 16 * 125);
|
||||||
ehci_to_hcd(ehci)->state = HC_STATE_HALT;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*-------------------------------------------------------------------------*/
|
/*-------------------------------------------------------------------------*/
|
||||||
|
|
|
@ -440,11 +440,10 @@ static int enable_periodic (struct ehci_hcd *ehci)
|
||||||
/* did clearing PSE did take effect yet?
|
/* did clearing PSE did take effect yet?
|
||||||
* takes effect only at frame boundaries...
|
* takes effect only at frame boundaries...
|
||||||
*/
|
*/
|
||||||
status = handshake(ehci, &ehci->regs->status, STS_PSS, 0, 9 * 125);
|
status = handshake_on_error_set_halt(ehci, &ehci->regs->status,
|
||||||
if (status != 0) {
|
STS_PSS, 0, 9 * 125);
|
||||||
ehci_to_hcd(ehci)->state = HC_STATE_HALT;
|
if (status)
|
||||||
return status;
|
return status;
|
||||||
}
|
|
||||||
|
|
||||||
cmd = ehci_readl(ehci, &ehci->regs->command) | CMD_PSE;
|
cmd = ehci_readl(ehci, &ehci->regs->command) | CMD_PSE;
|
||||||
ehci_writel(ehci, cmd, &ehci->regs->command);
|
ehci_writel(ehci, cmd, &ehci->regs->command);
|
||||||
|
@ -465,11 +464,10 @@ static int disable_periodic (struct ehci_hcd *ehci)
|
||||||
/* did setting PSE not take effect yet?
|
/* did setting PSE not take effect yet?
|
||||||
* takes effect only at frame boundaries...
|
* takes effect only at frame boundaries...
|
||||||
*/
|
*/
|
||||||
status = handshake(ehci, &ehci->regs->status, STS_PSS, STS_PSS, 9 * 125);
|
status = handshake_on_error_set_halt(ehci, &ehci->regs->status,
|
||||||
if (status != 0) {
|
STS_PSS, STS_PSS, 9 * 125);
|
||||||
ehci_to_hcd(ehci)->state = HC_STATE_HALT;
|
if (status)
|
||||||
return status;
|
return status;
|
||||||
}
|
|
||||||
|
|
||||||
cmd = ehci_readl(ehci, &ehci->regs->command) & ~CMD_PSE;
|
cmd = ehci_readl(ehci, &ehci->regs->command) & ~CMD_PSE;
|
||||||
ehci_writel(ehci, cmd, &ehci->regs->command);
|
ehci_writel(ehci, cmd, &ehci->regs->command);
|
||||||
|
|
Loading…
Reference in New Issue