5df859d2dff26ca8ebf6be7f2f6d4464b58f96f2
[openwrt/staging/pepe2k.git] /
1 From 69b838d2629e6b82bcd9e0ab3c1c03f46e5e01d3 Mon Sep 17 00:00:00 2001
2 From: Daniel Golle <daniel@makrotopia.org>
3 Date: Mon, 3 Apr 2023 02:18:50 +0100
4 Subject: [PATCH 09/13] net: dsa: mt7530: introduce mt7530_remove_common helper
5 function
6
7 Move commonly used parts from mt7530_remove into new
8 mt7530_remove_common helper function which will be used by both,
9 mt7530_remove and the to-be-introduced mt7988_remove.
10
11 Signed-off-by: Daniel Golle <daniel@makrotopia.org>
12 Reviewed-by: Andrew Lunn <andrew@lunn.ch>
13 Signed-off-by: David S. Miller <davem@davemloft.net>
14 ---
15 drivers/net/dsa/mt7530.c | 18 ++++++++++++------
16 1 file changed, 12 insertions(+), 6 deletions(-)
17
18 --- a/drivers/net/dsa/mt7530.c
19 +++ b/drivers/net/dsa/mt7530.c
20 @@ -3295,6 +3295,17 @@ mt7530_probe(struct mdio_device *mdiodev
21 }
22
23 static void
24 +mt7530_remove_common(struct mt7530_priv *priv)
25 +{
26 + if (priv->irq)
27 + mt7530_free_irq(priv);
28 +
29 + dsa_unregister_switch(priv->ds);
30 +
31 + mutex_destroy(&priv->reg_mutex);
32 +}
33 +
34 +static void
35 mt7530_remove(struct mdio_device *mdiodev)
36 {
37 struct mt7530_priv *priv = dev_get_drvdata(&mdiodev->dev);
38 @@ -3313,15 +3324,10 @@ mt7530_remove(struct mdio_device *mdiode
39 dev_err(priv->dev, "Failed to disable io pwr: %d\n",
40 ret);
41
42 - if (priv->irq)
43 - mt7530_free_irq(priv);
44 -
45 - dsa_unregister_switch(priv->ds);
46 + mt7530_remove_common(priv);
47
48 for (i = 0; i < 2; ++i)
49 mtk_pcs_lynxi_destroy(priv->ports[5 + i].sgmii_pcs);
50 -
51 - mutex_destroy(&priv->reg_mutex);
52 }
53
54 static void mt7530_shutdown(struct mdio_device *mdiodev)