UPSTREAM: usb: dwc3: gadget: hold gadget IRQ in dwc->irq_gadget
authorFelipe Balbi <felipe.balbi@linux.intel.com>
Mon, 16 May 2016 11:17:06 +0000 (14:17 +0300)
committerHuang, Tao <huangtao@rock-chips.com>
Tue, 16 Aug 2016 12:48:19 +0000 (20:48 +0800)
by holding gadget's IRQ number in dwc->irq_gadget,
it'll be simpler to free_irq() and disable the IRQ
in case an IRQ fires while we are runtime suspended.

Change-Id: I17ed4486bfcc1cd9fabb11fccb802e3a80d61501
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
Signed-off-by: Wu Liang feng <wulf@rock-chips.com>
(cherry picked from commit 3f308d17d7abbf35a6d40a7f16dc70cf43f12c98)

drivers/usb/dwc3/core.h
drivers/usb/dwc3/gadget.c

index a5a911b98b941fc86c45fec57768c7020bb60479..3d40a4faada17a7da900923c92dcb862a9fa63fb 100644 (file)
@@ -728,6 +728,7 @@ struct dwc3_scratchpad_array {
  * @regs: base address for our registers
  * @regs_size: address space size
  * @fladj: frame length adjustment
+ * @irq_gadget: peripheral controller's IRQ number
  * @nr_scratch: number of scratch buffers
  * @u1u2: only used on revisions <1.83a for workaround
  * @maximum_speed: maximum speed requested (mainly for testing purposes)
@@ -835,6 +836,7 @@ struct dwc3 {
        enum usb_dr_mode        dr_mode;
 
        u32                     fladj;
+       u32                     irq_gadget;
        u32                     nr_scratch;
        u32                     u1u2;
        u32                     maximum_speed;
index f24746b476dcb82611294c341cb524f46e534d85..bb4268a2d946a804fa901bb490a52f4c3d95ba2a 100644 (file)
@@ -1755,6 +1755,7 @@ static int dwc3_gadget_start(struct usb_gadget *g,
                                irq, ret);
                goto err0;
        }
+       dwc->irq_gadget = irq;
 
        spin_lock_irqsave(&dwc->lock, flags);
        if (dwc->gadget_driver) {
@@ -1791,15 +1792,13 @@ static int dwc3_gadget_stop(struct usb_gadget *g)
 {
        struct dwc3             *dwc = gadget_to_dwc(g);
        unsigned long           flags;
-       int                     irq;
 
        spin_lock_irqsave(&dwc->lock, flags);
        __dwc3_gadget_stop(dwc);
        dwc->gadget_driver      = NULL;
        spin_unlock_irqrestore(&dwc->lock, flags);
 
-       irq = platform_get_irq(to_platform_device(dwc->dev), 0);
-       free_irq(irq, dwc->ev_buf);
+       free_irq(dwc->irq_gadget, dwc->ev_buf);
 
        return 0;
 }