Skip to contentSkip to conversation

usb: dwc2: Register interrupt handler only once gadget is correctly initialized

PATCH Superseded Romain Perier 2 participants 2 messages Feb 5, 2015

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 usb: dwc2: Register interrupt handler only once gadget is correctly initialized

Don't register interrupt handler becore usb gadget is correctly initialized. For some embedded platforms which don't have a usb-phy it crashes the driver because an interrupt is emitted with non-initiliazed hardware. According to devm_request_irq documentation, an interrupt can be emitted at any time once the interrupt is registered, so we have to care about driver and hardware initialization.

---
 drivers/usb/dwc2/platform.c | 17 +++++++++--------
 1 file changed, 9 insertions(+), 8 deletions(-)
drivers/usb/dwc2/platform.c +9 -8
index ae095f0..b26cf8c 100644
@@ -196,14 +196,6 @@ static int dwc2_driver_probe(struct platform_device *dev)
 		return irq;
 	}
 
-	dev_dbg(hsotg->dev, "registering common handler for irq%d\n",
-		irq);
-	retval = devm_request_irq(hsotg->dev, irq,
-				  dwc2_handle_common_intr, IRQF_SHARED,
-				  dev_name(hsotg->dev), hsotg);
-	if (retval)
-		return retval;
-
 	res = platform_get_resource(dev, IORESOURCE_MEM, 0);
 	hsotg->regs = devm_ioremap_resource(&dev->dev, res);
 	if (IS_ERR(hsotg->regs))
@@ -237,6 +229,15 @@ static int dwc2_driver_probe(struct platform_device *dev)
 	retval = dwc2_gadget_init(hsotg, irq);
 	if (retval)
 		return retval;
+
+        dev_dbg(hsotg->dev, "registering common handler for irq%d\n",
+                irq);
+        retval = devm_request_irq(hsotg->dev, irq,
+                                dwc2_handle_common_intr, IRQF_SHARED,
+                                dev_name(hsotg->dev), hsotg);
+        if (retval)
+                return retval;
+
 	retval = dwc2_hcd_init(hsotg, irq, params);
 	if (retval)
 		return retval;
Signature · 1 line
1.9.1
#1 lore raw

Hello.

Quoted 1 line · Romain Perier

Don't register interrupt handler becore usb gadget is correctly initialized.

s/becore/before/?

Quoted 2 lines

For some embedded platforms which don't have a usb-phy it crashes the driver because an interrupt is emitted with non-initiliazed hardware.

s/non-initiliazed/non-initialized/.

Quoted 5 lines

According to devm_request_irq documentation, an interrupt can be emitted at any time once the interrupt is registered, so we have to care about driver and hardware initialization.

[...]

WBR, Sergei