backport r25619 to backfire
authorFlorian Fainelli <florian@openwrt.org>
Sun, 20 Feb 2011 17:29:13 +0000 (17:29 +0000)
committerFlorian Fainelli <florian@openwrt.org>
Sun, 20 Feb 2011 17:29:13 +0000 (17:29 +0000)
SVN-Revision: 25625

package/switch/Makefile
package/switch/src/switch-robo.c

index 74e42e6d93353fe0235e04f708f5f7456ec4363f..7c4bb093e0da5f8995b5f6be8d3d599b67065ccc 100644 (file)
@@ -1,5 +1,5 @@
 # 
-# Copyright (C) 2006 OpenWrt.org
+# Copyright (C) 2006-2011 OpenWrt.org
 #
 # This is free software, licensed under the GNU General Public License v2.
 # See /LICENSE for more information.
@@ -9,7 +9,7 @@ include $(TOPDIR)/rules.mk
 include $(INCLUDE_DIR)/kernel.mk
 
 PKG_NAME:=kmod-switch
-PKG_RELEASE:=3
+PKG_RELEASE:=4
 
 include $(INCLUDE_DIR)/package.mk
 
index 43e8098b5ac4504eb3b25cabcf37a996f3b379ed..35cf6df393d144679e55de9d62a94772481a6cfc 100644 (file)
@@ -306,7 +306,7 @@ static int robo_probe(char *devname)
 {
        __u32 phyid;
        unsigned int i;
-       int err;
+       int err = 1;
 
        printk(KERN_INFO PFX "Probing device %s: ", devname);
        strcpy(robo.ifr.ifr_name, devname);
@@ -336,7 +336,7 @@ static int robo_probe(char *devname)
                    (mii->phy_id != ROBO_PHY_ADDR_BCM63XX) &&
                    (mii->phy_id != ROBO_PHY_ADDR_TG3)) {
                        printk("Invalid phy address (%d)\n", mii->phy_id);
-                       return 1;
+                       goto done;
                }
                robo.use_et = 0;
                /* The robo has a fixed PHY address that is different from the
@@ -349,7 +349,7 @@ static int robo_probe(char *devname)
 
        if (phyid == 0xffffffff || phyid == 0x55210022) {
                printk("No Robo switch in managed mode found, phy_id = 0x%08x\n", phyid);
-               return 1;
+               goto done;
        }
 
        /* Get the device ID */
@@ -366,11 +366,18 @@ static int robo_probe(char *devname)
        robo_switch_reset();
        err = robo_switch_enable();
        if (err)
-               return err;
+               goto done;
+       err = 0;
 
        printk("found a 5%s%x!%s\n", robo.devid & 0xff00 ? "" : "3", robo.devid,
                robo.is_5350 ? " It's a 5350." : "");
-       return 0;
+
+done:
+       if (err) {
+               dev_put(robo.dev);
+               robo.dev = NULL;
+       }
+       return err;
 }
 
 
@@ -615,6 +622,8 @@ static int __init robo_init(void)
 static void __exit robo_exit(void)
 {
        switch_unregister_driver(DRIVER_NAME);
+       if (robo.dev)
+               dev_put(robo.dev);
        kfree(robo.device);
 }