Skip to content

Commit c723bd6

Browse files
tmlindgregkh
authored andcommitted
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>
1 parent a5d906b commit c723bd6

2 files changed

Lines changed: 7 additions & 4 deletions

File tree

drivers/usb/musb/musb_core.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2291,6 +2291,7 @@ musb_init_controller(struct device *dev, int nIrq, void __iomem *ctrl)
22912291
if (status)
22922292
goto fail5;
22932293

2294+
musb->is_initialized = 1;
22942295
pm_runtime_mark_last_busy(musb->controller);
22952296
pm_runtime_put_autosuspend(musb->controller);
22962297

@@ -2629,7 +2630,6 @@ static int musb_runtime_suspend(struct device *dev)
26292630
static int musb_runtime_resume(struct device *dev)
26302631
{
26312632
struct musb *musb = dev_to_musb(dev);
2632-
static int first = 1;
26332633

26342634
/*
26352635
* When pm_runtime_get_sync called for the first time in driver
@@ -2640,9 +2640,10 @@ static int musb_runtime_resume(struct device *dev)
26402640
* Also context restore without save does not make
26412641
* any sense
26422642
*/
2643-
if (!first)
2644-
musb_restore_context(musb);
2645-
first = 0;
2643+
if (!musb->is_initialized)
2644+
return 0;
2645+
2646+
musb_restore_context(musb);
26462647

26472648
if (musb->need_finish_resume) {
26482649
musb->need_finish_resume = 0;

drivers/usb/musb/musb_core.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -385,6 +385,8 @@ struct musb {
385385
int a_wait_bcon; /* VBUS timeout in msecs */
386386
unsigned long idle_timeout; /* Next timeout in jiffies */
387387

388+
unsigned is_initialized:1;
389+
388390
/* active means connected and not suspended */
389391
unsigned is_active:1;
390392

0 commit comments

Comments
 (0)