Skip to content

Commit 86a1768

Browse files
geertuvinodkoul
authored andcommitted
usb: host: ehci-exynos: Convert to devm_of_phy_optional_get()
Use the new devm_of_phy_optional_get() helper instead of open-coding the same operation. As devm_of_phy_optional_get() returns NULL if either the PHY cannot be found, or if support for the PHY framework is not enabled, it is no longer needed to check for -ENODEV or -ENOSYS. This lets us drop several checks for IS_ERR(), as phy_power_{on,off}() handle NULL parameters fine. Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be> Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Link: https://lore.kernel.org/r/a28baf4e07e464c43aff9e52263b5a902f5da9a0.1674584626.git.geert+renesas@glider.be Signed-off-by: Vinod Koul <vkoul@kernel.org>
1 parent a80becc commit 86a1768

File tree

1 file changed

+6
-17
lines changed

1 file changed

+6
-17
lines changed

drivers/usb/host/ehci-exynos.c

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -80,19 +80,11 @@ static int exynos_ehci_get_phy(struct device *dev,
8080
return -EINVAL;
8181
}
8282

83-
phy = devm_of_phy_get(dev, child, NULL);
83+
phy = devm_of_phy_optional_get(dev, child, NULL);
8484
exynos_ehci->phy[phy_number] = phy;
8585
if (IS_ERR(phy)) {
86-
ret = PTR_ERR(phy);
87-
if (ret == -EPROBE_DEFER) {
88-
of_node_put(child);
89-
return ret;
90-
} else if (ret != -ENOSYS && ret != -ENODEV) {
91-
dev_err(dev,
92-
"Error retrieving usb2 phy: %d\n", ret);
93-
of_node_put(child);
94-
return ret;
95-
}
86+
of_node_put(child);
87+
return PTR_ERR(phy);
9688
}
9789
}
9890

@@ -108,12 +100,10 @@ static int exynos_ehci_phy_enable(struct device *dev)
108100
int ret = 0;
109101

110102
for (i = 0; ret == 0 && i < PHY_NUMBER; i++)
111-
if (!IS_ERR(exynos_ehci->phy[i]))
112-
ret = phy_power_on(exynos_ehci->phy[i]);
103+
ret = phy_power_on(exynos_ehci->phy[i]);
113104
if (ret)
114105
for (i--; i >= 0; i--)
115-
if (!IS_ERR(exynos_ehci->phy[i]))
116-
phy_power_off(exynos_ehci->phy[i]);
106+
phy_power_off(exynos_ehci->phy[i]);
117107

118108
return ret;
119109
}
@@ -125,8 +115,7 @@ static void exynos_ehci_phy_disable(struct device *dev)
125115
int i;
126116

127117
for (i = 0; i < PHY_NUMBER; i++)
128-
if (!IS_ERR(exynos_ehci->phy[i]))
129-
phy_power_off(exynos_ehci->phy[i]);
118+
phy_power_off(exynos_ehci->phy[i]);
130119
}
131120

132121
static void exynos_setup_vbus_gpio(struct device *dev)

0 commit comments

Comments
 (0)