octeon: Introduce 5.15 testing kernel
[openwrt/openwrt.git] / target / linux / octeon / patches-5.15 / 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,8 +407,12 @@ static int cvm_oct_common_set_mac_addres
16 int cvm_oct_common_init(struct net_device *dev)
17 {
18 struct octeon_ethernet *priv = netdev_priv(dev);
19 + const u8 *label = NULL;
20 int ret;
21
22 + if (priv->of_node)
23 + label = of_get_property(priv->of_node, "label", NULL);
24 +
25 ret = of_get_mac_address(priv->of_node, dev->dev_addr);
26 if (ret)
27 eth_hw_addr_random(dev);
28 @@ -441,6 +445,9 @@ int cvm_oct_common_init(struct net_devic
29 if (dev->netdev_ops->ndo_stop)
30 dev->netdev_ops->ndo_stop(dev);
31
32 + if (!IS_ERR_OR_NULL(label))
33 + dev_alloc_name(dev, label);
34 +
35 return 0;
36 }
37