Commit 31a0ede0 authored by Felipe Balbi's avatar Felipe Balbi

usb: musb: core: improve musb_interrupt() a bit

instead of using manually spelled out bit-shits
and iterate over each of the 16-bits (one for
each endpoint) on each direction, we can make use
of for_each_set_bit() which internally uses
find_first_bit().

This makes the code slightly more readable while
also making we only iterate over bits which are
actually set.
Signed-off-by: default avatarFelipe Balbi <balbi@ti.com>
parent e3c93e1a
...@@ -1587,9 +1587,12 @@ static int musb_core_init(u16 musb_type, struct musb *musb) ...@@ -1587,9 +1587,12 @@ static int musb_core_init(u16 musb_type, struct musb *musb)
irqreturn_t musb_interrupt(struct musb *musb) irqreturn_t musb_interrupt(struct musb *musb)
{ {
irqreturn_t retval = IRQ_NONE; irqreturn_t retval = IRQ_NONE;
unsigned long status;
unsigned long epnum;
u8 devctl; u8 devctl;
int ep_num;
u32 reg; if (!musb->int_usb && !musb->int_tx && !musb->int_rx)
return IRQ_NONE;
devctl = musb_readb(musb->mregs, MUSB_DEVCTL); devctl = musb_readb(musb->mregs, MUSB_DEVCTL);
...@@ -1618,43 +1621,36 @@ irqreturn_t musb_interrupt(struct musb *musb) ...@@ -1618,43 +1621,36 @@ irqreturn_t musb_interrupt(struct musb *musb)
*/ */
if (musb->int_usb) if (musb->int_usb)
retval |= musb_stage0_irq(musb, musb->int_usb, retval |= musb_stage0_irq(musb, musb->int_usb, devctl);
devctl);
if (musb->int_tx & 1) { if (musb->int_tx & 1) {
if (is_host_active(musb)) if (is_host_active(musb))
retval |= musb_h_ep0_irq(musb); retval |= musb_h_ep0_irq(musb);
else else
retval |= musb_g_ep0_irq(musb); retval |= musb_g_ep0_irq(musb);
/* we have just handled endpoint 0 IRQ, clear it */
musb->int_tx &= ~BIT(0);
} }
reg = musb->int_tx >> 1; status = musb->int_tx;
ep_num = 1;
while (reg) { for_each_set_bit(epnum, &status, 16) {
if (reg & 1) {
retval = IRQ_HANDLED; retval = IRQ_HANDLED;
if (is_host_active(musb)) if (is_host_active(musb))
musb_host_tx(musb, ep_num); musb_host_tx(musb, epnum);
else else
musb_g_tx(musb, ep_num); musb_g_tx(musb, epnum);
}
reg >>= 1;
ep_num++;
} }
reg = musb->int_rx >> 1; status = musb->int_rx;
ep_num = 1;
while (reg) { for_each_set_bit(epnum, &status, 16) {
if (reg & 1) {
retval = IRQ_HANDLED; retval = IRQ_HANDLED;
if (is_host_active(musb)) if (is_host_active(musb))
musb_host_rx(musb, ep_num); musb_host_rx(musb, epnum);
else else
musb_g_rx(musb, ep_num); musb_g_rx(musb, epnum);
}
reg >>= 1;
ep_num++;
} }
return retval; return retval;
......
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