- memset(buf, 0, 512);
- //GetSNSectorInfo(char * pbuf);
-
- return ;
-}
-
-//#define ENABLE_WIFI_RAND_MAC
-#ifdef ENABLE_WIFI_RAND_MAC
-#define WIFI_RAND_MAC_FILE "/data/misc/wifi_rand_mac"
-
-static int rockchip_wifi_rand_mac_addr(unsigned char *buf)
-{
- struct file *fp;
- loff_t pos;
- mm_segment_t fs;
- char mac_buf[20] = {0};
-
- LOG("%s\n", __func__);
- fp = filp_open(WIFI_RAND_MAC_FILE, O_RDONLY, 0);
- if (fp == NULL || IS_ERR(fp)) {
- fp = filp_open(WIFI_RAND_MAC_FILE, O_RDWR | O_CREAT, 0644);
- if (fp == NULL || IS_ERR(fp)) {
- LOG("%s: create %s failed.\n", __func__, WIFI_RAND_MAC_FILE);
- return -1;
- }
- fs = get_fs();
- set_fs(KERNEL_DS);
- random_ether_addr(wifi_custom_mac_addr);
- pos = 0;
- vfs_write(fp, wifi_custom_mac_addr, 6, &pos);
- filp_close(fp, NULL);
- } else {
- fs = get_fs();
- set_fs(KERNEL_DS);
- pos = 0;
- vfs_read(fp, wifi_custom_mac_addr, 6, &pos);
- filp_close(fp, NULL);
- }
- sprintf(mac_buf,"%02x:%02x:%02x:%02x:%02x:%02x",wifi_custom_mac_addr[0],wifi_custom_mac_addr[1],
- wifi_custom_mac_addr[2],wifi_custom_mac_addr[3],wifi_custom_mac_addr[4],wifi_custom_mac_addr[5]);
- LOG("random wifi_custom_mac_addr=[%s]\n", mac_buf);
- return 0;
-}
+ int ret;
+
+ ret = rk_vendor_read(WIFI_MAC_ID, addr, 6);
+ if (ret != 6 || is_zero_ether_addr(addr)) {
+ LOG("%s: rk_vendor_read wifi mac address failed (%d)\n",
+ __func__, ret);
+#ifdef RANDOM_ADDRESS_SAVE
+ random_ether_addr(addr);
+ LOG("%s: generate random wifi mac address: "
+ "%02x:%02x:%02x:%02x:%02x:%02x\n",
+ __func__, addr[0], addr[1], addr[2],
+ addr[3], addr[4], addr[5]);
+ ret = rk_vendor_write(WIFI_MAC_ID, addr, 6);
+ if (ret != 0) {
+ LOG("%s: rk_vendor_write"
+ " wifi mac address failed (%d)\n",
+ __func__, ret);
+ memset(addr, 0, 6);
+ return -1;
+ }
+#else
+ return -1;