linux-sh.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Ben Dooks <ben.dooks@codethink.co.uk>
To: linux-sh@vger.kernel.org
Subject: [PATCH 4/9] usb: phy: check for of_node when getting phy
Date: Thu, 06 Mar 2014 18:01:22 +0000	[thread overview]
Message-ID: <1394128887-4197-5-git-send-email-ben.dooks@codethink.co.uk> (raw)

If the PHY is specified by usb-phy handle in the device tree, then
usb_get_phy_dev() should use the device tree specified PHY. This
fixes the issue where device-tree booted Renesas SoCs fail to find
the PHY for the USB controllers.

Signed-off-by: Ben Dooks <ben.dooks@codethink.co.uk>
---
Cc: linux-usb@vger.kernel.org
Cc: Felipe Balbi <balbi@ti.com>
---
 drivers/usb/phy/phy.c | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)

diff --git a/drivers/usb/phy/phy.c b/drivers/usb/phy/phy.c
index 8afa813..92b3c09 100644
--- a/drivers/usb/phy/phy.c
+++ b/drivers/usb/phy/phy.c
@@ -224,6 +224,29 @@ struct usb_phy *usb_get_phy_dev(struct device *dev, u8 index)
 	struct usb_phy	*phy = NULL;
 	unsigned long	flags;
 
+	if (dev->of_node) {
+		struct device_node *node;
+
+		node = of_parse_phandle(dev->of_node, "usb-phy", index);
+		if (!node) {
+			dev_dbg(dev, "failed to get %s phandle\n",
+				dev->of_node->full_name);
+			return ERR_PTR(-ENODEV);
+		}
+
+		spin_lock_irqsave(&phy_lock, flags);
+
+		phy = __of_usb_find_phy(node);
+		if (IS_ERR(phy) || !try_module_get(phy->dev->driver->owner)) {
+			phy = ERR_PTR(-EPROBE_DEFER);
+			of_node_put(node);
+			goto err0;
+		}
+
+		get_device(phy->dev);
+		goto err0;
+	}
+
 	spin_lock_irqsave(&phy_lock, flags);
 
 	phy = __usb_find_phy_dev(dev, &phy_bind_list, index);
-- 
1.9.0


                 reply	other threads:[~2014-03-06 18:01 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=1394128887-4197-5-git-send-email-ben.dooks@codethink.co.uk \
    --to=ben.dooks@codethink.co.uk \
    --cc=linux-sh@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 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).