[PATCH net-next v2 2/5] net: dsa: mt7530: factor out mt7530_disable_pwrs()

From: Haoran Wang

Date: Thu Dec 03 2026 - 01:49:33 EST


Pull the regulator disable out of mt753x_teardown() into a helper so it
can also be used on the setup error paths added in later patches. The
helper keeps reporting regulator_disable() failures, since a failed
disable is worth investigating.

Signed-off-by: Haoran Wang <wanghr2026@xxxxxxxxxxxxxxxxxx>
---
drivers/net/dsa/mt7530.c | 32 ++++++++++++++++++++------------
1 file changed, 20 insertions(+), 12 deletions(-)

diff --git a/drivers/net/dsa/mt7530.c b/drivers/net/dsa/mt7530.c
index c2f12ae2c6d7..17c62b53ca06 100644
--- a/drivers/net/dsa/mt7530.c
+++ b/drivers/net/dsa/mt7530.c
@@ -2376,6 +2376,25 @@ mt7530_setup_mdio(struct mt7530_priv *priv)
return ret;
}

+static void
+mt7530_disable_pwrs(struct mt7530_priv *priv)
+{
+ int ret;
+
+ if (priv->id != ID_MT7530)
+ return;
+
+ ret = regulator_disable(priv->core_pwr);
+ if (ret < 0)
+ dev_err(priv->dev,
+ "Failed to disable core power: %d\n", ret);
+
+ ret = regulator_disable(priv->io_pwr);
+ if (ret < 0)
+ dev_err(priv->dev, "Failed to disable io pwr: %d\n",
+ ret);
+}
+
static int
mt7530_setup(struct dsa_switch *ds)
{
@@ -3237,22 +3256,11 @@ static void
mt753x_teardown(struct dsa_switch *ds)
{
struct mt7530_priv *priv = ds->priv;
- int ret;

if (priv->bus)
cancel_delayed_work_sync(&priv->stats_work);

- if (priv->id == ID_MT7530) {
- ret = regulator_disable(priv->core_pwr);
- if (ret < 0)
- dev_err(priv->dev,
- "Failed to disable core power: %d\n", ret);
-
- ret = regulator_disable(priv->io_pwr);
- if (ret < 0)
- dev_err(priv->dev, "Failed to disable io pwr: %d\n",
- ret);
- }
+ mt7530_disable_pwrs(priv);
}

static int mt753x_set_mac_eee(struct dsa_switch *ds, int port,