Skip to content

Commit fb7a685

Browse files
committed
drivers: ethernet: dsa_nxp_imx_netc: fix zephyr random mac
zephyr,random-mac-address defaults to 0 or 1, which is always available in generated code. so we can use the value itself. Signed-off-by: Sven Ginka <s.ginka@sensry.de>
1 parent d77b58a commit fb7a685

File tree

2 files changed

+26
-25
lines changed

2 files changed

+26
-25
lines changed

doc/connectivity/networking/dsa.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ of i.MX NETC.
8383
.phy_mode = NETC_PHY_MODE(port), \
8484
}; \
8585
struct dsa_port_config dsa_##n##_##port##_config = { \
86-
.use_random_mac_addr = DT_NODE_HAS_PROP(port, zephyr_random_mac_address), \
86+
.use_random_mac_addr = DT_INST_PROP(port, zephyr_random_mac_address), \
8787
.mac_addr = DT_PROP_OR(port, local_mac_address, {0}), \
8888
.port_idx = DT_REG_ADDR(port), \
8989
.phy_dev = DEVICE_DT_GET_OR_NULL(DT_PHANDLE(port, phy_handle)), \

drivers/ethernet/dsa/dsa_nxp_imx_netc.c

Lines changed: 25 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -115,32 +115,33 @@ static struct dsa_api dsa_netc_api = {
115115
.port_phylink_change = dsa_netc_port_phylink_change,
116116
};
117117

118-
#define DSA_NETC_PORT_INST_INIT(port, n) \
119-
COND_CODE_1(DT_NUM_PINCTRL_STATES(port), \
120-
(PINCTRL_DT_DEFINE(port);), (EMPTY)) \
121-
struct dsa_netc_port_config dsa_netc_##n##_##port##_config = { \
122-
.pincfg = COND_CODE_1(DT_NUM_PINCTRL_STATES(port), \
123-
(PINCTRL_DT_DEV_CONFIG_GET(port)), NULL), \
124-
.phy_mode = NETC_PHY_MODE(port), \
125-
}; \
126-
struct dsa_port_config dsa_##n##_##port##_config = { \
127-
.use_random_mac_addr = DT_NODE_HAS_PROP(port, zephyr_random_mac_address), \
128-
.mac_addr = DT_PROP_OR(port, local_mac_address, {0}), \
129-
.port_idx = DT_REG_ADDR(port), \
130-
.phy_dev = DEVICE_DT_GET_OR_NULL(DT_PHANDLE(port, phy_handle)), \
131-
.phy_mode = DT_PROP_OR(port, phy_connection_type, ""), \
132-
.tag_proto = DT_PROP_OR(port, dsa_tag_protocol, DSA_TAG_PROTO_NOTAG), \
133-
.ethernet_connection = DEVICE_DT_GET_OR_NULL(DT_PHANDLE(port, ethernet)), \
134-
.prv_config = &dsa_netc_##n##_##port##_config, \
135-
}; \
118+
#define DSA_NETC_PORT_INST_INIT(port, n) \
119+
COND_CODE_1(DT_NUM_PINCTRL_STATES(port), (PINCTRL_DT_DEFINE(port);), (EMPTY)) \
120+
\
121+
struct dsa_netc_port_config dsa_netc_##n##_##port##_config = { \
122+
.pincfg = COND_CODE_1(DT_NUM_PINCTRL_STATES(port), \
123+
(PINCTRL_DT_DEV_CONFIG_GET(port)), NULL), \
124+
.phy_mode = NETC_PHY_MODE(port), \
125+
}; \
126+
\
127+
struct dsa_port_config dsa_##n##_##port##_config = { \
128+
.use_random_mac_addr = DT_INST_PROP(port, zephyr_random_mac_address), \
129+
.mac_addr = DT_PROP_OR(port, local_mac_address, {0}), \
130+
.port_idx = DT_REG_ADDR(port), \
131+
.phy_dev = DEVICE_DT_GET_OR_NULL(DT_PHANDLE(port, phy_handle)), \
132+
.phy_mode = DT_PROP_OR(port, phy_connection_type, ""), \
133+
.tag_proto = DT_PROP_OR(port, dsa_tag_protocol, DSA_TAG_PROTO_NOTAG), \
134+
.ethernet_connection = DEVICE_DT_GET_OR_NULL(DT_PHANDLE(port, ethernet)), \
135+
.prv_config = &dsa_netc_##n##_##port##_config, \
136+
}; \
136137
DSA_PORT_INST_INIT(port, n, &dsa_##n##_##port##_config)
137138

138-
#define DSA_NETC_DEVICE(n) \
139-
AT_NONCACHEABLE_SECTION_ALIGN(static netc_cmd_bd_t dsa_netc_##n##_cmd_bd[8], \
140-
NETC_BD_ALIGN); \
141-
static struct dsa_netc_data dsa_netc_data_##n = { \
142-
.cmd_bd = dsa_netc_##n##_cmd_bd, \
143-
}; \
139+
#define DSA_NETC_DEVICE(n) \
140+
AT_NONCACHEABLE_SECTION_ALIGN(static netc_cmd_bd_t dsa_netc_##n##_cmd_bd[8], \
141+
NETC_BD_ALIGN); \
142+
static struct dsa_netc_data dsa_netc_data_##n = { \
143+
.cmd_bd = dsa_netc_##n##_cmd_bd, \
144+
}; \
144145
DSA_SWITCH_INST_INIT(n, &dsa_netc_api, &dsa_netc_data_##n, DSA_NETC_PORT_INST_INIT);
145146

146147
DT_INST_FOREACH_STATUS_OKAY(DSA_NETC_DEVICE);

0 commit comments

Comments
 (0)