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=-6.7 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham 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 4B58EC38A2A for ; Thu, 7 May 2020 17:03:58 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0A7042083B for ; Thu, 7 May 2020 17:03:58 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=baylibre-com.20150623.gappssmtp.com header.i=@baylibre-com.20150623.gappssmtp.com header.b="EpvVqjRH" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726518AbgEGRD5 (ORCPT ); Thu, 7 May 2020 13:03:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45182 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1726491AbgEGRD4 (ORCPT ); Thu, 7 May 2020 13:03:56 -0400 Received: from mail-qk1-x744.google.com (mail-qk1-x744.google.com [IPv6:2607:f8b0:4864:20::744]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7613DC05BD43 for ; Thu, 7 May 2020 10:03:56 -0700 (PDT) Received: by mail-qk1-x744.google.com with SMTP id b188so6863373qkd.9 for ; Thu, 07 May 2020 10:03:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=Hld7f/Kw9bjvhfjaZsf7n7gSrldLUvvGkUrL/YswQok=; b=EpvVqjRHFxbK1wUeGGCkLIlkrmGeJJgfCrCsU+zmzM1wqgCW5VyfqZ7BHVia1xluk3 gTvSp++LYK9R3PE9phD5/DFTk3/tQNJuidf/vzvvPtt7kdJynt8wVj/QTKbLYd7LPJNt pjmMliIGNvRFvzqCRSw/0q8XbuQA5ONaif8qjvwLZ2fyu5P1nTO6HibWKYEIwhPXjO7N aOMb6cpnL80stcrIAMjulGkzuyr/hqMdxxZv/MM075BCRgcShupXD0aySGxg+vn1h/hs CN5+wmJ8NlmAuwXJLYvUs2oCDLXSa/LjT1/ErrAonSYhTh8NKuWUUMvQEzUM5Jvz2gik yP6A== 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=Hld7f/Kw9bjvhfjaZsf7n7gSrldLUvvGkUrL/YswQok=; b=VuhbguJz0Lai6yAtN9RgVK07RU6asegLwKUNWyisj64HfXv0pBzBxbbnBw7Sr2mykG tf8qdyTh7kum76Gh6hArf3ClI8QkTfxdKvy4+oI3uS3EMw1+BF5rBEW+TBoaJ6Qczqny pcvBJKBCWyy9oSRl+aGPuiAddEWFj6zhLSqfg0AeBGPDMnRqJGFqV6/YP5eLKvWcSJQq 7zvHGjgUZOsScR5yjZ7UXCoTk+0xGb5lbaALKyzYfCtm1+geJhYgD6qkwyOgHaLGF/c3 AjPWytiI2hYgf5Awzuj7Cpp9vXMOK0cYt6FcXBYRS/Q9qrjX89idMsEOttI9cotXxR85 7x5A== X-Gm-Message-State: AGi0Pua5yc3Wz2MLzT3vCo4bWxo0UViGMBHmGjW2jjANoPQHJG/bZyzN pJAdMpaG52DdM213KH46utBTuRHDdmlZP2k4t2Sn5UPk X-Google-Smtp-Source: APiQypJYPuD7vyBsx50AXMNfbjWRHiKRLtVBSWgqWt5R2mCiujv+F5SYL9Ov+qQKOQm8p348+/a1owCEaNzPso5tN/k= X-Received: by 2002:a05:620a:65a:: with SMTP id a26mr14772836qka.323.1588871035690; Thu, 07 May 2020 10:03:55 -0700 (PDT) MIME-Version: 1.0 References: <20200505140231.16600-1-brgl@bgdev.pl> <20200505140231.16600-6-brgl@bgdev.pl> <20200505103105.1c8b0ce3@kicinski-fedora-pc1c0hjn.dhcp.thefacebook.com> <20200506101236.25a13609@kicinski-fedora-pc1c0hjn.dhcp.thefacebook.com> <20200507095315.1154a1a6@kicinski-fedora-pc1c0hjn.dhcp.thefacebook.com> In-Reply-To: <20200507095315.1154a1a6@kicinski-fedora-pc1c0hjn.dhcp.thefacebook.com> From: Bartosz Golaszewski Date: Thu, 7 May 2020 19:03:44 +0200 Message-ID: Subject: Re: [PATCH 05/11] net: core: provide devm_register_netdev() To: Jakub Kicinski Cc: Bartosz Golaszewski , Rob Herring , "David S . Miller" , Matthias Brugger , John Crispin , Sean Wang , Mark Lee , Arnd Bergmann , Fabien Parent , devicetree , Linux Kernel Mailing List , netdev , Linux ARM , linux-mediatek@lists.infradead.org, Heiner Kallweit Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org czw., 7 maj 2020 o 18:53 Jakub Kicinski napisa=C5=82(a): > > On Thu, 7 May 2020 11:25:01 +0200 Bartosz Golaszewski wrote: > > =C5=9Br., 6 maj 2020 o 19:12 Jakub Kicinski napisa=C5= =82(a): > > > > > > On Wed, 6 May 2020 08:39:47 +0200 Bartosz Golaszewski wrote: > > > > wt., 5 maj 2020 o 19:31 Jakub Kicinski napisa=C5= =82(a): > > > > > > > > > > On Tue, 5 May 2020 16:02:25 +0200 Bartosz Golaszewski wrote: > > > > > > From: Bartosz Golaszewski > > > > > > > > > > > > Provide devm_register_netdev() - a device resource managed vari= ant > > > > > > of register_netdev(). This new helper will only work for net_de= vice > > > > > > structs that have a parent device assigned and are devres manag= ed too. > > > > > > > > > > > > Signed-off-by: Bartosz Golaszewski > > > > > > > > > > > diff --git a/net/core/dev.c b/net/core/dev.c > > > > > > index 522288177bbd..99db537c9468 100644 > > > > > > --- a/net/core/dev.c > > > > > > +++ b/net/core/dev.c > > > > > > @@ -9519,6 +9519,54 @@ int register_netdev(struct net_device *d= ev) > > > > > > } > > > > > > EXPORT_SYMBOL(register_netdev); > > > > > > > > > > > > +struct netdevice_devres { > > > > > > + struct net_device *ndev; > > > > > > +}; > > > > > > > > > > Is there really a need to define a structure if we only need a po= inter? > > > > > > > > > > > > > There is no need for that, but it really is more readable this way. > > > > Also: using a pointer directly doesn't save us any memory nor code > > > > here. > > > > > > I don't care either way but devm_alloc_etherdev_mqs() and co. are usi= ng > > > the double pointer directly. Please make things consistent. Either do > > > the same, or define the structure in some header and convert other > > > helpers to also make use of it. > > > > In order to use devres_find() to check if struct net_device is managed > > in devm_register_netdev() I need to know the address of the release > > function used by devm_alloc_etherdev_mqs(). Do you mind if I move all > > networking devres routines (currently only devm_alloc_etherdev_mqs()) > > into a separate .c file (e.g. under net/devres.c)? > > To implement Edwin's suggestion? Makes sense, but I'm no expert, let's > also CC Heiner since he was asking about it last time. Yes, because taking the last bit of priv_flags from net_device seems to be more controversial but if net maintainers are fine with that I can simply go with the current approach. Bart