0aef899a96727faa0d20f14ca1b8c287cc7dd372
[openwrt/openwrt.git] / target / linux / octeon / patches-5.4 / 700-allocate_interface_by_label.patch
1 From: Roman Kuzmitskii <damex.pp@icloud.com>
2 Date: Wed, 28 Oct 2020 19:00:00 +0000
3 Subject: [PATCH] staging: octeon: add net-labels support
4
5 With this patch, device name can be set within dts file
6 in the same way as dsa port can.
7
8 Add label to pip interface node to use this feature:
9 label = "lan0";
10
11 Tested-by: Johannes Kimmel <fff@bareminimum.eu>
12 Signed-off-by: Roman Kuzmitskii <damex.pp@icloud.com>
13 --- a/drivers/staging/octeon/ethernet.c
14 +++ b/drivers/staging/octeon/ethernet.c
15 @@ -407,9 +407,12 @@
16 {
17 struct octeon_ethernet *priv = netdev_priv(dev);
18 const u8 *mac = NULL;
19 + const u8 *label = NULL;
20
21 - if (priv->of_node)
22 + if (priv->of_node) {
23 mac = of_get_mac_address(priv->of_node);
24 + label = of_get_property(priv->of_node, "label", NULL);
25 + }
26
27 if (!IS_ERR_OR_NULL(mac))
28 ether_addr_copy(dev->dev_addr, mac);
29 @@ -444,6 +447,9 @@
30 if (dev->netdev_ops->ndo_stop)
31 dev->netdev_ops->ndo_stop(dev);
32
33 + if (!IS_ERR_OR_NULL(label))
34 + dev_alloc_name(dev, label);
35 +
36 return 0;
37 }
38