4ee6f8466099faaf29bf4a08158a3d870c9b50ac
[openwrt/staging/hauke.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 @@ -408,7 +408,11 @@ int cvm_oct_common_init(struct net_devic
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 @@ -445,6 +448,9 @@ int cvm_oct_common_init(struct net_devic
28 if (dev->netdev_ops->ndo_stop)
29 dev->netdev_ops->ndo_stop(dev);
30
31 + if (!IS_ERR_OR_NULL(label))
32 + dev_alloc_name(dev, label);
33 +
34 return 0;
35 }
36