aboutsummaryrefslogtreecommitdiffstats
path: root/net/dsa
diff options
context:
space:
mode:
authorAlexander Duyck <alexander.h.duyck@intel.com>2014-09-15 13:00:27 -0400
committerDavid S. Miller <davem@davemloft.net>2014-09-15 17:24:20 -0400
commitb4d2394d01bc642e95b2cba956d908423c1bef77 (patch)
tree348e36396eda758e021a8473b330c19cd571e76f /net/dsa
parent5075314e4e4b559cc37675ad8a721a89bccd6284 (diff)
dsa: Replace mii_bus with a generic host device
This change makes it so that instead of passing and storing a mii_bus we instead pass and store a host_dev. From there we can test to determine the exact type of device, and can verify it is the correct device for our switch. So for example it would be possible to pass a device pointer from a pci_dev and instead of checking for a PHY ID we could check for a vendor and/or device ID. Signed-off-by: Alexander Duyck <alexander.h.duyck@intel.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/dsa')
-rw-r--r--net/dsa/dsa.c24
-rw-r--r--net/dsa/slave.c2
2 files changed, 9 insertions, 17 deletions
diff --git a/net/dsa/dsa.c b/net/dsa/dsa.c
index 1df0a7cf1e9e..b34d6978d773 100644
--- a/net/dsa/dsa.c
+++ b/net/dsa/dsa.c
@@ -43,7 +43,7 @@ void unregister_switch_driver(struct dsa_switch_driver *drv)
43EXPORT_SYMBOL_GPL(unregister_switch_driver); 43EXPORT_SYMBOL_GPL(unregister_switch_driver);
44 44
45static struct dsa_switch_driver * 45static struct dsa_switch_driver *
46dsa_switch_probe(struct mii_bus *bus, int sw_addr, char **_name) 46dsa_switch_probe(struct device *host_dev, int sw_addr, char **_name)
47{ 47{
48 struct dsa_switch_driver *ret; 48 struct dsa_switch_driver *ret;
49 struct list_head *list; 49 struct list_head *list;
@@ -58,7 +58,7 @@ dsa_switch_probe(struct mii_bus *bus, int sw_addr, char **_name)
58 58
59 drv = list_entry(list, struct dsa_switch_driver, list); 59 drv = list_entry(list, struct dsa_switch_driver, list);
60 60
61 name = drv->probe(bus, sw_addr); 61 name = drv->probe(host_dev, sw_addr);
62 if (name != NULL) { 62 if (name != NULL) {
63 ret = drv; 63 ret = drv;
64 break; 64 break;
@@ -75,7 +75,7 @@ dsa_switch_probe(struct mii_bus *bus, int sw_addr, char **_name)
75/* basic switch operations **************************************************/ 75/* basic switch operations **************************************************/
76static struct dsa_switch * 76static struct dsa_switch *
77dsa_switch_setup(struct dsa_switch_tree *dst, int index, 77dsa_switch_setup(struct dsa_switch_tree *dst, int index,
78 struct device *parent, struct mii_bus *bus) 78 struct device *parent, struct device *host_dev)
79{ 79{
80 struct dsa_chip_data *pd = dst->pd->chip + index; 80 struct dsa_chip_data *pd = dst->pd->chip + index;
81 struct dsa_switch_driver *drv; 81 struct dsa_switch_driver *drv;
@@ -88,7 +88,7 @@ dsa_switch_setup(struct dsa_switch_tree *dst, int index,
88 /* 88 /*
89 * Probe for switch model. 89 * Probe for switch model.
90 */ 90 */
91 drv = dsa_switch_probe(bus, pd->sw_addr, &name); 91 drv = dsa_switch_probe(host_dev, pd->sw_addr, &name);
92 if (drv == NULL) { 92 if (drv == NULL) {
93 printk(KERN_ERR "%s[%d]: could not detect attached switch\n", 93 printk(KERN_ERR "%s[%d]: could not detect attached switch\n",
94 dst->master_netdev->name, index); 94 dst->master_netdev->name, index);
@@ -109,8 +109,7 @@ dsa_switch_setup(struct dsa_switch_tree *dst, int index,
109 ds->index = index; 109 ds->index = index;
110 ds->pd = dst->pd->chip + index; 110 ds->pd = dst->pd->chip + index;
111 ds->drv = drv; 111 ds->drv = drv;
112 ds->master_mii_bus = bus; 112 ds->master_dev = host_dev;
113
114 113
115 /* 114 /*
116 * Validate supplied switch configuration. 115 * Validate supplied switch configuration.
@@ -285,7 +284,7 @@ static struct device *dev_find_class(struct device *parent, char *class)
285 return device_find_child(parent, class, dev_is_class); 284 return device_find_child(parent, class, dev_is_class);
286} 285}
287 286
288static struct mii_bus *dev_to_mii_bus(struct device *dev) 287struct mii_bus *dsa_host_dev_to_mii_bus(struct device *dev)
289{ 288{
290 struct device *d; 289 struct device *d;
291 290
@@ -301,6 +300,7 @@ static struct mii_bus *dev_to_mii_bus(struct device *dev)
301 300
302 return NULL; 301 return NULL;
303} 302}
303EXPORT_SYMBOL_GPL(dsa_host_dev_to_mii_bus);
304 304
305static struct net_device *dev_to_net_device(struct device *dev) 305static struct net_device *dev_to_net_device(struct device *dev)
306{ 306{
@@ -566,17 +566,9 @@ static int dsa_probe(struct platform_device *pdev)
566 dst->cpu_port = -1; 566 dst->cpu_port = -1;
567 567
568 for (i = 0; i < pd->nr_chips; i++) { 568 for (i = 0; i < pd->nr_chips; i++) {
569 struct mii_bus *bus;
570 struct dsa_switch *ds; 569 struct dsa_switch *ds;
571 570
572 bus = dev_to_mii_bus(pd->chip[i].mii_bus); 571 ds = dsa_switch_setup(dst, i, &pdev->dev, pd->chip[i].host_dev);
573 if (bus == NULL) {
574 printk(KERN_ERR "%s[%d]: no mii bus found for "
575 "dsa switch\n", dev->name, i);
576 continue;
577 }
578
579 ds = dsa_switch_setup(dst, i, &pdev->dev, bus);
580 if (IS_ERR(ds)) { 572 if (IS_ERR(ds)) {
581 printk(KERN_ERR "%s[%d]: couldn't create dsa switch " 573 printk(KERN_ERR "%s[%d]: couldn't create dsa switch "
582 "instance (error %ld)\n", dev->name, i, 574 "instance (error %ld)\n", dev->name, i,
diff --git a/net/dsa/slave.c b/net/dsa/slave.c
index e38a331111c0..90c9689ed362 100644
--- a/net/dsa/slave.c
+++ b/net/dsa/slave.c
@@ -44,7 +44,7 @@ void dsa_slave_mii_bus_init(struct dsa_switch *ds)
44 ds->slave_mii_bus->write = dsa_slave_phy_write; 44 ds->slave_mii_bus->write = dsa_slave_phy_write;
45 snprintf(ds->slave_mii_bus->id, MII_BUS_ID_SIZE, "dsa-%d:%.2x", 45 snprintf(ds->slave_mii_bus->id, MII_BUS_ID_SIZE, "dsa-%d:%.2x",
46 ds->index, ds->pd->sw_addr); 46 ds->index, ds->pd->sw_addr);
47 ds->slave_mii_bus->parent = &ds->master_mii_bus->dev; 47 ds->slave_mii_bus->parent = ds->master_dev;
48} 48}
49 49
50 50