From 596cd64bb931e8f76c27489fb6a9e886fff42ac6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fin=20Maa=C3=9F?= Date: Wed, 25 Jun 2025 11:53:16 +0200 Subject: [PATCH] drivers: ethernet: use DT_INST_PROP_OR for local-mac-address MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit use DT_INST_PROP_OR for local-mac-address, so that it is not required to be set in dt, as there are other ways to se the mac address. Signed-off-by: Fin Maaß --- drivers/ethernet/dwc_xgmac/eth_dwc_xgmac.c | 2 +- drivers/ethernet/eth_lan865x.c | 2 +- drivers/ethernet/eth_lan9250.c | 2 +- drivers/ethernet/eth_litex_liteeth.c | 3 ++- drivers/ethernet/eth_xilinx_axienet.c | 2 +- drivers/ethernet/eth_xlnx_gem_priv.h | 2 +- 6 files changed, 7 insertions(+), 6 deletions(-) diff --git a/drivers/ethernet/dwc_xgmac/eth_dwc_xgmac.c b/drivers/ethernet/dwc_xgmac/eth_dwc_xgmac.c index 57ab2d04301..6eba5e32632 100644 --- a/drivers/ethernet/dwc_xgmac/eth_dwc_xgmac.c +++ b/drivers/ethernet/dwc_xgmac/eth_dwc_xgmac.c @@ -1699,7 +1699,7 @@ static const struct ethernet_api eth_dwc_xgmac_apis = { /* Device run-time data declaration macro */ #define ETH_DWC_XGMAC_DEV_DATA(port) \ static struct eth_dwc_xgmac_dev_data eth_dwc_xgmac##port##_dev_data = { \ - .mac_addr = DT_INST_PROP(port, local_mac_address), \ + .mac_addr = DT_INST_PROP_OR(port, local_mac_address, {0}), \ .link_speed = DT_INST_PROP(port, max_speed), \ .enable_full_duplex = DT_INST_PROP(port, full_duplex_mode_en), \ .dma_rx_desc = ð_dwc_xgmac##port##_rx_desc[0u][0u], \ diff --git a/drivers/ethernet/eth_lan865x.c b/drivers/ethernet/eth_lan865x.c index bdcb2ec553e..5ac715726ad 100644 --- a/drivers/ethernet/eth_lan865x.c +++ b/drivers/ethernet/eth_lan865x.c @@ -472,7 +472,7 @@ static const struct ethernet_api lan865x_api_func = { struct oa_tc6 oa_tc6_##inst = { \ .cps = 64, .protected = 0, .spi = &lan865x_config_##inst.spi}; \ static struct lan865x_data lan865x_data_##inst = { \ - .mac_address = DT_INST_PROP(inst, local_mac_address), \ + .mac_address = DT_INST_PROP_OR(inst, local_mac_address, {0}), \ .tx_rx_sem = Z_SEM_INITIALIZER((lan865x_data_##inst).tx_rx_sem, 1, 1), \ .int_sem = Z_SEM_INITIALIZER((lan865x_data_##inst).int_sem, 0, 1), \ .tc6 = &oa_tc6_##inst}; \ diff --git a/drivers/ethernet/eth_lan9250.c b/drivers/ethernet/eth_lan9250.c index 1315c9325ac..58616f258f0 100644 --- a/drivers/ethernet/eth_lan9250.c +++ b/drivers/ethernet/eth_lan9250.c @@ -702,7 +702,7 @@ static int lan9250_init(const struct device *dev) #define LAN9250_DEFINE(inst) \ static struct lan9250_runtime lan9250_##inst##_runtime = { \ - .mac_address = DT_INST_PROP(inst, local_mac_address), \ + .mac_address = DT_INST_PROP_OR(inst, local_mac_address, {0}), \ .tx_rx_sem = Z_SEM_INITIALIZER(lan9250_##inst##_runtime.tx_rx_sem, 1, UINT_MAX), \ .int_sem = Z_SEM_INITIALIZER(lan9250_##inst##_runtime.int_sem, 0, UINT_MAX), \ }; \ diff --git a/drivers/ethernet/eth_litex_liteeth.c b/drivers/ethernet/eth_litex_liteeth.c index 97cb73599d5..cbb5d52587c 100644 --- a/drivers/ethernet/eth_litex_liteeth.c +++ b/drivers/ethernet/eth_litex_liteeth.c @@ -331,7 +331,8 @@ static const struct ethernet_api eth_api = { } \ \ static struct eth_litex_dev_data eth_data##n = { \ - .mac_addr = DT_INST_PROP(n, local_mac_address)}; \ + .mac_addr = DT_INST_PROP_OR(n, local_mac_address, {0}), \ + }; \ \ static const struct eth_litex_config eth_config##n = { \ .phy_dev = DEVICE_DT_GET_OR_NULL(DT_INST_PHANDLE(n, phy_handle)), \ diff --git a/drivers/ethernet/eth_xilinx_axienet.c b/drivers/ethernet/eth_xilinx_axienet.c index 340284fb78b..f4d1a62c77c 100644 --- a/drivers/ethernet/eth_xilinx_axienet.c +++ b/drivers/ethernet/eth_xilinx_axienet.c @@ -586,7 +586,7 @@ static const struct ethernet_api xilinx_axienet_api = { } \ \ static struct xilinx_axienet_data data_##inst = { \ - .mac_addr = DT_INST_PROP(inst, local_mac_address), \ + .mac_addr = DT_INST_PROP_OR(inst, local_mac_address, {0}), \ .dma_is_configured_rx = false, \ .dma_is_configured_tx = false}; \ static const struct xilinx_axienet_config config_##inst = { \ diff --git a/drivers/ethernet/eth_xlnx_gem_priv.h b/drivers/ethernet/eth_xlnx_gem_priv.h index a4cb88f93b9..74a3058fddc 100644 --- a/drivers/ethernet/eth_xlnx_gem_priv.h +++ b/drivers/ethernet/eth_xlnx_gem_priv.h @@ -476,7 +476,7 @@ static const struct eth_xlnx_gem_dev_cfg eth_xlnx_gem##port##_dev_cfg = {\ /* Device run-time data declaration macro */ #define ETH_XLNX_GEM_DEV_DATA(port) \ static struct eth_xlnx_gem_dev_data eth_xlnx_gem##port##_dev_data = {\ - .mac_addr = DT_INST_PROP(port, local_mac_address),\ + .mac_addr = DT_INST_PROP_OR(port, local_mac_address, {0}),\ .started = 0,\ .eff_link_speed = LINK_DOWN,\ .phy_addr = 0,\