From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 51023C43460 for ; Mon, 19 Apr 2021 12:15:39 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 23D3661245 for ; Mon, 19 Apr 2021 12:15:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239027AbhDSMQH (ORCPT ); Mon, 19 Apr 2021 08:16:07 -0400 Received: from vps0.lunn.ch ([185.16.172.187]:58198 "EHLO vps0.lunn.ch" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233668AbhDSMQE (ORCPT ); Mon, 19 Apr 2021 08:16:04 -0400 Received: from andrew by vps0.lunn.ch with local (Exim 4.94) (envelope-from ) id 1lYSo4-00HWif-T8; Mon, 19 Apr 2021 14:15:12 +0200 Date: Mon, 19 Apr 2021 14:15:12 +0200 From: Andrew Lunn To: Ilya Lipnitskiy Cc: "David S. Miller" , Jakub Kicinski , Rob Herring , Felix Fietkau , John Crispin , Sean Wang , Mark Lee , Matthias Brugger , Russell King , netdev@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, =?iso-8859-1?Q?Ren=E9?= van Dorst Subject: Re: [PATCH net-next 2/2] net: ethernet: mediatek: support custom GMAC label Message-ID: References: <20210419040352.2452-1-ilya.lipnitskiy@gmail.com> <20210419040352.2452-3-ilya.lipnitskiy@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20210419040352.2452-3-ilya.lipnitskiy@gmail.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, Apr 18, 2021 at 09:03:52PM -0700, Ilya Lipnitskiy wrote: > The MAC device name can now be set within DTS file instead of always > being "ethX". This is helpful for DSA to clearly label the DSA master > device and distinguish it from DSA slave ports. > > For example, some devices, such as the Ubiquiti EdgeRouter X, may have > ports labeled ethX. Labeling the master GMAC with a different prefix > than DSA ports helps with clarity. > > Suggested-by: René van Dorst > Signed-off-by: Ilya Lipnitskiy > --- > 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 6b00c12c6c43..4c0ce4fb7735 100644 > --- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c > +++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c > @@ -2845,6 +2845,7 @@ static const struct net_device_ops mtk_netdev_ops = { > > static int mtk_add_mac(struct mtk_eth *eth, struct device_node *np) > { > + const char *label = of_get_property(np, "label", NULL); > const __be32 *_id = of_get_property(np, "reg", NULL); > phy_interface_t phy_mode; > struct phylink *phylink; > @@ -2940,6 +2941,9 @@ static int mtk_add_mac(struct mtk_eth *eth, struct device_node *np) > else > eth->netdev[id]->max_mtu = MTK_MAX_RX_LENGTH_2K - MTK_RX_ETH_HLEN; > > + if (label) > + strscpy(eth->netdev[id]->name, label, IFNAMSIZ); It is better to use alloc_netdev_mqs() so you get validation the name is unique. Andrew