Skip to content

Commit

Permalink
drivers: ethernet: fix adin set_config
Browse files Browse the repository at this point in the history
Corrects set_config to allow MAC config
at runtime.

* Add missing device lock
* Use correct mac argument

Signed-off-by: Georgij Cernysiov <[email protected]>
  • Loading branch information
GeorgeCGV authored and carlescufi committed Oct 25, 2023
1 parent cf51345 commit e364f29
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions drivers/ethernet/eth_adin2111.c
Original file line number Diff line number Diff line change
Expand Up @@ -696,19 +696,23 @@ static int adin2111_port_set_config(const struct device *dev,
const struct device *adin = cfg->adin;
int ret = -ENOTSUP;

(void)eth_adin2111_lock(dev, K_FOREVER);

if (type == ETHERNET_CONFIG_TYPE_MAC_ADDRESS) {
ret = adin2111_filter_unicast(adin, data->mac_addr, cfg->port_idx);
ret = adin2111_filter_unicast(adin, (uint8_t *)&config->mac_address.addr[0],
cfg->port_idx);
if (ret < 0) {
return ret;
goto end_unlock;
}

memcpy(data->mac_addr, config->mac_address.addr, sizeof(data->mac_addr));
(void)memcpy(data->mac_addr, config->mac_address.addr, sizeof(data->mac_addr));

net_if_set_link_addr(data->iface, data->mac_addr,
sizeof(data->mac_addr),
NET_LINK_ETHERNET);
(void)net_if_set_link_addr(data->iface, data->mac_addr, sizeof(data->mac_addr),
NET_LINK_ETHERNET);
}

end_unlock:
(void)eth_adin2111_unlock(dev);
return ret;
}

Expand Down

0 comments on commit e364f29

Please sign in to comment.