ulpi_phy.h 744 B

12345678910111213141516171819202122232425262728293031
  1. #include <linux/phy/phy.h>
  2. /**
  3. * Helper that registers PHY for a ULPI device and adds a lookup for binding it
  4. * and it's controller, which is always the parent.
  5. */
  6. static inline struct phy
  7. *ulpi_phy_create(struct ulpi *ulpi, const struct phy_ops *ops)
  8. {
  9. struct phy *phy;
  10. int ret;
  11. phy = phy_create(&ulpi->dev, NULL, ops);
  12. if (IS_ERR(phy))
  13. return phy;
  14. ret = phy_create_lookup(phy, "usb2-phy", dev_name(ulpi->dev.parent));
  15. if (ret) {
  16. phy_destroy(phy);
  17. return ERR_PTR(ret);
  18. }
  19. return phy;
  20. }
  21. /* Remove a PHY that was created with ulpi_phy_create() and it's lookup. */
  22. static inline void ulpi_phy_destroy(struct ulpi *ulpi, struct phy *phy)
  23. {
  24. phy_remove_lookup(phy, "usb2-phy", dev_name(ulpi->dev.parent));
  25. phy_destroy(phy);
  26. }