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