kernel: bump 4.14 to 4.14.48 for 18.06
[openwrt/openwrt.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 --- a/drivers/net/dsa/mt7530.c
12 +++ b/drivers/net/dsa/mt7530.c
13 @@ -1049,10 +1049,10 @@ static const struct dsa_switch_ops mt753
14 };
15
16 static int
17 -mt7530_probe(struct mdio_device *mdiodev)
18 +mt7530_probe(struct platform_device *mdiodev)
19 {
20 struct mt7530_priv *priv;
21 - struct device_node *dn;
22 + struct device_node *dn, *mdio;
23
24 dn = mdiodev->dev.of_node;
25
26 @@ -1100,7 +1100,12 @@ mt7530_probe(struct mdio_device *mdiodev
27 }
28 }
29
30 - priv->bus = mdiodev->bus;
31 + mdio = of_parse_phandle(dn, "dsa,mii-bus", 0);
32 + if (!mdio)
33 + return -EINVAL;
34 + priv->bus = of_mdio_find_bus(mdio);
35 + if (!priv->bus)
36 + return -EPROBE_DEFER;
37 priv->dev = &mdiodev->dev;
38 priv->ds->priv = priv;
39 priv->ds->ops = &mt7530_switch_ops;
40 @@ -1110,8 +1115,8 @@ mt7530_probe(struct mdio_device *mdiodev
41 return dsa_register_switch(priv->ds);
42 }
43
44 -static void
45 -mt7530_remove(struct mdio_device *mdiodev)
46 +static int
47 +mt7530_remove(struct platform_device *mdiodev)
48 {
49 struct mt7530_priv *priv = dev_get_drvdata(&mdiodev->dev);
50 int ret = 0;
51 @@ -1128,6 +1133,8 @@ mt7530_remove(struct mdio_device *mdiode
52
53 dsa_unregister_switch(priv->ds);
54 mutex_destroy(&priv->reg_mutex);
55 +
56 + return 0;
57 }
58
59 static const struct of_device_id mt7530_of_match[] = {
60 @@ -1136,16 +1143,16 @@ static const struct of_device_id mt7530_
61 };
62 MODULE_DEVICE_TABLE(of, mt7530_of_match);
63
64 -static struct mdio_driver mt7530_mdio_driver = {
65 +static struct platform_driver mtk_mt7530_driver = {
66 .probe = mt7530_probe,
67 .remove = mt7530_remove,
68 - .mdiodrv.driver = {
69 + .driver = {
70 .name = "mt7530",
71 .of_match_table = mt7530_of_match,
72 },
73 };
74 +module_platform_driver(mtk_mt7530_driver);
75
76 -mdio_module_driver(mt7530_mdio_driver);
77
78 MODULE_AUTHOR("Sean Wang <sean.wang@mediatek.com>");
79 MODULE_DESCRIPTION("Driver for Mediatek MT7530 Switch");