summaryrefslogtreecommitdiff
path: root/recipes/linux/linux-omap-pm/fix-musb-oops.diff
blob: 788e7be5a80397e02ea3ec9e9fe027491195ca6e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
From patchwork Mon Jun 29 09:06:48 2009
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Subject: [v2] usb: musb: Warn and check for OTG transceiver misconfiguration
Date: Mon, 29 Jun 2009 09:06:48 -0000
From: Roger Quadros <ext-roger.quadros@nokia.com>
X-Patchwork-Id: 32914

Warn if OTG is selected in Kconfig but not initialized by platform code.
Add checks to prevent NULL pointer exception in case the
OTG transceiver has not been initialized. i.e. musb->xceiv == NULL

Signed-off-by: Roger Quadros <ext-roger.quadros@nokia.com>
Tested-by: Paul Walmsley <paul@pwsan.com>

---
drivers/usb/musb/musb_core.c |    7 ++++++-
 drivers/usb/musb/omap2430.c  |    3 ++-
 2 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/musb/musb_core.c b/drivers/usb/musb/musb_core.c
index 554a414..d0cfc22 100644
--- a/drivers/usb/musb/musb_core.c
+++ b/drivers/usb/musb/musb_core.c
@@ -1861,7 +1861,8 @@ static void musb_free(struct musb *musb)
 	}
 
 #ifdef CONFIG_USB_MUSB_OTG
-	put_device(musb->xceiv->dev);
+	if (musb->xceiv)
+		put_device(musb->xceiv->dev);
 #endif
 
 #ifdef CONFIG_USB_MUSB_HDRC_HCD
@@ -1958,6 +1959,10 @@ bad_config:
 	musb->isr = generic_interrupt;
 	status = musb_platform_init(musb);
 
+#ifdef CONFIG_USB_MUSB_OTG
+	if (!musb->xceiv)
+		WARN(1, "MUSB: OTG transceiver not set up correctly\n");
+#endif
 	if (status < 0)
 		goto fail;
 	if (!musb->isr) {
diff --git a/drivers/usb/musb/omap2430.c b/drivers/usb/musb/omap2430.c
index 3487520..8987d60 100644
--- a/drivers/usb/musb/omap2430.c
+++ b/drivers/usb/musb/omap2430.c
@@ -271,7 +271,8 @@ int musb_platform_suspend(struct musb *musb)
 	l |= ENABLEWAKEUP;	/* enable wakeup */
 	omap_writel(l, OTG_SYSCONFIG);
 
-	otg_set_suspend(musb->xceiv, 1);
+	if (musb->xceiv)
+		otg_set_suspend(musb->xceiv, 1);
 
 	if (musb->set_clock)
 		musb->set_clock(musb->clock, 0);