diff options
author | Ziyan <jaraidaniel@gmail.com> | 2016-06-06 11:10:37 +0200 |
---|---|---|
committer | Andreas Blaesius <skate4life@gmx.de> | 2016-06-06 11:37:25 +0200 |
commit | 278cb9ed685599c3559ed5aea78b00a06b25abc6 (patch) | |
tree | 8853456260604fad0ddc54307c28d3ead3a55e1e | |
parent | 2075a8aa23cf47db5dafdc096858805abee683af (diff) | |
download | kernel_samsung_espresso10-278cb9ed685599c3559ed5aea78b00a06b25abc6.zip kernel_samsung_espresso10-278cb9ed685599c3559ed5aea78b00a06b25abc6.tar.gz kernel_samsung_espresso10-278cb9ed685599c3559ed5aea78b00a06b25abc6.tar.bz2 |
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
-rw-r--r-- | arch/arm/mach-omap2/board-espresso-wifi.c | 14 |
1 files 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 <linux/regulator/fixed.h> #include <plat/mmc.h> -#include <linux/random.h> -#include <linux/jiffies.h> +#include <mach/id.h> #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); |