diff options
author | Roger Quadros <rogerq@ti.com> | 2012-11-26 09:56:26 -0500 |
---|---|---|
committer | Roger Quadros <rogerq@ti.com> | 2013-02-13 06:22:43 -0500 |
commit | 6675144668883a506f0c11db668b582bd5a3161d (patch) | |
tree | 2d206b4682c321b8e3135ec1e4ab0e7445e5094f /drivers/mfd/omap-usb-tll.c | |
parent | 7ed8619141198191d09f63fa6f172af361ad280d (diff) |
mfd: omap-usb-tll: serialize access to TLL device
Get rid of the unnecessary spin_lock_irqsave/restore() as there is
no interrupt handler for this driver. Instead we serialize access
to tll_dev using a global spinlock.
Signed-off-by: Roger Quadros <rogerq@ti.com>
Reviewed-by: Felipe Balbi <balbi@ti.com>
Diffstat (limited to 'drivers/mfd/omap-usb-tll.c')
-rw-r--r-- | drivers/mfd/omap-usb-tll.c | 53 |
1 files changed, 27 insertions, 26 deletions
diff --git a/drivers/mfd/omap-usb-tll.c b/drivers/mfd/omap-usb-tll.c index eccc65e97202..55c85c78ba44 100644 --- a/drivers/mfd/omap-usb-tll.c +++ b/drivers/mfd/omap-usb-tll.c | |||
@@ -103,14 +103,13 @@ struct usbtll_omap { | |||
103 | int nch; /* num. of channels */ | 103 | int nch; /* num. of channels */ |
104 | struct usbhs_omap_platform_data *pdata; | 104 | struct usbhs_omap_platform_data *pdata; |
105 | struct clk **ch_clk; | 105 | struct clk **ch_clk; |
106 | /* secure the register updates */ | ||
107 | spinlock_t lock; | ||
108 | }; | 106 | }; |
109 | 107 | ||
110 | /*-------------------------------------------------------------------------*/ | 108 | /*-------------------------------------------------------------------------*/ |
111 | 109 | ||
112 | static const char usbtll_driver_name[] = USBTLL_DRIVER_NAME; | 110 | static const char usbtll_driver_name[] = USBTLL_DRIVER_NAME; |
113 | static struct device *tll_dev; | 111 | static struct device *tll_dev; |
112 | static DEFINE_SPINLOCK(tll_lock); /* serialize access to tll_dev */ | ||
114 | 113 | ||
115 | /*-------------------------------------------------------------------------*/ | 114 | /*-------------------------------------------------------------------------*/ |
116 | 115 | ||
@@ -212,7 +211,6 @@ static int usbtll_omap_probe(struct platform_device *pdev) | |||
212 | struct resource *res; | 211 | struct resource *res; |
213 | struct usbtll_omap *tll; | 212 | struct usbtll_omap *tll; |
214 | unsigned reg; | 213 | unsigned reg; |
215 | unsigned long flags; | ||
216 | int ret = 0; | 214 | int ret = 0; |
217 | int i, ver; | 215 | int i, ver; |
218 | bool needs_tll; | 216 | bool needs_tll; |
@@ -230,8 +228,6 @@ static int usbtll_omap_probe(struct platform_device *pdev) | |||
230 | return -ENODEV; | 228 | return -ENODEV; |
231 | } | 229 | } |
232 | 230 | ||
233 | spin_lock_init(&tll->lock); | ||
234 | |||
235 | tll->pdata = pdata; | 231 | tll->pdata = pdata; |
236 | 232 | ||
237 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 233 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
@@ -246,8 +242,6 @@ static int usbtll_omap_probe(struct platform_device *pdev) | |||
246 | pm_runtime_enable(dev); | 242 | pm_runtime_enable(dev); |
247 | pm_runtime_get_sync(dev); | 243 | pm_runtime_get_sync(dev); |
248 | 244 | ||
249 | spin_lock_irqsave(&tll->lock, flags); | ||
250 | |||
251 | ver = usbtll_read(base, OMAP_USBTLL_REVISION); | 245 | ver = usbtll_read(base, OMAP_USBTLL_REVISION); |
252 | switch (ver) { | 246 | switch (ver) { |
253 | case OMAP_USBTLL_REV1: | 247 | case OMAP_USBTLL_REV1: |
@@ -265,8 +259,6 @@ static int usbtll_omap_probe(struct platform_device *pdev) | |||
265 | break; | 259 | break; |
266 | } | 260 | } |
267 | 261 | ||
268 | spin_unlock_irqrestore(&tll->lock, flags); | ||
269 | |||
270 | tll->ch_clk = devm_kzalloc(dev, sizeof(struct clk * [tll->nch]), | 262 | tll->ch_clk = devm_kzalloc(dev, sizeof(struct clk * [tll->nch]), |
271 | GFP_KERNEL); | 263 | GFP_KERNEL); |
272 | if (!tll->ch_clk) { | 264 | if (!tll->ch_clk) { |
@@ -286,8 +278,6 @@ static int usbtll_omap_probe(struct platform_device *pdev) | |||
286 | dev_dbg(dev, "can't get clock : %s\n", clkname); | 278 | dev_dbg(dev, "can't get clock : %s\n", clkname); |
287 | } | 279 | } |
288 | 280 | ||
289 | spin_lock_irqsave(&tll->lock, flags); | ||
290 | |||
291 | needs_tll = false; | 281 | needs_tll = false; |
292 | for (i = 0; i < tll->nch; i++) | 282 | for (i = 0; i < tll->nch; i++) |
293 | needs_tll |= omap_usb_mode_needs_tll(pdata->port_mode[i]); | 283 | needs_tll |= omap_usb_mode_needs_tll(pdata->port_mode[i]); |
@@ -332,10 +322,11 @@ static int usbtll_omap_probe(struct platform_device *pdev) | |||
332 | } | 322 | } |
333 | } | 323 | } |
334 | 324 | ||
335 | spin_unlock_irqrestore(&tll->lock, flags); | ||
336 | pm_runtime_put_sync(dev); | 325 | pm_runtime_put_sync(dev); |
337 | /* only after this can omap_tll_enable/disable work */ | 326 | /* only after this can omap_tll_enable/disable work */ |
327 | spin_lock(&tll_lock); | ||
338 | tll_dev = dev; | 328 | tll_dev = dev; |
329 | spin_unlock(&tll_lock); | ||
339 | 330 | ||
340 | return 0; | 331 | return 0; |
341 | 332 | ||
@@ -357,7 +348,9 @@ static int usbtll_omap_remove(struct platform_device *pdev) | |||
357 | struct usbtll_omap *tll = platform_get_drvdata(pdev); | 348 | struct usbtll_omap *tll = platform_get_drvdata(pdev); |
358 | int i; | 349 | int i; |
359 | 350 | ||
351 | spin_lock(&tll_lock); | ||
360 | tll_dev = NULL; | 352 | tll_dev = NULL; |
353 | spin_unlock(&tll_lock); | ||
361 | 354 | ||
362 | for (i = 0; i < tll->nch; i++) | 355 | for (i = 0; i < tll->nch; i++) |
363 | if (!IS_ERR(tll->ch_clk[i])) | 356 | if (!IS_ERR(tll->ch_clk[i])) |
@@ -371,13 +364,10 @@ static int usbtll_runtime_resume(struct device *dev) | |||
371 | { | 364 | { |
372 | struct usbtll_omap *tll = dev_get_drvdata(dev); | 365 | struct usbtll_omap *tll = dev_get_drvdata(dev); |
373 | struct usbhs_omap_platform_data *pdata = tll->pdata; | 366 | struct usbhs_omap_platform_data *pdata = tll->pdata; |
374 | unsigned long flags; | ||
375 | int i; | 367 | int i; |
376 | 368 | ||
377 | dev_dbg(dev, "usbtll_runtime_resume\n"); | 369 | dev_dbg(dev, "usbtll_runtime_resume\n"); |
378 | 370 | ||
379 | spin_lock_irqsave(&tll->lock, flags); | ||
380 | |||
381 | for (i = 0; i < tll->nch; i++) { | 371 | for (i = 0; i < tll->nch; i++) { |
382 | if (omap_usb_mode_needs_tll(pdata->port_mode[i])) { | 372 | if (omap_usb_mode_needs_tll(pdata->port_mode[i])) { |
383 | int r; | 373 | int r; |
@@ -393,8 +383,6 @@ static int usbtll_runtime_resume(struct device *dev) | |||
393 | } | 383 | } |
394 | } | 384 | } |
395 | 385 | ||
396 | spin_unlock_irqrestore(&tll->lock, flags); | ||
397 | |||
398 | return 0; | 386 | return 0; |
399 | } | 387 | } |
400 | 388 | ||
@@ -402,13 +390,10 @@ static int usbtll_runtime_suspend(struct device *dev) | |||
402 | { | 390 | { |
403 | struct usbtll_omap *tll = dev_get_drvdata(dev); | 391 | struct usbtll_omap *tll = dev_get_drvdata(dev); |
404 | struct usbhs_omap_platform_data *pdata = tll->pdata; | 392 | struct usbhs_omap_platform_data *pdata = tll->pdata; |
405 | unsigned long flags; | ||
406 | int i; | 393 | int i; |
407 | 394 | ||
408 | dev_dbg(dev, "usbtll_runtime_suspend\n"); | 395 | dev_dbg(dev, "usbtll_runtime_suspend\n"); |
409 | 396 | ||
410 | spin_lock_irqsave(&tll->lock, flags); | ||
411 | |||
412 | for (i = 0; i < tll->nch; i++) { | 397 | for (i = 0; i < tll->nch; i++) { |
413 | if (omap_usb_mode_needs_tll(pdata->port_mode[i])) { | 398 | if (omap_usb_mode_needs_tll(pdata->port_mode[i])) { |
414 | if (!IS_ERR(tll->ch_clk[i])) | 399 | if (!IS_ERR(tll->ch_clk[i])) |
@@ -416,8 +401,6 @@ static int usbtll_runtime_suspend(struct device *dev) | |||
416 | } | 401 | } |
417 | } | 402 | } |
418 | 403 | ||
419 | spin_unlock_irqrestore(&tll->lock, flags); | ||
420 | |||
421 | return 0; | 404 | return 0; |
422 | } | 405 | } |
423 | 406 | ||
@@ -439,21 +422,39 @@ static struct platform_driver usbtll_omap_driver = { | |||
439 | 422 | ||
440 | int omap_tll_enable(void) | 423 | int omap_tll_enable(void) |
441 | { | 424 | { |
425 | int ret; | ||
426 | |||
427 | spin_lock(&tll_lock); | ||
428 | |||
442 | if (!tll_dev) { | 429 | if (!tll_dev) { |
443 | pr_err("%s: OMAP USB TLL not initialized\n", __func__); | 430 | pr_err("%s: OMAP USB TLL not initialized\n", __func__); |
444 | return -ENODEV; | 431 | ret = -ENODEV; |
432 | } else { | ||
433 | ret = pm_runtime_get_sync(tll_dev); | ||
445 | } | 434 | } |
446 | return pm_runtime_get_sync(tll_dev); | 435 | |
436 | spin_unlock(&tll_lock); | ||
437 | |||
438 | return ret; | ||
447 | } | 439 | } |
448 | EXPORT_SYMBOL_GPL(omap_tll_enable); | 440 | EXPORT_SYMBOL_GPL(omap_tll_enable); |
449 | 441 | ||
450 | int omap_tll_disable(void) | 442 | int omap_tll_disable(void) |
451 | { | 443 | { |
444 | int ret; | ||
445 | |||
446 | spin_lock(&tll_lock); | ||
447 | |||
452 | if (!tll_dev) { | 448 | if (!tll_dev) { |
453 | pr_err("%s: OMAP USB TLL not initialized\n", __func__); | 449 | pr_err("%s: OMAP USB TLL not initialized\n", __func__); |
454 | return -ENODEV; | 450 | ret = -ENODEV; |
451 | } else { | ||
452 | ret = pm_runtime_put_sync(tll_dev); | ||
455 | } | 453 | } |
456 | return pm_runtime_put_sync(tll_dev); | 454 | |
455 | spin_unlock(&tll_lock); | ||
456 | |||
457 | return ret; | ||
457 | } | 458 | } |
458 | EXPORT_SYMBOL_GPL(omap_tll_disable); | 459 | EXPORT_SYMBOL_GPL(omap_tll_disable); |
459 | 460 | ||