lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <1357836694-30788-3-git-send-email-rogerq@ti.com>
Date:	Thu, 10 Jan 2013 18:51:22 +0200
From:	Roger Quadros <rogerq@...com>
To:	<balbi@...com>
CC:	<gregkh@...uxfoundation.org>, <sameo@...ux.intel.com>,
	<tony@...mide.com>, <kishon@...com>, <linux-usb@...r.kernel.org>,
	<linux-kernel@...r.kernel.org>,
	<linux-arm-kernel@...ts.infradead.org>, <rogerq@...com>
Subject: [PATCH 02/14] usb: phy: Add new API usb_get_phy_from_dev()

This API allows PHY users to get the usb_phy data structure
from a device handle.

Signed-off-by: Roger Quadros <rogerq@...com>
---
 drivers/usb/otg/otg.c   |   36 ++++++++++++++++++++++++++++++++++++
 include/linux/usb/phy.h |    6 ++++++
 2 files changed, 42 insertions(+), 0 deletions(-)

diff --git a/drivers/usb/otg/otg.c b/drivers/usb/otg/otg.c
index a30c041..ba3a568 100644
--- a/drivers/usb/otg/otg.c
+++ b/drivers/usb/otg/otg.c
@@ -35,6 +35,21 @@ static struct usb_phy *__usb_find_phy(struct list_head *list,
 	return ERR_PTR(-ENODEV);
 }
 
+static struct usb_phy *__usb_find_phy_dev(struct list_head *list,
+	struct device *dev)
+{
+	struct usb_phy *phy;
+
+	list_for_each_entry(phy, list, head) {
+		if (phy->dev != dev)
+			continue;
+
+		return phy;
+	}
+
+	return ERR_PTR(-ENODEV);
+}
+
 static void devm_usb_phy_release(struct device *dev, void *res)
 {
 	struct usb_phy *phy = *(struct usb_phy **)res;
@@ -77,6 +92,27 @@ struct usb_phy *devm_usb_get_phy(struct device *dev, enum usb_phy_type type)
 }
 EXPORT_SYMBOL(devm_usb_get_phy);
 
+struct usb_phy *usb_get_phy_from_dev(struct device *dev)
+{
+	struct usb_phy *phy = NULL;
+	unsigned long flags;
+
+	spin_lock_irqsave(&phy_lock, flags);
+
+	phy = __usb_find_phy_dev(&phy_list, dev);
+	if (IS_ERR(phy)) {
+		dev_err(dev, "%s: unable to find PHY\n", __func__);
+		goto done;
+	}
+
+	get_device(phy->dev);
+
+done:
+	spin_unlock_irqrestore(&phy_lock, flags);
+	return phy;
+}
+EXPORT_SYMBOL(usb_get_phy_from_dev);
+
 /**
  * usb_get_phy - find the USB PHY
  * @type - the type of the phy the controller requires
diff --git a/include/linux/usb/phy.h b/include/linux/usb/phy.h
index a29ae1e..cd798c4 100644
--- a/include/linux/usb/phy.h
+++ b/include/linux/usb/phy.h
@@ -147,6 +147,7 @@ usb_phy_shutdown(struct usb_phy *x)
 /* for usb host and peripheral controller drivers */
 #ifdef CONFIG_USB_OTG_UTILS
 extern struct usb_phy *usb_get_phy(enum usb_phy_type type);
+extern struct usb_phy *usb_get_phy_from_dev(struct device *dev);
 extern struct usb_phy *devm_usb_get_phy(struct device *dev,
 	enum usb_phy_type type);
 extern void usb_put_phy(struct usb_phy *);
@@ -157,6 +158,11 @@ static inline struct usb_phy *usb_get_phy(enum usb_phy_type type)
 	return NULL;
 }
 
+static inline struct usb_phy *usb_get_phy_from_dev(struct device *dev)
+{
+	return NULL;
+}
+
 static inline struct usb_phy *devm_usb_get_phy(struct device *dev,
 	enum usb_phy_type type)
 {
-- 
1.7.4.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ