usb: dwc3: gadget: pass ev_buff as cookie to irq handler

we don't plan on using multiple event buffers, but
if we find a good use case for it, this little trick
will help us avoid a loop in hardirq handler looping
for each and every event buffer.

Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
This commit is contained in:
Felipe Balbi 2016-03-30 09:39:34 +03:00
parent 696c8b1282
commit dea520a4a2
1 changed files with 14 additions and 16 deletions

View File

@ -1536,7 +1536,7 @@ static int dwc3_gadget_start(struct usb_gadget *g,
irq = platform_get_irq(to_platform_device(dwc->dev), 0);
ret = request_threaded_irq(irq, dwc3_interrupt, dwc3_thread_interrupt,
IRQF_SHARED, "dwc3", dwc);
IRQF_SHARED, "dwc3", dwc->ev_buf);
if (ret) {
dev_err(dwc->dev, "failed to request irq #%d --> %d\n",
irq, ret);
@ -1636,7 +1636,7 @@ static int dwc3_gadget_start(struct usb_gadget *g,
err1:
spin_unlock_irqrestore(&dwc->lock, flags);
free_irq(irq, dwc);
free_irq(irq, dwc->ev_buf);
err0:
return ret;
@ -1659,7 +1659,7 @@ static int dwc3_gadget_stop(struct usb_gadget *g)
spin_unlock_irqrestore(&dwc->lock, flags);
irq = platform_get_irq(to_platform_device(dwc->dev), 0);
free_irq(irq, dwc);
free_irq(irq, dwc->ev_buf);
return 0;
}
@ -2602,14 +2602,13 @@ static void dwc3_process_event_entry(struct dwc3 *dwc,
}
}
static irqreturn_t dwc3_process_event_buf(struct dwc3 *dwc)
static irqreturn_t dwc3_process_event_buf(struct dwc3_event_buffer *evt)
{
struct dwc3_event_buffer *evt;
struct dwc3 *dwc = evt->dwc;
irqreturn_t ret = IRQ_NONE;
int left;
u32 reg;
evt = dwc->ev_buf;
left = evt->count;
if (!(evt->flags & DWC3_EVENT_PENDING))
@ -2649,27 +2648,26 @@ static irqreturn_t dwc3_process_event_buf(struct dwc3 *dwc)
return ret;
}
static irqreturn_t dwc3_thread_interrupt(int irq, void *_dwc)
static irqreturn_t dwc3_thread_interrupt(int irq, void *_evt)
{
struct dwc3 *dwc = _dwc;
struct dwc3_event_buffer *evt = _evt;
struct dwc3 *dwc = evt->dwc;
unsigned long flags;
irqreturn_t ret = IRQ_NONE;
spin_lock_irqsave(&dwc->lock, flags);
ret = dwc3_process_event_buf(dwc);
ret = dwc3_process_event_buf(evt);
spin_unlock_irqrestore(&dwc->lock, flags);
return ret;
}
static irqreturn_t dwc3_check_event_buf(struct dwc3 *dwc)
static irqreturn_t dwc3_check_event_buf(struct dwc3_event_buffer *evt)
{
struct dwc3_event_buffer *evt;
struct dwc3 *dwc = evt->dwc;
u32 count;
u32 reg;
evt = dwc->ev_buf;
count = dwc3_readl(dwc->regs, DWC3_GEVNTCOUNT(0));
count &= DWC3_GEVNTCOUNT_MASK;
if (!count)
@ -2686,11 +2684,11 @@ static irqreturn_t dwc3_check_event_buf(struct dwc3 *dwc)
return IRQ_WAKE_THREAD;
}
static irqreturn_t dwc3_interrupt(int irq, void *_dwc)
static irqreturn_t dwc3_interrupt(int irq, void *_evt)
{
struct dwc3 *dwc = _dwc;
struct dwc3_event_buffer *evt = _evt;
return dwc3_check_event_buf(dwc);
return dwc3_check_event_buf(evt);
}
/**