All of lore.kernel.org
 help / color / mirror / Atom feed
From: Romain Perier <romain.perier@gmail.com>
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	[thread overview]
Message-ID: <1423158439-1639-1-git-send-email-romain.perier@gmail.com> (raw)

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 <romain.perier@gmail.com>
---
 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


             reply	other threads:[~2015-02-05 17:47 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-02-05 17:47 Romain Perier [this message]
2015-02-05 18:04 ` [PATCH] usb: dwc2: Register interrupt handler only once gadget is correctly initialized Sergei Shtylyov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1423158439-1639-1-git-send-email-romain.perier@gmail.com \
    --to=romain.perier@gmail.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=johnyoun@synopsys.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-rockchip@lists.infradead.org \
    --cc=linux-usb@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.