Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 */
0002 #include <linux/phy/phy.h>
0003 
0004 /**
0005  * Helper that registers PHY for a ULPI device and adds a lookup for binding it
0006  * and it's controller, which is always the parent.
0007  */
0008 static inline struct phy
0009 *ulpi_phy_create(struct ulpi *ulpi, const struct phy_ops *ops)
0010 {
0011     struct phy *phy;
0012     int ret;
0013 
0014     phy = phy_create(&ulpi->dev, NULL, ops);
0015     if (IS_ERR(phy))
0016         return phy;
0017 
0018     ret = phy_create_lookup(phy, "usb2-phy", dev_name(ulpi->dev.parent));
0019     if (ret) {
0020         phy_destroy(phy);
0021         return ERR_PTR(ret);
0022     }
0023 
0024     return phy;
0025 }
0026 
0027 /* Remove a PHY that was created with ulpi_phy_create() and it's lookup. */
0028 static inline void ulpi_phy_destroy(struct ulpi *ulpi, struct phy *phy)
0029 {
0030     phy_remove_lookup(phy, "usb2-phy", dev_name(ulpi->dev.parent));
0031     phy_destroy(phy);
0032 }