2881365ec77d7bb2ba22dcb1f3c3c6b61444c6b9
[openwrt/staging/blogic.git] /
1 From 720d736351761574af02ed093658ab60de60576c 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 12/16] 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 @@ -3253,6 +3253,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 @@ -3271,16 +3282,11 @@ 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 dev_set_drvdata(&mdiodev->dev, NULL);
54 }
55