Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753531AbbBERrY (ORCPT ); Thu, 5 Feb 2015 12:47:24 -0500 Received: from mail-wg0-f43.google.com ([74.125.82.43]:62740 "EHLO mail-wg0-f43.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752476AbbBERrX (ORCPT ); Thu, 5 Feb 2015 12:47:23 -0500 From: Romain Perier To: johnyoun@synopsys.com Cc: gregkh@linuxfoundation.org, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, linux-rockchip@lists.infradead.org Subject: [PATCH] usb: dwc2: Register interrupt handler only once gadget is correctly initialized Date: Thu, 5 Feb 2015 17:47:19 +0000 Message-Id: <1423158439-1639-1-git-send-email-romain.perier@gmail.com> X-Mailer: git-send-email 1.9.1 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2022 Lines: 55 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. Signed-off-by: Romain Perier --- drivers/usb/dwc2/platform.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/drivers/usb/dwc2/platform.c b/drivers/usb/dwc2/platform.c index ae095f0..b26cf8c 100644 --- a/drivers/usb/dwc2/platform.c +++ b/drivers/usb/dwc2/platform.c @@ -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; -- 1.9.1 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/