net: dsa: Have the switch driver allocate there own private memory

Now the switch devices have a dev pointer, make use of it for allocating
the drivers private data structures using a devm_kzalloc().

Signed-off-by: Andrew Lunn <andrew@lunn.ch>
Acked-by: Florian Fainelli <f.fainelli@gmail.com>
Tested-by: Vivien Didelot <vivien.didelot@savoirfairelinux.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
Andrew Lunn
2016-04-13 02:40:40 +02:00
committed by David S. Miller
parent bbb8d79399
commit 7543a6d535
10 changed files with 86 additions and 22 deletions
+5 -3
View File
@@ -52,7 +52,7 @@ EXPORT_SYMBOL_GPL(unregister_switch_driver);
static struct dsa_switch_driver *
dsa_switch_probe(struct device *parent, struct device *host_dev, int sw_addr,
char **_name)
char **_name, void **priv)
{
struct dsa_switch_driver *ret;
struct list_head *list;
@@ -67,7 +67,7 @@ dsa_switch_probe(struct device *parent, struct device *host_dev, int sw_addr,
drv = list_entry(list, struct dsa_switch_driver, list);
name = drv->probe(parent, host_dev, sw_addr);
name = drv->probe(parent, host_dev, sw_addr, priv);
if (name != NULL) {
ret = drv;
break;
@@ -384,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(parent, 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);
@@ -409,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;