Don't rely on typedef for struct ctl_table, it's going away
[madwifi/.git] / net80211 / ieee80211_linux.c
index 176cbd1ee761b71c725457bd4713548eac1459c5..97b143f6d7a8a21d24e0a5828bfc0bc2b2875756 100644 (file)
@@ -33,7 +33,7 @@
 /*
  * IEEE 802.11 support (Linux-specific code)
  */
-#ifndef AUTOCONF_INCLUDED
+#if !defined(AUTOCONF_INCLUDED) && !defined(CONFIG_LOCALVERSION)
 #include <linux/config.h>
 #endif
 #include <linux/version.h>
@@ -99,7 +99,7 @@ static struct attribute *ieee80211_sysfs_attrs[] = {
 };
 
 static struct attribute_group ieee80211_attr_grp = {
-       .name   = NULL, /* No seperate (sub-)directory */
+       .name   = NULL, /* No separate (sub-)directory */
        .attrs  = ieee80211_sysfs_attrs
 };
 #endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,17) */
@@ -146,11 +146,7 @@ ieee80211_getmgtframe(u_int8_t **frm, u_int pktlen)
        u_int len;
 
        len = roundup(sizeof(struct ieee80211_frame) + pktlen, 4);
-#ifdef IEEE80211_DEBUG_REFCNT
-       skb = ieee80211_dev_alloc_skb_debug(len + align - 1, func, line);
-#else
        skb = ieee80211_dev_alloc_skb(len + align - 1);
-#endif
        if (skb != NULL) {
                u_int off = ((unsigned long) skb->data) % align;
                if (off != 0)
@@ -390,6 +386,7 @@ ieee80211_load_module(const char *modname)
 }
 
 
+#ifdef CONFIG_PROC_FS
 static struct proc_dir_entry *proc_madwifi;
 static int proc_madwifi_count = 0;
 
@@ -507,10 +504,10 @@ proc_iv_bss_print(struct ieee80211vap *vap, char *buf, int space)
        char *p = buf;
        const struct ieee80211_node *ni = vap->iv_bss;
 
-       p += sprintf(p, "vap:%p vap->iv_bss: %p\n",
-                    vap, ni);
-       if (ni == NULL)
+       if (ni == NULL) {
+               p += sprintf(p, "ni:    NULL\n");
                return (p - buf);
+       }
 
        p += sprintf(p, "ni_macaddr:    " MAC_FMT "\n"
                     "ni_bssid: " MAC_FMT "\n"
@@ -610,8 +607,7 @@ static int
 proc_ieee80211_open(struct inode *inode, struct file *file)
 {
        struct proc_ieee80211_priv *pv = NULL;
-       struct proc_dir_entry *dp = PDE(inode);
-       struct ieee80211vap *vap = dp->data;
+       struct ieee80211vap *vap = PDE_DATA(inode);
        int result;
 
        result = proc_common_open(inode, file);
@@ -628,8 +624,7 @@ static int
 proc_doth_open(struct inode *inode, struct file *file)
 {
        struct proc_ieee80211_priv *pv = NULL;
-       struct proc_dir_entry *dp = PDE(inode);
-       struct ieee80211vap *vap = dp->data;
+       struct ieee80211vap *vap = PDE_DATA(inode);
        int result;
 
        result = proc_common_open(inode, file);
@@ -646,8 +641,7 @@ static int
 proc_doth_state_open(struct inode *inode, struct file *file)
 {
        struct proc_ieee80211_priv *pv = NULL;
-       struct proc_dir_entry *dp = PDE(inode);
-       struct ieee80211vap *vap = dp->data;
+       struct ieee80211vap *vap = PDE_DATA(inode);
        int result;
 
        result = proc_common_open(inode, file);
@@ -665,8 +659,7 @@ static int
 proc_iv_bss_open(struct inode *inode, struct file *file)
 {
        struct proc_ieee80211_priv *pv = NULL;
-       struct proc_dir_entry *dp = PDE(inode);
-       struct ieee80211vap *vap = dp->data;
+       struct ieee80211vap *vap = PDE_DATA(inode);
        int result;
 
        result = proc_common_open(inode, file);
@@ -743,6 +736,7 @@ static struct file_operations proc_iv_bss_ops = {
        .open = proc_iv_bss_open,
        .release = proc_ieee80211_close,
 };
+#endif                 /* CONFIG_PROC_FS */
 
 #ifdef IEEE80211_DEBUG
 static int
@@ -895,47 +889,47 @@ IEEE80211_SYSCTL_DECL(ieee80211_sysctl_monitor_crc_errors, ctl, write, filp, buf
        return ret;
 }
 
-static const ctl_table ieee80211_sysctl_template[] = {
+static const struct ctl_table ieee80211_sysctl_template[] = {
 #ifdef IEEE80211_DEBUG
-       { .ctl_name     = CTL_AUTO,
+       { ATH_INIT_CTL_NAME(CTL_AUTO)
          .procname     = "debug",
          .mode         = 0644,
          .proc_handler = ieee80211_sysctl_debug
        },
 #endif
-       { .ctl_name     = CTL_AUTO,
+       { ATH_INIT_CTL_NAME(CTL_AUTO)
          .procname     = "dev_type",
          .mode         = 0644,
          .proc_handler = ieee80211_sysctl_dev_type
        },
-       { .ctl_name     = CTL_AUTO,
+       { ATH_INIT_CTL_NAME(CTL_AUTO)
          .procname     = "monitor_nods_only",
          .mode         = 0644,
          .proc_handler = ieee80211_sysctl_monitor_nods_only
        },
-       { .ctl_name     = CTL_AUTO,
+       { ATH_INIT_CTL_NAME(CTL_AUTO)
          .procname     = "monitor_txf_len",
          .mode         = 0644,
          .proc_handler = ieee80211_sysctl_monitor_txf_len
        },
-       { .ctl_name     = CTL_AUTO,
+       { ATH_INIT_CTL_NAME(CTL_AUTO)
          .procname     = "monitor_phy_errors",
          .mode         = 0644,
          .proc_handler = ieee80211_sysctl_monitor_phy_errors
        },
-       { .ctl_name     = CTL_AUTO,
+       { ATH_INIT_CTL_NAME(CTL_AUTO)
          .procname     = "monitor_crc_errors",
          .mode         = 0644,
          .proc_handler = ieee80211_sysctl_monitor_crc_errors
        },
        /* NB: must be last entry before NULL */
-       { .ctl_name     = CTL_AUTO,
+       { ATH_INIT_CTL_NAME(CTL_AUTO)
          .procname     = "%parent",
          .maxlen       = IFNAMSIZ,
          .mode         = 0444,
          .proc_handler = proc_dostring
        },
-       { }
+       { }
 };
 
 void
@@ -943,7 +937,6 @@ ieee80211_virtfs_latevattach(struct ieee80211vap *vap)
 {
        int i, space;
        char *devname = NULL;
-       struct ieee80211_proc_entry *tmp = NULL;
 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,17)
        int ret;
 
@@ -983,12 +976,12 @@ ieee80211_virtfs_latevattach(struct ieee80211vap *vap)
        strncpy(devname, vap->iv_dev->name, strlen(vap->iv_dev->name) + 1);
 
        /* setup the table */
-       vap->iv_sysctls[0].ctl_name = CTL_NET;
+       ATH_SET_CTL_NAME(vap->iv_sysctls[0], CTL_NET);
        vap->iv_sysctls[0].procname = "net";
        vap->iv_sysctls[0].mode = 0555;
        vap->iv_sysctls[0].child = &vap->iv_sysctls[2];
        /* [1] is NULL terminator */
-       vap->iv_sysctls[2].ctl_name = CTL_AUTO;
+       ATH_SET_CTL_NAME(vap->iv_sysctls[2], CTL_AUTO);
        vap->iv_sysctls[2].procname = devname; /* XXX bad idea? */
        vap->iv_sysctls[2].mode = 0555;
        vap->iv_sysctls[2].child = &vap->iv_sysctls[4];
@@ -1014,6 +1007,7 @@ ieee80211_virtfs_latevattach(struct ieee80211vap *vap)
                vap->iv_sysctls = NULL;
        }
 
+#ifdef CONFIG_PROC_FS
        /* Ensure the base madwifi directory exists */
        if (!proc_madwifi && proc_net != NULL) {
                proc_madwifi = proc_mkdir("madwifi", proc_net);
@@ -1035,19 +1029,21 @@ ieee80211_virtfs_latevattach(struct ieee80211vap *vap)
 
        /* Recreate any other proc entries that have been registered */
        if (vap->iv_proc) {
-               tmp = vap->iv_proc_entries;
+               struct ieee80211_proc_entry *tmp = vap->iv_proc_entries;
+
                while (tmp) {
                        if (!tmp->entry) {
-                               tmp->entry = create_proc_entry(tmp->name,
-                               PROC_IEEE80211_PERM, vap->iv_proc);
-                               tmp->entry->data = vap;
-                               tmp->entry->proc_fops = tmp->fileops;
+                               tmp->entry = proc_create_data(tmp->name,
+                               PROC_IEEE80211_PERM, vap->iv_proc,
+                               tmp->fileops, vap);
                        }
                        tmp = tmp->next;
                }
        }
+#endif                 /* CONFIG_PROC_FS */
 }
 
+#ifdef CONFIG_PROC_FS
 /* Frees all memory used for the list of proc entries */
 void
 ieee80211_proc_cleanup(struct ieee80211vap *vap)
@@ -1109,10 +1105,9 @@ ieee80211_proc_vcreate(struct ieee80211vap *vap,
 
        /* Create the actual proc entry */
        if (vap->iv_proc) {
-               entry->entry = create_proc_entry(entry->name,
-                               PROC_IEEE80211_PERM, vap->iv_proc);
-               entry->entry->data = vap;
-               entry->entry->proc_fops = entry->fileops;
+               entry->entry = proc_create_data(entry->name,
+                               PROC_IEEE80211_PERM, vap->iv_proc,
+                               entry->fileops, vap);
        }
 
        /* Add it to the list */
@@ -1127,12 +1122,11 @@ ieee80211_proc_vcreate(struct ieee80211vap *vap,
        return 0;
 }
 EXPORT_SYMBOL(ieee80211_proc_vcreate);
+#endif                 /* CONFIG_PROC_FS */
 
 void
 ieee80211_virtfs_vdetach(struct ieee80211vap *vap)
 {
-       struct ieee80211_proc_entry *tmp=NULL;
-
 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,21)
        sysfs_remove_group(&vap->iv_dev->dev.kobj, &ieee80211_attr_grp);
 #elif LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,17)
@@ -1144,23 +1138,26 @@ ieee80211_virtfs_vdetach(struct ieee80211vap *vap)
                vap->iv_sysctl_header = NULL;
        }
 
+#ifdef CONFIG_PROC_FS
        if (vap->iv_proc) {
                /* Remove child proc entries but leave them in the list */
-               tmp = vap->iv_proc_entries;
+               struct ieee80211_proc_entry *tmp = vap->iv_proc_entries;
+
                while (tmp) {
                        if (tmp->entry) {
-                               remove_proc_entry(tmp->name, vap->iv_proc);
+                               proc_remove(tmp->entry);
                                tmp->entry = NULL;
                        }
                        tmp = tmp->next;
                }
-               remove_proc_entry(vap->iv_proc->name, proc_madwifi);
+               proc_remove(vap->iv_proc);
                if (proc_madwifi_count == 1) {
-                       remove_proc_entry("madwifi", proc_net);
+                       proc_remove(proc_madwifi);
                        proc_madwifi = NULL;
                }
                proc_madwifi_count--;
        }
+#endif                 /* CONFIG_PROC_FS */
 
        if (vap->iv_sysctls && vap->iv_sysctls[2].procname) {
                kfree(vap->iv_sysctls[2].procname);
@@ -1183,7 +1180,7 @@ static int
 ieee80211_rcv_dev_event(struct notifier_block *this, unsigned long event,
        void *ptr)
 {
-       struct net_device *dev = (struct net_device *)ptr;
+       struct net_device *dev = netdev_notifier_info_to_dev(ptr);
 
 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,29)
        if (!dev || dev->open != &ieee80211_open)