Skip to content

Commit

Permalink
USB: pxa27x_udc: avoid compiler warnings and misbehavior on buggy har…
Browse files Browse the repository at this point in the history
…dware

hardware reports wrong interrupt.  Although such a situation should not
happen, the compiler complains about this access.

This patch adds a sanity check and generates warning to detect such
issues.

Signed-off-by: Enrico Scholz <enrico.scholz@sigma-chemnitz.de>
Acked-by: Robert Jarzmik <robert.jarzmik@free.fr>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
  • Loading branch information
Enrico Scholz authored and Greg Kroah-Hartman committed Mar 2, 2010
1 parent 2f0e40a commit 4fdb31d
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions drivers/usb/gadget/pxa27x_udc.c
Original file line number Diff line number Diff line change
Expand Up @@ -2218,19 +2218,26 @@ static void irq_handle_data(int irq, struct pxa_udc *udc)
continue;

udc_writel(udc, UDCISR0, UDCISR_INT(i, UDCISR_INT_MASK));
ep = &udc->pxa_ep[i];
ep->stats.irqs++;
handle_ep(ep);

WARN_ON(i >= ARRAY_SIZE(udc->pxa_ep));
if (i < ARRAY_SIZE(udc->pxa_ep)) {
ep = &udc->pxa_ep[i];
ep->stats.irqs++;
handle_ep(ep);
}
}

for (i = 16; udcisr1 != 0 && i < 24; udcisr1 >>= 2, i++) {
udc_writel(udc, UDCISR1, UDCISR_INT(i - 16, UDCISR_INT_MASK));
if (!(udcisr1 & UDCISR_INT_MASK))
continue;

ep = &udc->pxa_ep[i];
ep->stats.irqs++;
handle_ep(ep);
WARN_ON(i >= ARRAY_SIZE(udc->pxa_ep));
if (i < ARRAY_SIZE(udc->pxa_ep)) {
ep = &udc->pxa_ep[i];
ep->stats.irqs++;
handle_ep(ep);
}
}

}
Expand Down

0 comments on commit 4fdb31d

Please sign in to comment.