linux-arm-msm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Ivan T. Ivanov" <ivan.ivanov@linaro.org>
To: Felipe Balbi <balbi@ti.com>, Tim Bird <tim.bird@sonymobile.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-arm-msm@vger.kernel.org
Subject: [PATCH v2] usb: phy: msm: Unregister VBUS and ID events notifiers
Date: Mon,  7 Sep 2015 11:07:09 +0300	[thread overview]
Message-ID: <1441613229-13867-1-git-send-email-ivan.ivanov@linaro.org> (raw)

Right now even if driver failed to probe extcon framework will
still deliver its VBUS and ID events, which will lead to random
exception codes.

Fix this by removing VBUS and ID events notifiers when probe fail.

Fixes: 591fc116f330 ("usb: phy: msm: Use extcon framework for VBUS and ID detection")

Reported-by: Tim Bird <tim.bird@sonymobile.com>
Signed-off-by: Ivan T. Ivanov <ivan.ivanov@linaro.org>
---

Patch reworked to use new extcon API.

 drivers/usb/phy/phy-msm-usb.c | 25 ++++++++++++++++---------
 1 file changed, 16 insertions(+), 9 deletions(-)

diff --git a/drivers/usb/phy/phy-msm-usb.c b/drivers/usb/phy/phy-msm-usb.c
index c58c3c0dbe35..0fd21c147c7e 100644
--- a/drivers/usb/phy/phy-msm-usb.c
+++ b/drivers/usb/phy/phy-msm-usb.c
@@ -1598,6 +1598,8 @@ static int msm_otg_read_dt(struct platform_device *pdev, struct msm_otg *motg)
 		ret = extcon_register_notifier(ext_id, EXTCON_USB_HOST,
 						&motg->id.nb);
 		if (ret < 0) {
+			extcon_unregister_notifier(motg->vbus.extcon,
+						   EXTCON_USB, &motg->vbus.nb);
 			dev_err(&pdev->dev, "register ID notifier failed\n");
 			return ret;
 		}
@@ -1660,15 +1662,6 @@ static int msm_otg_probe(struct platform_device *pdev)
 	if (!motg)
 		return -ENOMEM;

-	pdata = dev_get_platdata(&pdev->dev);
-	if (!pdata) {
-		if (!np)
-			return -ENXIO;
-		ret = msm_otg_read_dt(pdev, motg);
-		if (ret)
-			return ret;
-	}
-
 	motg->phy.otg = devm_kzalloc(&pdev->dev, sizeof(struct usb_otg),
 				     GFP_KERNEL);
 	if (!motg->phy.otg)
@@ -1731,6 +1724,15 @@ static int msm_otg_probe(struct platform_device *pdev)
 		return motg->irq;
 	}

+	pdata = dev_get_platdata(&pdev->dev);
+	if (!pdata) {
+		if (!np)
+			return -ENXIO;
+		ret = msm_otg_read_dt(pdev, motg);
+		if (ret)
+			return ret;
+	}
+
 	regs[0].supply = "vddcx";
 	regs[1].supply = "v3p3";
 	regs[2].supply = "v1p8";
@@ -1834,6 +1836,11 @@ disable_clks:
 	clk_disable_unprepare(motg->clk);
 	if (!IS_ERR(motg->core_clk))
 		clk_disable_unprepare(motg->core_clk);
+
+	extcon_unregister_notifier(motg->id.extcon,
+				   EXTCON_USB_HOST, &motg->id.nb);
+	extcon_unregister_notifier(motg->vbus.extcon,
+				   EXTCON_USB, &motg->vbus.nb);
 	return ret;
 }

--
1.9.1

             reply	other threads:[~2015-09-07  8:07 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-09-07  8:07 Ivan T. Ivanov [this message]
     [not found] ` <1441613229-13867-1-git-send-email-ivan.ivanov-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
2015-09-08 19:07   ` [PATCH v2] usb: phy: msm: Unregister VBUS and ID events notifiers Tim Bird

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=1441613229-13867-1-git-send-email-ivan.ivanov@linaro.org \
    --to=ivan.ivanov@linaro.org \
    --cc=balbi@ti.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=tim.bird@sonymobile.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).