Commit f42f2447 authored by Felipe Balbi's avatar Felipe Balbi

usb: dwc3: gadget: introduce dwc3_process_event_buf

in order to make our IRQ handler thread easier
to read, we re-factor the inner loop to a separate
function.
Signed-off-by: default avatarFelipe Balbi <balbi@ti.com>
parent 7f97aa98
...@@ -2442,25 +2442,18 @@ static void dwc3_process_event_entry(struct dwc3 *dwc, ...@@ -2442,25 +2442,18 @@ static void dwc3_process_event_entry(struct dwc3 *dwc,
} }
} }
static irqreturn_t dwc3_thread_interrupt(int irq, void *_dwc) static irqreturn_t dwc3_process_event_buf(struct dwc3 *dwc, u32 buf)
{ {
struct dwc3 *dwc = _dwc;
unsigned long flags;
irqreturn_t ret = IRQ_NONE;
u32 reg;
int i;
spin_lock_irqsave(&dwc->lock, flags);
for (i = 0; i < dwc->num_event_buffers; i++) {
struct dwc3_event_buffer *evt; struct dwc3_event_buffer *evt;
irqreturn_t ret = IRQ_NONE;
int left; int left;
u32 reg;
evt = dwc->ev_buffs[i]; evt = dwc->ev_buffs[buf];
left = evt->count; left = evt->count;
if (!(evt->flags & DWC3_EVENT_PENDING)) if (!(evt->flags & DWC3_EVENT_PENDING))
continue; return IRQ_NONE;
while (left > 0) { while (left > 0) {
union dwc3_event event; union dwc3_event event;
...@@ -2481,7 +2474,7 @@ static irqreturn_t dwc3_thread_interrupt(int irq, void *_dwc) ...@@ -2481,7 +2474,7 @@ static irqreturn_t dwc3_thread_interrupt(int irq, void *_dwc)
evt->lpos = (evt->lpos + 4) % DWC3_EVENT_BUFFERS_SIZE; evt->lpos = (evt->lpos + 4) % DWC3_EVENT_BUFFERS_SIZE;
left -= 4; left -= 4;
dwc3_writel(dwc->regs, DWC3_GEVNTCOUNT(i), 4); dwc3_writel(dwc->regs, DWC3_GEVNTCOUNT(buf), 4);
} }
evt->count = 0; evt->count = 0;
...@@ -2489,10 +2482,24 @@ static irqreturn_t dwc3_thread_interrupt(int irq, void *_dwc) ...@@ -2489,10 +2482,24 @@ static irqreturn_t dwc3_thread_interrupt(int irq, void *_dwc)
ret = IRQ_HANDLED; ret = IRQ_HANDLED;
/* Unmask interrupt */ /* Unmask interrupt */
reg = dwc3_readl(dwc->regs, DWC3_GEVNTSIZ(i)); reg = dwc3_readl(dwc->regs, DWC3_GEVNTSIZ(buf));
reg &= ~DWC3_GEVNTSIZ_INTMASK; reg &= ~DWC3_GEVNTSIZ_INTMASK;
dwc3_writel(dwc->regs, DWC3_GEVNTSIZ(i), reg); dwc3_writel(dwc->regs, DWC3_GEVNTSIZ(buf), reg);
}
return ret;
}
static irqreturn_t dwc3_thread_interrupt(int irq, void *_dwc)
{
struct dwc3 *dwc = _dwc;
unsigned long flags;
irqreturn_t ret = IRQ_NONE;
int i;
spin_lock_irqsave(&dwc->lock, flags);
for (i = 0; i < dwc->num_event_buffers; i++)
ret |= dwc3_process_event_buf(dwc, i);
spin_unlock_irqrestore(&dwc->lock, flags); spin_unlock_irqrestore(&dwc->lock, flags);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment