From nobody Mon Feb 9 08:49:38 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6792AEB64DA for ; Sat, 17 Jun 2023 14:24:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236085AbjFQOYt (ORCPT ); Sat, 17 Jun 2023 10:24:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53518 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231936AbjFQOYq (ORCPT ); Sat, 17 Jun 2023 10:24:46 -0400 Received: from smtp.smtpout.orange.fr (smtp-24.smtpout.orange.fr [80.12.242.24]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 35F081BDF for ; Sat, 17 Jun 2023 07:24:44 -0700 (PDT) Received: from pop-os.home ([86.243.2.178]) by smtp.orange.fr with ESMTPA id AWr1qVPAYtGgOAWr1qGHnt; Sat, 17 Jun 2023 16:24:42 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=wanadoo.fr; s=t20230301; t=1687011882; bh=GIaDZ9qklWwCYGZElFRs429MfAWUnecD/VWmPgF+bfY=; h=From:To:Cc:Subject:Date; b=EsDt6VHU0nK0znr5mGgmD6crpCfBtSLB4BhR9Q6Lbaddn+iw4BjqZoPxyrr4JOLFq McsQ/hEuurzNaffGGPzyrTNfaV+re3ifr9eOVkX/Wg8QPIK3hnkYmqVB+wdIsysXYs FQPDsGA0+u+u44NQ/wApENDbTVXDOcgFwmQU8vA9n4G4wH+WLZfjJUjQNV1rUTUplJ S8WZFIC+SmFudMIgCuMSgvJJ2cW7KWTF2i0cPPm+S3zcnljTwX79zHrFfOGj8hae1p JX/lZ9ZUTbu0aJADDKIMMxXTcLhx6Y31jnd2aWOA25nayV9TeQZpF9XhAEjP/UjL5v E0oO/fhSnUKlQ== X-ME-Helo: pop-os.home X-ME-Auth: Y2hyaXN0b3BoZS5qYWlsbGV0QHdhbmFkb28uZnI= X-ME-Date: Sat, 17 Jun 2023 16:24:42 +0200 X-ME-IP: 86.243.2.178 From: Christophe JAILLET To: Andrew Lunn , Heiner Kallweit , Russell King , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Liam Girdwood , Mark Brown Cc: linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, Christophe JAILLET , netdev@vger.kernel.org Subject: [PATCH net-next] net: phy: at803x: Use devm_regulator_get_enable_optional() Date: Sat, 17 Jun 2023 16:24:37 +0200 Message-Id: X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Use devm_regulator_get_enable_optional() instead of hand writing it. It saves some line of code. Signed-off-by: Christophe JAILLET Reviewed-by: Andrew Lunn --- Compile tested-only. If my reading is correct, regulator_disable() is still called in the same order, should an error occur or the driver be removed. --- drivers/net/phy/at803x.c | 44 +++++++--------------------------------- 1 file changed, 7 insertions(+), 37 deletions(-) diff --git a/drivers/net/phy/at803x.c b/drivers/net/phy/at803x.c index 656136628ffd..c1f307d90518 100644 --- a/drivers/net/phy/at803x.c +++ b/drivers/net/phy/at803x.c @@ -304,7 +304,6 @@ struct at803x_priv { bool is_1000basex; struct regulator_dev *vddio_rdev; struct regulator_dev *vddh_rdev; - struct regulator *vddio; u64 stats[ARRAY_SIZE(at803x_hw_stats)]; }; =20 @@ -824,11 +823,11 @@ static int at803x_parse_dt(struct phy_device *phydev) if (ret < 0) return ret; =20 - priv->vddio =3D devm_regulator_get_optional(&phydev->mdio.dev, - "vddio"); - if (IS_ERR(priv->vddio)) { + ret =3D devm_regulator_get_enable_optional(&phydev->mdio.dev, + "vddio"); + if (ret) { phydev_err(phydev, "failed to get VDDIO regulator\n"); - return PTR_ERR(priv->vddio); + return ret; } =20 /* Only AR8031/8033 support 1000Base-X for SFP modules */ @@ -856,12 +855,6 @@ static int at803x_probe(struct phy_device *phydev) if (ret) return ret; =20 - if (priv->vddio) { - ret =3D regulator_enable(priv->vddio); - if (ret < 0) - return ret; - } - if (phydev->drv->phy_id =3D=3D ATH8031_PHY_ID) { int ccr =3D phy_read(phydev, AT803X_REG_CHIP_CONFIG); int mode_cfg; @@ -869,10 +862,8 @@ static int at803x_probe(struct phy_device *phydev) .wolopts =3D 0, }; =20 - if (ccr < 0) { - ret =3D ccr; - goto err; - } + if (ccr < 0) + return ccr; mode_cfg =3D ccr & AT803X_MODE_CFG_MASK; =20 switch (mode_cfg) { @@ -890,25 +881,11 @@ static int at803x_probe(struct phy_device *phydev) ret =3D at803x_set_wol(phydev, &wol); if (ret < 0) { phydev_err(phydev, "failed to disable WOL on probe: %d\n", ret); - goto err; + return ret; } } =20 return 0; - -err: - if (priv->vddio) - regulator_disable(priv->vddio); - - return ret; -} - -static void at803x_remove(struct phy_device *phydev) -{ - struct at803x_priv *priv =3D phydev->priv; - - if (priv->vddio) - regulator_disable(priv->vddio); } =20 static int at803x_get_features(struct phy_device *phydev) @@ -2021,7 +1998,6 @@ static struct phy_driver at803x_driver[] =3D { .name =3D "Qualcomm Atheros AR8035", .flags =3D PHY_POLL_CABLE_TEST, .probe =3D at803x_probe, - .remove =3D at803x_remove, .config_aneg =3D at803x_config_aneg, .config_init =3D at803x_config_init, .soft_reset =3D genphy_soft_reset, @@ -2043,7 +2019,6 @@ static struct phy_driver at803x_driver[] =3D { .name =3D "Qualcomm Atheros AR8030", .phy_id_mask =3D AT8030_PHY_ID_MASK, .probe =3D at803x_probe, - .remove =3D at803x_remove, .config_init =3D at803x_config_init, .link_change_notify =3D at803x_link_change_notify, .set_wol =3D at803x_set_wol, @@ -2059,7 +2034,6 @@ static struct phy_driver at803x_driver[] =3D { .name =3D "Qualcomm Atheros AR8031/AR8033", .flags =3D PHY_POLL_CABLE_TEST, .probe =3D at803x_probe, - .remove =3D at803x_remove, .config_init =3D at803x_config_init, .config_aneg =3D at803x_config_aneg, .soft_reset =3D genphy_soft_reset, @@ -2082,7 +2056,6 @@ static struct phy_driver at803x_driver[] =3D { PHY_ID_MATCH_EXACT(ATH8032_PHY_ID), .name =3D "Qualcomm Atheros AR8032", .probe =3D at803x_probe, - .remove =3D at803x_remove, .flags =3D PHY_POLL_CABLE_TEST, .config_init =3D at803x_config_init, .link_change_notify =3D at803x_link_change_notify, @@ -2100,7 +2073,6 @@ static struct phy_driver at803x_driver[] =3D { PHY_ID_MATCH_EXACT(ATH9331_PHY_ID), .name =3D "Qualcomm Atheros AR9331 built-in PHY", .probe =3D at803x_probe, - .remove =3D at803x_remove, .suspend =3D at803x_suspend, .resume =3D at803x_resume, .flags =3D PHY_POLL_CABLE_TEST, @@ -2117,7 +2089,6 @@ static struct phy_driver at803x_driver[] =3D { PHY_ID_MATCH_EXACT(QCA9561_PHY_ID), .name =3D "Qualcomm Atheros QCA9561 built-in PHY", .probe =3D at803x_probe, - .remove =3D at803x_remove, .suspend =3D at803x_suspend, .resume =3D at803x_resume, .flags =3D PHY_POLL_CABLE_TEST, @@ -2183,7 +2154,6 @@ static struct phy_driver at803x_driver[] =3D { .name =3D "Qualcomm QCA8081", .flags =3D PHY_POLL_CABLE_TEST, .probe =3D at803x_probe, - .remove =3D at803x_remove, .config_intr =3D at803x_config_intr, .handle_interrupt =3D at803x_handle_interrupt, .get_tunable =3D at803x_get_tunable, --=20 2.34.1