aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/dsa/mv88e6171.c
diff options
context:
space:
mode:
authorAndrew Lunn <andrew@lunn.ch>2016-04-12 20:40:40 -0400
committerDavid S. Miller <davem@davemloft.net>2016-04-13 18:15:23 -0400
commit7543a6d5359e371ce9434955dbe6a79f548ea321 (patch)
tree84401371308e64ff4ca525e410619e5e223e5112 /drivers/net/dsa/mv88e6171.c
parentbbb8d793994c894eef2a48a35fac6de3c6b4fa93 (diff)
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>
Diffstat (limited to 'drivers/net/dsa/mv88e6171.c')
-rw-r--r--drivers/net/dsa/mv88e6171.c17
1 files changed, 14 insertions, 3 deletions
diff --git a/drivers/net/dsa/mv88e6171.c b/drivers/net/dsa/mv88e6171.c
index fb35d3ac1644..15200928cecc 100644
--- a/drivers/net/dsa/mv88e6171.c
+++ b/drivers/net/dsa/mv88e6171.c
@@ -25,10 +25,20 @@ static const struct mv88e6xxx_switch_id mv88e6171_table[] = {
25}; 25};
26 26
27static char *mv88e6171_probe(struct device *dsa_dev, struct device *host_dev, 27static char *mv88e6171_probe(struct device *dsa_dev, struct device *host_dev,
28 int sw_addr) 28 int sw_addr, void **priv)
29{ 29{
30 return mv88e6xxx_lookup_name(host_dev, sw_addr, mv88e6171_table, 30 struct mv88e6xxx_priv_state *ps;
31 char *name;
32
33 name = mv88e6xxx_lookup_name(host_dev, sw_addr, mv88e6171_table,
31 ARRAY_SIZE(mv88e6171_table)); 34 ARRAY_SIZE(mv88e6171_table));
35 if (name) {
36 ps = devm_kzalloc(dsa_dev, sizeof(*ps), GFP_KERNEL);
37 if (!ps)
38 return NULL;
39 *priv = ps;
40 }
41 return name;
32} 42}
33 43
34static int mv88e6171_setup_global(struct dsa_switch *ds) 44static int mv88e6171_setup_global(struct dsa_switch *ds)
@@ -70,6 +80,8 @@ static int mv88e6171_setup(struct dsa_switch *ds)
70 struct mv88e6xxx_priv_state *ps = ds_to_priv(ds); 80 struct mv88e6xxx_priv_state *ps = ds_to_priv(ds);
71 int ret; 81 int ret;
72 82
83 ps->ds = ds;
84
73 ret = mv88e6xxx_setup_common(ds); 85 ret = mv88e6xxx_setup_common(ds);
74 if (ret < 0) 86 if (ret < 0)
75 return ret; 87 return ret;
@@ -89,7 +101,6 @@ static int mv88e6171_setup(struct dsa_switch *ds)
89 101
90struct dsa_switch_driver mv88e6171_switch_driver = { 102struct dsa_switch_driver mv88e6171_switch_driver = {
91 .tag_protocol = DSA_TAG_PROTO_EDSA, 103 .tag_protocol = DSA_TAG_PROTO_EDSA,
92 .priv_size = sizeof(struct mv88e6xxx_priv_state),
93 .probe = mv88e6171_probe, 104 .probe = mv88e6171_probe,
94 .setup = mv88e6171_setup, 105 .setup = mv88e6171_setup,
95 .set_addr = mv88e6xxx_set_addr_indirect, 106 .set_addr = mv88e6xxx_set_addr_indirect,