Commit 86a17684 authored by Geert Uytterhoeven's avatar Geert Uytterhoeven Committed by Vinod Koul
Browse files

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: default avatarGeert Uytterhoeven <geert+renesas@glider.be>
Reviewed-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Acked-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Link: https://lore.kernel.org/r/a28baf4e07e464c43aff9e52263b5a902f5da9a0.1674584626.git.geert+renesas@glider.be


Signed-off-by: default avatarVinod Koul <vkoul@kernel.org>
parent a80becc5
Loading
Loading
Loading
Loading
+6 −17
Original line number Diff line number Diff line
@@ -80,19 +80,11 @@ static int exynos_ehci_get_phy(struct device *dev,
			return -EINVAL;
		}

		phy = devm_of_phy_get(dev, child, NULL);
		phy = devm_of_phy_optional_get(dev, child, NULL);
		exynos_ehci->phy[phy_number] = phy;
		if (IS_ERR(phy)) {
			ret = PTR_ERR(phy);
			if (ret == -EPROBE_DEFER) {
			of_node_put(child);
				return ret;
			} else if (ret != -ENOSYS && ret != -ENODEV) {
				dev_err(dev,
					"Error retrieving usb2 phy: %d\n", ret);
				of_node_put(child);
				return ret;
			}
			return PTR_ERR(phy);
		}
	}

@@ -108,11 +100,9 @@ static int exynos_ehci_phy_enable(struct device *dev)
	int ret = 0;

	for (i = 0; ret == 0 && i < PHY_NUMBER; i++)
		if (!IS_ERR(exynos_ehci->phy[i]))
		ret = phy_power_on(exynos_ehci->phy[i]);
	if (ret)
		for (i--; i >= 0; i--)
			if (!IS_ERR(exynos_ehci->phy[i]))
			phy_power_off(exynos_ehci->phy[i]);

	return ret;
@@ -125,7 +115,6 @@ static void exynos_ehci_phy_disable(struct device *dev)
	int i;

	for (i = 0; i < PHY_NUMBER; i++)
		if (!IS_ERR(exynos_ehci->phy[i]))
		phy_power_off(exynos_ehci->phy[i]);
}