1*b2441318SGreg Kroah-Hartman /* SPDX-License-Identifier: GPL-2.0 */
2858edde0SVivek Gautam #include <linux/phy/phy.h>
3858edde0SVivek Gautam
4858edde0SVivek Gautam /**
5858edde0SVivek Gautam * Helper that registers PHY for a ULPI device and adds a lookup for binding it
6858edde0SVivek Gautam * and it's controller, which is always the parent.
7858edde0SVivek Gautam */
8858edde0SVivek Gautam static inline struct phy
ulpi_phy_create(struct ulpi * ulpi,const struct phy_ops * ops)9858edde0SVivek Gautam *ulpi_phy_create(struct ulpi *ulpi, const struct phy_ops *ops)
10858edde0SVivek Gautam {
11858edde0SVivek Gautam struct phy *phy;
12858edde0SVivek Gautam int ret;
13858edde0SVivek Gautam
14858edde0SVivek Gautam phy = phy_create(&ulpi->dev, NULL, ops);
15858edde0SVivek Gautam if (IS_ERR(phy))
16858edde0SVivek Gautam return phy;
17858edde0SVivek Gautam
18858edde0SVivek Gautam ret = phy_create_lookup(phy, "usb2-phy", dev_name(ulpi->dev.parent));
19858edde0SVivek Gautam if (ret) {
20858edde0SVivek Gautam phy_destroy(phy);
21858edde0SVivek Gautam return ERR_PTR(ret);
22858edde0SVivek Gautam }
23858edde0SVivek Gautam
24858edde0SVivek Gautam return phy;
25858edde0SVivek Gautam }
26858edde0SVivek Gautam
27858edde0SVivek Gautam /* Remove a PHY that was created with ulpi_phy_create() and it's lookup. */
ulpi_phy_destroy(struct ulpi * ulpi,struct phy * phy)28858edde0SVivek Gautam static inline void ulpi_phy_destroy(struct ulpi *ulpi, struct phy *phy)
29858edde0SVivek Gautam {
30858edde0SVivek Gautam phy_remove_lookup(phy, "usb2-phy", dev_name(ulpi->dev.parent));
31858edde0SVivek Gautam phy_destroy(phy);
32858edde0SVivek Gautam }
33