diff options
author | Karsten Wiese <fzu@wemgehoertderstaat.de> | 2008-02-16 16:44:42 -0500 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2008-04-25 00:16:35 -0400 |
commit | c765d4cad977f7e454a53d5bca5a942156b2d94c (patch) | |
tree | f73f80b89d96d5a05bed5d261ac0437b1b966b84 /drivers/usb/host/ehci-hcd.c | |
parent | 96f9bc373c83a67922dc32f358e8a3b3dd4e18a0 (diff) |
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>
Diffstat (limited to 'drivers/usb/host/ehci-hcd.c')
-rw-r--r-- | drivers/usb/host/ehci-hcd.c | 23 |
1 files changed, 14 insertions, 9 deletions
diff --git a/drivers/usb/host/ehci-hcd.c b/drivers/usb/host/ehci-hcd.c index 360712207262..40f7391bf2aa 100644 --- a/drivers/usb/host/ehci-hcd.c +++ b/drivers/usb/host/ehci-hcd.c | |||
@@ -145,6 +145,16 @@ static int handshake (struct ehci_hcd *ehci, void __iomem *ptr, | |||
145 | return -ETIMEDOUT; | 145 | return -ETIMEDOUT; |
146 | } | 146 | } |
147 | 147 | ||
148 | static int handshake_on_error_set_halt(struct ehci_hcd *ehci, void __iomem *ptr, | ||
149 | u32 mask, u32 done, int usec) | ||
150 | { | ||
151 | int error = handshake(ehci, ptr, mask, done, usec); | ||
152 | if (error) | ||
153 | ehci_to_hcd(ehci)->state = HC_STATE_HALT; | ||
154 | |||
155 | return error; | ||
156 | } | ||
157 | |||
148 | /* force HC to halt state from unknown (EHCI spec section 2.3) */ | 158 | /* force HC to halt state from unknown (EHCI spec section 2.3) */ |
149 | static int ehci_halt (struct ehci_hcd *ehci) | 159 | static int ehci_halt (struct ehci_hcd *ehci) |
150 | { | 160 | { |
@@ -217,11 +227,9 @@ static void ehci_quiesce (struct ehci_hcd *ehci) | |||
217 | /* wait for any schedule enables/disables to take effect */ | 227 | /* wait for any schedule enables/disables to take effect */ |
218 | temp = ehci_readl(ehci, &ehci->regs->command) << 10; | 228 | temp = ehci_readl(ehci, &ehci->regs->command) << 10; |
219 | temp &= STS_ASS | STS_PSS; | 229 | temp &= STS_ASS | STS_PSS; |
220 | if (handshake (ehci, &ehci->regs->status, STS_ASS | STS_PSS, | 230 | if (handshake_on_error_set_halt(ehci, &ehci->regs->status, |
221 | temp, 16 * 125) != 0) { | 231 | STS_ASS | STS_PSS, temp, 16 * 125)) |
222 | ehci_to_hcd(ehci)->state = HC_STATE_HALT; | ||
223 | return; | 232 | return; |
224 | } | ||
225 | 233 | ||
226 | /* then disable anything that's still active */ | 234 | /* then disable anything that's still active */ |
227 | temp = ehci_readl(ehci, &ehci->regs->command); | 235 | temp = ehci_readl(ehci, &ehci->regs->command); |
@@ -229,11 +237,8 @@ static void ehci_quiesce (struct ehci_hcd *ehci) | |||
229 | ehci_writel(ehci, temp, &ehci->regs->command); | 237 | ehci_writel(ehci, temp, &ehci->regs->command); |
230 | 238 | ||
231 | /* hardware can take 16 microframes to turn off ... */ | 239 | /* hardware can take 16 microframes to turn off ... */ |
232 | if (handshake (ehci, &ehci->regs->status, STS_ASS | STS_PSS, | 240 | handshake_on_error_set_halt(ehci, &ehci->regs->status, |
233 | 0, 16 * 125) != 0) { | 241 | STS_ASS | STS_PSS, 0, 16 * 125); |
234 | ehci_to_hcd(ehci)->state = HC_STATE_HALT; | ||
235 | return; | ||
236 | } | ||
237 | } | 242 | } |
238 | 243 | ||
239 | /*-------------------------------------------------------------------------*/ | 244 | /*-------------------------------------------------------------------------*/ |