aboutsummaryrefslogtreecommitdiffstats
path: root/target/linux/octeon/patches-5.4/700-allocate_interface_by_label.patch
blob: 0aef899a96727faa0d20f14ca1b8c287cc7dd372 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
From: Roman Kuzmitskii <damex.pp@icloud.com>
Date: Wed, 28 Oct 2020 19:00:00 +0000
Subject: [PATCH] staging: octeon: add net-labels support

With this patch, device name can be set within dts file
in the same way as dsa port can.

Add label to pip interface node to use this feature:
label = "lan0";

Tested-by: Johannes Kimmel <fff@bareminimum.eu>
Signed-off-by: Roman Kuzmitskii <damex.pp@icloud.com>
--- a/drivers/staging/octeon/ethernet.c
+++ b/drivers/staging/octeon/ethernet.c
@@ -407,9 +407,12 @@
 {
 	struct octeon_ethernet *priv = netdev_priv(dev);
 	const u8 *mac = NULL;
+	const u8 *label = NULL;
 
-	if (priv->of_node)
+	if (priv->of_node) {
 		mac = of_get_mac_address(priv->of_node);
+		label = of_get_property(priv->of_node, "label", NULL);
+	}
 
 	if (!IS_ERR_OR_NULL(mac))
 		ether_addr_copy(dev->dev_addr, mac);
@@ -444,6 +447,9 @@
 	if (dev->netdev_ops->ndo_stop)
 		dev->netdev_ops->ndo_stop(dev);
 
+	if (!IS_ERR_OR_NULL(label))
+		dev_alloc_name(dev, label);
+
 	return 0;
 }