usb: musb: dsps: use msecs_to_jiffies instead
authorFelipe Balbi <balbi@ti.com>
Sat, 28 Feb 2015 01:02:41 +0000 (19:02 -0600)
committerFelipe Balbi <balbi@ti.com>
Tue, 10 Mar 2015 20:33:32 +0000 (15:33 -0500)
when polling, we were using n * HZ (where n is
an integer in seconds), however HZ isn't always
correct if we're using cpufreq. A better way
is to use msecs_to_jiffies(n) (where n is now
an integer in miliseconds).

while at that, also rename poll_seconds to poll_timeout
and  change its type to unsigned int.

Signed-off-by: Felipe Balbi <balbi@ti.com>
drivers/usb/musb/musb_dsps.c

index 30eb6ac29b813d70f7ffa6f53a0b322917c8e402..9271450ebacd5585b84f466ade142cd0ba3911a2 100644 (file)
@@ -119,7 +119,7 @@ struct dsps_musb_wrapper {
        unsigned        iddig:5;
        unsigned        iddig_mux:5;
        /* miscellaneous stuff */
-       u8              poll_seconds;
+       unsigned        poll_timeout;
 };
 
 /*
@@ -285,7 +285,8 @@ static void otg_timer(unsigned long _musb)
                }
                if (!(devctl & MUSB_DEVCTL_SESSION) && !skip_session)
                        dsps_writeb(mregs, MUSB_DEVCTL, MUSB_DEVCTL_SESSION);
-               mod_timer(&glue->timer, jiffies + wrp->poll_seconds * HZ);
+               mod_timer(&glue->timer, jiffies +
+                               msecs_to_jiffies(wrp->poll_timeout));
                break;
        case OTG_STATE_A_WAIT_VFALL:
                musb->xceiv->otg->state = OTG_STATE_A_WAIT_VRISE;
@@ -352,8 +353,8 @@ static irqreturn_t dsps_interrupt(int irq, void *hci)
                         */
                        musb->int_usb &= ~MUSB_INTR_VBUSERROR;
                        musb->xceiv->otg->state = OTG_STATE_A_WAIT_VFALL;
-                       mod_timer(&glue->timer,
-                                       jiffies + wrp->poll_seconds * HZ);
+                       mod_timer(&glue->timer, jiffies +
+                                       msecs_to_jiffies(wrp->poll_timeout));
                        WARNING("VBUS error workaround (delay coming)\n");
                } else if (drvvbus) {
                        MUSB_HST_MODE(musb);
@@ -382,7 +383,8 @@ static irqreturn_t dsps_interrupt(int irq, void *hci)
        /* Poll for ID change in OTG port mode */
        if (musb->xceiv->otg->state == OTG_STATE_B_IDLE &&
                        musb->port_mode == MUSB_PORT_MODE_DUAL_ROLE)
-               mod_timer(&glue->timer, jiffies + wrp->poll_seconds * HZ);
+               mod_timer(&glue->timer, jiffies +
+                               msecs_to_jiffies(wrp->poll_timeout));
 out:
        spin_unlock_irqrestore(&musb->lock, flags);
 
@@ -832,7 +834,7 @@ static const struct dsps_musb_wrapper am33xx_driver_data = {
        .rxep_shift             = 16,
        .rxep_mask              = 0xfffe,
        .rxep_bitmap            = (0xfffe << 16),
-       .poll_seconds           = 2,
+       .poll_timeout           = 2000, /* ms */
 };
 
 static const struct of_device_id musb_dsps_of_match[] = {
@@ -888,7 +890,8 @@ static int dsps_resume(struct device *dev)
        dsps_writel(mbase, wrp->rx_mode, glue->context.rx_mode);
        if (musb->xceiv->otg->state == OTG_STATE_B_IDLE &&
            musb->port_mode == MUSB_PORT_MODE_DUAL_ROLE)
-               mod_timer(&glue->timer, jiffies + wrp->poll_seconds * HZ);
+               mod_timer(&glue->timer, jiffies +
+                               msecs_to_jiffies(wrp->poll_timeout));
 
        return 0;
 }