diff options
author | Sarah Sharp <sarah.a.sharp@linux.intel.com> | 2010-10-21 14:14:54 -0400 |
---|---|---|
committer | Sarah Sharp <sarah.a.sharp@linux.intel.com> | 2011-03-13 21:07:14 -0400 |
commit | 23e0d1066f429ab44305e96fbff13f1793886277 (patch) | |
tree | 39421fefa903781b6f219b041bfbaec783027ddd /drivers/usb/core | |
parent | 8766c815607e572556b04075d4545330123c4f27 (diff) |
usb: Refactor irq enabling out of usb_add_hcd()
Refactor out the code in usb_add_hcd() to request the IRQ line for the
HCD. This will only need to be called once for the two xHCI roothubs, so
it's easier to refactor it into a function, rather than wrapping the long
if-else block into another if statement.
Signed-off-by: Sarah Sharp <sarah.a.sharp@linux.intel.com>
Diffstat (limited to 'drivers/usb/core')
-rw-r--r-- | drivers/usb/core/hcd.c | 75 |
1 files changed, 43 insertions, 32 deletions
diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c index 93c0b92ae402..40c7a46ba7d3 100644 --- a/drivers/usb/core/hcd.c +++ b/drivers/usb/core/hcd.c | |||
@@ -2236,6 +2236,46 @@ void usb_put_hcd (struct usb_hcd *hcd) | |||
2236 | } | 2236 | } |
2237 | EXPORT_SYMBOL_GPL(usb_put_hcd); | 2237 | EXPORT_SYMBOL_GPL(usb_put_hcd); |
2238 | 2238 | ||
2239 | static int usb_hcd_request_irqs(struct usb_hcd *hcd, | ||
2240 | unsigned int irqnum, unsigned long irqflags) | ||
2241 | { | ||
2242 | int retval; | ||
2243 | |||
2244 | if (hcd->driver->irq) { | ||
2245 | |||
2246 | /* IRQF_DISABLED doesn't work as advertised when used together | ||
2247 | * with IRQF_SHARED. As usb_hcd_irq() will always disable | ||
2248 | * interrupts we can remove it here. | ||
2249 | */ | ||
2250 | if (irqflags & IRQF_SHARED) | ||
2251 | irqflags &= ~IRQF_DISABLED; | ||
2252 | |||
2253 | snprintf(hcd->irq_descr, sizeof(hcd->irq_descr), "%s:usb%d", | ||
2254 | hcd->driver->description, hcd->self.busnum); | ||
2255 | retval = request_irq(irqnum, &usb_hcd_irq, irqflags, | ||
2256 | hcd->irq_descr, hcd); | ||
2257 | if (retval != 0) { | ||
2258 | dev_err(hcd->self.controller, | ||
2259 | "request interrupt %d failed\n", | ||
2260 | irqnum); | ||
2261 | return retval; | ||
2262 | } | ||
2263 | hcd->irq = irqnum; | ||
2264 | dev_info(hcd->self.controller, "irq %d, %s 0x%08llx\n", irqnum, | ||
2265 | (hcd->driver->flags & HCD_MEMORY) ? | ||
2266 | "io mem" : "io base", | ||
2267 | (unsigned long long)hcd->rsrc_start); | ||
2268 | } else { | ||
2269 | hcd->irq = -1; | ||
2270 | if (hcd->rsrc_start) | ||
2271 | dev_info(hcd->self.controller, "%s 0x%08llx\n", | ||
2272 | (hcd->driver->flags & HCD_MEMORY) ? | ||
2273 | "io mem" : "io base", | ||
2274 | (unsigned long long)hcd->rsrc_start); | ||
2275 | } | ||
2276 | return 0; | ||
2277 | } | ||
2278 | |||
2239 | /** | 2279 | /** |
2240 | * usb_add_hcd - finish generic HCD structure initialization and register | 2280 | * usb_add_hcd - finish generic HCD structure initialization and register |
2241 | * @hcd: the usb_hcd structure to initialize | 2281 | * @hcd: the usb_hcd structure to initialize |
@@ -2317,38 +2357,9 @@ int usb_add_hcd(struct usb_hcd *hcd, | |||
2317 | dev_dbg(hcd->self.controller, "supports USB remote wakeup\n"); | 2357 | dev_dbg(hcd->self.controller, "supports USB remote wakeup\n"); |
2318 | 2358 | ||
2319 | /* enable irqs just before we start the controller */ | 2359 | /* enable irqs just before we start the controller */ |
2320 | if (hcd->driver->irq) { | 2360 | retval = usb_hcd_request_irqs(hcd, irqnum, irqflags); |
2321 | 2361 | if (retval) | |
2322 | /* IRQF_DISABLED doesn't work as advertised when used together | 2362 | goto err_request_irq; |
2323 | * with IRQF_SHARED. As usb_hcd_irq() will always disable | ||
2324 | * interrupts we can remove it here. | ||
2325 | */ | ||
2326 | if (irqflags & IRQF_SHARED) | ||
2327 | irqflags &= ~IRQF_DISABLED; | ||
2328 | |||
2329 | snprintf(hcd->irq_descr, sizeof(hcd->irq_descr), "%s:usb%d", | ||
2330 | hcd->driver->description, hcd->self.busnum); | ||
2331 | retval = request_irq(irqnum, &usb_hcd_irq, irqflags, | ||
2332 | hcd->irq_descr, hcd); | ||
2333 | if (retval != 0) { | ||
2334 | dev_err(hcd->self.controller, | ||
2335 | "request interrupt %d failed\n", | ||
2336 | irqnum); | ||
2337 | goto err_request_irq; | ||
2338 | } | ||
2339 | hcd->irq = irqnum; | ||
2340 | dev_info(hcd->self.controller, "irq %d, %s 0x%08llx\n", irqnum, | ||
2341 | (hcd->driver->flags & HCD_MEMORY) ? | ||
2342 | "io mem" : "io base", | ||
2343 | (unsigned long long)hcd->rsrc_start); | ||
2344 | } else { | ||
2345 | hcd->irq = -1; | ||
2346 | if (hcd->rsrc_start) | ||
2347 | dev_info(hcd->self.controller, "%s 0x%08llx\n", | ||
2348 | (hcd->driver->flags & HCD_MEMORY) ? | ||
2349 | "io mem" : "io base", | ||
2350 | (unsigned long long)hcd->rsrc_start); | ||
2351 | } | ||
2352 | 2363 | ||
2353 | hcd->state = HC_STATE_RUNNING; | 2364 | hcd->state = HC_STATE_RUNNING; |
2354 | retval = hcd->driver->start(hcd); | 2365 | retval = hcd->driver->start(hcd); |