network: wireless: bcm4329: Fix MAC address import
authorGreg Goldman <ggoldman@broadcom.com>
Fri, 4 Jun 2010 01:07:27 +0000 (18:07 -0700)
committerColin Cross <ccross@android.com>
Thu, 30 Sep 2010 00:49:36 +0000 (17:49 -0700)
Signed-off-by: Dmitry Shmidt <dimitrysh@google.com>
drivers/net/wireless/bcm4329/Makefile
drivers/net/wireless/bcm4329/dhd_cdc.c
drivers/net/wireless/bcm4329/dhd_common.c

index a7c0267dfcfca9c236063480b65590895b446710..453630e90836bf6edd2cfe67bf87966c1dfe01a4 100644 (file)
@@ -6,6 +6,7 @@ DHDCFLAGS = -DLINUX -DBCMDRIVER -DBCMDONGLEHOST -DDHDTHREAD -DBCMWPA2         \
        -Wall -Wstrict-prototypes -Werror -DOOB_INTR_ONLY -DCUSTOMER_HW2      \
        -DDHD_USE_STATIC_BUF -DMMC_SDIO_ABORT -DDHD_DEBUG_TRAP -DSOFTAP       \
        -DEMBEDDED_PLATFORM -DARP_OFFLOAD_SUPPORT -DPKT_FILTER_SUPPORT        \
+       -DGET_CUSTOM_MAC_ENABLE                                               \
        -Idrivers/net/wireless/bcm4329 -Idrivers/net/wireless/bcm4329/include
 
 DHDOFILES = dhd_linux.o linux_osl.o bcmutils.o dhd_common.o dhd_custom_gpio.o \
index 835b30a9f8f31c7dd241c1c0bb9bc3f11eb5655a..f091e797a92e6851edbdc6865fa888b0546001a1 100644 (file)
 #include <dhd_bus.h>
 #include <dhd_dbg.h>
 
-#ifdef CUSTOMER_HW2
-int wifi_get_mac_addr(unsigned char *buf);
-#endif
-
 extern int dhd_preinit_ioctls(dhd_pub_t *dhd);
 
 /* Packet alignment for most efficient SDIO (can change based on platform) */
@@ -520,26 +516,11 @@ dhd_prot_init(dhd_pub_t *dhd)
 {
        int ret = 0;
        char buf[128];
-#ifdef CUSTOMER_HW2
-       struct ether_addr ea_addr;
-#endif
+
        DHD_TRACE(("%s: Enter\n", __FUNCTION__));
 
        dhd_os_proto_block(dhd);
 
-#ifdef CUSTOMER_HW2
-       /* Set the device MAC address if applicable */
-       ret = wifi_get_mac_addr(ea_addr.octet);
-       if (!ret) {
-               bcm_mkiovar("cur_etheraddr", (void *)&ea_addr, ETHER_ADDR_LEN, buf, sizeof(buf));
-               ret = dhdcdc_set_ioctl(dhd, 0, WLC_SET_VAR, buf, sizeof(buf));
-               if (ret < 0) {
-                       DHD_ERROR(("%s: can't set MAC address , error=%d\n", __FUNCTION__, ret));
-                       goto fail;
-               }
-       }
-#endif
-
        /* Get the device MAC address */
        strcpy(buf, "cur_etheraddr");
        ret = dhdcdc_query_ioctl(dhd, 0, WLC_GET_VAR, buf, sizeof(buf));
index 1fd07215fe9b5e2a869986e37f9b1a8d4539bb07..03349845358163788c778d2b7e6f8437a15a56a4 100644 (file)
 #include <dhd_dbg.h>
 #include <msgtrace.h>
 
-
 #include <wlioctl.h>
 
+#ifdef GET_CUSTOM_MAC_ENABLE
+int wifi_get_mac_addr(unsigned char *buf);
+#endif /* GET_CUSTOM_MAC_ENABLE */
+
 int dhd_msg_level;
 
 char fw_path[MOD_PARAM_PATHLEN];
@@ -1236,6 +1239,29 @@ dhd_preinit_ioctls(dhd_pub_t *dhd)
        uint bcn_timeout = 3;
        int scan_assoc_time = 40;
        int scan_unassoc_time = 80;
+#ifdef GET_CUSTOM_MAC_ENABLE
+       int ret;
+       struct ether_addr ea_addr;
+#endif /* GET_CUSTOM_MAC_ENABLE */
+
+#ifdef GET_CUSTOM_MAC_ENABLE
+       /*
+       ** Read MAC address from external customer place
+       ** NOTE that default mac address has to be present in otp or nvram file
+       ** to bring up firmware but unique per board mac address maybe provided
+       ** by customer code
+       */
+       ret = wifi_get_mac_addr(ea_addr.octet);
+       if (!ret) {
+               bcm_mkiovar("cur_etheraddr", (void *)&ea_addr, ETHER_ADDR_LEN, buf, sizeof(buf));
+               ret = dhdcdc_set_ioctl(dhd, 0, WLC_SET_VAR, buf, sizeof(buf));
+               if (ret < 0) {
+                       DHD_ERROR(("%s: can't set MAC address , error=%d\n", __FUNCTION__, ret));
+               }
+               else
+                       memcpy(dhd->mac.octet, (void *)&ea_addr, ETHER_ADDR_LEN);
+       }
+#endif /* GET_CUSTOM_MAC_ENABLE */
 
        /* Set Country code */
        if (dhd->country_code[0] != 0) {