sample: eliminate clever code to determine which proc file is accessed
[madwifi/.git] / regression / wep / test_wep.c
index 62d1e1c3a144167f3a4859eb27349259a766b301..9f4e17a5b69ea484a4d6219babd372e6ce827f09 100644 (file)
@@ -44,7 +44,7 @@
  * you want; e.g. insmod wep_test tests=7 will run only test MPDUs
  * 1, 2, and 3.
  */
-#ifndef AUTOCONF_INCLUDED
+#if !defined(AUTOCONF_INCLUDED) && !defined(CONFIG_LOCALVERSION)
 #include <linux/config.h>
 #endif
 #include <linux/version.h>
@@ -302,14 +302,9 @@ MODULE_LICENSE("Dual BSD/GPL");
 static int tests = -1;
 static int debug = 0;
 
-#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,52))
-MODULE_PARM(tests, "i");
-MODULE_PARM(debug, "i");
-#else
 #include <linux/moduleparam.h>
 module_param(tests, int, 0600);
 module_param(debug, int, 0600);
-#endif
 
 MODULE_PARM_DESC(tests, "Specify which tests to run");
 MODULE_PARM_DESC(debug, "Enable IEEE80211_MSG_CRYPTO");
@@ -317,26 +312,28 @@ MODULE_PARM_DESC(debug, "Enable IEEE80211_MSG_CRYPTO");
 static int __init
 init_crypto_wep_test(void)
 {
-       struct ieee80211com *ic;
+       struct {
+               struct ieee80211vap vap;
+               struct ieee80211com ic;
+               struct net_device netdev;
+       } *buf;
        struct ieee80211vap *vap;
        int i, pass, total;
 
-       ic = kzalloc(sizeof(*ic), GFP_KERNEL);
-       if (!ic)
+       buf = kzalloc(sizeof(*buf), GFP_KERNEL);
+       if (!buf)
                return -ENOMEM;
 
-       ieee80211_crypto_attach(ic);
-
-       vap = kzalloc(sizeof(*vap), GFP_KERNEL);
-       if (!vap) {
-               kfree(ic);
-               return -ENOMEM;
-       }
+       vap = &buf->vap;
+       vap->iv_ic = &buf->ic;
+       vap->iv_dev = &buf->netdev;
+       vap->iv_ic->ic_dev = vap->iv_dev;
+       strncpy(vap->iv_dev->name, "WEP test", sizeof(vap->iv_dev->name) - 1);
 
-       vap->iv_ic = ic;
        if (debug)
                vap->iv_debug = IEEE80211_MSG_CRYPTO;
 
+       ieee80211_crypto_attach(vap->iv_ic);
        ieee80211_crypto_vattach(vap);
 
        pass = 0;
@@ -348,9 +345,8 @@ init_crypto_wep_test(void)
                }
        printk("%u of %u 802.11i WEP test vectors passed\n", pass, total);
        ieee80211_crypto_vdetach(vap);
-       ieee80211_crypto_detach(ic);
-       kfree(vap);
-       kfree(ic);
+       ieee80211_crypto_detach(vap->iv_ic);
+       kfree(buf);
        return (pass == total ? 0 : -ENXIO);
 }
 module_init(init_crypto_wep_test);