ulpi_phy.h 783 B

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