diff options
author | Grazvydas Ignotas <notasas@gmail.com> | 2012-02-04 12:43:51 -0500 |
---|---|---|
committer | Felipe Balbi <balbi@ti.com> | 2012-04-10 12:11:43 -0400 |
commit | c04352a590538123f8c93bd87ef1d4bb9e3a64c7 (patch) | |
tree | b4c4b1881f1168e2e82b33fe8af357fed5085392 /drivers/usb | |
parent | afb76df140823c57738598a876cd1d6568cd57c7 (diff) |
usb: musb: fix some runtime_pm issues
When runtime_pm was originally added, it was done in rather confusing
way: omap2430_musb_init() (called from musb_init_controller) would do
runtime_pm_get_sync() and musb_init_controller() itself would do
runtime_pm_put to balance it out. This is not only confusing but also
wrong if non-omap2430 glue layer is used.
This confusion resulted in commit 772aed45b604 "usb: musb: fix
pm_runtime mismatch", that removed runtime_pm_put() from
musb_init_controller as that looked unbalanced, and also happened to
fix unrelated isp1704_charger crash. However this broke runtime PM
functionality (musb is now always powered, even without gadget active).
Avoid these confusing runtime pm dependences by making
musb_init_controller() and omap2430_musb_init() do their own runtime
get/put pairs; also cover error paths. Remove unneeded runtime_pm_put
in omap2430_remove too. isp1704_charger crash that motivated
772aed45b604 will be fixed by following patch.
Cc: Felipe Contreras <felipe.contreras@gmail.com>
Signed-off-by: Grazvydas Ignotas <notasas@gmail.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
Diffstat (limited to 'drivers/usb')
-rw-r--r-- | drivers/usb/musb/musb_core.c | 9 | ||||
-rw-r--r-- | drivers/usb/musb/omap2430.c | 2 |
2 files changed, 9 insertions, 2 deletions
diff --git a/drivers/usb/musb/musb_core.c b/drivers/usb/musb/musb_core.c index 0f8b82918a40..239214626ec5 100644 --- a/drivers/usb/musb/musb_core.c +++ b/drivers/usb/musb/musb_core.c | |||
@@ -1904,7 +1904,7 @@ musb_init_controller(struct device *dev, int nIrq, void __iomem *ctrl) | |||
1904 | 1904 | ||
1905 | if (!musb->isr) { | 1905 | if (!musb->isr) { |
1906 | status = -ENODEV; | 1906 | status = -ENODEV; |
1907 | goto fail3; | 1907 | goto fail2; |
1908 | } | 1908 | } |
1909 | 1909 | ||
1910 | if (!musb->xceiv->io_ops) { | 1910 | if (!musb->xceiv->io_ops) { |
@@ -1912,6 +1912,8 @@ musb_init_controller(struct device *dev, int nIrq, void __iomem *ctrl) | |||
1912 | musb->xceiv->io_ops = &musb_ulpi_access; | 1912 | musb->xceiv->io_ops = &musb_ulpi_access; |
1913 | } | 1913 | } |
1914 | 1914 | ||
1915 | pm_runtime_get_sync(musb->controller); | ||
1916 | |||
1915 | #ifndef CONFIG_MUSB_PIO_ONLY | 1917 | #ifndef CONFIG_MUSB_PIO_ONLY |
1916 | if (use_dma && dev->dma_mask) { | 1918 | if (use_dma && dev->dma_mask) { |
1917 | struct dma_controller *c; | 1919 | struct dma_controller *c; |
@@ -2023,6 +2025,8 @@ musb_init_controller(struct device *dev, int nIrq, void __iomem *ctrl) | |||
2023 | goto fail5; | 2025 | goto fail5; |
2024 | #endif | 2026 | #endif |
2025 | 2027 | ||
2028 | pm_runtime_put(musb->controller); | ||
2029 | |||
2026 | dev_info(dev, "USB %s mode controller at %p using %s, IRQ %d\n", | 2030 | dev_info(dev, "USB %s mode controller at %p using %s, IRQ %d\n", |
2027 | ({char *s; | 2031 | ({char *s; |
2028 | switch (musb->board_mode) { | 2032 | switch (musb->board_mode) { |
@@ -2047,6 +2051,9 @@ fail4: | |||
2047 | musb_gadget_cleanup(musb); | 2051 | musb_gadget_cleanup(musb); |
2048 | 2052 | ||
2049 | fail3: | 2053 | fail3: |
2054 | pm_runtime_put_sync(musb->controller); | ||
2055 | |||
2056 | fail2: | ||
2050 | if (musb->irq_wake) | 2057 | if (musb->irq_wake) |
2051 | device_init_wakeup(dev, 0); | 2058 | device_init_wakeup(dev, 0); |
2052 | musb_platform_exit(musb); | 2059 | musb_platform_exit(musb); |
diff --git a/drivers/usb/musb/omap2430.c b/drivers/usb/musb/omap2430.c index 11b571ec22f2..3dfd122266f4 100644 --- a/drivers/usb/musb/omap2430.c +++ b/drivers/usb/musb/omap2430.c | |||
@@ -333,6 +333,7 @@ static int omap2430_musb_init(struct musb *musb) | |||
333 | 333 | ||
334 | setup_timer(&musb_idle_timer, musb_do_idle, (unsigned long) musb); | 334 | setup_timer(&musb_idle_timer, musb_do_idle, (unsigned long) musb); |
335 | 335 | ||
336 | pm_runtime_put_noidle(musb->controller); | ||
336 | return 0; | 337 | return 0; |
337 | 338 | ||
338 | err1: | 339 | err1: |
@@ -478,7 +479,6 @@ static int __devexit omap2430_remove(struct platform_device *pdev) | |||
478 | 479 | ||
479 | platform_device_del(glue->musb); | 480 | platform_device_del(glue->musb); |
480 | platform_device_put(glue->musb); | 481 | platform_device_put(glue->musb); |
481 | pm_runtime_put(&pdev->dev); | ||
482 | kfree(glue); | 482 | kfree(glue); |
483 | 483 | ||
484 | return 0; | 484 | return 0; |