Commit c42f56d96d1ec642496ee0fdf741dc13fbbec2e2

Authored by Masahiro Yamada
Committed by Tom Rini
1 parent da384a9d76

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: Masahiro Yamada <yamada.m@jp.panasonic.com>
Cc: Sonic Zhang <sonic.zhang@analog.com>

Showing 31 changed files with 31 additions and 69 deletions Side-by-side Diff

arch/blackfin/include/asm/net.h
1   -/*
2   - * net.h - misc Blackfin network helpers
3   - *
4   - * Copyright (c) 2008-2009 Analog Devices Inc.
5   - *
6   - * Licensed under the GPL-2 or later.
7   - */
8   -
9   -#ifndef __ASM_BFIN_RAND_MAC__
10   -#define __ASM_BFIN_RAND_MAC__
11   -
12   -/* If the board does not have a real MAC assigned to it, then generate a
13   - * locally administrated pseudo-random one based on CYCLES and compile date.
14   - */
15   -static inline void bfin_gen_rand_mac(uchar *mac_addr)
16   -{
17   - /* make something up */
18   - const char s[] = __DATE__;
19   - size_t i;
20   - u32 cycles;
21   - for (i = 0; i < 6; ++i) {
22   - asm("%0 = CYCLES;" : "=r" (cycles));
23   - mac_addr[i] = cycles ^ s[i];
24   - }
25   - mac_addr[0] = (mac_addr[0] | 0x02) & ~0x01; /* make it local unicast */
26   -}
27   -
28   -#endif
board/bct-brettl2/bct-brettl2.c
... ... @@ -12,7 +12,6 @@
12 12 #include <asm/blackfin.h>
13 13 #include <asm/portmux.h>
14 14 #include <asm/gpio.h>
15   -#include <asm/net.h>
16 15 #include <net.h>
17 16 #include <netdev.h>
18 17 #include <miiphy.h>
... ... @@ -33,7 +32,7 @@
33 32 static void board_init_enetaddr(uchar *mac_addr)
34 33 {
35 34 puts("Warning: Generating 'random' MAC address\n");
36   - bfin_gen_rand_mac(mac_addr);
  35 + eth_random_addr(mac_addr);
37 36 eth_setenv_enetaddr("ethaddr", mac_addr);
38 37 }
39 38  
board/bf518f-ezbrd/bf518f-ezbrd.c
... ... @@ -13,7 +13,6 @@
13 13 #include <netdev.h>
14 14 #include <spi.h>
15 15 #include <asm/blackfin.h>
16   -#include <asm/net.h>
17 16 #include <asm/portmux.h>
18 17 #include <asm/mach-common/bits/otp.h>
19 18 #include <asm/sdh.h>
... ... @@ -48,7 +47,7 @@
48 47  
49 48 if (!valid_mac) {
50 49 puts("Warning: Generating 'random' MAC address\n");
51   - bfin_gen_rand_mac(mac_addr);
  50 + eth_random_addr(mac_addr);
52 51 }
53 52  
54 53 eth_setenv_enetaddr("ethaddr", mac_addr);
board/bf526-ezbrd/bf526-ezbrd.c
... ... @@ -12,7 +12,6 @@
12 12 #include <net.h>
13 13 #include <netdev.h>
14 14 #include <asm/blackfin.h>
15   -#include <asm/net.h>
16 15 #include <asm/mach-common/bits/otp.h>
17 16  
18 17 DECLARE_GLOBAL_DATA_PTR;
... ... @@ -45,7 +44,7 @@
45 44  
46 45 if (!valid_mac) {
47 46 puts("Warning: Generating 'random' MAC address\n");
48   - bfin_gen_rand_mac(mac_addr);
  47 + eth_random_addr(mac_addr);
49 48 }
50 49  
51 50 eth_setenv_enetaddr("ethaddr", mac_addr);
board/bf527-ezkit/bf527-ezkit.c
... ... @@ -13,7 +13,6 @@
13 13 #include <netdev.h>
14 14 #include <asm/blackfin.h>
15 15 #include <asm/gpio.h>
16   -#include <asm/net.h>
17 16 #include <asm/mach-common/bits/otp.h>
18 17  
19 18 DECLARE_GLOBAL_DATA_PTR;
... ... @@ -47,7 +46,7 @@
47 46  
48 47 if (!valid_mac) {
49 48 puts("Warning: Generating 'random' MAC address\n");
50   - bfin_gen_rand_mac(mac_addr);
  49 + eth_random_addr(mac_addr);
51 50 }
52 51  
53 52 eth_setenv_enetaddr("ethaddr", mac_addr);
board/bf537-minotaur/bf537-minotaur.c
... ... @@ -12,7 +12,6 @@
12 12 #include <netdev.h>
13 13 #include <net.h>
14 14 #include <asm/blackfin.h>
15   -#include <asm/net.h>
16 15  
17 16 DECLARE_GLOBAL_DATA_PTR;
18 17  
... ... @@ -27,7 +26,7 @@
27 26 static void board_init_enetaddr(uchar *mac_addr)
28 27 {
29 28 puts("Warning: Generating 'random' MAC address\n");
30   - bfin_gen_rand_mac(mac_addr);
  29 + eth_random_addr(mac_addr);
31 30 eth_setenv_enetaddr("ethaddr", mac_addr);
32 31 }
33 32  
board/bf537-pnav/bf537-pnav.c
... ... @@ -12,7 +12,6 @@
12 12 #include <netdev.h>
13 13 #include <net.h>
14 14 #include <asm/blackfin.h>
15   -#include <asm/net.h>
16 15  
17 16 DECLARE_GLOBAL_DATA_PTR;
18 17  
... ... @@ -27,7 +26,7 @@
27 26 static void board_init_enetaddr(uchar *mac_addr)
28 27 {
29 28 puts("Warning: Generating 'random' MAC address\n");
30   - bfin_gen_rand_mac(mac_addr);
  29 + eth_random_addr(mac_addr);
31 30 eth_setenv_enetaddr("ethaddr", mac_addr);
32 31 }
33 32  
board/bf537-srv1/bf537-srv1.c
... ... @@ -12,7 +12,6 @@
12 12 #include <netdev.h>
13 13 #include <net.h>
14 14 #include <asm/blackfin.h>
15   -#include <asm/net.h>
16 15  
17 16 DECLARE_GLOBAL_DATA_PTR;
18 17  
... ... @@ -27,7 +26,7 @@
27 26 static void board_init_enetaddr(uchar *mac_addr)
28 27 {
29 28 puts("Warning: Generating 'random' MAC address\n");
30   - bfin_gen_rand_mac(mac_addr);
  29 + eth_random_addr(mac_addr);
31 30 eth_setenv_enetaddr("ethaddr", mac_addr);
32 31 }
33 32  
board/bf537-stamp/bf537-stamp.c
... ... @@ -13,7 +13,6 @@
13 13 #include <config.h>
14 14 #include <command.h>
15 15 #include <asm/blackfin.h>
16   -#include <asm/net.h>
17 16 #include <net.h>
18 17 #include <asm/mach-common/bits/bootrom.h>
19 18 #include <netdev.h>
... ... @@ -48,7 +47,7 @@
48 47  
49 48 if (!valid_mac) {
50 49 puts("Warning: Generating 'random' MAC address\n");
51   - bfin_gen_rand_mac(mac_addr);
  50 + eth_random_addr(mac_addr);
52 51 }
53 52  
54 53 eth_setenv_enetaddr("ethaddr", mac_addr);
board/cm-bf527/cm-bf527.c
... ... @@ -11,7 +11,6 @@
11 11 #include <net.h>
12 12 #include <netdev.h>
13 13 #include <asm/blackfin.h>
14   -#include <asm/net.h>
15 14 #include <asm/mach-common/bits/otp.h>
16 15 #include "../cm-bf537e/gpio_cfi_flash.h"
17 16  
... ... @@ -46,7 +45,7 @@
46 45  
47 46 if (!valid_mac) {
48 47 puts("Warning: Generating 'random' MAC address\n");
49   - bfin_gen_rand_mac(mac_addr);
  48 + eth_random_addr(mac_addr);
50 49 }
51 50  
52 51 eth_setenv_enetaddr("ethaddr", mac_addr);
board/cm-bf537e/cm-bf537e.c
... ... @@ -12,7 +12,6 @@
12 12 #include <net.h>
13 13 #include <netdev.h>
14 14 #include <asm/blackfin.h>
15   -#include <asm/net.h>
16 15 #include "gpio_cfi_flash.h"
17 16  
18 17 DECLARE_GLOBAL_DATA_PTR;
... ... @@ -32,7 +31,7 @@
32 31 return;
33 32  
34 33 printf("Warning: %s: generating 'random' MAC address\n", var);
35   - bfin_gen_rand_mac(enetaddr);
  34 + eth_random_addr(enetaddr);
36 35 eth_setenv_enetaddr(var, enetaddr);
37 36 }
38 37  
board/cm-bf537u/cm-bf537u.c
... ... @@ -12,7 +12,6 @@
12 12 #include <net.h>
13 13 #include <netdev.h>
14 14 #include <asm/blackfin.h>
15   -#include <asm/net.h>
16 15 #include "../cm-bf537e/gpio_cfi_flash.h"
17 16  
18 17 DECLARE_GLOBAL_DATA_PTR;
... ... @@ -32,7 +31,7 @@
32 31 return;
33 32  
34 33 printf("Warning: %s: generating 'random' MAC address\n", var);
35   - bfin_gen_rand_mac(enetaddr);
  34 + eth_random_addr(enetaddr);
36 35 eth_setenv_enetaddr(var, enetaddr);
37 36 }
38 37  
board/dnp5370/dnp5370.c
... ... @@ -14,7 +14,6 @@
14 14 #include <common.h>
15 15 #include <config.h>
16 16 #include <asm/blackfin.h>
17   -#include <asm/net.h>
18 17 #include <net.h>
19 18 #include <netdev.h>
20 19 #include <asm/gpio.h>
... ... @@ -55,7 +54,7 @@
55 54  
56 55 if (!valid_mac) {
57 56 puts("Warning: Generating 'random' MAC address\n");
58   - bfin_gen_rand_mac(mac_addr);
  57 + eth_random_addr(mac_addr);
59 58 }
60 59  
61 60 eth_setenv_enetaddr("ethaddr", mac_addr);
... ... @@ -13,7 +13,6 @@
13 13 #include <common.h>
14 14 #include <net.h>
15 15 #include <netdev.h>
16   -#include <asm/net.h>
17 16  
18 17 int checkboard(void)
19 18 {
... ... @@ -33,7 +32,7 @@
33 32 uchar enetaddr[6];
34 33 if (!eth_getenv_enetaddr("ethaddr", enetaddr)) {
35 34 puts("Warning: Generating 'random' MAC address\n");
36   - bfin_gen_rand_mac(enetaddr);
  35 + eth_random_addr(enetaddr);
37 36 eth_setenv_enetaddr("ethaddr", enetaddr);
38 37 }
39 38  
board/tcm-bf518/tcm-bf518.c
... ... @@ -11,7 +11,6 @@
11 11 #include <net.h>
12 12 #include <netdev.h>
13 13 #include <asm/blackfin.h>
14   -#include <asm/net.h>
15 14 #include <asm/mach-common/bits/otp.h>
16 15 #include <asm/sdh.h>
17 16  
... ... @@ -47,7 +46,7 @@
47 46  
48 47 if (!valid_mac) {
49 48 puts("Warning: Generating 'random' MAC address\n");
50   - bfin_gen_rand_mac(mac_addr);
  49 + eth_random_addr(mac_addr);
51 50 }
52 51  
53 52 eth_setenv_enetaddr("ethaddr", mac_addr);
board/tcm-bf537/tcm-bf537.c
... ... @@ -12,7 +12,6 @@
12 12 #include <net.h>
13 13 #include <netdev.h>
14 14 #include <asm/blackfin.h>
15   -#include <asm/net.h>
16 15 #include "../cm-bf537e/gpio_cfi_flash.h"
17 16  
18 17 DECLARE_GLOBAL_DATA_PTR;
... ... @@ -32,7 +31,7 @@
32 31 return;
33 32  
34 33 printf("Warning: %s: generating 'random' MAC address\n", var);
35   - bfin_gen_rand_mac(enetaddr);
  34 + eth_random_addr(enetaddr);
36 35 eth_setenv_enetaddr(var, enetaddr);
37 36 }
38 37  
include/configs/bct-brettl2.h
... ... @@ -75,6 +75,7 @@
75 75 #define CONFIG_ROOTPATH "/romfs/brettl2"
76 76 /* Uncomment next line to use fixed MAC address */
77 77 /* #define CONFIG_ETHADDR 02:80:ad:20:31:e8 */
  78 +#define CONFIG_LIB_RAND
78 79 #endif
79 80  
80 81  
include/configs/bf518f-ezbrd.h
... ... @@ -89,7 +89,7 @@
89 89 #define CONFIG_PHY_ADDR 3
90 90 /* Uncomment next line to use fixed MAC address */
91 91 /* #define CONFIG_ETHADDR 02:80:ad:20:31:e8 */
92   -
  92 +#define CONFIG_LIB_RAND
93 93  
94 94 /*
95 95 * Flash Settings
include/configs/bf526-ezbrd.h
... ... @@ -87,7 +87,7 @@
87 87 #define CONFIG_HOSTNAME bf526-ezbrd
88 88 /* Uncomment next line to use fixed MAC address */
89 89 /* #define CONFIG_ETHADDR 02:80:ad:20:31:e8 */
90   -
  90 +#define CONFIG_LIB_RAND
91 91  
92 92 /*
93 93 * Flash Settings
include/configs/bf527-ezkit.h
... ... @@ -85,7 +85,7 @@
85 85 #define CONFIG_HOSTNAME bf527-ezkit
86 86 /* Uncomment next line to use fixed MAC address */
87 87 /* #define CONFIG_ETHADDR 02:80:ad:20:31:e8 */
88   -
  88 +#define CONFIG_LIB_RAND
89 89  
90 90 /*
91 91 * Flash Settings
include/configs/bf537-minotaur.h
... ... @@ -89,6 +89,7 @@
89 89 /* Uncomment next line to use fixed MAC address */
90 90 /* #define CONFIG_ETHADDR 02:80:ad:20:31:42 */
91 91  
  92 +#define CONFIG_LIB_RAND
92 93  
93 94 /*
94 95 * Flash Settings
include/configs/bf537-pnav.h
... ... @@ -67,7 +67,7 @@
67 67 #define CONFIG_HOSTNAME bf537-pnav
68 68 /* Uncomment next line to use fixed MAC address */
69 69 /* #define CONFIG_ETHADDR 02:80:ad:24:21:18 */
70   -
  70 +#define CONFIG_LIB_RAND
71 71  
72 72 /*
73 73 * Flash Settings
include/configs/bf537-srv1.h
... ... @@ -88,7 +88,7 @@
88 88 #define CONFIG_ROOTPATH "/romfs"
89 89 /* Uncomment next line to use fixed MAC address */
90 90 /* #define CONFIG_ETHADDR 02:80:ad:20:31:42 */
91   -
  91 +#define CONFIG_LIB_RAND
92 92  
93 93 /*
94 94 * Flash Settings
include/configs/bf537-stamp.h
... ... @@ -67,7 +67,7 @@
67 67 #define CONFIG_HOSTNAME bf537-stamp
68 68 /* Uncomment next line to use fixed MAC address */
69 69 /* #define CONFIG_ETHADDR 02:80:ad:20:31:e8 */
70   -
  70 +#define CONFIG_LIB_RAND
71 71  
72 72 /*
73 73 * Flash Settings
include/configs/cm-bf527.h
... ... @@ -85,7 +85,7 @@
85 85 #define CONFIG_HOSTNAME cm-bf527
86 86 /* Uncomment next line to use fixed MAC address */
87 87 /* #define CONFIG_ETHADDR 02:80:ad:20:31:e8 */
88   -
  88 +#define CONFIG_LIB_RAND
89 89  
90 90 /*
91 91 * Flash Settings
include/configs/cm-bf537e.h
... ... @@ -73,7 +73,7 @@
73 73 #define CONFIG_HOSTNAME cm-bf537e
74 74 /* Uncomment next line to use fixed MAC address */
75 75 /* #define CONFIG_ETHADDR 02:80:ad:20:31:e8 */
76   -
  76 +#define CONFIG_LIB_RAND
77 77  
78 78 /*
79 79 * Flash Settings
include/configs/cm-bf537u.h
... ... @@ -71,7 +71,7 @@
71 71 #define CONFIG_HOSTNAME cm-bf537u
72 72 /* Uncomment next line to use fixed MAC address */
73 73 /* #define CONFIG_ETHADDR 02:80:ad:20:31:e8 */
74   -
  74 +#define CONFIG_LIB_RAND
75 75  
76 76 /*
77 77 * Flash Settings
include/configs/dnp5370.h
... ... @@ -55,6 +55,8 @@
55 55  
56 56 #define CONFIG_CMD_MII
57 57 #define CONFIG_CMD_PING
  58 +
  59 +#define CONFIG_LIB_RAND
58 60 #endif
59 61  
60 62 /*
include/configs/ip04.h
... ... @@ -77,6 +77,7 @@
77 77 #define DM9000_IO CONFIG_DM9000_BASE
78 78 #define DM9000_DATA (CONFIG_DM9000_BASE + 2)
79 79  
  80 +#define CONFIG_LIB_RAND
80 81  
81 82 /*
82 83 * Flash Settings
include/configs/tcm-bf518.h
... ... @@ -68,7 +68,7 @@
68 68 #define CONFIG_HOSTNAME tcm-bf518
69 69 /* Uncomment next line to use fixed MAC address */
70 70 /* #define CONFIG_ETHADDR 02:80:ad:20:31:e8 */
71   -
  71 +#define CONFIG_LIB_RAND
72 72  
73 73 /*
74 74 * Flash Settings
include/configs/tcm-bf537.h
... ... @@ -73,7 +73,7 @@
73 73 #define CONFIG_HOSTNAME tcm-bf537
74 74 /* Uncomment next line to use fixed MAC address */
75 75 /* #define CONFIG_ETHADDR 02:80:ad:20:31:e8 */
76   -
  76 +#define CONFIG_LIB_RAND
77 77  
78 78 /*
79 79 * Flash Settings