Skip to content

Commit ebb75b3

Browse files
ndrs-pstnashif
authored andcommitted
drivers: ethernet: stm32: replace reverse with intrinsic __RBIT
Replaced the software `reverse` function, used for bit reversal, with the intrinsic `__RBIT` function. This utilizes the hardware bit-reversal instruction for improved efficiency. Signed-off-by: Pisit Sawangvonganan <[email protected]>
1 parent bcc6d41 commit ebb75b3

File tree

1 file changed

+1
-15
lines changed

1 file changed

+1
-15
lines changed

drivers/ethernet/eth_stm32_hal.c

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1239,20 +1239,6 @@ static int eth_initialize(const struct device *dev)
12391239
}
12401240

12411241
#if defined(CONFIG_ETH_STM32_MULTICAST_FILTER)
1242-
static uint32_t reverse(uint32_t val)
1243-
{
1244-
uint32_t res = 0;
1245-
int i;
1246-
1247-
for (i = 0; i < 32; i++) {
1248-
if (val & BIT(i)) {
1249-
res |= BIT(31 - i);
1250-
}
1251-
}
1252-
1253-
return res;
1254-
}
1255-
12561242
static void eth_stm32_mcast_filter(const struct device *dev, const struct ethernet_filter *filter)
12571243
{
12581244
struct eth_stm32_hal_dev_data *dev_data = (struct eth_stm32_hal_dev_data *)dev->data;
@@ -1263,7 +1249,7 @@ static void eth_stm32_mcast_filter(const struct device *dev, const struct ethern
12631249

12641250
heth = &dev_data->heth;
12651251

1266-
crc = reverse(crc32_ieee(filter->mac_address.addr, sizeof(struct net_eth_addr)));
1252+
crc = __RBIT(crc32_ieee(filter->mac_address.addr, sizeof(struct net_eth_addr)));
12671253
hash_index = (crc >> 26) & 0x3f;
12681254

12691255
__ASSERT_NO_MSG(hash_index < ARRAY_SIZE(dev_data->hash_index_cnt));

0 commit comments

Comments
 (0)