devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Michael Grzeschik <mgr-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
To: linux-usb-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Cc: alexander.shishkin-VuQAYsv1563Yd54FQh9/CA@public.gmane.org,
	devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ@public.gmane.org,
	Sascha Hauer <s.hauer-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>,
	kernel-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org,
	balbi-l0cyMroinI0@public.gmane.org
Subject: [PATCH 5/7] USB chipidea i.MX: use devm_usb_get_phy_by_phandle to get phy
Date: Fri, 31 May 2013 20:38:47 +0200	[thread overview]
Message-ID: <1370025529-7414-6-git-send-email-mgr@pengutronix.de> (raw)
In-Reply-To: <1370025529-7414-1-git-send-email-mgr-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>

From: Sascha Hauer <s.hauer-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>

Signed-off-by: Sascha Hauer <s.hauer-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
---
 drivers/usb/chipidea/ci13xxx_imx.c | 41 ++++++++++++++++++--------------------
 1 file changed, 19 insertions(+), 22 deletions(-)

diff --git a/drivers/usb/chipidea/ci13xxx_imx.c b/drivers/usb/chipidea/ci13xxx_imx.c
index 4d64541..48c446b 100644
--- a/drivers/usb/chipidea/ci13xxx_imx.c
+++ b/drivers/usb/chipidea/ci13xxx_imx.c
@@ -29,7 +29,6 @@
 	((struct usb_phy *)platform_get_drvdata(pdev))
 
 struct ci13xxx_imx_data {
-	struct device_node *phy_np;
 	struct usb_phy *phy;
 	struct platform_device *ci_pdev;
 	struct clk *clk;
@@ -98,12 +97,12 @@ static int ci13xxx_imx_probe(struct platform_device *pdev)
 				  CI13XXX_PULLUP_ON_VBUS |
 				  CI13XXX_DISABLE_STREAMING,
 	};
-	struct platform_device *plat_ci, *phy_pdev;
-	struct device_node *phy_np;
+	struct platform_device *plat_ci;
 	struct resource *res;
 	struct regulator *reg_vbus;
 	struct pinctrl *pinctrl;
 	int ret;
+	struct usb_phy *phy;
 
 	if (of_find_property(pdev->dev.of_node, "fsl,usbmisc", NULL)
 		&& !usbmisc_ops)
@@ -140,19 +139,21 @@ static int ci13xxx_imx_probe(struct platform_device *pdev)
 		return ret;
 	}
 
-	phy_np = of_parse_phandle(pdev->dev.of_node, "fsl,usbphy", 0);
-	if (phy_np) {
-		data->phy_np = phy_np;
-		phy_pdev = of_find_device_by_node(phy_np);
-		if (phy_pdev) {
-			struct usb_phy *phy;
-			phy = pdev_to_phy(phy_pdev);
-			if (phy &&
-			    try_module_get(phy_pdev->dev.driver->owner)) {
-				usb_phy_init(phy);
-				data->phy = phy;
-			}
+	phy = devm_usb_get_phy_by_phandle(&pdev->dev, "fsl,usbphy", 0);
+
+	if (PTR_ERR(phy) == -EPROBE_DEFER) {
+		ret = -EPROBE_DEFER;
+		goto err_clk;
+	}
+
+	if (!IS_ERR(phy)) {
+		ret = usb_phy_init(phy);
+		if (ret) {
+			dev_err(&pdev->dev, "unable to init phy: %d\n", ret);
+			goto err_clk;
 		}
+
+		data->phy = phy;
 	}
 
 	/* we only support host now, so enable vbus here */
@@ -163,7 +164,7 @@ static int ci13xxx_imx_probe(struct platform_device *pdev)
 			dev_err(&pdev->dev,
 				"Failed to enable vbus regulator, err=%d\n",
 				ret);
-			goto put_np;
+			goto err_clk;
 		}
 		data->reg_vbus = reg_vbus;
 	} else {
@@ -202,7 +203,7 @@ static int ci13xxx_imx_probe(struct platform_device *pdev)
 		if (ret) {
 			dev_err(&pdev->dev,
 				"usbmisc post failed, ret=%d\n", ret);
-			goto put_np;
+			goto err;
 		}
 	}
 
@@ -217,9 +218,7 @@ static int ci13xxx_imx_probe(struct platform_device *pdev)
 err:
 	if (reg_vbus)
 		regulator_disable(reg_vbus);
-put_np:
-	if (phy_np)
-		of_node_put(phy_np);
+err_clk:
 	clk_disable_unprepare(data->clk);
 	return ret;
 }
@@ -239,8 +238,6 @@ static int ci13xxx_imx_remove(struct platform_device *pdev)
 		module_put(data->phy->dev->driver->owner);
 	}
 
-	of_node_put(data->phy_np);
-
 	clk_disable_unprepare(data->clk);
 
 	platform_set_drvdata(pdev, NULL);
-- 
1.8.2.rc2

  parent reply	other threads:[~2013-05-31 18:38 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-05-31 18:38 [PATCH v6 0/7] USB: add devicetree helpers for determining dr_mode and phy_type Michael Grzeschik
     [not found] ` <1370025529-7414-1-git-send-email-mgr-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
2013-05-31 18:38   ` [PATCH 1/7] " Michael Grzeschik
     [not found]     ` <1370025529-7414-2-git-send-email-mgr-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
2013-06-03 12:32       ` Alexander Shishkin
     [not found]         ` <8761xvjrwt.fsf-qxRn5AmX6ZD9BXuAQUXR0fooFf0ArEBIu+b9c/7xato@public.gmane.org>
2013-06-04 13:01           ` Michael Grzeschik
     [not found]             ` <20130604130140.GF28181-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
2013-06-04 20:25               ` Felipe Balbi
2013-05-31 18:38   ` [PATCH 2/7] USB: chipidea: ci13xxx-imx: move static pdata into probe function Michael Grzeschik
     [not found]     ` <1370025529-7414-3-git-send-email-mgr-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
2013-06-05 12:29       ` Michael Grzeschik
     [not found]         ` <20130605122906.GB20095-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
2013-06-05 13:04           ` Alexander Shishkin
2013-05-31 18:38   ` [PATCH 3/7] USB: chipidea: add PTW, PTS and STS handling Michael Grzeschik
     [not found]     ` <1370025529-7414-4-git-send-email-mgr-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
2013-06-03 12:35       ` Alexander Shishkin
     [not found]         ` <8738szjrs6.fsf-qxRn5AmX6ZD9BXuAQUXR0fooFf0ArEBIu+b9c/7xato@public.gmane.org>
2013-06-03 16:11           ` Michael Grzeschik
     [not found]             ` <20130603161136.GB28181-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
2013-06-04  9:22               ` Alexander Shishkin
2013-06-06 10:54       ` Michael Grzeschik
2013-05-31 18:38   ` [PATCH 4/7] USB chipidea: introduce dual role mode pdata flags Michael Grzeschik
     [not found]     ` <1370025529-7414-5-git-send-email-mgr-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
2013-06-03 12:37       ` Alexander Shishkin
     [not found]         ` <87zjv7id52.fsf-qxRn5AmX6ZD9BXuAQUXR0fooFf0ArEBIu+b9c/7xato@public.gmane.org>
2013-06-04  1:42           ` Peter Chen
     [not found]             ` <CAL411-pMnJC55M3n5bAuffH3pwRZTzhBfDiEfT+egtGN29c7uw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2013-06-04  9:31               ` Alexander Shishkin
     [not found]                 ` <87ehcii5n0.fsf-qxRn5AmX6ZD9BXuAQUXR0fooFf0ArEBIu+b9c/7xato@public.gmane.org>
2013-06-04 10:09                   ` Peter Chen
     [not found]                     ` <CAL411-pyrFXxyEX_GAFRS5ubh_Pf2yWLZXYC3PJevu1WSJS78g-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2013-06-04 11:09                       ` Alexander Shishkin
2013-05-31 18:38   ` Michael Grzeschik [this message]
     [not found]     ` <1370025529-7414-6-git-send-email-mgr-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
2013-05-31 19:23       ` [PATCH 5/7] USB chipidea i.MX: use devm_usb_get_phy_by_phandle to get phy Sergei Shtylyov
2013-06-03 12:39       ` Alexander Shishkin
2013-05-31 18:38   ` [PATCH 6/7] usb: chipidea: udc: add force-full-speed option Michael Grzeschik
     [not found]     ` <1370025529-7414-7-git-send-email-mgr-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
2013-06-01  7:39       ` Sascha Hauer
     [not found]         ` <20130601073933.GK32299-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
2013-06-01  8:19           ` Michael Grzeschik
     [not found]             ` <20130601081932.GA28181-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
2013-06-01  9:21               ` Sascha Hauer
     [not found]                 ` <20130601092151.GP32299-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
2013-06-03 12:40                   ` Alexander Shishkin
2013-05-31 18:38   ` [PATCH 7/7] usb: chipidea: usbmisc: use module_platform_driver Michael Grzeschik
     [not found]     ` <1370025529-7414-8-git-send-email-mgr-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
2013-06-03 12:41       ` Alexander Shishkin

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=1370025529-7414-6-git-send-email-mgr@pengutronix.de \
    --to=mgr-bicnvbalz9megne8c9+irq@public.gmane.org \
    --cc=alexander.shishkin-VuQAYsv1563Yd54FQh9/CA@public.gmane.org \
    --cc=balbi-l0cyMroinI0@public.gmane.org \
    --cc=devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ@public.gmane.org \
    --cc=kernel-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org \
    --cc=linux-usb-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=s.hauer-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.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 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).