ChangeSet 1.1729, 2004/05/17 11:13:32-07:00, david-b@pacbell.net [PATCH] USB: fix MSEC_TO_JIFFIES in usb code Here are some MSEC_TO_JIFFIES() fixes missed by whoever did it, plus a minor fix to grab root_hub->serialize() during OHCI suspend. (I forgot to cut/paste those lines from resume.) drivers/usb/host/ehci-hcd.c | 2 +- drivers/usb/host/ehci-hub.c | 10 +++++----- drivers/usb/host/ehci.h | 6 ++---- drivers/usb/host/ohci-hub.c | 4 ++-- drivers/usb/host/ohci-pci.c | 3 ++- drivers/usb/host/ohci.h | 6 ++---- 6 files changed, 14 insertions(+), 17 deletions(-) diff -Nru a/drivers/usb/host/ehci-hcd.c b/drivers/usb/host/ehci-hcd.c --- a/drivers/usb/host/ehci-hcd.c Mon May 17 16:37:51 2004 +++ b/drivers/usb/host/ehci-hcd.c Mon May 17 16:37:51 2004 @@ -769,7 +769,7 @@ * and make khubd collect PORT_STAT_C_SUSPEND to * stop that signaling. */ - ehci->reset_done [i] = jiffies + MSEC_TO_JIFFIES (20); + ehci->reset_done [i] = jiffies + msecs_to_jiffies (20); mod_timer (&ehci->hcd.rh_timer, ehci->reset_done [i] + 1); ehci_dbg (ehci, "port %d remote wakeup\n", i + 1); diff -Nru a/drivers/usb/host/ehci-hub.c b/drivers/usb/host/ehci-hub.c --- a/drivers/usb/host/ehci-hub.c Mon May 17 16:37:51 2004 +++ b/drivers/usb/host/ehci-hub.c Mon May 17 16:37:51 2004 @@ -75,7 +75,7 @@ (void) handshake (&ehci->regs->status, STS_HALT, STS_HALT, 2000); root->dev.power.power_state = 3; - ehci->next_statechange = jiffies + MSEC_TO_JIFFIES(10); + ehci->next_statechange = jiffies + msecs_to_jiffies(10); spin_unlock_irq (&ehci->lock); return status; } @@ -112,7 +112,7 @@ temp = readl (&ehci->regs->port_status [i]); temp &= ~(PORT_WKOC_E|PORT_WKDISC_E|PORT_WKCONN_E); if (temp & PORT_SUSPEND) { - ehci->reset_done [i] = jiffies + MSEC_TO_JIFFIES (20); + ehci->reset_done [i] = jiffies + msecs_to_jiffies (20); temp |= PORT_RESUME; } writel (temp, &ehci->regs->port_status [i]); @@ -139,7 +139,7 @@ writel (ehci->command | temp, &ehci->regs->command); root->dev.power.power_state = 0; - ehci->next_statechange = jiffies + MSEC_TO_JIFFIES(5); + ehci->next_statechange = jiffies + msecs_to_jiffies(5); ehci->hcd.state = USB_STATE_RUNNING; return 0; } @@ -334,7 +334,7 @@ writel ((temp & ~PORT_WAKE_BITS) | PORT_RESUME, &ehci->regs->port_status [wIndex]); ehci->reset_done [wIndex] = jiffies - + MSEC_TO_JIFFIES (20); + + msecs_to_jiffies (20); } break; case USB_PORT_FEAT_C_SUSPEND: @@ -514,7 +514,7 @@ * usb 2.0 spec says 50 ms resets on root */ ehci->reset_done [wIndex] = jiffies - + MSEC_TO_JIFFIES (50); + + msecs_to_jiffies (50); } writel (temp, &ehci->regs->port_status [wIndex]); break; diff -Nru a/drivers/usb/host/ehci.h b/drivers/usb/host/ehci.h --- a/drivers/usb/host/ehci.h Mon May 17 16:37:51 2004 +++ b/drivers/usb/host/ehci.h Mon May 17 16:37:51 2004 @@ -596,12 +596,10 @@ /*-------------------------------------------------------------------------*/ -#define MSEC_TO_JIFFIES(msec) ((HZ * (msec) + 999) / 1000) - -static inline void msec_delay(int msec) +static inline void msec_delay(unsigned msec) { set_current_state(TASK_UNINTERRUPTIBLE); - schedule_timeout(MSEC_TO_JIFFIES(msec)); + schedule_timeout(msecs_to_jiffies(msec)); } #ifndef DEBUG diff -Nru a/drivers/usb/host/ohci-hub.c b/drivers/usb/host/ohci-hub.c --- a/drivers/usb/host/ohci-hub.c Mon May 17 16:37:51 2004 +++ b/drivers/usb/host/ohci-hub.c Mon May 17 16:37:51 2004 @@ -143,7 +143,7 @@ (void) readl (&ohci->regs->control); /* no resumes until devices finish suspending */ - ohci->next_statechange = jiffies + MSEC_TO_JIFFIES (5); + ohci->next_statechange = jiffies + msecs_to_jiffies (5); succeed: /* it's not USB_STATE_SUSPENDED unless access to this @@ -262,7 +262,7 @@ root->dev.power.power_state = 0; /* keep it alive for ~5x suspend + resume costs */ - ohci->next_statechange = jiffies + MSEC_TO_JIFFIES (250); + ohci->next_statechange = jiffies + msecs_to_jiffies (250); /* maybe turn schedules back on */ enables = 0; diff -Nru a/drivers/usb/host/ohci-pci.c b/drivers/usb/host/ohci-pci.c --- a/drivers/usb/host/ohci-pci.c Mon May 17 16:37:51 2004 +++ b/drivers/usb/host/ohci-pci.c Mon May 17 16:37:51 2004 @@ -127,8 +127,9 @@ #ifdef CONFIG_USB_SUSPEND (void) usb_suspend_device (hcd->self.root_hub); #else - /* FIXME lock root hub */ + down (&hcd->self.root_hub->serialize); (void) ohci_hub_suspend (hcd); + up (&hcd->self.root_hub->serialize); #endif /* let things settle down a bit */ diff -Nru a/drivers/usb/host/ohci.h b/drivers/usb/host/ohci.h --- a/drivers/usb/host/ohci.h Mon May 17 16:37:51 2004 +++ b/drivers/usb/host/ohci.h Mon May 17 16:37:51 2004 @@ -397,12 +397,10 @@ ohci->hcd.state = USB_STATE_HALT; } -#define MSEC_TO_JIFFIES(msec) ((HZ * (msec) + 999) / 1000) - -static inline void msec_delay(int msec) +static inline void msec_delay(unsigned msec) { set_current_state(TASK_UNINTERRUPTIBLE); - schedule_timeout(MSEC_TO_JIFFIES(msec)); + schedule_timeout(msecs_to_jiffies(msec)); } #define FI 0x2edf /* 12000 bits per frame (-1) */