mediatek: bump to v4.14
[openwrt/staging/kaloz.git] / target / linux / mediatek / patches-4.14 / 0045-net-dsa-mediatek-turn-into-platform-driver.patch
1 From 1e33784f665cb95c2af5481d3e776d2d3099921b Mon Sep 17 00:00:00 2001
2 From: John Crispin <john@phrozen.org>
3 Date: Thu, 10 Aug 2017 15:57:17 +0200
4 Subject: [PATCH 45/57] net: dsa: mediatek: turn into platform driver
5
6 Signed-off-by: John Crispin <john@phrozen.org>
7 ---
8 drivers/net/dsa/mt7530.c | 23 +++++++++++++++--------
9 1 file changed, 15 insertions(+), 8 deletions(-)
10
11 Index: linux-4.14.12/drivers/net/dsa/mt7530.c
12 ===================================================================
13 --- linux-4.14.12.orig/drivers/net/dsa/mt7530.c
14 +++ linux-4.14.12/drivers/net/dsa/mt7530.c
15 @@ -1049,10 +1049,10 @@ static const struct dsa_switch_ops mt753
16 };
17
18 static int
19 -mt7530_probe(struct mdio_device *mdiodev)
20 +mt7530_probe(struct platform_device *mdiodev)
21 {
22 struct mt7530_priv *priv;
23 - struct device_node *dn;
24 + struct device_node *dn, *mdio;
25
26 dn = mdiodev->dev.of_node;
27
28 @@ -1100,7 +1100,12 @@ mt7530_probe(struct mdio_device *mdiodev
29 }
30 }
31
32 - priv->bus = mdiodev->bus;
33 + mdio = of_parse_phandle(dn, "dsa,mii-bus", 0);
34 + if (!mdio)
35 + return -EINVAL;
36 + priv->bus = of_mdio_find_bus(mdio);
37 + if (!priv->bus)
38 + return -EPROBE_DEFER;
39 priv->dev = &mdiodev->dev;
40 priv->ds->priv = priv;
41 priv->ds->ops = &mt7530_switch_ops;
42 @@ -1110,8 +1115,8 @@ mt7530_probe(struct mdio_device *mdiodev
43 return dsa_register_switch(priv->ds);
44 }
45
46 -static void
47 -mt7530_remove(struct mdio_device *mdiodev)
48 +static int
49 +mt7530_remove(struct platform_device *mdiodev)
50 {
51 struct mt7530_priv *priv = dev_get_drvdata(&mdiodev->dev);
52 int ret = 0;
53 @@ -1128,6 +1133,8 @@ mt7530_remove(struct mdio_device *mdiode
54
55 dsa_unregister_switch(priv->ds);
56 mutex_destroy(&priv->reg_mutex);
57 +
58 + return 0;
59 }
60
61 static const struct of_device_id mt7530_of_match[] = {
62 @@ -1135,16 +1142,16 @@ static const struct of_device_id mt7530_
63 { /* sentinel */ },
64 };
65
66 -static struct mdio_driver mt7530_mdio_driver = {
67 +static struct platform_driver mtk_mt7530_driver = {
68 .probe = mt7530_probe,
69 .remove = mt7530_remove,
70 - .mdiodrv.driver = {
71 + .driver = {
72 .name = "mt7530",
73 .of_match_table = mt7530_of_match,
74 },
75 };
76 +module_platform_driver(mtk_mt7530_driver);
77
78 -mdio_module_driver(mt7530_mdio_driver);
79
80 MODULE_AUTHOR("Sean Wang <sean.wang@mediatek.com>");
81 MODULE_DESCRIPTION("Driver for Mediatek MT7530 Switch");