diff options
author | Andrew Lunn <andrew@lunn.ch> | 2016-04-12 20:40:39 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2016-04-13 18:15:22 -0400 |
commit | bbb8d793994c894eef2a48a35fac6de3c6b4fa93 (patch) | |
tree | b77344abffc2f441f5a2a17f6a8852df63519e06 | |
parent | 71bbe25d01fa4f35551ff7bffc3e03ddd3e960cd (diff) |
net: dsa: Pass the dsa device to the switch drivers
By passing a device structure to the switch devices, it allows them
to use devm_* methods for resource management.
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>
-rw-r--r-- | drivers/net/dsa/bcm_sf2.c | 3 | ||||
-rw-r--r-- | drivers/net/dsa/mv88e6060.c | 3 | ||||
-rw-r--r-- | drivers/net/dsa/mv88e6123.c | 3 | ||||
-rw-r--r-- | drivers/net/dsa/mv88e6131.c | 3 | ||||
-rw-r--r-- | drivers/net/dsa/mv88e6171.c | 3 | ||||
-rw-r--r-- | drivers/net/dsa/mv88e6352.c | 3 | ||||
-rw-r--r-- | include/net/dsa.h | 3 | ||||
-rw-r--r-- | net/dsa/dsa.c | 7 |
8 files changed, 18 insertions, 10 deletions
diff --git a/drivers/net/dsa/bcm_sf2.c b/drivers/net/dsa/bcm_sf2.c index 780f22876538..18a79579141f 100644 --- a/drivers/net/dsa/bcm_sf2.c +++ b/drivers/net/dsa/bcm_sf2.c | |||
@@ -135,7 +135,8 @@ static int bcm_sf2_sw_get_sset_count(struct dsa_switch *ds) | |||
135 | return BCM_SF2_STATS_SIZE; | 135 | return BCM_SF2_STATS_SIZE; |
136 | } | 136 | } |
137 | 137 | ||
138 | static char *bcm_sf2_sw_probe(struct device *host_dev, int sw_addr) | 138 | static char *bcm_sf2_sw_probe(struct device *dsa_dev, struct device *host_dev, |
139 | int sw_addr) | ||
139 | { | 140 | { |
140 | return "Broadcom Starfighter 2"; | 141 | return "Broadcom Starfighter 2"; |
141 | } | 142 | } |
diff --git a/drivers/net/dsa/mv88e6060.c b/drivers/net/dsa/mv88e6060.c index 0527f485c3dc..34d0f9fe19db 100644 --- a/drivers/net/dsa/mv88e6060.c +++ b/drivers/net/dsa/mv88e6060.c | |||
@@ -57,7 +57,8 @@ static int reg_write(struct dsa_switch *ds, int addr, int reg, u16 val) | |||
57 | return __ret; \ | 57 | return __ret; \ |
58 | }) | 58 | }) |
59 | 59 | ||
60 | static char *mv88e6060_probe(struct device *host_dev, int sw_addr) | 60 | static char *mv88e6060_probe(struct device *dsa_dev, struct device *host_dev, |
61 | int sw_addr) | ||
61 | { | 62 | { |
62 | struct mii_bus *bus = dsa_host_dev_to_mii_bus(host_dev); | 63 | struct mii_bus *bus = dsa_host_dev_to_mii_bus(host_dev); |
63 | int ret; | 64 | int ret; |
diff --git a/drivers/net/dsa/mv88e6123.c b/drivers/net/dsa/mv88e6123.c index 69a6f79dcb10..ede4c6f0b31a 100644 --- a/drivers/net/dsa/mv88e6123.c +++ b/drivers/net/dsa/mv88e6123.c | |||
@@ -29,7 +29,8 @@ static const struct mv88e6xxx_switch_id mv88e6123_table[] = { | |||
29 | { PORT_SWITCH_ID_6165_A2, "Marvell 88e6165 (A2)" }, | 29 | { PORT_SWITCH_ID_6165_A2, "Marvell 88e6165 (A2)" }, |
30 | }; | 30 | }; |
31 | 31 | ||
32 | static char *mv88e6123_probe(struct device *host_dev, int sw_addr) | 32 | static char *mv88e6123_probe(struct device *dsa_dev, struct device *host_dev, |
33 | int sw_addr) | ||
33 | { | 34 | { |
34 | return mv88e6xxx_lookup_name(host_dev, sw_addr, mv88e6123_table, | 35 | return mv88e6xxx_lookup_name(host_dev, sw_addr, mv88e6123_table, |
35 | ARRAY_SIZE(mv88e6123_table)); | 36 | ARRAY_SIZE(mv88e6123_table)); |
diff --git a/drivers/net/dsa/mv88e6131.c b/drivers/net/dsa/mv88e6131.c index 24070287c2bc..bfadfd2cbb8d 100644 --- a/drivers/net/dsa/mv88e6131.c +++ b/drivers/net/dsa/mv88e6131.c | |||
@@ -25,7 +25,8 @@ static const struct mv88e6xxx_switch_id mv88e6131_table[] = { | |||
25 | { PORT_SWITCH_ID_6185, "Marvell 88E6185" }, | 25 | { PORT_SWITCH_ID_6185, "Marvell 88E6185" }, |
26 | }; | 26 | }; |
27 | 27 | ||
28 | static char *mv88e6131_probe(struct device *host_dev, int sw_addr) | 28 | static char *mv88e6131_probe(struct device *dsa_dev, struct device *host_dev, |
29 | int sw_addr) | ||
29 | { | 30 | { |
30 | return mv88e6xxx_lookup_name(host_dev, sw_addr, mv88e6131_table, | 31 | return mv88e6xxx_lookup_name(host_dev, sw_addr, mv88e6131_table, |
31 | ARRAY_SIZE(mv88e6131_table)); | 32 | ARRAY_SIZE(mv88e6131_table)); |
diff --git a/drivers/net/dsa/mv88e6171.c b/drivers/net/dsa/mv88e6171.c index 0e62f3b5bc81..fb35d3ac1644 100644 --- a/drivers/net/dsa/mv88e6171.c +++ b/drivers/net/dsa/mv88e6171.c | |||
@@ -24,7 +24,8 @@ static const struct mv88e6xxx_switch_id mv88e6171_table[] = { | |||
24 | { PORT_SWITCH_ID_6351, "Marvell 88E6351" }, | 24 | { PORT_SWITCH_ID_6351, "Marvell 88E6351" }, |
25 | }; | 25 | }; |
26 | 26 | ||
27 | static char *mv88e6171_probe(struct device *host_dev, int sw_addr) | 27 | static char *mv88e6171_probe(struct device *dsa_dev, struct device *host_dev, |
28 | int sw_addr) | ||
28 | { | 29 | { |
29 | return mv88e6xxx_lookup_name(host_dev, sw_addr, mv88e6171_table, | 30 | return mv88e6xxx_lookup_name(host_dev, sw_addr, mv88e6171_table, |
30 | ARRAY_SIZE(mv88e6171_table)); | 31 | ARRAY_SIZE(mv88e6171_table)); |
diff --git a/drivers/net/dsa/mv88e6352.c b/drivers/net/dsa/mv88e6352.c index 7f452e4a04a5..577ab2cfa944 100644 --- a/drivers/net/dsa/mv88e6352.c +++ b/drivers/net/dsa/mv88e6352.c | |||
@@ -37,7 +37,8 @@ static const struct mv88e6xxx_switch_id mv88e6352_table[] = { | |||
37 | { PORT_SWITCH_ID_6352_A1, "Marvell 88E6352 (A1)" }, | 37 | { PORT_SWITCH_ID_6352_A1, "Marvell 88E6352 (A1)" }, |
38 | }; | 38 | }; |
39 | 39 | ||
40 | static char *mv88e6352_probe(struct device *host_dev, int sw_addr) | 40 | static char *mv88e6352_probe(struct device *dsa_dev, struct device *host_dev, |
41 | int sw_addr) | ||
41 | { | 42 | { |
42 | return mv88e6xxx_lookup_name(host_dev, sw_addr, mv88e6352_table, | 43 | return mv88e6xxx_lookup_name(host_dev, sw_addr, mv88e6352_table, |
43 | ARRAY_SIZE(mv88e6352_table)); | 44 | ARRAY_SIZE(mv88e6352_table)); |
diff --git a/include/net/dsa.h b/include/net/dsa.h index 18d1be3ad62d..0f9f6f38f255 100644 --- a/include/net/dsa.h +++ b/include/net/dsa.h | |||
@@ -212,7 +212,8 @@ struct dsa_switch_driver { | |||
212 | /* | 212 | /* |
213 | * Probing and setup. | 213 | * Probing and setup. |
214 | */ | 214 | */ |
215 | char *(*probe)(struct device *host_dev, int sw_addr); | 215 | char *(*probe)(struct device *dsa_dev, struct device *host_dev, |
216 | int sw_addr); | ||
216 | int (*setup)(struct dsa_switch *ds); | 217 | int (*setup)(struct dsa_switch *ds); |
217 | int (*set_addr)(struct dsa_switch *ds, u8 *addr); | 218 | int (*set_addr)(struct dsa_switch *ds, u8 *addr); |
218 | u32 (*get_phy_flags)(struct dsa_switch *ds, int port); | 219 | u32 (*get_phy_flags)(struct dsa_switch *ds, int port); |
diff --git a/net/dsa/dsa.c b/net/dsa/dsa.c index c28c47463b7e..c06275311cb2 100644 --- a/net/dsa/dsa.c +++ b/net/dsa/dsa.c | |||
@@ -51,7 +51,8 @@ void unregister_switch_driver(struct dsa_switch_driver *drv) | |||
51 | EXPORT_SYMBOL_GPL(unregister_switch_driver); | 51 | EXPORT_SYMBOL_GPL(unregister_switch_driver); |
52 | 52 | ||
53 | static struct dsa_switch_driver * | 53 | static struct dsa_switch_driver * |
54 | dsa_switch_probe(struct device *host_dev, int sw_addr, char **_name) | 54 | dsa_switch_probe(struct device *parent, struct device *host_dev, int sw_addr, |
55 | char **_name) | ||
55 | { | 56 | { |
56 | struct dsa_switch_driver *ret; | 57 | struct dsa_switch_driver *ret; |
57 | struct list_head *list; | 58 | struct list_head *list; |
@@ -66,7 +67,7 @@ dsa_switch_probe(struct device *host_dev, int sw_addr, char **_name) | |||
66 | 67 | ||
67 | drv = list_entry(list, struct dsa_switch_driver, list); | 68 | drv = list_entry(list, struct dsa_switch_driver, list); |
68 | 69 | ||
69 | name = drv->probe(host_dev, sw_addr); | 70 | name = drv->probe(parent, host_dev, sw_addr); |
70 | if (name != NULL) { | 71 | if (name != NULL) { |
71 | ret = drv; | 72 | ret = drv; |
72 | break; | 73 | break; |
@@ -387,7 +388,7 @@ dsa_switch_setup(struct dsa_switch_tree *dst, int index, | |||
387 | /* | 388 | /* |
388 | * Probe for switch model. | 389 | * Probe for switch model. |
389 | */ | 390 | */ |
390 | drv = dsa_switch_probe(host_dev, pd->sw_addr, &name); | 391 | drv = dsa_switch_probe(parent, host_dev, pd->sw_addr, &name); |
391 | if (drv == NULL) { | 392 | if (drv == NULL) { |
392 | netdev_err(dst->master_netdev, "[%d]: could not detect attached switch\n", | 393 | netdev_err(dst->master_netdev, "[%d]: could not detect attached switch\n", |
393 | index); | 394 | index); |