aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/renesas_usbhs
diff options
context:
space:
mode:
authorKuninori Morimoto <kuninori.morimoto.gx@renesas.com>2011-10-31 03:48:35 -0400
committerFelipe Balbi <balbi@ti.com>2011-12-12 04:45:07 -0500
commitd399f90d192f4cbda2527d42d054d090e327a9a0 (patch)
treee685a303dfaa3ab85a0bb68ab5b58d5a891ea6c6 /drivers/usb/renesas_usbhs
parentab14230854aba9d0c99b3cd0e4bb1ef430973d84 (diff)
usb: gadget: renesas_usbhs: adds spin lock area on mod_host
spin lock was needed in mod_host. Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> Signed-off-by: Felipe Balbi <balbi@ti.com>
Diffstat (limited to 'drivers/usb/renesas_usbhs')
-rw-r--r--drivers/usb/renesas_usbhs/mod_host.c67
1 files changed, 49 insertions, 18 deletions
diff --git a/drivers/usb/renesas_usbhs/mod_host.c b/drivers/usb/renesas_usbhs/mod_host.c
index e6fd044adfa3..1816a3e11b78 100644
--- a/drivers/usb/renesas_usbhs/mod_host.c
+++ b/drivers/usb/renesas_usbhs/mod_host.c
@@ -228,9 +228,13 @@ static struct usbhsh_device *usbhsh_device_alloc(struct usbhsh_hpriv *hpriv,
228 struct device *dev = usbhsh_hcd_to_dev(hcd); 228 struct device *dev = usbhsh_hcd_to_dev(hcd);
229 struct usb_device *usbv = usbhsh_urb_to_usbv(urb); 229 struct usb_device *usbv = usbhsh_urb_to_usbv(urb);
230 struct usbhs_priv *priv = usbhsh_hpriv_to_priv(hpriv); 230 struct usbhs_priv *priv = usbhsh_hpriv_to_priv(hpriv);
231 unsigned long flags;
231 u16 upphub, hubport; 232 u16 upphub, hubport;
232 int i; 233 int i;
233 234
235 /******************** spin lock ********************/
236 usbhs_lock(priv, flags);
237
234 /* 238 /*
235 * find device 239 * find device
236 */ 240 */
@@ -255,6 +259,19 @@ static struct usbhsh_device *usbhsh_device_alloc(struct usbhsh_hpriv *hpriv,
255 } 259 }
256 } 260 }
257 261
262 if (udev) {
263 /*
264 * usbhsh_usbv_to_udev()
265 * usbhsh_udev_to_usbv()
266 * will be enable
267 */
268 dev_set_drvdata(&usbv->dev, udev);
269 udev->usbv = usbv;
270 }
271
272 usbhs_unlock(priv, flags);
273 /******************** spin unlock ******************/
274
258 if (!udev) { 275 if (!udev) {
259 dev_err(dev, "no free usbhsh_device\n"); 276 dev_err(dev, "no free usbhsh_device\n");
260 return NULL; 277 return NULL;
@@ -266,14 +283,6 @@ static struct usbhsh_device *usbhsh_device_alloc(struct usbhsh_hpriv *hpriv,
266 /* uep will be attached */ 283 /* uep will be attached */
267 INIT_LIST_HEAD(&udev->ep_list_head); 284 INIT_LIST_HEAD(&udev->ep_list_head);
268 285
269 /*
270 * usbhsh_usbv_to_udev()
271 * usbhsh_udev_to_usbv()
272 * will be enable
273 */
274 dev_set_drvdata(&usbv->dev, udev);
275 udev->usbv = usbv;
276
277 upphub = 0; 286 upphub = 0;
278 hubport = 0; 287 hubport = 0;
279 if (!usbhsh_connected_to_rhdev(hcd, udev)) { 288 if (!usbhsh_connected_to_rhdev(hcd, udev)) {
@@ -302,8 +311,10 @@ static void usbhsh_device_free(struct usbhsh_hpriv *hpriv,
302 struct usbhsh_device *udev) 311 struct usbhsh_device *udev)
303{ 312{
304 struct usb_hcd *hcd = usbhsh_hpriv_to_hcd(hpriv); 313 struct usb_hcd *hcd = usbhsh_hpriv_to_hcd(hpriv);
314 struct usbhs_priv *priv = usbhsh_hpriv_to_priv(hpriv);
305 struct device *dev = usbhsh_hcd_to_dev(hcd); 315 struct device *dev = usbhsh_hcd_to_dev(hcd);
306 struct usb_device *usbv = usbhsh_udev_to_usbv(udev); 316 struct usb_device *usbv = usbhsh_udev_to_usbv(udev);
317 unsigned long flags;
307 318
308 dev_dbg(dev, "%s [%d](%p)\n", __func__, 319 dev_dbg(dev, "%s [%d](%p)\n", __func__,
309 usbhsh_device_number(hpriv, udev), udev); 320 usbhsh_device_number(hpriv, udev), udev);
@@ -311,6 +322,9 @@ static void usbhsh_device_free(struct usbhsh_hpriv *hpriv,
311 if (usbhsh_device_has_endpoint(udev)) 322 if (usbhsh_device_has_endpoint(udev))
312 dev_warn(dev, "udev still have endpoint\n"); 323 dev_warn(dev, "udev still have endpoint\n");
313 324
325 /******************** spin lock ********************/
326 usbhs_lock(priv, flags);
327
314 /* 328 /*
315 * usbhsh_usbv_to_udev() 329 * usbhsh_usbv_to_udev()
316 * usbhsh_udev_to_usbv() 330 * usbhsh_udev_to_usbv()
@@ -318,6 +332,9 @@ static void usbhsh_device_free(struct usbhsh_hpriv *hpriv,
318 */ 332 */
319 dev_set_drvdata(&usbv->dev, NULL); 333 dev_set_drvdata(&usbv->dev, NULL);
320 udev->usbv = NULL; 334 udev->usbv = NULL;
335
336 usbhs_unlock(priv, flags);
337 /******************** spin unlock ******************/
321} 338}
322 339
323/* 340/*
@@ -338,6 +355,7 @@ struct usbhsh_ep *usbhsh_endpoint_alloc(struct usbhsh_hpriv *hpriv,
338 struct usb_endpoint_descriptor *desc = &ep->desc; 355 struct usb_endpoint_descriptor *desc = &ep->desc;
339 int type, i, dir_in; 356 int type, i, dir_in;
340 unsigned int min_usr; 357 unsigned int min_usr;
358 unsigned long flags;
341 359
342 dir_in_req = !!dir_in_req; 360 dir_in_req = !!dir_in_req;
343 361
@@ -352,6 +370,9 @@ struct usbhsh_ep *usbhsh_endpoint_alloc(struct usbhsh_hpriv *hpriv,
352 goto usbhsh_endpoint_alloc_find_pipe; 370 goto usbhsh_endpoint_alloc_find_pipe;
353 } 371 }
354 372
373 /******************** spin lock ********************/
374 usbhs_lock(priv, flags);
375
355 /* 376 /*
356 * find best pipe for endpoint 377 * find best pipe for endpoint
357 * see 378 * see
@@ -376,6 +397,19 @@ struct usbhsh_ep *usbhsh_endpoint_alloc(struct usbhsh_hpriv *hpriv,
376 } 397 }
377 } 398 }
378 399
400 if (best_pipe) {
401 /* update pipe user count */
402 info = usbhsh_pipe_info(best_pipe);
403 info->usr_cnt++;
404
405 /* init this endpoint, and attach it to udev */
406 INIT_LIST_HEAD(&uep->ep_list);
407 list_add_tail(&uep->ep_list, &udev->ep_list_head);
408 }
409
410 usbhs_unlock(priv, flags);
411 /******************** spin unlock ******************/
412
379 if (unlikely(!best_pipe)) { 413 if (unlikely(!best_pipe)) {
380 dev_err(dev, "couldn't find best pipe\n"); 414 dev_err(dev, "couldn't find best pipe\n");
381 kfree(uep); 415 kfree(uep);
@@ -391,16 +425,6 @@ usbhsh_endpoint_alloc_find_pipe:
391 usbhsh_ep_to_uep(ep) = uep; 425 usbhsh_ep_to_uep(ep) = uep;
392 426
393 /* 427 /*
394 * update pipe user count
395 */
396 info = usbhsh_pipe_info(best_pipe);
397 info->usr_cnt++;
398
399 /* init this endpoint, and attach it to udev */
400 INIT_LIST_HEAD(&uep->ep_list);
401 list_add_tail(&uep->ep_list, &udev->ep_list_head);
402
403 /*
404 * usbhs_pipe_config_update() should be called after 428 * usbhs_pipe_config_update() should be called after
405 * usbhs_set_device_config() 429 * usbhs_set_device_config()
406 * see 430 * see
@@ -426,6 +450,7 @@ void usbhsh_endpoint_free(struct usbhsh_hpriv *hpriv,
426 struct device *dev = usbhs_priv_to_dev(priv); 450 struct device *dev = usbhs_priv_to_dev(priv);
427 struct usbhsh_ep *uep = usbhsh_ep_to_uep(ep); 451 struct usbhsh_ep *uep = usbhsh_ep_to_uep(ep);
428 struct usbhsh_pipe_info *info; 452 struct usbhsh_pipe_info *info;
453 unsigned long flags;
429 454
430 if (!uep) 455 if (!uep)
431 return; 456 return;
@@ -434,6 +459,9 @@ void usbhsh_endpoint_free(struct usbhsh_hpriv *hpriv,
434 usbhsh_device_number(hpriv, usbhsh_uep_to_udev(uep)), 459 usbhsh_device_number(hpriv, usbhsh_uep_to_udev(uep)),
435 usbhs_pipe_name(uep->pipe), uep); 460 usbhs_pipe_name(uep->pipe), uep);
436 461
462 /******************** spin lock ********************/
463 usbhs_lock(priv, flags);
464
437 info = usbhsh_pipe_info(uep->pipe); 465 info = usbhsh_pipe_info(uep->pipe);
438 info->usr_cnt--; 466 info->usr_cnt--;
439 467
@@ -443,6 +471,9 @@ void usbhsh_endpoint_free(struct usbhsh_hpriv *hpriv,
443 usbhsh_uep_to_udev(uep) = NULL; 471 usbhsh_uep_to_udev(uep) = NULL;
444 usbhsh_ep_to_uep(ep) = NULL; 472 usbhsh_ep_to_uep(ep) = NULL;
445 473
474 usbhs_unlock(priv, flags);
475 /******************** spin unlock ******************/
476
446 kfree(uep); 477 kfree(uep);
447} 478}
448 479