drivers: ieee802154: use sys_rand_get directly

use sys_rand_get() directly.

Signed-off-by: Fin Maaß <f.maass@vogl-electronic.com>
This commit is contained in:
Fin Maaß 2024-04-03 11:38:07 +02:00 committed by Carles Cufí
parent 362389ee17
commit 9e8e21b36f
8 changed files with 8 additions and 30 deletions

View File

@ -110,11 +110,7 @@ static inline uint8_t *b91_get_mac(const struct device *dev)
struct b91_data *b91 = dev->data;
#if defined(CONFIG_IEEE802154_B91_RANDOM_MAC)
uint32_t *ptr = (uint32_t *)(b91->mac_addr);
UNALIGNED_PUT(sys_rand32_get(), ptr);
ptr = (uint32_t *)(b91->mac_addr + 4);
UNALIGNED_PUT(sys_rand32_get(), ptr);
sys_rand_get(b91->mac_addr, sizeof(b91->mac_addr));
/*
* Clear bit 0 to ensure it isn't a multicast address and set

View File

@ -129,9 +129,7 @@ static inline uint8_t *get_mac(const struct device *dev)
struct cc1200_context *cc1200 = dev->data;
#if defined(CONFIG_IEEE802154_CC1200_RANDOM_MAC)
uint32_t *ptr = (uint32_t *)(cc1200->mac_addr + 4);
UNALIGNED_PUT(sys_rand32_get(), ptr);
sys_rand_get(&cc1200->mac_addr[4], 4U);
cc1200->mac_addr[7] = (cc1200->mac_addr[7] & ~0x01) | 0x02;
#else

View File

@ -279,9 +279,7 @@ static inline uint8_t *get_mac(const struct device *dev)
struct cc2520_context *cc2520 = dev->data;
#if defined(CONFIG_IEEE802154_CC2520_RANDOM_MAC)
uint32_t *ptr = (uint32_t *)(cc2520->mac_addr + 4);
UNALIGNED_PUT(sys_rand32_get(), ptr);
sys_rand_get(&cc2520->mac_addr[4], 4U);
cc2520->mac_addr[7] = (cc2520->mac_addr[7] & ~0x01) | 0x02;
#else

View File

@ -1633,11 +1633,8 @@ static int dw1000_init(const struct device *dev)
static inline uint8_t *get_mac(const struct device *dev)
{
struct dwt_context *dw1000 = dev->data;
uint32_t *ptr = (uint32_t *)(dw1000->mac_addr);
UNALIGNED_PUT(sys_rand32_get(), ptr);
ptr = (uint32_t *)(dw1000->mac_addr + 4);
UNALIGNED_PUT(sys_rand32_get(), ptr);
sys_rand_get(dw1000->mac_addr, sizeof(dw1000->mac_addr));
dw1000->mac_addr[0] = (dw1000->mac_addr[0] & ~0x01) | 0x02;

View File

@ -935,11 +935,7 @@ static inline uint8_t *get_mac(const struct device *dev)
* and how to allow for a OUI portion?
*/
uint32_t *ptr = (uint32_t *)(kw41z->mac_addr);
UNALIGNED_PUT(sys_rand32_get(), ptr);
ptr = (uint32_t *)(kw41z->mac_addr + 4);
UNALIGNED_PUT(sys_rand32_get(), ptr);
sys_rand_get(kw41z->mac_addr, sizeof(kw41z->mac_addr));
/*
* Clear bit 0 to ensure it isn't a multicast address and set

View File

@ -515,11 +515,8 @@ static inline int16_t mcr20a_get_rssi(uint8_t lqi)
static inline uint8_t *get_mac(const struct device *dev)
{
struct mcr20a_context *mcr20a = dev->data;
uint32_t *ptr = (uint32_t *)(mcr20a->mac_addr);
UNALIGNED_PUT(sys_rand32_get(), ptr);
ptr = (uint32_t *)(mcr20a->mac_addr + 4);
UNALIGNED_PUT(sys_rand32_get(), ptr);
sys_rand_get(mcr20a->mac_addr, sizeof(mcr20a->mac_addr));
mcr20a->mac_addr[0] = (mcr20a->mac_addr[0] & ~0x01) | 0x02;

View File

@ -347,12 +347,9 @@ static inline uint8_t *get_mac(const struct device *dev)
{
const struct rf2xx_config *conf = dev->config;
struct rf2xx_context *ctx = dev->data;
uint32_t *ptr = (uint32_t *)(ctx->mac_addr);
if (!conf->has_mac) {
UNALIGNED_PUT(sys_rand32_get(), ptr);
ptr = (uint32_t *)(ctx->mac_addr + 4);
UNALIGNED_PUT(sys_rand32_get(), ptr);
sys_rand_get(ctx->mac_addr, sizeof(ctx->mac_addr));
}
/*

View File

@ -357,8 +357,7 @@ static inline uint8_t *get_mac(const struct device *dev)
upipe->mac_addr[3] = 0x30;
#if defined(CONFIG_IEEE802154_UPIPE_RANDOM_MAC)
UNALIGNED_PUT(sys_cpu_to_be32(sys_rand32_get()),
(uint32_t *) ((uint8_t *)upipe->mac_addr+4));
sys_rand_get(&upipe->mac_addr[4], 4U);
#else
upipe->mac_addr[4] = CONFIG_IEEE802154_UPIPE_MAC4;
upipe->mac_addr[5] = CONFIG_IEEE802154_UPIPE_MAC5;