aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/dwc3/gadget.c
diff options
context:
space:
mode:
authorSebastian Andrzej Siewior <bigeasy@linutronix.de>2011-08-29 10:46:38 -0400
committerFelipe Balbi <balbi@ti.com>2011-09-09 06:02:13 -0400
commit61d58242f634642de42d6a4098913b7254a65053 (patch)
treebf72c276a653ee677fa32514f241010239da4c9a /drivers/usb/dwc3/gadget.c
parent624407f96f134bcd3063eb0d404fc6d41323bef8 (diff)
usb: dwc3: gadget: replace mdelay with udelay in the busy loop
There are two spots where we wait until the HW finishes processing a certain command. Initially we had a few problems and we used 500ms as a limit to be on a the safe side. Paul Zimmerman mentioned this is little too much. After a debugging session, we noticed that we hardly ever go over 20us and didn't pass 30usec so far. Using mdelay() seems way overloaded. Giving the current numbers 500usec as the upper limit is more than enough. Should it ever timeout then something is definitely wrong. While here, also replace the type with u32 since long does not really fit here. Cc: Paul Zimmerman <paul.zimmerman@synopsys.com> Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de> Signed-off-by: Felipe Balbi <balbi@ti.com>
Diffstat (limited to 'drivers/usb/dwc3/gadget.c')
-rw-r--r--drivers/usb/dwc3/gadget.c12
1 files changed, 4 insertions, 8 deletions
diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c
index 7c014e9c1277..b5d95f8329f2 100644
--- a/drivers/usb/dwc3/gadget.c
+++ b/drivers/usb/dwc3/gadget.c
@@ -153,7 +153,7 @@ int dwc3_send_gadget_ep_cmd(struct dwc3 *dwc, unsigned ep,
153 unsigned cmd, struct dwc3_gadget_ep_cmd_params *params) 153 unsigned cmd, struct dwc3_gadget_ep_cmd_params *params)
154{ 154{
155 struct dwc3_ep *dep = dwc->eps[ep]; 155 struct dwc3_ep *dep = dwc->eps[ep];
156 unsigned long timeout = 500; 156 u32 timeout = 500;
157 u32 reg; 157 u32 reg;
158 158
159 dev_vdbg(dwc->dev, "%s: cmd '%s' params %08x %08x %08x\n", 159 dev_vdbg(dwc->dev, "%s: cmd '%s' params %08x %08x %08x\n",
@@ -175,7 +175,6 @@ int dwc3_send_gadget_ep_cmd(struct dwc3 *dwc, unsigned ep,
175 } 175 }
176 176
177 /* 177 /*
178 * XXX Figure out a sane timeout here. 500ms is way too much.
179 * We can't sleep here, because it is also called from 178 * We can't sleep here, because it is also called from
180 * interrupt context. 179 * interrupt context.
181 */ 180 */
@@ -183,7 +182,7 @@ int dwc3_send_gadget_ep_cmd(struct dwc3 *dwc, unsigned ep,
183 if (!timeout) 182 if (!timeout)
184 return -ETIMEDOUT; 183 return -ETIMEDOUT;
185 184
186 mdelay(1); 185 udelay(1);
187 } while (1); 186 } while (1);
188} 187}
189 188
@@ -1066,7 +1065,7 @@ static int dwc3_gadget_set_selfpowered(struct usb_gadget *g,
1066static void dwc3_gadget_run_stop(struct dwc3 *dwc, int is_on) 1065static void dwc3_gadget_run_stop(struct dwc3 *dwc, int is_on)
1067{ 1066{
1068 u32 reg; 1067 u32 reg;
1069 unsigned long timeout = 500; 1068 u32 timeout = 500;
1070 1069
1071 reg = dwc3_readl(dwc->regs, DWC3_DCTL); 1070 reg = dwc3_readl(dwc->regs, DWC3_DCTL);
1072 if (is_on) 1071 if (is_on)
@@ -1085,13 +1084,10 @@ static void dwc3_gadget_run_stop(struct dwc3 *dwc, int is_on)
1085 if (reg & DWC3_DSTS_DEVCTRLHLT) 1084 if (reg & DWC3_DSTS_DEVCTRLHLT)
1086 break; 1085 break;
1087 } 1086 }
1088 /*
1089 * XXX reduce the 500ms delay
1090 */
1091 timeout--; 1087 timeout--;
1092 if (!timeout) 1088 if (!timeout)
1093 break; 1089 break;
1094 mdelay(1); 1090 udelay(1);
1095 } while (1); 1091 } while (1);
1096 1092
1097 dev_vdbg(dwc->dev, "gadget %s data soft-%s\n", 1093 dev_vdbg(dwc->dev, "gadget %s data soft-%s\n",