usb: musb: Fix broken use of static variable for multiple instances

We can't use static variable first for checking when musb is
initialized when we have multiple musb instances like on am335x.

Tested-by: Ladislav Michl <ladis@linux-mips.org>
Reviewed-by: Johan Hovold <johan@hovoldconsulting.com>
Tested-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Tony Lindgren <tony@atomide.com>
Signed-off-by: Bin Liu <b-liu@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
Tony Lindgren 2016-11-16 13:21:22 -06:00 committed by Greg Kroah-Hartman
parent a5d906bb26
commit c723bd6ec2
2 changed files with 7 additions and 4 deletions

View File

@ -2291,6 +2291,7 @@ musb_init_controller(struct device *dev, int nIrq, void __iomem *ctrl)
if (status) if (status)
goto fail5; goto fail5;
musb->is_initialized = 1;
pm_runtime_mark_last_busy(musb->controller); pm_runtime_mark_last_busy(musb->controller);
pm_runtime_put_autosuspend(musb->controller); pm_runtime_put_autosuspend(musb->controller);
@ -2629,7 +2630,6 @@ static int musb_runtime_suspend(struct device *dev)
static int musb_runtime_resume(struct device *dev) static int musb_runtime_resume(struct device *dev)
{ {
struct musb *musb = dev_to_musb(dev); struct musb *musb = dev_to_musb(dev);
static int first = 1;
/* /*
* When pm_runtime_get_sync called for the first time in driver * When pm_runtime_get_sync called for the first time in driver
@ -2640,9 +2640,10 @@ static int musb_runtime_resume(struct device *dev)
* Also context restore without save does not make * Also context restore without save does not make
* any sense * any sense
*/ */
if (!first) if (!musb->is_initialized)
musb_restore_context(musb); return 0;
first = 0;
musb_restore_context(musb);
if (musb->need_finish_resume) { if (musb->need_finish_resume) {
musb->need_finish_resume = 0; musb->need_finish_resume = 0;

View File

@ -385,6 +385,8 @@ struct musb {
int a_wait_bcon; /* VBUS timeout in msecs */ int a_wait_bcon; /* VBUS timeout in msecs */
unsigned long idle_timeout; /* Next timeout in jiffies */ unsigned long idle_timeout; /* Next timeout in jiffies */
unsigned is_initialized:1;
/* active means connected and not suspended */ /* active means connected and not suspended */
unsigned is_active:1; unsigned is_active:1;