aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--arch/arm/plat-orion/common.c2
-rw-r--r--drivers/net/dsa/bcm_sf2.c2
-rw-r--r--drivers/net/dsa/mv88e6060.c13
-rw-r--r--drivers/net/dsa/mv88e6123_61_65.c6
-rw-r--r--drivers/net/dsa/mv88e6131.c6
-rw-r--r--drivers/net/dsa/mv88e6171.c6
-rw-r--r--drivers/net/dsa/mv88e6xxx.c4
-rw-r--r--include/net/dsa.h9
-rw-r--r--net/dsa/dsa.c24
-rw-r--r--net/dsa/slave.c2
10 files changed, 42 insertions, 32 deletions
diff --git a/arch/arm/plat-orion/common.c b/arch/arm/plat-orion/common.c
index 3ec6e8e8d368..f5b00f41c4f6 100644
--- a/arch/arm/plat-orion/common.c
+++ b/arch/arm/plat-orion/common.c
@@ -499,7 +499,7 @@ void __init orion_ge00_switch_init(struct dsa_platform_data *d, int irq)
499 499
500 d->netdev = &orion_ge00.dev; 500 d->netdev = &orion_ge00.dev;
501 for (i = 0; i < d->nr_chips; i++) 501 for (i = 0; i < d->nr_chips; i++)
502 d->chip[i].mii_bus = &orion_ge00_shared.dev; 502 d->chip[i].host_dev = &orion_ge00_shared.dev;
503 orion_switch_device.dev.platform_data = d; 503 orion_switch_device.dev.platform_data = d;
504 504
505 platform_device_register(&orion_switch_device); 505 platform_device_register(&orion_switch_device);
diff --git a/drivers/net/dsa/bcm_sf2.c b/drivers/net/dsa/bcm_sf2.c
index e9918c7f1792..02d7db320d90 100644
--- a/drivers/net/dsa/bcm_sf2.c
+++ b/drivers/net/dsa/bcm_sf2.c
@@ -129,7 +129,7 @@ static int bcm_sf2_sw_get_sset_count(struct dsa_switch *ds)
129 return BCM_SF2_STATS_SIZE; 129 return BCM_SF2_STATS_SIZE;
130} 130}
131 131
132static char *bcm_sf2_sw_probe(struct mii_bus *bus, int sw_addr) 132static char *bcm_sf2_sw_probe(struct device *host_dev, int sw_addr)
133{ 133{
134 return "Broadcom Starfighter 2"; 134 return "Broadcom Starfighter 2";
135} 135}
diff --git a/drivers/net/dsa/mv88e6060.c b/drivers/net/dsa/mv88e6060.c
index d8037c1055ac..776e965dc9f4 100644
--- a/drivers/net/dsa/mv88e6060.c
+++ b/drivers/net/dsa/mv88e6060.c
@@ -21,7 +21,8 @@
21 21
22static int reg_read(struct dsa_switch *ds, int addr, int reg) 22static int reg_read(struct dsa_switch *ds, int addr, int reg)
23{ 23{
24 return mdiobus_read(ds->master_mii_bus, ds->pd->sw_addr + addr, reg); 24 return mdiobus_read(to_mii_bus(ds->master_dev),
25 ds->pd->sw_addr + addr, reg);
25} 26}
26 27
27#define REG_READ(addr, reg) \ 28#define REG_READ(addr, reg) \
@@ -37,8 +38,8 @@ static int reg_read(struct dsa_switch *ds, int addr, int reg)
37 38
38static int reg_write(struct dsa_switch *ds, int addr, int reg, u16 val) 39static int reg_write(struct dsa_switch *ds, int addr, int reg, u16 val)
39{ 40{
40 return mdiobus_write(ds->master_mii_bus, ds->pd->sw_addr + addr, 41 return mdiobus_write(to_mii_bus(ds->master_dev),
41 reg, val); 42 ds->pd->sw_addr + addr, reg, val);
42} 43}
43 44
44#define REG_WRITE(addr, reg, val) \ 45#define REG_WRITE(addr, reg, val) \
@@ -50,10 +51,14 @@ static int reg_write(struct dsa_switch *ds, int addr, int reg, u16 val)
50 return __ret; \ 51 return __ret; \
51 }) 52 })
52 53
53static char *mv88e6060_probe(struct mii_bus *bus, int sw_addr) 54static char *mv88e6060_probe(struct device *host_dev, int sw_addr)
54{ 55{
56 struct mii_bus *bus = dsa_host_dev_to_mii_bus(host_dev);
55 int ret; 57 int ret;
56 58
59 if (bus == NULL)
60 return NULL;
61
57 ret = mdiobus_read(bus, sw_addr + REG_PORT(0), 0x03); 62 ret = mdiobus_read(bus, sw_addr + REG_PORT(0), 0x03);
58 if (ret >= 0) { 63 if (ret >= 0) {
59 ret &= 0xfff0; 64 ret &= 0xfff0;
diff --git a/drivers/net/dsa/mv88e6123_61_65.c b/drivers/net/dsa/mv88e6123_61_65.c
index 975774f338c2..a332c53ff955 100644
--- a/drivers/net/dsa/mv88e6123_61_65.c
+++ b/drivers/net/dsa/mv88e6123_61_65.c
@@ -17,10 +17,14 @@
17#include <net/dsa.h> 17#include <net/dsa.h>
18#include "mv88e6xxx.h" 18#include "mv88e6xxx.h"
19 19
20static char *mv88e6123_61_65_probe(struct mii_bus *bus, int sw_addr) 20static char *mv88e6123_61_65_probe(struct device *host_dev, int sw_addr)
21{ 21{
22 struct mii_bus *bus = dsa_host_dev_to_mii_bus(host_dev);
22 int ret; 23 int ret;
23 24
25 if (bus == NULL)
26 return NULL;
27
24 ret = __mv88e6xxx_reg_read(bus, sw_addr, REG_PORT(0), 0x03); 28 ret = __mv88e6xxx_reg_read(bus, sw_addr, REG_PORT(0), 0x03);
25 if (ret >= 0) { 29 if (ret >= 0) {
26 if (ret == 0x1212) 30 if (ret == 0x1212)
diff --git a/drivers/net/dsa/mv88e6131.c b/drivers/net/dsa/mv88e6131.c
index 35541f2ceca3..244c735014fa 100644
--- a/drivers/net/dsa/mv88e6131.c
+++ b/drivers/net/dsa/mv88e6131.c
@@ -22,10 +22,14 @@
22#define ID_6095 0x0950 22#define ID_6095 0x0950
23#define ID_6131 0x1060 23#define ID_6131 0x1060
24 24
25static char *mv88e6131_probe(struct mii_bus *bus, int sw_addr) 25static char *mv88e6131_probe(struct device *host_dev, int sw_addr)
26{ 26{
27 struct mii_bus *bus = dsa_host_dev_to_mii_bus(host_dev);
27 int ret; 28 int ret;
28 29
30 if (bus == NULL)
31 return NULL;
32
29 ret = __mv88e6xxx_reg_read(bus, sw_addr, REG_PORT(0), 0x03); 33 ret = __mv88e6xxx_reg_read(bus, sw_addr, REG_PORT(0), 0x03);
30 if (ret >= 0) { 34 if (ret >= 0) {
31 ret &= 0xfff0; 35 ret &= 0xfff0;
diff --git a/drivers/net/dsa/mv88e6171.c b/drivers/net/dsa/mv88e6171.c
index 03a70069a8c6..6365e30138af 100644
--- a/drivers/net/dsa/mv88e6171.c
+++ b/drivers/net/dsa/mv88e6171.c
@@ -17,10 +17,14 @@
17#include <net/dsa.h> 17#include <net/dsa.h>
18#include "mv88e6xxx.h" 18#include "mv88e6xxx.h"
19 19
20static char *mv88e6171_probe(struct mii_bus *bus, int sw_addr) 20static char *mv88e6171_probe(struct device *host_dev, int sw_addr)
21{ 21{
22 struct mii_bus *bus = dsa_host_dev_to_mii_bus(host_dev);
22 int ret; 23 int ret;
23 24
25 if (bus == NULL)
26 return NULL;
27
24 ret = __mv88e6xxx_reg_read(bus, sw_addr, REG_PORT(0), 0x03); 28 ret = __mv88e6xxx_reg_read(bus, sw_addr, REG_PORT(0), 0x03);
25 if (ret >= 0) { 29 if (ret >= 0) {
26 if ((ret & 0xfff0) == 0x1710) 30 if ((ret & 0xfff0) == 0x1710)
diff --git a/drivers/net/dsa/mv88e6xxx.c b/drivers/net/dsa/mv88e6xxx.c
index 901d2a9704ef..d6f6428b27dc 100644
--- a/drivers/net/dsa/mv88e6xxx.c
+++ b/drivers/net/dsa/mv88e6xxx.c
@@ -78,7 +78,7 @@ int mv88e6xxx_reg_read(struct dsa_switch *ds, int addr, int reg)
78 int ret; 78 int ret;
79 79
80 mutex_lock(&ps->smi_mutex); 80 mutex_lock(&ps->smi_mutex);
81 ret = __mv88e6xxx_reg_read(ds->master_mii_bus, 81 ret = __mv88e6xxx_reg_read(to_mii_bus(ds->master_dev),
82 ds->pd->sw_addr, addr, reg); 82 ds->pd->sw_addr, addr, reg);
83 mutex_unlock(&ps->smi_mutex); 83 mutex_unlock(&ps->smi_mutex);
84 84
@@ -122,7 +122,7 @@ int mv88e6xxx_reg_write(struct dsa_switch *ds, int addr, int reg, u16 val)
122 int ret; 122 int ret;
123 123
124 mutex_lock(&ps->smi_mutex); 124 mutex_lock(&ps->smi_mutex);
125 ret = __mv88e6xxx_reg_write(ds->master_mii_bus, 125 ret = __mv88e6xxx_reg_write(to_mii_bus(ds->master_dev),
126 ds->pd->sw_addr, addr, reg, val); 126 ds->pd->sw_addr, addr, reg, val);
127 mutex_unlock(&ps->smi_mutex); 127 mutex_unlock(&ps->smi_mutex);
128 128
diff --git a/include/net/dsa.h b/include/net/dsa.h
index a55c4e6a4f0f..c779e9bba1b3 100644
--- a/include/net/dsa.h
+++ b/include/net/dsa.h
@@ -34,7 +34,7 @@ struct dsa_chip_data {
34 /* 34 /*
35 * How to access the switch configuration registers. 35 * How to access the switch configuration registers.
36 */ 36 */
37 struct device *mii_bus; 37 struct device *host_dev;
38 int sw_addr; 38 int sw_addr;
39 39
40 /* Device tree node pointer for this specific switch chip 40 /* Device tree node pointer for this specific switch chip
@@ -134,9 +134,9 @@ struct dsa_switch {
134 struct dsa_switch_driver *drv; 134 struct dsa_switch_driver *drv;
135 135
136 /* 136 /*
137 * Reference to mii bus to use. 137 * Reference to host device to use.
138 */ 138 */
139 struct mii_bus *master_mii_bus; 139 struct device *master_dev;
140 140
141 /* 141 /*
142 * Slave mii_bus and devices for the individual ports. 142 * Slave mii_bus and devices for the individual ports.
@@ -178,7 +178,7 @@ struct dsa_switch_driver {
178 /* 178 /*
179 * Probing and setup. 179 * Probing and setup.
180 */ 180 */
181 char *(*probe)(struct mii_bus *bus, int sw_addr); 181 char *(*probe)(struct device *host_dev, int sw_addr);
182 int (*setup)(struct dsa_switch *ds); 182 int (*setup)(struct dsa_switch *ds);
183 int (*set_addr)(struct dsa_switch *ds, u8 *addr); 183 int (*set_addr)(struct dsa_switch *ds, u8 *addr);
184 184
@@ -213,6 +213,7 @@ struct dsa_switch_driver {
213 213
214void register_switch_driver(struct dsa_switch_driver *type); 214void register_switch_driver(struct dsa_switch_driver *type);
215void unregister_switch_driver(struct dsa_switch_driver *type); 215void unregister_switch_driver(struct dsa_switch_driver *type);
216struct mii_bus *dsa_host_dev_to_mii_bus(struct device *dev);
216 217
217static inline void *ds_to_priv(struct dsa_switch *ds) 218static inline void *ds_to_priv(struct dsa_switch *ds)
218{ 219{
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