usb: musb: Convert timers to use timer_setup()
In preparation for unconditionally passing the struct timer_list pointer to all timer callbacks, switch to using the new timer_setup() and from_timer() to pass the timer pointer explicitly. Instead of a per-device static timer variable, a spare timer "dev_timer" is added to the musb structure for devices to use for their per-device timer. Cc: linux-usb@vger.kernel.org Signed-off-by: Kees Cook <keescook@chromium.org> Acked-by: Bin Liu <b-liu@ti.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:

committed by
Greg Kroah-Hartman

parent
0c63636440
commit
0567849727
@@ -135,11 +135,9 @@ static void da8xx_musb_set_vbus(struct musb *musb, int is_on)
|
||||
|
||||
#define POLL_SECONDS 2
|
||||
|
||||
static struct timer_list otg_workaround;
|
||||
|
||||
static void otg_timer(unsigned long _musb)
|
||||
static void otg_timer(struct timer_list *t)
|
||||
{
|
||||
struct musb *musb = (void *)_musb;
|
||||
struct musb *musb = from_timer(musb, t, dev_timer);
|
||||
void __iomem *mregs = musb->mregs;
|
||||
u8 devctl;
|
||||
unsigned long flags;
|
||||
@@ -175,7 +173,7 @@ static void otg_timer(unsigned long _musb)
|
||||
* VBUSERR got reported during enumeration" cases.
|
||||
*/
|
||||
if (devctl & MUSB_DEVCTL_VBUS) {
|
||||
mod_timer(&otg_workaround, jiffies + POLL_SECONDS * HZ);
|
||||
mod_timer(&musb->dev_timer, jiffies + POLL_SECONDS * HZ);
|
||||
break;
|
||||
}
|
||||
musb->xceiv->otg->state = OTG_STATE_A_WAIT_VRISE;
|
||||
@@ -198,7 +196,7 @@ static void otg_timer(unsigned long _musb)
|
||||
musb_writeb(mregs, MUSB_DEVCTL, devctl | MUSB_DEVCTL_SESSION);
|
||||
devctl = musb_readb(mregs, MUSB_DEVCTL);
|
||||
if (devctl & MUSB_DEVCTL_BDEVICE)
|
||||
mod_timer(&otg_workaround, jiffies + POLL_SECONDS * HZ);
|
||||
mod_timer(&musb->dev_timer, jiffies + POLL_SECONDS * HZ);
|
||||
else
|
||||
musb->xceiv->otg->state = OTG_STATE_A_IDLE;
|
||||
break;
|
||||
@@ -220,12 +218,12 @@ static void da8xx_musb_try_idle(struct musb *musb, unsigned long timeout)
|
||||
musb->xceiv->otg->state == OTG_STATE_A_WAIT_BCON)) {
|
||||
dev_dbg(musb->controller, "%s active, deleting timer\n",
|
||||
usb_otg_state_string(musb->xceiv->otg->state));
|
||||
del_timer(&otg_workaround);
|
||||
del_timer(&musb->dev_timer);
|
||||
last_timer = jiffies;
|
||||
return;
|
||||
}
|
||||
|
||||
if (time_after(last_timer, timeout) && timer_pending(&otg_workaround)) {
|
||||
if (time_after(last_timer, timeout) && timer_pending(&musb->dev_timer)) {
|
||||
dev_dbg(musb->controller, "Longer idle timer already pending, ignoring...\n");
|
||||
return;
|
||||
}
|
||||
@@ -234,7 +232,7 @@ static void da8xx_musb_try_idle(struct musb *musb, unsigned long timeout)
|
||||
dev_dbg(musb->controller, "%s inactive, starting idle timer for %u ms\n",
|
||||
usb_otg_state_string(musb->xceiv->otg->state),
|
||||
jiffies_to_msecs(timeout - jiffies));
|
||||
mod_timer(&otg_workaround, timeout);
|
||||
mod_timer(&musb->dev_timer, timeout);
|
||||
}
|
||||
|
||||
static irqreturn_t da8xx_musb_interrupt(int irq, void *hci)
|
||||
@@ -294,14 +292,14 @@ static irqreturn_t da8xx_musb_interrupt(int irq, void *hci)
|
||||
*/
|
||||
musb->int_usb &= ~MUSB_INTR_VBUSERROR;
|
||||
musb->xceiv->otg->state = OTG_STATE_A_WAIT_VFALL;
|
||||
mod_timer(&otg_workaround, jiffies + POLL_SECONDS * HZ);
|
||||
mod_timer(&musb->dev_timer, jiffies + POLL_SECONDS * HZ);
|
||||
WARNING("VBUS error workaround (delay coming)\n");
|
||||
} else if (drvvbus) {
|
||||
MUSB_HST_MODE(musb);
|
||||
otg->default_a = 1;
|
||||
musb->xceiv->otg->state = OTG_STATE_A_WAIT_VRISE;
|
||||
portstate(musb->port1_status |= USB_PORT_STAT_POWER);
|
||||
del_timer(&otg_workaround);
|
||||
del_timer(&musb->dev_timer);
|
||||
} else {
|
||||
musb->is_active = 0;
|
||||
MUSB_DEV_MODE(musb);
|
||||
@@ -328,7 +326,7 @@ static irqreturn_t da8xx_musb_interrupt(int irq, void *hci)
|
||||
|
||||
/* Poll for ID change */
|
||||
if (musb->xceiv->otg->state == OTG_STATE_B_IDLE)
|
||||
mod_timer(&otg_workaround, jiffies + POLL_SECONDS * HZ);
|
||||
mod_timer(&musb->dev_timer, jiffies + POLL_SECONDS * HZ);
|
||||
|
||||
spin_unlock_irqrestore(&musb->lock, flags);
|
||||
|
||||
@@ -390,7 +388,7 @@ static int da8xx_musb_init(struct musb *musb)
|
||||
goto fail;
|
||||
}
|
||||
|
||||
setup_timer(&otg_workaround, otg_timer, (unsigned long)musb);
|
||||
timer_setup(&musb->dev_timer, otg_timer, 0);
|
||||
|
||||
/* Reset the controller */
|
||||
musb_writel(reg_base, DA8XX_USB_CTRL_REG, DA8XX_SOFT_RESET_MASK);
|
||||
@@ -428,7 +426,7 @@ static int da8xx_musb_exit(struct musb *musb)
|
||||
{
|
||||
struct da8xx_glue *glue = dev_get_drvdata(musb->controller->parent);
|
||||
|
||||
del_timer_sync(&otg_workaround);
|
||||
del_timer_sync(&musb->dev_timer);
|
||||
|
||||
phy_power_off(glue->phy);
|
||||
phy_exit(glue->phy);
|
||||
|
Reference in New Issue
Block a user