net: wireless: bcmdhd: Fix MAC address setting
Dmitry Shmidt [Wed, 29 Jun 2011 23:03:25 +0000 (16:03 -0700)]
If MAC address setting fails from wifi_get_mac_addr() it will be picked up
from nvram.

Signed-off-by: Dmitry Shmidt <dimitrysh@google.com>

drivers/net/wireless/bcmdhd/Makefile
drivers/net/wireless/bcmdhd/dhd_common.c
drivers/net/wireless/bcmdhd/dhd_sdio.c
drivers/net/wireless/bcmdhd/wl_android.c

index fc5a02f..936d7ac 100644 (file)
@@ -7,7 +7,7 @@ DHDCFLAGS = -Wall -Wstrict-prototypes -Werror -Dlinux -DBCMDRIVER             \
        -DMMC_SDIO_ABORT -DBCMSDIO -DBCMLXSDMMC -DBCMPLATFORM_BUS -DWLP2P     \
        -DNEW_COMPAT_WIRELESS -DWIFI_ACT_FRAME -DARP_OFFLOAD_SUPPORT          \
        -DKEEP_ALIVE -DCSCAN -DGET_CUSTOM_MAC_ENABLE -DPKT_FILTER_SUPPORT     \
-       -DEMBEDDED_PLATFORM                                                   \
+       -DEMBEDDED_PLATFORM -DENABLE_INSMOD_NO_FW_LOAD                        \
        -Idrivers/net/wireless/bcmdhd -Idrivers/net/wireless/bcmdhd/include
 
 DHDOFILES = aiutils.o bcmsdh_sdmmc_linux.o dhd_linux.o siutils.o bcmutils.o   \
index b17e580..8beb1b4 100644 (file)
@@ -1551,27 +1551,34 @@ dhd_preinit_ioctls(dhd_pub_t *dhd)
        uint32 mpc = 0; /* Turn MPC off for AP/APSTA mode */
        uint32 apsta = 1; /* Enable APSTA mode */
 #endif
+#ifdef GET_CUSTOM_MAC_ENABLE
+       struct ether_addr ea_addr;
+#endif /* GET_CUSTOM_MAC_ENABLE */
 
 #ifdef GET_CUSTOM_MAC_ENABLE
-       /* MAC address already defined in dhd->mac.octet */
-       memset(buf, 0, sizeof(buf));
-       bcm_mkiovar("cur_etheraddr", dhd->mac.octet, ETHER_ADDR_LEN, buf, sizeof(buf));
+       ret = dhd_custom_get_mac_address(ea_addr.octet);
+       if (!ret) {
+               memset(buf, 0, sizeof(buf));
+               bcm_mkiovar("cur_etheraddr", (void *)&ea_addr, ETHER_ADDR_LEN, buf, sizeof(buf));
                ret = dhd_wl_ioctl_cmd(dhd, WLC_SET_VAR, buf, sizeof(buf), TRUE, 0);
                if (ret < 0) {
                        DHD_ERROR(("%s: can't set MAC address , error=%d\n", __FUNCTION__, ret));
-               return BCME_NOTUP;
-       }
-#else /* GET_CUSTOM_MAC_ENABLE */
+                       return BCME_NOTUP;
+               }
+       } else {
+#endif /* GET_CUSTOM_MAC_ENABLE */
                /* Get the default device MAC address directly from firmware */
-       memset(buf, 0, sizeof(buf));
-       bcm_mkiovar("cur_etheraddr", 0, 0, buf, sizeof(buf));
-       if ((ret = dhd_wl_ioctl_cmd(dhd, WLC_GET_VAR, buf, sizeof(buf),
+               memset(buf, 0, sizeof(buf));
+               bcm_mkiovar("cur_etheraddr", 0, 0, buf, sizeof(buf));
+               if ((ret = dhd_wl_ioctl_cmd(dhd, WLC_GET_VAR, buf, sizeof(buf),
                        FALSE, 0)) < 0) {
                        DHD_ERROR(("%s: can't get MAC address , error=%d\n", __FUNCTION__, ret));
                        return BCME_NOTUP;
                }
-       /* Update public MAC address after reading from Firmware */
-       memcpy(dhd->mac.octet, buf, ETHER_ADDR_LEN);
+               /* Update public MAC address after reading from Firmware */
+               memcpy(dhd->mac.octet, buf, ETHER_ADDR_LEN);
+#ifdef GET_CUSTOM_MAC_ENABLE
+       }
 #endif /* GET_CUSTOM_MAC_ENABLE */
 
 #ifdef SET_RANDOM_MAC_SOFTAP
index 725441e..ce9d26b 100644 (file)
@@ -5309,10 +5309,6 @@ dhdsdio_probe(uint16 venid, uint16 devid, uint16 bus_no, uint16 slot,
        ret = dhd_custom_get_mac_address(ea_addr.octet);
        if (!ret) {
                memcpy(bus->dhd->mac.octet, (void *)&ea_addr, ETHER_ADDR_LEN);
-       } else {
-               /* MAC address must be present when Driver insmod */
-               DHD_ERROR(("%s unable to get MAC address\n", __FUNCTION__));
-               goto fail;
        }
 #endif /* GET_CUSTOM_MAC_ENABLE */
 
index 54b5d92..79fdb08 100644 (file)
@@ -326,11 +326,7 @@ int wl_android_init(void)
 
        dhd_msg_level = DHD_ERROR_VAL;
 #ifdef ENABLE_INSMOD_NO_FW_LOAD
-#ifdef GET_CUSTOM_MAC_ENABLE
        dhd_download_fw_on_driverload = FALSE;
-#else
-#error  GET_CUSTOM_MAC_ENABLE must be defined to isnmod Driver with no FW load
-#endif /* GET_CUSTOM_MAC_ENABLE */
 #endif /* ENABLE_INSMOD_NO_FW_LOAD */
        return ret;
 }