[adm5120] fix support for 2.6.38 kernel
[openwrt.git] / package / switch / src / switch-robo.c
index 817fba3..7bac919 100644 (file)
 #include "switch-core.h"
 #include "etc53xx.h"
 
+#ifdef CONFIG_BCM47XX
+#include <nvram.h>
+#endif
+
 #define DRIVER_NAME            "bcm53xx"
 #define DRIVER_VERSION         "0.02"
 #define PFX                    "roboswitch: "
 #define SIOCGETCPHYRD           (SIOCDEVPRIVATE + 9)
 #define SIOCSETCPHYWR           (SIOCDEVPRIVATE + 10)
 
-/* Only available on brcm47xx */
-#ifdef BROADCOM
-extern char *nvram_get(const char *name);
-#define getvar(str) (nvram_get(str)?:"")
-#else
-#define getvar(str) ""
-#endif
-
 /* Data structure for a Roboswitch device. */
 struct robo_switch {
        char *device;                   /* The device name string (ethX) */
@@ -258,6 +254,9 @@ static int robo_switch_enable(void)
 {
        unsigned int i, last_port;
        u16 val;
+#ifdef CONFIG_BCM47XX
+       char buf[20];
+#endif
 
        val = robo_read16(ROBO_CTRL_PAGE, ROBO_SWITCH_MODE);
        if (!(val & (1 << 1))) {
@@ -278,10 +277,13 @@ static int robo_switch_enable(void)
                        robo_write16(ROBO_CTRL_PAGE, i, 0);
        }
 
+#ifdef CONFIG_BCM47XX
        /* WAN port LED, except for Netgear WGT634U */
-       if (strcmp(getvar("nvram_type"), "cfe") != 0)
-               robo_write16(ROBO_CTRL_PAGE, 0x16, 0x1F);
-
+       if (nvram_getenv("nvram_type", buf, sizeof(buf)) >= 0) {
+               if (strcmp(buf, "cfe") != 0)
+                       robo_write16(ROBO_CTRL_PAGE, 0x16, 0x1F);
+       }
+#endif
        return 0;
 }
 
@@ -457,6 +459,7 @@ static int handle_vlan_port_write(void *driver, char *buf, int nr)
                robo_write32(ROBO_ARLIO_PAGE, 0x63 + regoff, (c->untag << 9) | c->port);
                robo_write16(ROBO_ARLIO_PAGE, 0x61 + regoff, nr);
                robo_write16(ROBO_ARLIO_PAGE, 0x60 + regoff, 1 << 7);
+               kfree(c);
                return 0;
        }
 
@@ -471,6 +474,7 @@ static int handle_vlan_port_write(void *driver, char *buf, int nr)
                robo_write16(ROBO_VLAN_PAGE, ROBO_VLAN_TABLE_ACCESS, val16);
        }
 
+       kfree(c);
        return 0;
 }
 
@@ -518,13 +522,9 @@ static int handle_enable_vlan_write(void *driver, char *buf, int nr)
 static int handle_reset(void *driver, char *buf, int nr)
 {
        switch_driver *d = (switch_driver *) driver;
-       switch_vlan_config *c = switch_parse_vlan(d, buf);
        int j;
        __u16 val16;
 
-       if (c == NULL)
-               return -EINVAL;
-
        /* disable switching */
        set_switch(0);
 
This page took 0.024539 seconds and 4 git commands to generate.