]> git.karo-electronics.de Git - linux-beck.git/commitdiff
ath5k: set mac address in add_interface
authorBob Copeland <me@bobcopeland.com>
Tue, 18 Nov 2008 04:40:38 +0000 (23:40 -0500)
committerJohn W. Linville <linville@tuxdriver.com>
Wed, 26 Nov 2008 14:47:35 +0000 (09:47 -0500)
Configure the mac address in add_interface and clear it in
remove_interface so that users can change the mac address
to something other than the one in the eeprom.  Also avoid
setting it at attach time so that we won't ack packets
until fully set up.

Signed-off-by: Bob Copeland <me@bobcopeland.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
drivers/net/wireless/ath5k/attach.c
drivers/net/wireless/ath5k/base.c

index 51d569883cdd787a7a9b3de3f567f4e415aa1ea1..49d82d79d3fc62ac6db9ff17ae9b4ff0ebadedc4 100644 (file)
@@ -106,7 +106,7 @@ struct ath5k_hw *ath5k_hw_attach(struct ath5k_softc *sc, u8 mac_version)
 {
        struct ath5k_hw *ah;
        struct pci_dev *pdev = sc->pdev;
-       u8 mac[ETH_ALEN];
+       u8 mac[ETH_ALEN] = {};
        int ret;
        u32 srev;
 
@@ -317,15 +317,9 @@ struct ath5k_hw *ath5k_hw_attach(struct ath5k_softc *sc, u8 mac_version)
                goto err_free;
        }
 
-       /* Set MAC address */
-       ret = ath5k_eeprom_read_mac(ah, mac);
-       if (ret) {
-               ATH5K_ERR(sc, "unable to read address from EEPROM: 0x%04x\n",
-                       sc->pdev->device);
-               goto err_free;
-       }
-
+       /* MAC address is cleared until add_interface */
        ath5k_hw_set_lladdr(ah, mac);
+
        /* Set BSSID to bcast address: ff:ff:ff:ff:ff:ff for now */
        memset(ah->ah_bssid, 0xff, ETH_ALEN);
        ath5k_hw_set_associd(ah, ah->ah_bssid, 0);
index 7fdb59c813cad896754dbaece94eb8f544162f2b..4bcea5a9d70be255dce04c992348f9ef27acc652 100644 (file)
@@ -707,7 +707,7 @@ ath5k_attach(struct pci_dev *pdev, struct ieee80211_hw *hw)
 {
        struct ath5k_softc *sc = hw->priv;
        struct ath5k_hw *ah = sc->ah;
-       u8 mac[ETH_ALEN];
+       u8 mac[ETH_ALEN] = {};
        int ret;
 
        ATH5K_DBG(sc, ATH5K_DEBUG_ANY, "devid 0x%x\n", pdev->device);
@@ -777,7 +777,13 @@ ath5k_attach(struct pci_dev *pdev, struct ieee80211_hw *hw)
        tasklet_init(&sc->restq, ath5k_tasklet_reset, (unsigned long)sc);
        setup_timer(&sc->calib_tim, ath5k_calibrate, (unsigned long)sc);
 
-       ath5k_hw_get_lladdr(ah, mac);
+       ret = ath5k_eeprom_read_mac(ah, mac);
+       if (ret) {
+               ATH5K_ERR(sc, "unable to read address from EEPROM: 0x%04x\n",
+                       sc->pdev->device);
+               goto err_queues;
+       }
+
        SET_IEEE80211_PERM_ADDR(hw, mac);
        /* All MAC address bits matter for ACKs */
        memset(sc->bssidmask, 0xff, ETH_ALEN);
@@ -2765,6 +2771,7 @@ static int ath5k_add_interface(struct ieee80211_hw *hw,
        /* Set to a reasonable value. Note that this will
         * be set to mac80211's value at ath5k_config(). */
        sc->bintval = 1000;
+       ath5k_hw_set_lladdr(sc->ah, conf->mac_addr);
 
        ret = 0;
 end:
@@ -2777,11 +2784,13 @@ ath5k_remove_interface(struct ieee80211_hw *hw,
                        struct ieee80211_if_init_conf *conf)
 {
        struct ath5k_softc *sc = hw->priv;
+       u8 mac[ETH_ALEN] = {};
 
        mutex_lock(&sc->lock);
        if (sc->vif != conf->vif)
                goto end;
 
+       ath5k_hw_set_lladdr(sc->ah, mac);
        sc->vif = NULL;
 end:
        mutex_unlock(&sc->lock);