net: fman: memac: Convert to devm_of_phy_optional_get()
authorGeert Uytterhoeven <geert+renesas@glider.be>
Tue, 24 Jan 2023 18:37:23 +0000 (19:37 +0100)
committerVinod Koul <vkoul@kernel.org>
Fri, 3 Feb 2023 05:22:49 +0000 (10:52 +0530)
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.

Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Reviewed-by: Sean Anderson <sean.anderson@seco.com>
Link: https://lore.kernel.org/r/f2d801cd73cca36a7162819289480d7fc91fcc7e.1674584626.git.geert+renesas@glider.be
Signed-off-by: Vinod Koul <vkoul@kernel.org>
drivers/net/ethernet/freescale/fman/fman_memac.c

index 9349f841bd0645a068d4538c81ea461df177e531..ddd9d13f1166e120fc8ce36a6c07d5e092e0de0d 100644 (file)
@@ -1152,13 +1152,12 @@ int memac_initialization(struct mac_device *mac_dev,
        else
                memac->sgmii_pcs = pcs;
 
-       memac->serdes = devm_of_phy_get(mac_dev->dev, mac_node, "serdes");
-       err = PTR_ERR(memac->serdes);
-       if (err == -ENODEV || err == -ENOSYS) {
+       memac->serdes = devm_of_phy_optional_get(mac_dev->dev, mac_node,
+                                                "serdes");
+       if (!memac->serdes) {
                dev_dbg(mac_dev->dev, "could not get (optional) serdes\n");
-               memac->serdes = NULL;
        } else if (IS_ERR(memac->serdes)) {
-               dev_err_probe(mac_dev->dev, err, "could not get serdes\n");
+               err = PTR_ERR(memac->serdes);
                goto _return_fm_mac_free;
        }