@@ -622,10 +622,20 @@ static int enetc4_pf_netdev_create(struct enetc_si *si)
struct device *dev = &si->pdev->dev;
struct enetc_ndev_priv *priv;
struct net_device *ndev;
+ char ifname[IFNAMSIZ];
int err;
- ndev = alloc_etherdev_mqs(sizeof(struct enetc_ndev_priv),
- si->num_tx_rings, si->num_rx_rings);
+ err = of_alias_get_id(dev->of_node, "ethernet");
+ if (err >= 0) {
+ snprintf(ifname, IFNAMSIZ, "eth%d", err);
+ ndev = alloc_netdev_mqs(sizeof(struct enetc_ndev_priv),
+ ifname, NET_NAME_PREDICTABLE, ether_setup,
+ si->num_tx_rings, si->num_rx_rings);
+ } else {
+ ndev = alloc_etherdev_mqs(sizeof(struct enetc_ndev_priv),
+ si->num_tx_rings, si->num_rx_rings);
+ }
+
if (!ndev)
return -ENOMEM;
Retrieve the "ethernet" alias ID from the DTS and assign it as the interface name (e.g., "eth0", "eth1"). This ensures predictable naming aligned with the DTS's configuration. If no alias is defined, fall back to the kernel's default enumeration to maintain backward compatibility. Signed-off-by: Shenwei Wang <shenwei.wang@nxp.com> --- drivers/net/ethernet/freescale/enetc/enetc4_pf.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-)