iwlwifi: fix iwl_mac_add_interface handler
authorTomas Winkler <tomas.winkler@intel.com>
Tue, 27 Nov 2007 19:00:52 +0000 (21:00 +0200)
committerJohn W. Linville <linville@tuxdriver.com>
Fri, 30 Nov 2007 02:34:53 +0000 (21:34 -0500)
This patch fixes iwl_mac_add_interface.

1. Currently only one interface is supported, instead of silently retuning
 0 now it returns  -EOPNOTSUPP (By Johannes Berg)
2. It enables changing mac address from user space (By Ian Schram)

Signed-off-by: Tomas Winkler <tomas@localhost.localdomain>
Cc: Zhu Yi <yi.zhu@intel.com>
Cc: Reinette Chatre <reinette.chatre@intel.com>
Cc: linux-wireless <linux-wireless@vger.kernel.org
Cc: Ian Schram <ischram@telenet.be>
Cc: Johannes Berg <johannes@sipsolutions.net>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
drivers/net/wireless/iwlwifi/iwl3945-base.c
drivers/net/wireless/iwlwifi/iwl4965-base.c

index 5751c89857f0d14a6ec9276c6e664bf6e1b97aa9..ae89a0f2c799aee09f98198453e880e75b1b56bc 100644 (file)
@@ -6940,13 +6940,10 @@ static int iwl_mac_add_interface(struct ieee80211_hw *hw,
        DECLARE_MAC_BUF(mac);
 
        IWL_DEBUG_MAC80211("enter: id %d, type %d\n", conf->if_id, conf->type);
-       if (conf->mac_addr)
-               IWL_DEBUG_MAC80211("enter: MAC %s\n",
-                                  print_mac(mac, conf->mac_addr));
 
        if (priv->interface_id) {
                IWL_DEBUG_MAC80211("leave - interface_id != 0\n");
-               return 0;
+               return -EOPNOTSUPP;
        }
 
        spin_lock_irqsave(&priv->lock, flags);
@@ -6955,6 +6952,12 @@ static int iwl_mac_add_interface(struct ieee80211_hw *hw,
        spin_unlock_irqrestore(&priv->lock, flags);
 
        mutex_lock(&priv->mutex);
+
+       if (conf->mac_addr) {
+               IWL_DEBUG_MAC80211("Set: %s\n", print_mac(mac, conf->mac_addr));
+               memcpy(priv->mac_addr, conf->mac_addr, ETH_ALEN);
+       }
+
        iwl_set_mode(priv, conf->type);
 
        IWL_DEBUG_MAC80211("leave\n");
index 0b22e01735765df43f174faeee720368b0c8405c..22d3bbc7be52db2c0d973824f50d5b274f60f2af 100644 (file)
@@ -7330,9 +7330,6 @@ static int iwl_mac_add_interface(struct ieee80211_hw *hw,
        DECLARE_MAC_BUF(mac);
 
        IWL_DEBUG_MAC80211("enter: id %d, type %d\n", conf->if_id, conf->type);
-       if (conf->mac_addr)
-               IWL_DEBUG_MAC80211("enter: MAC %s\n",
-                                  print_mac(mac, conf->mac_addr));
 
        if (priv->interface_id) {
                IWL_DEBUG_MAC80211("leave - interface_id != 0\n");
@@ -7345,6 +7342,11 @@ static int iwl_mac_add_interface(struct ieee80211_hw *hw,
        spin_unlock_irqrestore(&priv->lock, flags);
 
        mutex_lock(&priv->mutex);
+
+       if (conf->mac_addr) {
+               IWL_DEBUG_MAC80211("Set %s\n", print_mac(mac, conf->mac_addr));
+               memcpy(priv->mac_addr, conf->mac_addr, ETH_ALEN);
+       }
        iwl_set_mode(priv, conf->type);
 
        IWL_DEBUG_MAC80211("leave\n");