summaryrefslogtreecommitdiff
path: root/include/linux/phy
diff options
context:
space:
mode:
authorDoug Ledford <dledford@redhat.com>2017-07-17 18:26:58 +0300
committerDoug Ledford <dledford@redhat.com>2017-07-17 18:26:58 +0300
commit3d886aa3be15439e05784ac1cbd4acc2f13c0048 (patch)
tree5d7d5943c7f6697e640bdd684a560e9af7942300 /include/linux/phy
parentb6ea01ba3fe9dcb5e08bbd9ed482845582a1e80b (diff)
parent5771a8c08880cdca3bfb4a3fc6d309d6bba20877 (diff)
downloadlinux-3d886aa3be15439e05784ac1cbd4acc2f13c0048.tar.xz
Merge tag 'v4.13-rc1' into k.o/for-4.13-rc
Linux v4.13-rc1
Diffstat (limited to 'include/linux/phy')
-rw-r--r--include/linux/phy/ulpi_phy.h31
1 files changed, 31 insertions, 0 deletions
diff --git a/include/linux/phy/ulpi_phy.h b/include/linux/phy/ulpi_phy.h
new file mode 100644
index 000000000000..f2ebe490a4bc
--- /dev/null
+++ b/include/linux/phy/ulpi_phy.h
@@ -0,0 +1,31 @@
+#include <linux/phy/phy.h>
+
+/**
+ * Helper that registers PHY for a ULPI device and adds a lookup for binding it
+ * and it's controller, which is always the parent.
+ */
+static inline struct phy
+*ulpi_phy_create(struct ulpi *ulpi, const struct phy_ops *ops)
+{
+ struct phy *phy;
+ int ret;
+
+ phy = phy_create(&ulpi->dev, NULL, ops);
+ if (IS_ERR(phy))
+ return phy;
+
+ ret = phy_create_lookup(phy, "usb2-phy", dev_name(ulpi->dev.parent));
+ if (ret) {
+ phy_destroy(phy);
+ return ERR_PTR(ret);
+ }
+
+ return phy;
+}
+
+/* Remove a PHY that was created with ulpi_phy_create() and it's lookup. */
+static inline void ulpi_phy_destroy(struct ulpi *ulpi, struct phy *phy)
+{
+ phy_remove_lookup(phy, "usb2-phy", dev_name(ulpi->dev.parent));
+ phy_destroy(phy);
+}