Commit 792cbb9a authored by Fin Maaß's avatar Fin Maaß Committed by Carles Cufi
Browse files

drivers: ethernet: use sys_rand_get directly



use sys_rand_get() directly.

Signed-off-by: default avatarFin Maaß <f.maass@vogl-electronic.com>
parent 9e8e21b3
Loading
Loading
Loading
Loading
+1 −7
Original line number Diff line number Diff line
@@ -32,10 +32,6 @@

static inline void gen_random_mac(uint8_t *mac_addr, uint8_t b0, uint8_t b1, uint8_t b2)
{
	uint32_t entropy;

	entropy = sys_rand32_get();

	mac_addr[0] = b0;
	mac_addr[1] = b1;
	mac_addr[2] = b2;
@@ -43,9 +39,7 @@ static inline void gen_random_mac(uint8_t *mac_addr, uint8_t b0, uint8_t b1, uin
	/* Set MAC address locally administered, unicast (LAA) */
	mac_addr[0] |= 0x02;

	mac_addr[3] = (entropy >> 16) & 0xff;
	mac_addr[4] = (entropy >>  8) & 0xff;
	mac_addr[5] = (entropy >>  0) & 0xff;
	sys_rand_get(&mac_addr[3], 3U);
}

#endif /* ZEPHYR_DRIVERS_ETHERNET_ETH_H_ */
+1 −4
Original line number Diff line number Diff line
@@ -390,10 +390,7 @@ static const struct ethernet_api eth_ivshmem_api = {
#define ETH_IVSHMEM_RANDOM_MAC_ADDR(inst)						\
	static void generate_mac_addr_##inst(uint8_t mac_addr[6])			\
	{										\
		uint32_t entropy = sys_rand32_get();					\
		mac_addr[0] = (entropy >> 16) & 0xff;					\
		mac_addr[1] = (entropy >>  8) & 0xff;					\
		mac_addr[2] = (entropy >>  0) & 0xff;					\
		sys_rand_get(mac_addr, 3U);						\
		/* Clear multicast bit */						\
		mac_addr[0] &= 0xFE;							\
		gen_random_mac(mac_addr, mac_addr[0], mac_addr[1], mac_addr[2]);	\