netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Reto Schneider <code@reto-schneider.ch>
To: devicetree@vger.kernel.org, linux-mediatek@lists.infradead.org,
	netdev@vger.kernel.org
Cc: Stefan Roese <sr@denx.de>,
	Reto Schneider <reto.schneider@husqvarnagroup.com>,
	"David S. Miller" <davem@davemloft.net>,
	Felix Fietkau <nbd@nbd.name>, Jakub Kicinski <kuba@kernel.org>,
	John Crispin <john@phrozen.org>,
	Mark Lee <Mark-MC.Lee@mediatek.com>,
	Matthias Brugger <matthias.bgg@gmail.com>,
	Russell King <linux@armlinux.org.uk>,
	Sean Wang <sean.wang@mediatek.com>,
	linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org
Subject: [PATCH v1 2/2] net: ethernet: mtk_eth_soc: Support custom ifname
Date: Sun, 13 Jun 2021 13:58:19 +0200	[thread overview]
Message-ID: <20210613115820.1525478-2-code@reto-schneider.ch> (raw)
In-Reply-To: <20210613115820.1525478-1-code@reto-schneider.ch>

From: Reto Schneider <reto.schneider@husqvarnagroup.com>

Name the MAC interface name according to the label property. If the
property is missing, the default name (ethX) gets used.

Signed-off-by: Reto Schneider <reto.schneider@husqvarnagroup.com>

---

 drivers/net/ethernet/mediatek/mtk_eth_soc.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/net/ethernet/mediatek/mtk_eth_soc.c b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
index 64adfd24e134..8bb09801918f 100644
--- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c
+++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
@@ -2948,6 +2948,7 @@ static const struct net_device_ops mtk_netdev_ops = {
 static int mtk_add_mac(struct mtk_eth *eth, struct device_node *np)
 {
 	const __be32 *_id = of_get_property(np, "reg", NULL);
+	const char *const name = of_get_property(np, "label", NULL);
 	phy_interface_t phy_mode;
 	struct phylink *phylink;
 	struct mtk_mac *mac;
@@ -3020,6 +3021,9 @@ static int mtk_add_mac(struct mtk_eth *eth, struct device_node *np)
 
 	mac->phylink = phylink;
 
+	if (name)
+		strncpy(eth->netdev[id]->name, name, IFNAMSIZ);
+
 	SET_NETDEV_DEV(eth->netdev[id], eth->dev);
 	eth->netdev[id]->watchdog_timeo = 5 * HZ;
 	eth->netdev[id]->netdev_ops = &mtk_netdev_ops;
-- 
2.30.2


  reply	other threads:[~2021-06-13 11:58 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-13 11:58 [PATCH v1 1/2] dt-bindings: net: mediatek: Support custom ifname Reto Schneider
2021-06-13 11:58 ` Reto Schneider [this message]
2021-06-13 12:20   ` [PATCH v1 2/2] net: ethernet: mtk_eth_soc: " Russell King (Oracle)
2021-06-13 13:53     ` Reto Schneider
2021-06-14 19:48   ` David Miller
2021-06-13 14:58 ` [PATCH v2 1/2] dt-bindings: net: mediatek: " Reto Schneider
2021-06-13 14:59 ` [PATCH v2 2/2] net: ethernet: mtk_eth_soc: " Reto Schneider

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210613115820.1525478-2-code@reto-schneider.ch \
    --to=code@reto-schneider.ch \
    --cc=Mark-MC.Lee@mediatek.com \
    --cc=davem@davemloft.net \
    --cc=devicetree@vger.kernel.org \
    --cc=john@phrozen.org \
    --cc=kuba@kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mediatek@lists.infradead.org \
    --cc=linux@armlinux.org.uk \
    --cc=matthias.bgg@gmail.com \
    --cc=nbd@nbd.name \
    --cc=netdev@vger.kernel.org \
    --cc=reto.schneider@husqvarnagroup.com \
    --cc=sean.wang@mediatek.com \
    --cc=sr@denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).