diff options
author | Felix Fietkau <nbd@openwrt.org> | 2008-06-15 11:10:27 +0000 |
---|---|---|
committer | Felix Fietkau <nbd@openwrt.org> | 2008-06-15 11:10:27 +0000 |
commit | ec81fa9d4e8175468d96fd7d23548f2ed6b32315 (patch) | |
tree | e9ffa5ddb51761909cb903da543229dc05407612 /package/switch/src | |
parent | 0c1bbd505a3c9221b85f2708a09984aa233014a2 (diff) | |
download | master-187ad058-ec81fa9d4e8175468d96fd7d23548f2ed6b32315.tar.gz master-187ad058-ec81fa9d4e8175468d96fd7d23548f2ed6b32315.tar.bz2 master-187ad058-ec81fa9d4e8175468d96fd7d23548f2ed6b32315.zip |
(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>
git-svn-id: svn://svn.openwrt.org/openwrt/trunk@11469 3c298f89-4303-0410-b956-a3cf2f4a3e73
Diffstat (limited to 'package/switch/src')
-rw-r--r-- | package/switch/src/switch-core.c | 16 | ||||
-rw-r--r-- | package/switch/src/switch-core.h | 1 | ||||
-rw-r--r-- | package/switch/src/switch-robo.c | 3 |
3 files changed, 19 insertions, 1 deletions
diff --git a/package/switch/src/switch-core.c b/package/switch/src/switch-core.c index 87aa9729cc..c34386b76f 100644 --- a/package/switch/src/switch-core.c +++ b/package/switch/src/switch-core.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) { struct list_head *pos; @@ -476,6 +491,7 @@ static void __exit switch_exit(void) MODULE_AUTHOR("Felix Fietkau <openwrt@nbd.name>"); MODULE_LICENSE("GPL"); +EXPORT_SYMBOL(switch_device_registered); EXPORT_SYMBOL(switch_register_driver); EXPORT_SYMBOL(switch_unregister_driver); EXPORT_SYMBOL(switch_parse_vlan); diff --git a/package/switch/src/switch-core.h b/package/switch/src/switch-core.h index 5a64efb752..31c81f6ed7 100644 --- a/package/switch/src/switch-core.h +++ b/package/switch/src/switch-core.h @@ -42,6 +42,7 @@ typedef struct { } switch_vlan_config; +extern int switch_device_registered (char* device); extern int switch_register_driver(switch_driver *driver); extern void switch_unregister_driver(char *name); extern switch_vlan_config *switch_parse_vlan(switch_driver *driver, char *buf); diff --git a/package/switch/src/switch-robo.c b/package/switch/src/switch-robo.c index 045dce1c4b..779b89f615 100644 --- a/package/switch/src/switch-robo.c +++ b/package/switch/src/switch-robo.c @@ -528,7 +528,8 @@ static int __init robo_init(void) device = strdup("ethX"); for (device[3] = '0'; (device[3] <= '3') && notfound; device[3]++) { - notfound = robo_probe(device); + if (! switch_device_registered (device)) + notfound = robo_probe(device); } device[3]--; |