(4/6) bcm57xx: switch-core.c/switch-robo.c check for port already registered

This patch prevents switch-robo.c from attempting robo_probe on a port
that is already registered.  robo_probe will adjust kernel reference counts
if it detects a switch on the port.  If this patch wasn't applied, the
wrt350n would hang on reboot, waiting for the network driver reference count
to reach zero indefinitely.

Signed-off-by: Ben Pfountz <netprince (at) vt (dot) edu>

SVN-Revision: 11469
master
Felix Fietkau 17 years ago
parent 9621d872ca
commit 40990382e5
  1. 16
      package/switch/src/switch-core.c
  2. 1
      package/switch/src/switch-core.h
  3. 1
      package/switch/src/switch-robo.c

@ -404,6 +404,21 @@ switch_vlan_config *switch_parse_vlan(switch_driver *driver, char *buf)
} }
int switch_device_registered (char* device) {
struct list_head *pos;
switch_driver *new;
list_for_each(pos, &drivers.list) {
if (strcmp(list_entry(pos, switch_driver, list)->interface, device) == 0) {
printk("There is already a switch registered on the device '%s'\n", device);
return -EINVAL;
}
}
return 0;
}
int switch_register_driver(switch_driver *driver) int switch_register_driver(switch_driver *driver)
{ {
struct list_head *pos; struct list_head *pos;
@ -476,6 +491,7 @@ static void __exit switch_exit(void)
MODULE_AUTHOR("Felix Fietkau <openwrt@nbd.name>"); MODULE_AUTHOR("Felix Fietkau <openwrt@nbd.name>");
MODULE_LICENSE("GPL"); MODULE_LICENSE("GPL");
EXPORT_SYMBOL(switch_device_registered);
EXPORT_SYMBOL(switch_register_driver); EXPORT_SYMBOL(switch_register_driver);
EXPORT_SYMBOL(switch_unregister_driver); EXPORT_SYMBOL(switch_unregister_driver);
EXPORT_SYMBOL(switch_parse_vlan); EXPORT_SYMBOL(switch_parse_vlan);

@ -42,6 +42,7 @@ typedef struct {
} switch_vlan_config; } switch_vlan_config;
extern int switch_device_registered (char* device);
extern int switch_register_driver(switch_driver *driver); extern int switch_register_driver(switch_driver *driver);
extern void switch_unregister_driver(char *name); extern void switch_unregister_driver(char *name);
extern switch_vlan_config *switch_parse_vlan(switch_driver *driver, char *buf); extern switch_vlan_config *switch_parse_vlan(switch_driver *driver, char *buf);

@ -528,6 +528,7 @@ static int __init robo_init(void)
device = strdup("ethX"); device = strdup("ethX");
for (device[3] = '0'; (device[3] <= '3') && notfound; device[3]++) { for (device[3] = '0'; (device[3] <= '3') && notfound; device[3]++) {
if (! switch_device_registered (device))
notfound = robo_probe(device); notfound = robo_probe(device);
} }
device[3]--; device[3]--;

Loading…
Cancel
Save