patch nvram library for new nas version (thx to Vincent Bernat)
[openwrt.git] / openwrt / target / linux / package / switch / src / switch-adm.c
index 6ad9844..f2bc8e1 100644 (file)
@@ -32,6 +32,7 @@
 #include "gpio.h"
 
 #define DRIVER_NAME "adm6996"
+#define DRIVER_VERSION "0.01"
 
 static int eecs = 2;
 static int eesk = 3;
@@ -57,8 +58,9 @@ MODULE_PARM(force, "i");
 #define adm_write16(cs, w) { __u16 val = hton16(w); adm_write(cs, (__u8 *)&val, sizeof(val)*8); }
 #define adm_write32(cs, i) { uint32 val = hton32(i); adm_write(cs, (__u8 *)&val, sizeof(val)*8); }
 
+#define atoi(str) simple_strtoul(((str != NULL) ? str : ""), NULL, 0)
 
-extern int getintvar(char **vars, char *name);
+extern char *nvram_get(char *name);
 
 
 static void adm_write(int cs, char *buf, unsigned int bits)
@@ -442,11 +444,8 @@ static int detect_adm()
        int ret = 0;
 
 #if defined(BCMGPIO2) || defined(BCMGPIO)
-#ifdef LINUX_2_4
-       int boardflags = getintvar(NULL, "boardflags");
-#else
-       extern int boardflags;
-#endif
+       int boardflags = atoi(nvram_get("boardflags"));
+
        if ((boardflags & 0x80) || force)
                ret = 1;
        else 
@@ -454,13 +453,6 @@ static int detect_adm()
 #else
        ret = 1;
 #endif
-       if (ret == 1) {
-               int i = adm_rreg(0, 0);
-               if ((i == 0) || (i == 0xffff)) {
-                       printk("No ADM6996 chip detected.\n");
-                       ret = 0;
-               }
-       }
 
        return ret;
 }
@@ -475,7 +467,7 @@ static int __init adm_init()
                {NULL, NULL, NULL}
        };
        switch_config port[] = {
-               {"enabled", handle_port_enable_read, handle_port_enable_write},
+               {"enable", handle_port_enable_read, handle_port_enable_write},
                {"media", handle_port_media_read, handle_port_media_write},
                {NULL, NULL, NULL}
        };
@@ -485,6 +477,7 @@ static int __init adm_init()
        };
        switch_driver driver = {
                name: DRIVER_NAME,
+               version: DRIVER_VERSION,
                interface: "eth0",
                ports: 6,
                cpuport: 5,
This page took 0.028543 seconds and 4 git commands to generate.