Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Andrew Lunn and committed by
David S. Miller
bbb8d793 71bbe25d

+18 -10
+2 -1
drivers/net/dsa/bcm_sf2.c
··· 135 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 141 return "Broadcom Starfighter 2"; 141 142 }
+2 -1
drivers/net/dsa/mv88e6060.c
··· 57 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 63 struct mii_bus *bus = dsa_host_dev_to_mii_bus(host_dev); 63 64 int ret;
+2 -1
drivers/net/dsa/mv88e6123.c
··· 29 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 35 return mv88e6xxx_lookup_name(host_dev, sw_addr, mv88e6123_table, 35 36 ARRAY_SIZE(mv88e6123_table));
+2 -1
drivers/net/dsa/mv88e6131.c
··· 25 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 31 return mv88e6xxx_lookup_name(host_dev, sw_addr, mv88e6131_table, 31 32 ARRAY_SIZE(mv88e6131_table));
+2 -1
drivers/net/dsa/mv88e6171.c
··· 24 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 30 return mv88e6xxx_lookup_name(host_dev, sw_addr, mv88e6171_table, 30 31 ARRAY_SIZE(mv88e6171_table));
+2 -1
drivers/net/dsa/mv88e6352.c
··· 37 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 43 return mv88e6xxx_lookup_name(host_dev, sw_addr, mv88e6352_table, 43 44 ARRAY_SIZE(mv88e6352_table));
+2 -1
include/net/dsa.h
··· 212 212 /* 213 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 217 int (*setup)(struct dsa_switch *ds); 217 218 int (*set_addr)(struct dsa_switch *ds, u8 *addr); 218 219 u32 (*get_phy_flags)(struct dsa_switch *ds, int port);
+4 -3
net/dsa/dsa.c
··· 51 51 EXPORT_SYMBOL_GPL(unregister_switch_driver); 52 52 53 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 57 struct dsa_switch_driver *ret; 57 58 struct list_head *list; ··· 67 66 68 67 drv = list_entry(list, struct dsa_switch_driver, list); 69 68 70 - name = drv->probe(host_dev, sw_addr); 69 + name = drv->probe(parent, host_dev, sw_addr); 71 70 if (name != NULL) { 72 71 ret = drv; 73 72 break; ··· 388 387 /* 389 388 * Probe for switch model. 390 389 */ 391 - drv = dsa_switch_probe(host_dev, pd->sw_addr, &name); 390 + drv = dsa_switch_probe(parent, host_dev, pd->sw_addr, &name); 392 391 if (drv == NULL) { 393 392 netdev_err(dst->master_netdev, "[%d]: could not detect attached switch\n", 394 393 index);