Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

net: phy: at803x: Use devm_regulator_get_enable_optional()

Use devm_regulator_get_enable_optional() instead of hand writing it. It
saves some line of code.

Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Christophe JAILLET and committed by
David S. Miller
988e8d90 264879fd

+7 -37
+7 -37
drivers/net/phy/at803x.c
··· 304 304 bool is_1000basex; 305 305 struct regulator_dev *vddio_rdev; 306 306 struct regulator_dev *vddh_rdev; 307 - struct regulator *vddio; 308 307 u64 stats[ARRAY_SIZE(at803x_hw_stats)]; 309 308 }; 310 309 ··· 823 824 if (ret < 0) 824 825 return ret; 825 826 826 - priv->vddio = devm_regulator_get_optional(&phydev->mdio.dev, 827 - "vddio"); 828 - if (IS_ERR(priv->vddio)) { 827 + ret = devm_regulator_get_enable_optional(&phydev->mdio.dev, 828 + "vddio"); 829 + if (ret) { 829 830 phydev_err(phydev, "failed to get VDDIO regulator\n"); 830 - return PTR_ERR(priv->vddio); 831 + return ret; 831 832 } 832 833 833 834 /* Only AR8031/8033 support 1000Base-X for SFP modules */ ··· 855 856 if (ret) 856 857 return ret; 857 858 858 - if (priv->vddio) { 859 - ret = regulator_enable(priv->vddio); 860 - if (ret < 0) 861 - return ret; 862 - } 863 - 864 859 if (phydev->drv->phy_id == ATH8031_PHY_ID) { 865 860 int ccr = phy_read(phydev, AT803X_REG_CHIP_CONFIG); 866 861 int mode_cfg; ··· 862 869 .wolopts = 0, 863 870 }; 864 871 865 - if (ccr < 0) { 866 - ret = ccr; 867 - goto err; 868 - } 872 + if (ccr < 0) 873 + return ccr; 869 874 mode_cfg = ccr & AT803X_MODE_CFG_MASK; 870 875 871 876 switch (mode_cfg) { ··· 881 890 ret = at803x_set_wol(phydev, &wol); 882 891 if (ret < 0) { 883 892 phydev_err(phydev, "failed to disable WOL on probe: %d\n", ret); 884 - goto err; 893 + return ret; 885 894 } 886 895 } 887 896 888 897 return 0; 889 - 890 - err: 891 - if (priv->vddio) 892 - regulator_disable(priv->vddio); 893 - 894 - return ret; 895 - } 896 - 897 - static void at803x_remove(struct phy_device *phydev) 898 - { 899 - struct at803x_priv *priv = phydev->priv; 900 - 901 - if (priv->vddio) 902 - regulator_disable(priv->vddio); 903 898 } 904 899 905 900 static int at803x_get_features(struct phy_device *phydev) ··· 1998 2021 .name = "Qualcomm Atheros AR8035", 1999 2022 .flags = PHY_POLL_CABLE_TEST, 2000 2023 .probe = at803x_probe, 2001 - .remove = at803x_remove, 2002 2024 .config_aneg = at803x_config_aneg, 2003 2025 .config_init = at803x_config_init, 2004 2026 .soft_reset = genphy_soft_reset, ··· 2019 2043 .name = "Qualcomm Atheros AR8030", 2020 2044 .phy_id_mask = AT8030_PHY_ID_MASK, 2021 2045 .probe = at803x_probe, 2022 - .remove = at803x_remove, 2023 2046 .config_init = at803x_config_init, 2024 2047 .link_change_notify = at803x_link_change_notify, 2025 2048 .set_wol = at803x_set_wol, ··· 2034 2059 .name = "Qualcomm Atheros AR8031/AR8033", 2035 2060 .flags = PHY_POLL_CABLE_TEST, 2036 2061 .probe = at803x_probe, 2037 - .remove = at803x_remove, 2038 2062 .config_init = at803x_config_init, 2039 2063 .config_aneg = at803x_config_aneg, 2040 2064 .soft_reset = genphy_soft_reset, ··· 2056 2082 PHY_ID_MATCH_EXACT(ATH8032_PHY_ID), 2057 2083 .name = "Qualcomm Atheros AR8032", 2058 2084 .probe = at803x_probe, 2059 - .remove = at803x_remove, 2060 2085 .flags = PHY_POLL_CABLE_TEST, 2061 2086 .config_init = at803x_config_init, 2062 2087 .link_change_notify = at803x_link_change_notify, ··· 2073 2100 PHY_ID_MATCH_EXACT(ATH9331_PHY_ID), 2074 2101 .name = "Qualcomm Atheros AR9331 built-in PHY", 2075 2102 .probe = at803x_probe, 2076 - .remove = at803x_remove, 2077 2103 .suspend = at803x_suspend, 2078 2104 .resume = at803x_resume, 2079 2105 .flags = PHY_POLL_CABLE_TEST, ··· 2089 2117 PHY_ID_MATCH_EXACT(QCA9561_PHY_ID), 2090 2118 .name = "Qualcomm Atheros QCA9561 built-in PHY", 2091 2119 .probe = at803x_probe, 2092 - .remove = at803x_remove, 2093 2120 .suspend = at803x_suspend, 2094 2121 .resume = at803x_resume, 2095 2122 .flags = PHY_POLL_CABLE_TEST, ··· 2154 2183 .name = "Qualcomm QCA8081", 2155 2184 .flags = PHY_POLL_CABLE_TEST, 2156 2185 .probe = at803x_probe, 2157 - .remove = at803x_remove, 2158 2186 .config_intr = at803x_config_intr, 2159 2187 .handle_interrupt = at803x_handle_interrupt, 2160 2188 .get_tunable = at803x_get_tunable,