aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/musb
diff options
context:
space:
mode:
authorFelipe Balbi <balbi@ti.com>2013-12-30 13:42:38 -0500
committerFelipe Balbi <balbi@ti.com>2015-03-09 11:38:49 -0400
commit31a0ede0de49a5897d7d97c68228ae79f86c38f0 (patch)
tree5e40b35e31b416f4fdd9b7eba10d743455436bd1 /drivers/usb/musb
parente3c93e1a3f35be4cf1493d3ccfb0c6d9209e4922 (diff)
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: Felipe Balbi <balbi@ti.com>
Diffstat (limited to 'drivers/usb/musb')
-rw-r--r--drivers/usb/musb/musb_core.c52
1 files changed, 24 insertions, 28 deletions
diff --git a/drivers/usb/musb/musb_core.c b/drivers/usb/musb/musb_core.c
index 461bfe8efcf2..e59ae7395ba8 100644
--- a/drivers/usb/musb/musb_core.c
+++ b/drivers/usb/musb/musb_core.c
@@ -1587,9 +1587,12 @@ static int musb_core_init(u16 musb_type, struct musb *musb)
1587irqreturn_t musb_interrupt(struct musb *musb) 1587irqreturn_t musb_interrupt(struct musb *musb)
1588{ 1588{
1589 irqreturn_t retval = IRQ_NONE; 1589 irqreturn_t retval = IRQ_NONE;
1590 unsigned long status;
1591 unsigned long epnum;
1590 u8 devctl; 1592 u8 devctl;
1591 int ep_num; 1593
1592 u32 reg; 1594 if (!musb->int_usb && !musb->int_tx && !musb->int_rx)
1595 return IRQ_NONE;
1593 1596
1594 devctl = musb_readb(musb->mregs, MUSB_DEVCTL); 1597 devctl = musb_readb(musb->mregs, MUSB_DEVCTL);
1595 1598
@@ -1618,43 +1621,36 @@ irqreturn_t musb_interrupt(struct musb *musb)
1618 */ 1621 */
1619 1622
1620 if (musb->int_usb) 1623 if (musb->int_usb)
1621 retval |= musb_stage0_irq(musb, musb->int_usb, 1624 retval |= musb_stage0_irq(musb, musb->int_usb, devctl);
1622 devctl);
1623 1625
1624 if (musb->int_tx & 1) { 1626 if (musb->int_tx & 1) {
1625 if (is_host_active(musb)) 1627 if (is_host_active(musb))
1626 retval |= musb_h_ep0_irq(musb); 1628 retval |= musb_h_ep0_irq(musb);
1627 else 1629 else
1628 retval |= musb_g_ep0_irq(musb); 1630 retval |= musb_g_ep0_irq(musb);
1631
1632 /* we have just handled endpoint 0 IRQ, clear it */
1633 musb->int_tx &= ~BIT(0);
1629 } 1634 }
1630 1635
1631 reg = musb->int_tx >> 1; 1636 status = musb->int_tx;
1632 ep_num = 1; 1637
1633 while (reg) { 1638 for_each_set_bit(epnum, &status, 16) {
1634 if (reg & 1) { 1639 retval = IRQ_HANDLED;
1635 retval = IRQ_HANDLED; 1640 if (is_host_active(musb))
1636 if (is_host_active(musb)) 1641 musb_host_tx(musb, epnum);
1637 musb_host_tx(musb, ep_num); 1642 else
1638 else 1643 musb_g_tx(musb, epnum);
1639 musb_g_tx(musb, ep_num);
1640 }
1641 reg >>= 1;
1642 ep_num++;
1643 } 1644 }
1644 1645
1645 reg = musb->int_rx >> 1; 1646 status = musb->int_rx;
1646 ep_num = 1;
1647 while (reg) {
1648 if (reg & 1) {
1649 retval = IRQ_HANDLED;
1650 if (is_host_active(musb))
1651 musb_host_rx(musb, ep_num);
1652 else
1653 musb_g_rx(musb, ep_num);
1654 }
1655 1647
1656 reg >>= 1; 1648 for_each_set_bit(epnum, &status, 16) {
1657 ep_num++; 1649 retval = IRQ_HANDLED;
1650 if (is_host_active(musb))
1651 musb_host_rx(musb, epnum);
1652 else
1653 musb_g_rx(musb, epnum);
1658 } 1654 }
1659 1655
1660 return retval; 1656 return retval;