Skip to content

Commit 41a435e

Browse files
geertuvinodkoul
authored andcommitted
usb: host: ohci-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> Acked-by: Alan Stern <stern@rowland.harvard.edu> Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Link: https://lore.kernel.org/r/3adc5dd1149a17ea7daf4463549feab886c6b145.1674584626.git.geert+renesas@glider.be Signed-off-by: Vinod Koul <vkoul@kernel.org>
1 parent 86a1768 commit 41a435e

File tree

1 file changed

+6
-17
lines changed

1 file changed

+6
-17
lines changed

drivers/usb/host/ohci-exynos.c

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -69,19 +69,11 @@ static int exynos_ohci_get_phy(struct device *dev,
6969
return -EINVAL;
7070
}
7171

72-
phy = devm_of_phy_get(dev, child, NULL);
72+
phy = devm_of_phy_optional_get(dev, child, NULL);
7373
exynos_ohci->phy[phy_number] = phy;
7474
if (IS_ERR(phy)) {
75-
ret = PTR_ERR(phy);
76-
if (ret == -EPROBE_DEFER) {
77-
of_node_put(child);
78-
return ret;
79-
} else if (ret != -ENOSYS && ret != -ENODEV) {
80-
dev_err(dev,
81-
"Error retrieving usb2 phy: %d\n", ret);
82-
of_node_put(child);
83-
return ret;
84-
}
75+
of_node_put(child);
76+
return PTR_ERR(phy);
8577
}
8678
}
8779

@@ -97,12 +89,10 @@ static int exynos_ohci_phy_enable(struct device *dev)
9789
int ret = 0;
9890

9991
for (i = 0; ret == 0 && i < PHY_NUMBER; i++)
100-
if (!IS_ERR(exynos_ohci->phy[i]))
101-
ret = phy_power_on(exynos_ohci->phy[i]);
92+
ret = phy_power_on(exynos_ohci->phy[i]);
10293
if (ret)
10394
for (i--; i >= 0; i--)
104-
if (!IS_ERR(exynos_ohci->phy[i]))
105-
phy_power_off(exynos_ohci->phy[i]);
95+
phy_power_off(exynos_ohci->phy[i]);
10696

10797
return ret;
10898
}
@@ -114,8 +104,7 @@ static void exynos_ohci_phy_disable(struct device *dev)
114104
int i;
115105

116106
for (i = 0; i < PHY_NUMBER; i++)
117-
if (!IS_ERR(exynos_ohci->phy[i]))
118-
phy_power_off(exynos_ohci->phy[i]);
107+
phy_power_off(exynos_ohci->phy[i]);
119108
}
120109

121110
static int exynos_ohci_probe(struct platform_device *pdev)

0 commit comments

Comments
 (0)