diff options
author | Tom Rini <trini@konsulko.com> | 2021-01-19 14:46:45 -0500 |
---|---|---|
committer | Tom Rini <trini@konsulko.com> | 2021-01-19 14:46:45 -0500 |
commit | 9d13cd95f1df7d04f702975cdcdd8e087f71f74c (patch) | |
tree | ecdb97433ba17bf82c463affdf47ab96100cf64b /net/net_rand.h | |
parent | db0dd72e27ce62c5b28f07595b91ed00d0565819 (diff) | |
parent | 1231184caacad32c180d7e2338a645f7dfe9571a (diff) |
Merge branch '2021-01-19-networking-improvements'
- e1000, ftgmac100: Add support for getting the MAC
- General networking improvements
- dwc_eth_qos, ks8851 fixes
Diffstat (limited to 'net/net_rand.h')
-rw-r--r-- | net/net_rand.h | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/net/net_rand.h b/net/net_rand.h index 4bf9bd817e5..6a52cda85e0 100644 --- a/net/net_rand.h +++ b/net/net_rand.h @@ -10,6 +10,8 @@ #define __NET_RAND_H__ #include <common.h> +#include <dm/uclass.h> +#include <rng.h> /* * Return a seed for the PRNG derived from the eth0 MAC address. @@ -37,7 +39,22 @@ static inline unsigned int seed_mac(void) */ static inline void srand_mac(void) { - srand(seed_mac()); + int ret; + struct udevice *devp; + u32 randv = 0; + + if (IS_ENABLED(CONFIG_DM_RNG)) { + ret = uclass_get_device(UCLASS_RNG, 0, &devp); + if (ret) { + ret = dm_rng_read(devp, &randv, sizeof(randv)); + if (ret < 0) + randv = 0; + } + } + if (randv) + srand(randv); + else + srand(seed_mac()); } #endif /* __NET_RAND_H__ */ |