Commit c42f56d9 authored by Masahiro Yamada's avatar Masahiro Yamada Committed by Tom Rini

blackfin: replace bfin_gen_rand_mac() with eth_random_addr()

bfin_gen_rand_mac() uses __DATE__ as the seed for random ethernet
address. This makes the build non-deterministic.

In the first place, it should not be implemented as a Bfin-specific
function. Use eth_random_addr() instead.
Signed-off-by: 's avatarMasahiro Yamada <yamada.m@jp.panasonic.com>
Cc: Sonic Zhang <sonic.zhang@analog.com>
parent da384a9d
/*
* net.h - misc Blackfin network helpers
*
* Copyright (c) 2008-2009 Analog Devices Inc.
*
* Licensed under the GPL-2 or later.
*/
#ifndef __ASM_BFIN_RAND_MAC__
#define __ASM_BFIN_RAND_MAC__
/* If the board does not have a real MAC assigned to it, then generate a
* locally administrated pseudo-random one based on CYCLES and compile date.
*/
static inline void bfin_gen_rand_mac(uchar *mac_addr)
{
/* make something up */
const char s[] = __DATE__;
size_t i;
u32 cycles;
for (i = 0; i < 6; ++i) {
asm("%0 = CYCLES;" : "=r" (cycles));
mac_addr[i] = cycles ^ s[i];
}
mac_addr[0] = (mac_addr[0] | 0x02) & ~0x01; /* make it local unicast */
}
#endif
...@@ -12,7 +12,6 @@ ...@@ -12,7 +12,6 @@
#include <asm/blackfin.h> #include <asm/blackfin.h>
#include <asm/portmux.h> #include <asm/portmux.h>
#include <asm/gpio.h> #include <asm/gpio.h>
#include <asm/net.h>
#include <net.h> #include <net.h>
#include <netdev.h> #include <netdev.h>
#include <miiphy.h> #include <miiphy.h>
...@@ -33,7 +32,7 @@ int checkboard(void) ...@@ -33,7 +32,7 @@ int checkboard(void)
static void board_init_enetaddr(uchar *mac_addr) static void board_init_enetaddr(uchar *mac_addr)
{ {
puts("Warning: Generating 'random' MAC address\n"); puts("Warning: Generating 'random' MAC address\n");
bfin_gen_rand_mac(mac_addr); eth_random_addr(mac_addr);
eth_setenv_enetaddr("ethaddr", mac_addr); eth_setenv_enetaddr("ethaddr", mac_addr);
} }
......
...@@ -13,7 +13,6 @@ ...@@ -13,7 +13,6 @@
#include <netdev.h> #include <netdev.h>
#include <spi.h> #include <spi.h>
#include <asm/blackfin.h> #include <asm/blackfin.h>
#include <asm/net.h>
#include <asm/portmux.h> #include <asm/portmux.h>
#include <asm/mach-common/bits/otp.h> #include <asm/mach-common/bits/otp.h>
#include <asm/sdh.h> #include <asm/sdh.h>
...@@ -48,7 +47,7 @@ static void board_init_enetaddr(uchar *mac_addr) ...@@ -48,7 +47,7 @@ static void board_init_enetaddr(uchar *mac_addr)
if (!valid_mac) { if (!valid_mac) {
puts("Warning: Generating 'random' MAC address\n"); puts("Warning: Generating 'random' MAC address\n");
bfin_gen_rand_mac(mac_addr); eth_random_addr(mac_addr);
} }
eth_setenv_enetaddr("ethaddr", mac_addr); eth_setenv_enetaddr("ethaddr", mac_addr);
......
...@@ -12,7 +12,6 @@ ...@@ -12,7 +12,6 @@
#include <net.h> #include <net.h>
#include <netdev.h> #include <netdev.h>
#include <asm/blackfin.h> #include <asm/blackfin.h>
#include <asm/net.h>
#include <asm/mach-common/bits/otp.h> #include <asm/mach-common/bits/otp.h>
DECLARE_GLOBAL_DATA_PTR; DECLARE_GLOBAL_DATA_PTR;
...@@ -45,7 +44,7 @@ static void board_init_enetaddr(uchar *mac_addr) ...@@ -45,7 +44,7 @@ static void board_init_enetaddr(uchar *mac_addr)
if (!valid_mac) { if (!valid_mac) {
puts("Warning: Generating 'random' MAC address\n"); puts("Warning: Generating 'random' MAC address\n");
bfin_gen_rand_mac(mac_addr); eth_random_addr(mac_addr);
} }
eth_setenv_enetaddr("ethaddr", mac_addr); eth_setenv_enetaddr("ethaddr", mac_addr);
......
...@@ -13,7 +13,6 @@ ...@@ -13,7 +13,6 @@
#include <netdev.h> #include <netdev.h>
#include <asm/blackfin.h> #include <asm/blackfin.h>
#include <asm/gpio.h> #include <asm/gpio.h>
#include <asm/net.h>
#include <asm/mach-common/bits/otp.h> #include <asm/mach-common/bits/otp.h>
DECLARE_GLOBAL_DATA_PTR; DECLARE_GLOBAL_DATA_PTR;
...@@ -47,7 +46,7 @@ static void board_init_enetaddr(uchar *mac_addr) ...@@ -47,7 +46,7 @@ static void board_init_enetaddr(uchar *mac_addr)
if (!valid_mac) { if (!valid_mac) {
puts("Warning: Generating 'random' MAC address\n"); puts("Warning: Generating 'random' MAC address\n");
bfin_gen_rand_mac(mac_addr); eth_random_addr(mac_addr);
} }
eth_setenv_enetaddr("ethaddr", mac_addr); eth_setenv_enetaddr("ethaddr", mac_addr);
......
...@@ -12,7 +12,6 @@ ...@@ -12,7 +12,6 @@
#include <netdev.h> #include <netdev.h>
#include <net.h> #include <net.h>
#include <asm/blackfin.h> #include <asm/blackfin.h>
#include <asm/net.h>
DECLARE_GLOBAL_DATA_PTR; DECLARE_GLOBAL_DATA_PTR;
...@@ -27,7 +26,7 @@ int checkboard(void) ...@@ -27,7 +26,7 @@ int checkboard(void)
static void board_init_enetaddr(uchar *mac_addr) static void board_init_enetaddr(uchar *mac_addr)
{ {
puts("Warning: Generating 'random' MAC address\n"); puts("Warning: Generating 'random' MAC address\n");
bfin_gen_rand_mac(mac_addr); eth_random_addr(mac_addr);
eth_setenv_enetaddr("ethaddr", mac_addr); eth_setenv_enetaddr("ethaddr", mac_addr);
} }
......
...@@ -12,7 +12,6 @@ ...@@ -12,7 +12,6 @@
#include <netdev.h> #include <netdev.h>
#include <net.h> #include <net.h>
#include <asm/blackfin.h> #include <asm/blackfin.h>
#include <asm/net.h>
DECLARE_GLOBAL_DATA_PTR; DECLARE_GLOBAL_DATA_PTR;
...@@ -27,7 +26,7 @@ int checkboard(void) ...@@ -27,7 +26,7 @@ int checkboard(void)
static void board_init_enetaddr(uchar *mac_addr) static void board_init_enetaddr(uchar *mac_addr)
{ {
puts("Warning: Generating 'random' MAC address\n"); puts("Warning: Generating 'random' MAC address\n");
bfin_gen_rand_mac(mac_addr); eth_random_addr(mac_addr);
eth_setenv_enetaddr("ethaddr", mac_addr); eth_setenv_enetaddr("ethaddr", mac_addr);
} }
......
...@@ -12,7 +12,6 @@ ...@@ -12,7 +12,6 @@
#include <netdev.h> #include <netdev.h>
#include <net.h> #include <net.h>
#include <asm/blackfin.h> #include <asm/blackfin.h>
#include <asm/net.h>
DECLARE_GLOBAL_DATA_PTR; DECLARE_GLOBAL_DATA_PTR;
...@@ -27,7 +26,7 @@ int checkboard(void) ...@@ -27,7 +26,7 @@ int checkboard(void)
static void board_init_enetaddr(uchar *mac_addr) static void board_init_enetaddr(uchar *mac_addr)
{ {
puts("Warning: Generating 'random' MAC address\n"); puts("Warning: Generating 'random' MAC address\n");
bfin_gen_rand_mac(mac_addr); eth_random_addr(mac_addr);
eth_setenv_enetaddr("ethaddr", mac_addr); eth_setenv_enetaddr("ethaddr", mac_addr);
} }
......
...@@ -13,7 +13,6 @@ ...@@ -13,7 +13,6 @@
#include <config.h> #include <config.h>
#include <command.h> #include <command.h>
#include <asm/blackfin.h> #include <asm/blackfin.h>
#include <asm/net.h>
#include <net.h> #include <net.h>
#include <asm/mach-common/bits/bootrom.h> #include <asm/mach-common/bits/bootrom.h>
#include <netdev.h> #include <netdev.h>
...@@ -48,7 +47,7 @@ static void board_init_enetaddr(uchar *mac_addr) ...@@ -48,7 +47,7 @@ static void board_init_enetaddr(uchar *mac_addr)
if (!valid_mac) { if (!valid_mac) {
puts("Warning: Generating 'random' MAC address\n"); puts("Warning: Generating 'random' MAC address\n");
bfin_gen_rand_mac(mac_addr); eth_random_addr(mac_addr);
} }
eth_setenv_enetaddr("ethaddr", mac_addr); eth_setenv_enetaddr("ethaddr", mac_addr);
......
...@@ -11,7 +11,6 @@ ...@@ -11,7 +11,6 @@
#include <net.h> #include <net.h>
#include <netdev.h> #include <netdev.h>
#include <asm/blackfin.h> #include <asm/blackfin.h>
#include <asm/net.h>
#include <asm/mach-common/bits/otp.h> #include <asm/mach-common/bits/otp.h>
#include "../cm-bf537e/gpio_cfi_flash.h" #include "../cm-bf537e/gpio_cfi_flash.h"
...@@ -46,7 +45,7 @@ static void board_init_enetaddr(uchar *mac_addr) ...@@ -46,7 +45,7 @@ static void board_init_enetaddr(uchar *mac_addr)
if (!valid_mac) { if (!valid_mac) {
puts("Warning: Generating 'random' MAC address\n"); puts("Warning: Generating 'random' MAC address\n");
bfin_gen_rand_mac(mac_addr); eth_random_addr(mac_addr);
} }
eth_setenv_enetaddr("ethaddr", mac_addr); eth_setenv_enetaddr("ethaddr", mac_addr);
......
...@@ -12,7 +12,6 @@ ...@@ -12,7 +12,6 @@
#include <net.h> #include <net.h>
#include <netdev.h> #include <netdev.h>
#include <asm/blackfin.h> #include <asm/blackfin.h>
#include <asm/net.h>
#include "gpio_cfi_flash.h" #include "gpio_cfi_flash.h"
DECLARE_GLOBAL_DATA_PTR; DECLARE_GLOBAL_DATA_PTR;
...@@ -32,7 +31,7 @@ static void board_init_enetaddr(char *var) ...@@ -32,7 +31,7 @@ static void board_init_enetaddr(char *var)
return; return;
printf("Warning: %s: generating 'random' MAC address\n", var); printf("Warning: %s: generating 'random' MAC address\n", var);
bfin_gen_rand_mac(enetaddr); eth_random_addr(enetaddr);
eth_setenv_enetaddr(var, enetaddr); eth_setenv_enetaddr(var, enetaddr);
} }
......
...@@ -12,7 +12,6 @@ ...@@ -12,7 +12,6 @@
#include <net.h> #include <net.h>
#include <netdev.h> #include <netdev.h>
#include <asm/blackfin.h> #include <asm/blackfin.h>
#include <asm/net.h>
#include "../cm-bf537e/gpio_cfi_flash.h" #include "../cm-bf537e/gpio_cfi_flash.h"
DECLARE_GLOBAL_DATA_PTR; DECLARE_GLOBAL_DATA_PTR;
...@@ -32,7 +31,7 @@ static void board_init_enetaddr(char *var) ...@@ -32,7 +31,7 @@ static void board_init_enetaddr(char *var)
return; return;
printf("Warning: %s: generating 'random' MAC address\n", var); printf("Warning: %s: generating 'random' MAC address\n", var);
bfin_gen_rand_mac(enetaddr); eth_random_addr(enetaddr);
eth_setenv_enetaddr(var, enetaddr); eth_setenv_enetaddr(var, enetaddr);
} }
......
...@@ -14,7 +14,6 @@ ...@@ -14,7 +14,6 @@
#include <common.h> #include <common.h>
#include <config.h> #include <config.h>
#include <asm/blackfin.h> #include <asm/blackfin.h>
#include <asm/net.h>
#include <net.h> #include <net.h>
#include <netdev.h> #include <netdev.h>
#include <asm/gpio.h> #include <asm/gpio.h>
...@@ -55,7 +54,7 @@ static void board_init_enetaddr(uchar *mac_addr) ...@@ -55,7 +54,7 @@ static void board_init_enetaddr(uchar *mac_addr)
if (!valid_mac) { if (!valid_mac) {
puts("Warning: Generating 'random' MAC address\n"); puts("Warning: Generating 'random' MAC address\n");
bfin_gen_rand_mac(mac_addr); eth_random_addr(mac_addr);
} }
eth_setenv_enetaddr("ethaddr", mac_addr); eth_setenv_enetaddr("ethaddr", mac_addr);
......
...@@ -13,7 +13,6 @@ ...@@ -13,7 +13,6 @@
#include <common.h> #include <common.h>
#include <net.h> #include <net.h>
#include <netdev.h> #include <netdev.h>
#include <asm/net.h>
int checkboard(void) int checkboard(void)
{ {
...@@ -33,7 +32,7 @@ int misc_init_r(void) ...@@ -33,7 +32,7 @@ int misc_init_r(void)
uchar enetaddr[6]; uchar enetaddr[6];
if (!eth_getenv_enetaddr("ethaddr", enetaddr)) { if (!eth_getenv_enetaddr("ethaddr", enetaddr)) {
puts("Warning: Generating 'random' MAC address\n"); puts("Warning: Generating 'random' MAC address\n");
bfin_gen_rand_mac(enetaddr); eth_random_addr(enetaddr);
eth_setenv_enetaddr("ethaddr", enetaddr); eth_setenv_enetaddr("ethaddr", enetaddr);
} }
......
...@@ -11,7 +11,6 @@ ...@@ -11,7 +11,6 @@
#include <net.h> #include <net.h>
#include <netdev.h> #include <netdev.h>
#include <asm/blackfin.h> #include <asm/blackfin.h>
#include <asm/net.h>
#include <asm/mach-common/bits/otp.h> #include <asm/mach-common/bits/otp.h>
#include <asm/sdh.h> #include <asm/sdh.h>
...@@ -47,7 +46,7 @@ static void board_init_enetaddr(uchar *mac_addr) ...@@ -47,7 +46,7 @@ static void board_init_enetaddr(uchar *mac_addr)
if (!valid_mac) { if (!valid_mac) {
puts("Warning: Generating 'random' MAC address\n"); puts("Warning: Generating 'random' MAC address\n");
bfin_gen_rand_mac(mac_addr); eth_random_addr(mac_addr);
} }
eth_setenv_enetaddr("ethaddr", mac_addr); eth_setenv_enetaddr("ethaddr", mac_addr);
......
...@@ -12,7 +12,6 @@ ...@@ -12,7 +12,6 @@
#include <net.h> #include <net.h>
#include <netdev.h> #include <netdev.h>
#include <asm/blackfin.h> #include <asm/blackfin.h>
#include <asm/net.h>
#include "../cm-bf537e/gpio_cfi_flash.h" #include "../cm-bf537e/gpio_cfi_flash.h"
DECLARE_GLOBAL_DATA_PTR; DECLARE_GLOBAL_DATA_PTR;
...@@ -32,7 +31,7 @@ static void board_init_enetaddr(char *var) ...@@ -32,7 +31,7 @@ static void board_init_enetaddr(char *var)
return; return;
printf("Warning: %s: generating 'random' MAC address\n", var); printf("Warning: %s: generating 'random' MAC address\n", var);
bfin_gen_rand_mac(enetaddr); eth_random_addr(enetaddr);
eth_setenv_enetaddr(var, enetaddr); eth_setenv_enetaddr(var, enetaddr);
} }
......
...@@ -75,6 +75,7 @@ ...@@ -75,6 +75,7 @@
#define CONFIG_ROOTPATH "/romfs/brettl2" #define CONFIG_ROOTPATH "/romfs/brettl2"
/* Uncomment next line to use fixed MAC address */ /* Uncomment next line to use fixed MAC address */
/* #define CONFIG_ETHADDR 02:80:ad:20:31:e8 */ /* #define CONFIG_ETHADDR 02:80:ad:20:31:e8 */
#define CONFIG_LIB_RAND
#endif #endif
......
...@@ -89,7 +89,7 @@ ...@@ -89,7 +89,7 @@
#define CONFIG_PHY_ADDR 3 #define CONFIG_PHY_ADDR 3
/* Uncomment next line to use fixed MAC address */ /* Uncomment next line to use fixed MAC address */
/* #define CONFIG_ETHADDR 02:80:ad:20:31:e8 */ /* #define CONFIG_ETHADDR 02:80:ad:20:31:e8 */
#define CONFIG_LIB_RAND
/* /*
* Flash Settings * Flash Settings
......
...@@ -87,7 +87,7 @@ ...@@ -87,7 +87,7 @@
#define CONFIG_HOSTNAME bf526-ezbrd #define CONFIG_HOSTNAME bf526-ezbrd
/* Uncomment next line to use fixed MAC address */ /* Uncomment next line to use fixed MAC address */
/* #define CONFIG_ETHADDR 02:80:ad:20:31:e8 */ /* #define CONFIG_ETHADDR 02:80:ad:20:31:e8 */
#define CONFIG_LIB_RAND
/* /*
* Flash Settings * Flash Settings
......
...@@ -85,7 +85,7 @@ ...@@ -85,7 +85,7 @@
#define CONFIG_HOSTNAME bf527-ezkit #define CONFIG_HOSTNAME bf527-ezkit
/* Uncomment next line to use fixed MAC address */ /* Uncomment next line to use fixed MAC address */
/* #define CONFIG_ETHADDR 02:80:ad:20:31:e8 */ /* #define CONFIG_ETHADDR 02:80:ad:20:31:e8 */
#define CONFIG_LIB_RAND
/* /*
* Flash Settings * Flash Settings
......
...@@ -89,6 +89,7 @@ ...@@ -89,6 +89,7 @@
/* Uncomment next line to use fixed MAC address */ /* Uncomment next line to use fixed MAC address */
/* #define CONFIG_ETHADDR 02:80:ad:20:31:42 */ /* #define CONFIG_ETHADDR 02:80:ad:20:31:42 */
#define CONFIG_LIB_RAND
/* /*
* Flash Settings * Flash Settings
......
...@@ -67,7 +67,7 @@ ...@@ -67,7 +67,7 @@
#define CONFIG_HOSTNAME bf537-pnav #define CONFIG_HOSTNAME bf537-pnav
/* Uncomment next line to use fixed MAC address */ /* Uncomment next line to use fixed MAC address */
/* #define CONFIG_ETHADDR 02:80:ad:24:21:18 */ /* #define CONFIG_ETHADDR 02:80:ad:24:21:18 */
#define CONFIG_LIB_RAND
/* /*
* Flash Settings * Flash Settings
......
...@@ -88,7 +88,7 @@ ...@@ -88,7 +88,7 @@
#define CONFIG_ROOTPATH "/romfs" #define CONFIG_ROOTPATH "/romfs"
/* Uncomment next line to use fixed MAC address */ /* Uncomment next line to use fixed MAC address */
/* #define CONFIG_ETHADDR 02:80:ad:20:31:42 */ /* #define CONFIG_ETHADDR 02:80:ad:20:31:42 */
#define CONFIG_LIB_RAND
/* /*
* Flash Settings * Flash Settings
......
...@@ -67,7 +67,7 @@ ...@@ -67,7 +67,7 @@
#define CONFIG_HOSTNAME bf537-stamp #define CONFIG_HOSTNAME bf537-stamp
/* Uncomment next line to use fixed MAC address */ /* Uncomment next line to use fixed MAC address */
/* #define CONFIG_ETHADDR 02:80:ad:20:31:e8 */ /* #define CONFIG_ETHADDR 02:80:ad:20:31:e8 */
#define CONFIG_LIB_RAND
/* /*
* Flash Settings * Flash Settings
......
...@@ -85,7 +85,7 @@ ...@@ -85,7 +85,7 @@
#define CONFIG_HOSTNAME cm-bf527 #define CONFIG_HOSTNAME cm-bf527
/* Uncomment next line to use fixed MAC address */ /* Uncomment next line to use fixed MAC address */
/* #define CONFIG_ETHADDR 02:80:ad:20:31:e8 */ /* #define CONFIG_ETHADDR 02:80:ad:20:31:e8 */
#define CONFIG_LIB_RAND
/* /*
* Flash Settings * Flash Settings
......
...@@ -73,7 +73,7 @@ ...@@ -73,7 +73,7 @@
#define CONFIG_HOSTNAME cm-bf537e #define CONFIG_HOSTNAME cm-bf537e
/* Uncomment next line to use fixed MAC address */ /* Uncomment next line to use fixed MAC address */
/* #define CONFIG_ETHADDR 02:80:ad:20:31:e8 */ /* #define CONFIG_ETHADDR 02:80:ad:20:31:e8 */
#define CONFIG_LIB_RAND
/* /*
* Flash Settings * Flash Settings
......
...@@ -71,7 +71,7 @@ ...@@ -71,7 +71,7 @@
#define CONFIG_HOSTNAME cm-bf537u #define CONFIG_HOSTNAME cm-bf537u
/* Uncomment next line to use fixed MAC address */ /* Uncomment next line to use fixed MAC address */
/* #define CONFIG_ETHADDR 02:80:ad:20:31:e8 */ /* #define CONFIG_ETHADDR 02:80:ad:20:31:e8 */
#define CONFIG_LIB_RAND
/* /*
* Flash Settings * Flash Settings
......
...@@ -55,6 +55,8 @@ ...@@ -55,6 +55,8 @@
#define CONFIG_CMD_MII #define CONFIG_CMD_MII
#define CONFIG_CMD_PING #define CONFIG_CMD_PING
#define CONFIG_LIB_RAND
#endif #endif
/* /*
......
...@@ -77,6 +77,7 @@ ...@@ -77,6 +77,7 @@
#define DM9000_IO CONFIG_DM9000_BASE #define DM9000_IO CONFIG_DM9000_BASE
#define DM9000_DATA (CONFIG_DM9000_BASE + 2) #define DM9000_DATA (CONFIG_DM9000_BASE + 2)
#define CONFIG_LIB_RAND
/* /*
* Flash Settings * Flash Settings
......
...@@ -68,7 +68,7 @@ ...@@ -68,7 +68,7 @@
#define CONFIG_HOSTNAME tcm-bf518 #define CONFIG_HOSTNAME tcm-bf518
/* Uncomment next line to use fixed MAC address */ /* Uncomment next line to use fixed MAC address */
/* #define CONFIG_ETHADDR 02:80:ad:20:31:e8 */ /* #define CONFIG_ETHADDR 02:80:ad:20:31:e8 */
#define CONFIG_LIB_RAND
/* /*
* Flash Settings * Flash Settings
......
...@@ -73,7 +73,7 @@ ...@@ -73,7 +73,7 @@
#define CONFIG_HOSTNAME tcm-bf537 #define CONFIG_HOSTNAME tcm-bf537
/* Uncomment next line to use fixed MAC address */ /* Uncomment next line to use fixed MAC address */
/* #define CONFIG_ETHADDR 02:80:ad:20:31:e8 */ /* #define CONFIG_ETHADDR 02:80:ad:20:31:e8 */
#define CONFIG_LIB_RAND
/* /*
* Flash Settings * Flash Settings
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment