Skip to content

Commit d1f63ab

Browse files
maass-hamburgkartben
authored andcommitted
ethernet: stm32: use DT_INST_*
use DT_INST_* where possible Signed-off-by: Fin Maaß <[email protected]>
1 parent 30a634c commit d1f63ab

File tree

1 file changed

+11
-13
lines changed

1 file changed

+11
-13
lines changed

drivers/ethernet/eth_stm32_hal.c

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -88,17 +88,15 @@ static const struct device *eth_stm32_phy_dev = DEVICE_DT_GET(DT_INST_PHANDLE(0,
8888
#define ETH_RMII_MODE ETH_MEDIA_INTERFACE_RMII
8989
#endif
9090

91-
#define MAC_NODE DT_NODELABEL(mac)
92-
9391
#if DT_HAS_COMPAT_STATUS_OKAY(st_stm32n6_ethernet)
94-
#define STM32_ETH_PHY_MODE(node_id) \
95-
((DT_ENUM_HAS_VALUE(node_id, phy_connection_type, rgmii) ? ETH_RGMII_MODE : \
96-
(DT_ENUM_HAS_VALUE(node_id, phy_connection_type, gmii) ? ETH_GMII_MODE : \
97-
(DT_ENUM_HAS_VALUE(node_id, phy_connection_type, mii) ? ETH_MII_MODE : \
92+
#define STM32_ETH_PHY_MODE(inst) \
93+
((DT_INST_ENUM_HAS_VALUE(inst, phy_connection_type, rgmii) ? ETH_RGMII_MODE : \
94+
(DT_INST_ENUM_HAS_VALUE(inst, phy_connection_type, gmii) ? ETH_GMII_MODE : \
95+
(DT_INST_ENUM_HAS_VALUE(inst, phy_connection_type, mii) ? ETH_MII_MODE : \
9896
ETH_RMII_MODE))))
9997
#else
100-
#define STM32_ETH_PHY_MODE(node_id) \
101-
(DT_ENUM_HAS_VALUE(node_id, phy_connection_type, mii) ? \
98+
#define STM32_ETH_PHY_MODE(inst) \
99+
(DT_INST_ENUM_HAS_VALUE(inst, phy_connection_type, mii) ? \
102100
ETH_MII_MODE : ETH_RMII_MODE)
103101
#endif
104102

@@ -1453,11 +1451,11 @@ static const struct eth_stm32_hal_dev_cfg eth0_config = {
14531451
.pcfg = PINCTRL_DT_INST_DEV_CONFIG_GET(0),
14541452
};
14551453

1456-
BUILD_ASSERT(DT_ENUM_HAS_VALUE(MAC_NODE, phy_connection_type, mii)
1457-
|| DT_ENUM_HAS_VALUE(MAC_NODE, phy_connection_type, rmii)
1454+
BUILD_ASSERT(DT_INST_ENUM_HAS_VALUE(0, phy_connection_type, mii)
1455+
|| DT_INST_ENUM_HAS_VALUE(0, phy_connection_type, rmii)
14581456
IF_ENABLED(DT_HAS_COMPAT_STATUS_OKAY(st_stm32n6_ethernet),
1459-
(|| DT_ENUM_HAS_VALUE(MAC_NODE, phy_connection_type, rgmii)
1460-
|| DT_ENUM_HAS_VALUE(MAC_NODE, phy_connection_type, gmii))),
1457+
(|| DT_INST_ENUM_HAS_VALUE(0, phy_connection_type, rgmii)
1458+
|| DT_INST_ENUM_HAS_VALUE(0, phy_connection_type, gmii))),
14611459
"Unsupported PHY connection type");
14621460

14631461
static struct eth_stm32_hal_dev_data eth0_data = {
@@ -1472,7 +1470,7 @@ static struct eth_stm32_hal_dev_data eth0_data = {
14721470
.ChecksumMode = IS_ENABLED(CONFIG_ETH_STM32_HW_CHECKSUM) ?
14731471
ETH_CHECKSUM_BY_HARDWARE : ETH_CHECKSUM_BY_SOFTWARE,
14741472
#endif /* CONFIG_ETH_STM32_HAL_API_V1 */
1475-
.MediaInterface = STM32_ETH_PHY_MODE(MAC_NODE),
1473+
.MediaInterface = STM32_ETH_PHY_MODE(0),
14761474
},
14771475
},
14781476
};

0 commit comments

Comments
 (0)