From fd7b635db5f127daa6914307b8a84efb9c51d52e Mon Sep 17 00:00:00 2001 From: David Brownell Date: Sun, 16 May 2004 21:13:32 -0700 Subject: [PATCH] [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 --git a/drivers/usb/host/ehci-hcd.c b/drivers/usb/host/ehci-hcd.c index 24efaae7e2e66..d902511717015 100644 --- a/drivers/usb/host/ehci-hcd.c +++ b/drivers/usb/host/ehci-hcd.c @@ -769,7 +769,7 @@ static irqreturn_t ehci_irq (struct usb_hcd *hcd, struct pt_regs *regs) * 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 --git a/drivers/usb/host/ehci-hub.c b/drivers/usb/host/ehci-hub.c index 35f06f8a42206..c424bcab7c907 100644 --- a/drivers/usb/host/ehci-hub.c +++ b/drivers/usb/host/ehci-hub.c @@ -75,7 +75,7 @@ static int ehci_hub_suspend (struct usb_hcd *hcd) (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 @@ static int ehci_hub_resume (struct usb_hcd *hcd) 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 @@ static int ehci_hub_resume (struct usb_hcd *hcd) 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 @@ static int ehci_hub_control ( 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 @@ static int ehci_hub_control ( * 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 --git a/drivers/usb/host/ehci.h b/drivers/usb/host/ehci.h index affcebdfd7b69..d2debae2bc7ed 100644 --- a/drivers/usb/host/ehci.h +++ b/drivers/usb/host/ehci.h @@ -596,12 +596,10 @@ ehci_port_speed(struct ehci_hcd *ehci, unsigned int portsc) /*-------------------------------------------------------------------------*/ -#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 --git a/drivers/usb/host/ohci-hub.c b/drivers/usb/host/ohci-hub.c index d15f50c823bfa..ef2015f94c6b3 100644 --- a/drivers/usb/host/ohci-hub.c +++ b/drivers/usb/host/ohci-hub.c @@ -143,7 +143,7 @@ static int ohci_hub_suspend (struct usb_hcd *hcd) (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 @@ static int ohci_hub_resume (struct usb_hcd *hcd) 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 --git a/drivers/usb/host/ohci-pci.c b/drivers/usb/host/ohci-pci.c index 474564f1a714a..f69036014ff5b 100644 --- a/drivers/usb/host/ohci-pci.c +++ b/drivers/usb/host/ohci-pci.c @@ -127,8 +127,9 @@ static int ohci_pci_suspend (struct usb_hcd *hcd, u32 state) #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 --git a/drivers/usb/host/ohci.h b/drivers/usb/host/ohci.h index 878b032f068cd..10166f9f8e85f 100644 --- a/drivers/usb/host/ohci.h +++ b/drivers/usb/host/ohci.h @@ -397,12 +397,10 @@ static inline void disable (struct ohci_hcd *ohci) 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) */ -- 2.53.0