00e48fe662a0390b61a1e1b40abf1251b16f7877
[openwrt/openwrt.git] / target / linux / ramips / patches-5.4 / 401-net-ethernet-mediatek-support-net-labels.patch
1 From bd0f89de5476ca25e73fae829ba3e1dafae1d90d Mon Sep 17 00:00:00 2001
2 From: =?UTF-8?q?Ren=C3=A9=20van=20Dorst?= <opensource@vdorst.com>
3 Date: Fri, 21 Jun 2019 10:04:05 +0200
4 Subject: [PATCH] net: ethernet: mediatek: support net-labels
5
6 With this patch, device name can be set within dts file in the same way as dsa
7 port can.
8 Add: label = "wan"; to GMAC node.
9
10 Signed-off-by: René van Dorst <opensource@vdorst.com>
11 ---
12 drivers/net/ethernet/mediatek/mtk_eth_soc.c | 4 ++++
13 1 file changed, 4 insertions(+)
14
15 --- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c
16 +++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
17 @@ -2863,6 +2863,7 @@ static const struct net_device_ops mtk_n
18
19 static int mtk_add_mac(struct mtk_eth *eth, struct device_node *np)
20 {
21 + const char *name = of_get_property(np, "label", NULL);
22 const __be32 *_id = of_get_property(np, "reg", NULL);
23 struct phylink *phylink;
24 int phy_mode, id, err;
25 @@ -2955,6 +2956,9 @@ static int mtk_add_mac(struct mtk_eth *e
26
27 eth->netdev[id]->max_mtu = MTK_MAX_RX_LENGTH - MTK_RX_ETH_HLEN;
28
29 + if (name)
30 + strlcpy(eth->netdev[id]->name, name, IFNAMSIZ);
31 +
32 return 0;
33
34 free_netdev: