Received: by 2002:a05:6a10:17d3:0:0:0:0 with SMTP id hz19csp2595194pxb; Mon, 19 Apr 2021 09:10:27 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzbPx7rqhggWTlK3iXL7OygZvoi7LYISDTl+O7pcnl+xVH9WObhROHihRRRI+tFmaEmMA2f X-Received: by 2002:a17:906:5906:: with SMTP id h6mr7189988ejq.176.1618848627410; Mon, 19 Apr 2021 09:10:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1618848627; cv=none; d=google.com; s=arc-20160816; b=vmoOlNOE9xFAwK6W0fKlpk2XWSYHD0LgMNo+m+1ynHLZjOql2MPQ2LCknOFIdkZ+bc dag2HgiSBJ47gU8H8bUok6CgoDDoPUIo6COttqxUhE+KsbeO3EzIf8Pt731sDJ7YbFSO ThOuQ7nu3KQuGnDGZV81fPNcPjb+v1kdJ+5SDS+ImzoEbqbezfX1nVssq80LZCZI7U7M m2BSFeBNv0ZHBf/AgjOrrR8TgOsUwUbJEd4HoQf0OG/XgavHqGvhyK8DPv1ZomGgKu35 L75yZ3gfv8E3/i1iquP3umyf02MUH+7LgGut4gHJfIDTqYZOOxb9dM1+jwvL6qBHERxf 1L7Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=sK9kJH32/DEKrA6KoYri3PZGBlZT1dWah2hqamZZ9Cc=; b=cuo/rH1d8ofTtUNiesGNqBy0DtVgpHa3oAOzghVGFN1O1sdXE2RUevTB8FipRbS3wm 5+drDdPv9zD6qdPZiDJ+zDjz7xI8CkX/SiNbuRaqRdQUh/rPchM9Y7Sus1KIKTQ44pOX 2vw8Dqicc0PWRrurZIYXGIBmuCDpFVLYRLsMbAu9BVGmvUDMXn6lSfGCGUe4B8ftW6Po 1vMqzTCOzv5Z5LDrm7orXkFSZKt0PhYJ/myNv9OKj0IVzNKQqmFtMFGQzpFwvqi8SRlL 9Nnapfqd0v3ygaWr14mw8USb1zsNPXm0HZsUcLULc69cjKiO0KQztiuESYDVBBmg+wun RtZA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=s7wVo0vA; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id v11si9645666eju.403.2021.04.19.09.10.01; Mon, 19 Apr 2021 09:10:27 -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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=s7wVo0vA; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235536AbhDSPFC (ORCPT + 99 others); Mon, 19 Apr 2021 11:05:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54198 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231496AbhDSPEy (ORCPT ); Mon, 19 Apr 2021 11:04:54 -0400 Received: from mail-io1-xd2d.google.com (mail-io1-xd2d.google.com [IPv6:2607:f8b0:4864:20::d2d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1F5FDC06174A; Mon, 19 Apr 2021 08:04:24 -0700 (PDT) Received: by mail-io1-xd2d.google.com with SMTP id x16so35222715iob.1; Mon, 19 Apr 2021 08:04:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=sK9kJH32/DEKrA6KoYri3PZGBlZT1dWah2hqamZZ9Cc=; b=s7wVo0vApXU/OM1jt4+gMA9B0M0TVD8p1XDGpgxiXAxuyzaHz2Gj1uaR28sDh9Meyq M+ZPjuGWqIFb91kh+t5jJbJhqs8vxijOqlUhQ4V3TEo8yK7ZobGdz5Hr1JHP3AjtAn59 Re249SBEmo/8oNw//lAyJDppVQ0CHLS5EtwgWyNYZNNCIRMuCnfCXdAvTdD4zSc/vpbc vTMTAbEzFLOBOQTWIt4/WlgQzt3Iahmlb6W8ItRJAayJiQUHk2q6qO7zju/SgZJ6EGFn YBYjVlEXIUwLGeNoNGzxjQ0CwwpVAeSLagMmZf0XzsRv0HX/+FQoSJGxYUlm4OUkYYnA TiBw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=sK9kJH32/DEKrA6KoYri3PZGBlZT1dWah2hqamZZ9Cc=; b=L2/BomEruN9lYVixdEFEhq0ZQGQA2sLIisIUrfphUTndu2xlRGi2jDHEQkMt62pWZm cyWHCVdhhtCYCWC4BRxodLuWUgy2gsGwNQEHcK/nK/2NrGsYUCPOklvcrdNfnKqW1v5w /kXiuQswFAaVYZvf0Anzelf7s+HOZSb7bWd/VKp7YyaWwoMgW+sVtmrLYn9eoBC5EanF 0hGlS/O0F4CI4KbdvMU3IPtxJiRLBB8DNu0O2oiY212/2NbGvdEVy14D5LzDI2wmAH9V mASv5sRidOOTX2DycB2YzOGBiDa5l3tUWx/F+n/UeNTzd6R7GBBF9bRRV0t0BV2ILgYh lPrA== X-Gm-Message-State: AOAM530spKkFxu5Cca/rbuXtOvSKZ7DyN2TJTLw6AI49O+nVeSDsblHZ rrDW/yZTp4yxIwQZnRQ/1zvAdrVS3DUF70B2nes= X-Received: by 2002:a02:a487:: with SMTP id d7mr2653012jam.84.1618844661634; Mon, 19 Apr 2021 08:04:21 -0700 (PDT) MIME-Version: 1.0 References: <20210419040352.2452-1-ilya.lipnitskiy@gmail.com> <20210419040352.2452-3-ilya.lipnitskiy@gmail.com> In-Reply-To: From: Ilya Lipnitskiy Date: Mon, 19 Apr 2021 08:04:10 -0700 Message-ID: Subject: Re: [PATCH net-next 2/2] net: ethernet: mediatek: support custom GMAC label To: Andrew Lunn Cc: "David S. Miller" , Jakub Kicinski , Rob Herring , Felix Fietkau , John Crispin , Sean Wang , Mark Lee , Matthias Brugger , Russell King , netdev@vger.kernel.org, "open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS" , Linux Kernel Mailing List , linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, =?UTF-8?Q?Ren=C3=A9_van_Dorst?= Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Apr 19, 2021 at 5:15 AM Andrew Lunn wrote: > > 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=C3=A9 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= =3D { > > > > static int mtk_add_mac(struct mtk_eth *eth, struct device_node *np) > > { > > + const char *label =3D of_get_property(np, "label", NULL); > > const __be32 *_id =3D 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, struc= t device_node *np) > > else > > eth->netdev[id]->max_mtu =3D MTK_MAX_RX_LENGTH_2K - MTK_R= X_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. It doesn't look like the name validation happens until the netdev is registered, and it does not get registered at alloc, right? I do agree that it's better to use the correct name in the first place instead of renaming, regardless, so using alloc_netdev_mqs() seems like a better solution - I'll make the change. Ilya