2017-08-18 16:11:52 +00:00
|
|
|
From 1e33784f665cb95c2af5481d3e776d2d3099921b Mon Sep 17 00:00:00 2001
|
|
|
|
From: John Crispin <john@phrozen.org>
|
|
|
|
Date: Thu, 10 Aug 2017 15:57:17 +0200
|
|
|
|
Subject: [PATCH 45/57] net: dsa: mediatek: turn into platform driver
|
|
|
|
|
|
|
|
Signed-off-by: John Crispin <john@phrozen.org>
|
|
|
|
---
|
|
|
|
drivers/net/dsa/mt7530.c | 23 +++++++++++++++--------
|
|
|
|
1 file changed, 15 insertions(+), 8 deletions(-)
|
|
|
|
|
2018-01-08 14:06:24 +00:00
|
|
|
Index: linux-4.14.12/drivers/net/dsa/mt7530.c
|
|
|
|
===================================================================
|
|
|
|
--- linux-4.14.12.orig/drivers/net/dsa/mt7530.c
|
|
|
|
+++ linux-4.14.12/drivers/net/dsa/mt7530.c
|
|
|
|
@@ -1049,10 +1049,10 @@ static const struct dsa_switch_ops mt753
|
2017-08-18 16:11:52 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static int
|
|
|
|
-mt7530_probe(struct mdio_device *mdiodev)
|
|
|
|
+mt7530_probe(struct platform_device *mdiodev)
|
|
|
|
{
|
|
|
|
struct mt7530_priv *priv;
|
|
|
|
- struct device_node *dn;
|
|
|
|
+ struct device_node *dn, *mdio;
|
|
|
|
|
|
|
|
dn = mdiodev->dev.of_node;
|
|
|
|
|
2018-01-08 14:06:24 +00:00
|
|
|
@@ -1100,7 +1100,12 @@ mt7530_probe(struct mdio_device *mdiodev
|
2017-08-18 16:11:52 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
- priv->bus = mdiodev->bus;
|
|
|
|
+ mdio = of_parse_phandle(dn, "dsa,mii-bus", 0);
|
|
|
|
+ if (!mdio)
|
|
|
|
+ return -EINVAL;
|
|
|
|
+ priv->bus = of_mdio_find_bus(mdio);
|
|
|
|
+ if (!priv->bus)
|
|
|
|
+ return -EPROBE_DEFER;
|
|
|
|
priv->dev = &mdiodev->dev;
|
|
|
|
priv->ds->priv = priv;
|
2018-01-08 14:06:24 +00:00
|
|
|
priv->ds->ops = &mt7530_switch_ops;
|
|
|
|
@@ -1110,8 +1115,8 @@ mt7530_probe(struct mdio_device *mdiodev
|
|
|
|
return dsa_register_switch(priv->ds);
|
2017-08-18 16:11:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
-static void
|
|
|
|
-mt7530_remove(struct mdio_device *mdiodev)
|
|
|
|
+static int
|
|
|
|
+mt7530_remove(struct platform_device *mdiodev)
|
|
|
|
{
|
|
|
|
struct mt7530_priv *priv = dev_get_drvdata(&mdiodev->dev);
|
|
|
|
int ret = 0;
|
2018-01-08 14:06:24 +00:00
|
|
|
@@ -1128,6 +1133,8 @@ mt7530_remove(struct mdio_device *mdiode
|
2017-08-18 16:11:52 +00:00
|
|
|
|
|
|
|
dsa_unregister_switch(priv->ds);
|
|
|
|
mutex_destroy(&priv->reg_mutex);
|
|
|
|
+
|
|
|
|
+ return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const struct of_device_id mt7530_of_match[] = {
|
2018-01-08 14:06:24 +00:00
|
|
|
@@ -1135,16 +1142,16 @@ static const struct of_device_id mt7530_
|
2017-08-18 16:11:52 +00:00
|
|
|
{ /* sentinel */ },
|
|
|
|
};
|
|
|
|
|
|
|
|
-static struct mdio_driver mt7530_mdio_driver = {
|
|
|
|
+static struct platform_driver mtk_mt7530_driver = {
|
|
|
|
.probe = mt7530_probe,
|
|
|
|
.remove = mt7530_remove,
|
|
|
|
- .mdiodrv.driver = {
|
|
|
|
+ .driver = {
|
|
|
|
.name = "mt7530",
|
|
|
|
.of_match_table = mt7530_of_match,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
+module_platform_driver(mtk_mt7530_driver);
|
|
|
|
|
|
|
|
-mdio_module_driver(mt7530_mdio_driver);
|
|
|
|
|
|
|
|
MODULE_AUTHOR("Sean Wang <sean.wang@mediatek.com>");
|
|
|
|
MODULE_DESCRIPTION("Driver for Mediatek MT7530 Switch");
|