Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp2081807pxj; Sun, 13 Jun 2021 08:04:35 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwXPJntOF9NGGiSApfDPeFOvEp/Eo1eBuKFxcIZxBHZmH8h4C7p+DWv4VC8J3E0Z0cudOgE X-Received: by 2002:aa7:cc98:: with SMTP id p24mr13125024edt.353.1623596675757; Sun, 13 Jun 2021 08:04:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623596675; cv=none; d=google.com; s=arc-20160816; b=cjxRojTOk3TP6lkoasemqPT9QluJHoJa/wXOAaGEEU7mEeTP0YuWuVJlmEm4MtkO4h MERpsar3NZasZObxOb3s0hiieXqYfejX4ehsFzjOAGgTeH1zLT6Zn0CnBqtFT60wo6+J yM9mksMj7UAcpjJsFIGVkB1nPcun70Mr1EXvMYG/EKbATFD9zTn4cYuNwMK78FfxJwSn DyW9grIJNcLXsDRYXoqRe5tqeDgAkUto4IrDMlBDlkJMe0aJ4ETGQ7HTFNCHcgC5pPTr UFVbWYnZ1IzEcM9pfwHGJSEAdTkx92lJssW+Q3+nrdx7QiKrSFzUTTvbFlP2uGLb84jX 3jGw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=rR2Ljv+UDUKT4nxDcyyC+71xxKNJsNyEqYpWJWgM80I=; b=Tum6E/UCJhDcjjAxXmHFVGe7jeljVJiTTYGty4YsbO9rotL0H6Aplc8/aQNOOzoD3T cJk3NnwmEjEmkx344wqLMBSEAeJN8ZSIhoGVzmIaBAbJ5QC9Jz5CMo2zz+0GvzsfoSdH CHOcC6Z/q68miARmO1N0h/ePSoGk1twGKh7qzU04zLOeGvnGLHM8m4Owjx/LWcC27NO+ 6j7LMkdqQk7pzVgWW57Xpi9ERDnInkDaZfR7rLNgpMXr9eBsbKGzQFEhMGnP/EHPEfmu FkEnPWxUE4Ym19c3rFhVCBW/y30r7bDDQ10LEL+OXs0xriKaiUH4sUqFAxuQ6yzhf6YT a/eg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id kl9si9935054ejc.603.2021.06.13.08.04.04; Sun, 13 Jun 2021 08:04:35 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231935AbhFMPBy (ORCPT + 99 others); Sun, 13 Jun 2021 11:01:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33538 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231755AbhFMPBx (ORCPT ); Sun, 13 Jun 2021 11:01:53 -0400 Received: from mxout012.mail.hostpoint.ch (mxout012.mail.hostpoint.ch [IPv6:2a00:d70:0:e::312]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5BE47C061574; Sun, 13 Jun 2021 07:59:52 -0700 (PDT) Received: from [10.0.2.46] (helo=asmtp013.mail.hostpoint.ch) by mxout012.mail.hostpoint.ch with esmtp (Exim 4.94.2 (FreeBSD)) (envelope-from ) id 1lsRaV-000AWg-EJ; Sun, 13 Jun 2021 16:59:47 +0200 Received: from [2a02:168:6182:1:d747:8127:5b7a:4266] (helo=eleanor.home.reto-schneider.ch) by asmtp013.mail.hostpoint.ch with esmtpsa (TLS1.3) tls TLS_AES_256_GCM_SHA384 (Exim 4.94.2 (FreeBSD)) (envelope-from ) id 1lsRaV-00020T-BT; Sun, 13 Jun 2021 16:59:47 +0200 X-Authenticated-Sender-Id: reto-schneider@reto-schneider.ch From: Reto Schneider To: devicetree@vger.kernel.org, linux-mediatek@lists.infradead.org, netdev@vger.kernel.org Cc: Stefan Roese , Reto Schneider , "David S. Miller" , Felix Fietkau , Jakub Kicinski , John Crispin , Mark Lee , Matthias Brugger , Russell King , Sean Wang , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 2/2] net: ethernet: mtk_eth_soc: Support custom ifname Date: Sun, 13 Jun 2021 16:59:01 +0200 Message-Id: <20210613145859.1774246-2-code@reto-schneider.ch> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210613115820.1525478-1-code@reto-schneider.ch> References: <20210613115820.1525478-1-code@reto-schneider.ch> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Reto Schneider Name the MAC interface name according to the label property. If the property is missing, the default name (ethX) gets used. Labels with more than IFNAMSIZ -1 characters will be truncated silently, which seems to be what most of the code base does when using strscpy. Signed-off-by: Reto Schneider --- Changes in v2: - Avoid dangerous usage of strncpy 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..a921ecc1c997 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) + strscpy(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