From cb72c5119463897df2ba4a007b490e6251a15f75 Mon Sep 17 00:00:00 2001
From: Christian Marangi <ansuelsmth@gmail.com>
Date: Wed, 4 Dec 2024 01:37:05 +0100
Subject: [PATCH] net: ethernet: qualcomm: Add support for label property for
 EDMA port

Add support for label property for EDMA port. This is useful to define
custom name in DTS for specific ethernet port instead of assigning a
dynamic name at runtime.

This also improve the log output by using modern APIs.

Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
---
 drivers/net/ethernet/qualcomm/ppe/edma_port.c | 18 +++++++++++++++---
 1 file changed, 15 insertions(+), 3 deletions(-)

--- a/drivers/net/ethernet/qualcomm/ppe/edma_port.c
+++ b/drivers/net/ethernet/qualcomm/ppe/edma_port.c
@@ -355,13 +355,25 @@ int edma_port_setup(struct ppe_port *por
 	int port_id = port->port_id;
 	struct net_device *netdev;
 	u8 mac_addr[ETH_ALEN];
+	const char *name;
+	int assign_type;
 	int ret = 0;
 	u8 *maddr;
 
-	netdev = alloc_etherdev_mqs(sizeof(struct edma_port_priv),
-				    EDMA_NETDEV_QUEUE_NUM, EDMA_NETDEV_QUEUE_NUM);
+	name = of_get_property(np, "label", NULL);
+	if (name) {
+		assign_type = NET_NAME_PREDICTABLE;
+	} else {
+		name = "eth%d";
+		assign_type = NET_NAME_ENUM;
+	}
+
+	netdev = alloc_netdev_mqs(sizeof(struct edma_port_priv),
+				  name, assign_type,
+				  ether_setup,
+				  EDMA_NETDEV_QUEUE_NUM, EDMA_NETDEV_QUEUE_NUM);
 	if (!netdev) {
-		pr_err("alloc_etherdev() failed\n");
+		dev_err(ppe_dev->dev, "alloc_netdev_mqs() failed\n");
 		return -ENOMEM;
 	}
 
