From 278cb9ed685599c3559ed5aea78b00a06b25abc6 Mon Sep 17 00:00:00 2001 From: Ziyan Date: Mon, 6 Jun 2016 11:10:37 +0200 Subject: espresso: wifi: calculate MAC address based on the die ID The Samsung BCMDHD used to read the factory MAC address from /efs. Accessing the filesystem in-kernel is a very bad practice, but what can we expect from Samsung? This commit calculates the MAC address based on the SoC Die ID: this is unique for all devices, and ensures that the same device will always have the same MAC address, not a randomly generated one. Change-Id: Ie62935f79149e82c62462828880de2610b93ee5f --- arch/arm/mach-omap2/board-espresso-wifi.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/arch/arm/mach-omap2/board-espresso-wifi.c b/arch/arm/mach-omap2/board-espresso-wifi.c index 123811f..cbbd74e 100644 --- a/arch/arm/mach-omap2/board-espresso-wifi.c +++ b/arch/arm/mach-omap2/board-espresso-wifi.c @@ -31,8 +31,7 @@ #include #include -#include -#include +#include #include "board-espresso.h" #include "hsmmc.h" @@ -187,17 +186,16 @@ __setup("androidboot.macaddr=", espresso_mac_addr_setup); static int espresso_wifi_get_mac_addr(unsigned char *buf) { - uint rand_mac; + struct omap_die_id opi; if (!buf) return -EFAULT; if ((espresso_mac_addr[4] == 0) && (espresso_mac_addr[5] == 0)) { - srandom32((uint)jiffies); - rand_mac = random32(); - espresso_mac_addr[3] = (unsigned char)rand_mac; - espresso_mac_addr[4] = (unsigned char)(rand_mac >> 8); - espresso_mac_addr[5] = (unsigned char)(rand_mac >> 16); + omap_get_die_id(&opi); + espresso_mac_addr[3] = (opi.id_3 >> 24) & 0xFF; + espresso_mac_addr[4] = opi.id_1 & 0xFF; + espresso_mac_addr[5] = opi.id_0 & 0xFF; } memcpy(buf, espresso_mac_addr, IFHWADDRLEN); -- cgit v1.1