summaryrefslogtreecommitdiff
path: root/net
diff options
context:
space:
mode:
authorDavid S. Miller <davem@davemloft.net>2016-04-13 18:15:24 -0400
committerDavid S. Miller <davem@davemloft.net>2016-04-13 18:15:24 -0400
commit99717bdfdbeaaf387ba6ecbf7eba7fbb7a47e50a (patch)
tree502d26a5f6e655a657f4280b98ac257d83adeaf4 /net
parent71bbe25d01fa4f35551ff7bffc3e03ddd3e960cd (diff)
parentc156913b5d62cbaa0e3be29409de562b7d2e006e (diff)
Merge branch 'dsa-refactoring-set-1'
Andrew Lunn says: ==================== DSA refactoring: set 1 There has been a long running effort to refractor DSA probing to make the switches true linux devices. Here are a small collection of patches moving in this direction. Most have been seen before. We take a little step forward by passing the dsa device point to the driver, thus allowing it to perform resource allocations using the normal mechanisms. This device structure will later be replaced by the devices own device structure. Future patches will add a true driver probe function, so we rename the current probe function, cleaning up the namespace. phys_port_mask continually confuses me, thinking it is about PHYs. But it is actually about ports enabled to the outside world. So rename it to enabled_port_mask. Lots more patches yet to follow, this is just doing some ground work. v2: enabled_port_mask instread of user_port_masks Added Tested-by's and Reviewed-by. ==================== Tested-by: Florian Fainelli <f.fainelli@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net')
-rw-r--r--net/dsa/dsa.c19
1 files changed, 11 insertions, 8 deletions
diff --git a/net/dsa/dsa.c b/net/dsa/dsa.c
index c28c47463b7e..60ea98481806 100644
--- a/net/dsa/dsa.c
+++ b/net/dsa/dsa.c
@@ -51,7 +51,8 @@ void unregister_switch_driver(struct dsa_switch_driver *drv)
EXPORT_SYMBOL_GPL(unregister_switch_driver);
static struct dsa_switch_driver *
-dsa_switch_probe(struct device *host_dev, int sw_addr, char **_name)
+dsa_switch_probe(struct device *parent, struct device *host_dev, int sw_addr,
+ char **_name, void **priv)
{
struct dsa_switch_driver *ret;
struct list_head *list;
@@ -66,7 +67,7 @@ dsa_switch_probe(struct device *host_dev, int sw_addr, char **_name)
drv = list_entry(list, struct dsa_switch_driver, list);
- name = drv->probe(host_dev, sw_addr);
+ name = drv->probe(parent, host_dev, sw_addr, priv);
if (name != NULL) {
ret = drv;
break;
@@ -245,7 +246,7 @@ static int dsa_switch_setup_one(struct dsa_switch *ds, struct device *parent)
} else if (!strcmp(name, "dsa")) {
ds->dsa_port_mask |= 1 << i;
} else {
- ds->phys_port_mask |= 1 << i;
+ ds->enabled_port_mask |= 1 << i;
}
valid_name_found = true;
}
@@ -258,7 +259,7 @@ static int dsa_switch_setup_one(struct dsa_switch *ds, struct device *parent)
/* Make the built-in MII bus mask match the number of ports,
* switch drivers can override this later
*/
- ds->phys_mii_mask = ds->phys_port_mask;
+ ds->phys_mii_mask = ds->enabled_port_mask;
/*
* If the CPU connects to this switch, set the switch tree
@@ -324,7 +325,7 @@ static int dsa_switch_setup_one(struct dsa_switch *ds, struct device *parent)
* Create network devices for physical switch ports.
*/
for (i = 0; i < DSA_MAX_PORTS; i++) {
- if (!(ds->phys_port_mask & (1 << i)))
+ if (!(ds->enabled_port_mask & (1 << i)))
continue;
ret = dsa_slave_create(ds, parent, i, pd->port_names[i]);
@@ -383,11 +384,12 @@ dsa_switch_setup(struct dsa_switch_tree *dst, int index,
struct dsa_switch *ds;
int ret;
char *name;
+ void *priv;
/*
* Probe for switch model.
*/
- drv = dsa_switch_probe(host_dev, pd->sw_addr, &name);
+ drv = dsa_switch_probe(parent, host_dev, pd->sw_addr, &name, &priv);
if (drv == NULL) {
netdev_err(dst->master_netdev, "[%d]: could not detect attached switch\n",
index);
@@ -400,7 +402,7 @@ dsa_switch_setup(struct dsa_switch_tree *dst, int index,
/*
* Allocate and initialise switch state.
*/
- ds = devm_kzalloc(parent, sizeof(*ds) + drv->priv_size, GFP_KERNEL);
+ ds = devm_kzalloc(parent, sizeof(*ds), GFP_KERNEL);
if (ds == NULL)
return ERR_PTR(-ENOMEM);
@@ -408,6 +410,7 @@ dsa_switch_setup(struct dsa_switch_tree *dst, int index,
ds->index = index;
ds->pd = pd;
ds->drv = drv;
+ ds->priv = priv;
ds->tag_protocol = drv->tag_protocol;
ds->master_dev = host_dev;
@@ -432,7 +435,7 @@ static void dsa_switch_destroy(struct dsa_switch *ds)
/* Destroy network devices for physical switch ports. */
for (port = 0; port < DSA_MAX_PORTS; port++) {
- if (!(ds->phys_port_mask & (1 << port)))
+ if (!(ds->enabled_port_mask & (1 << port)))
continue;
if (!ds->ports[port])