pr_debug("rx'd ioctl, cmd=%d, len=%d\n", cmd, req->len);
 
+       mutex_lock(&wlandev->ioctl_lock);
+
 #ifdef SIOCETHTOOL
        if (cmd == SIOCETHTOOL) {
                result =
                result = -ENOMEM;
        }
 bail:
+       mutex_unlock(&wlandev->ioctl_lock);
+
        return result;          /* If allocate,copyfrom or copyto fails, return errno */
 }
 
                dev->open = p80211knetdev_open;
                dev->stop = p80211knetdev_stop;
 
+               mutex_init(&wlandev->ioctl_lock);
+               /* block ioctls until fully initialised. Don't forget to call
+                  allow_ioctls at some point!*/
+               mutex_lock(&wlandev->ioctl_lock);
+
 #if (WIRELESS_EXT < 21)
                dev->get_wireless_stats = p80211wext_get_wireless_stats;
 #endif
                netif_wake_queue(wlandev->netdev);
        }
 }
+
+void p80211_allow_ioctls(wlandevice_t *wlandev)
+{
+       mutex_unlock(&wlandev->ioctl_lock);
+}
 
        u8 spy_number;
        char spy_address[IW_MAX_SPY][ETH_ALEN];
        struct iw_quality spy_stat[IW_MAX_SPY];
+
+       struct mutex ioctl_lock;
 } wlandevice_t;
 
 /* WEP stuff */
 int unregister_wlandev(wlandevice_t *wlandev);
 void p80211netdev_rx(wlandevice_t *wlandev, struct sk_buff *skb);
 void p80211netdev_hwremoved(wlandevice_t *wlandev);
-
+void p80211_allow_ioctls(wlandevice_t *wlandev);
 #endif