[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20200622100056.10151-4-brgl@bgdev.pl>
Date: Mon, 22 Jun 2020 12:00:48 +0200
From: Bartosz Golaszewski <brgl@...ev.pl>
To: Jonathan Corbet <corbet@....net>,
Jeff Kirsher <jeffrey.t.kirsher@...el.com>,
"David S . Miller" <davem@...emloft.net>,
Jakub Kicinski <kuba@...nel.org>,
John Crispin <john@...ozen.org>,
Sean Wang <sean.wang@...iatek.com>,
Mark Lee <Mark-MC.Lee@...iatek.com>,
Matthias Brugger <matthias.bgg@...il.com>,
Realtek linux nic maintainers <nic_swsd@...ltek.com>,
Heiner Kallweit <hkallweit1@...il.com>,
Andrew Lunn <andrew@...n.ch>,
Florian Fainelli <f.fainelli@...il.com>,
Russell King <linux@...linux.org.uk>,
Rob Herring <robh+dt@...nel.org>,
Frank Rowand <frowand.list@...il.com>
Cc: linux-doc@...r.kernel.org, linux-kernel@...r.kernel.org,
intel-wired-lan@...ts.osuosl.org, netdev@...r.kernel.org,
linux-arm-kernel@...ts.infradead.org,
linux-mediatek@...ts.infradead.org, devicetree@...r.kernel.org,
Fabien Parent <fparent@...libre.com>,
Stephane Le Provost <stephane.leprovost@...iatek.com>,
Pedro Tsai <pedro.tsai@...iatek.com>,
Andrew Perepech <andrew.perepech@...iatek.com>,
Bartosz Golaszewski <bgolaszewski@...libre.com>
Subject: [PATCH 03/11] net: devres: relax devm_register_netdev()
From: Bartosz Golaszewski <bgolaszewski@...libre.com>
This devres helper registers a release callback that only unregisters
the net_device. It works perfectly fine with netdev structs that are
not managed on their own. There's no reason to check this - drop the
warning.
Signed-off-by: Bartosz Golaszewski <bgolaszewski@...libre.com>
---
net/devres.c | 19 +------------------
1 file changed, 1 insertion(+), 18 deletions(-)
diff --git a/net/devres.c b/net/devres.c
index 57a6a88d11f6..1583ccb207c0 100644
--- a/net/devres.c
+++ b/net/devres.c
@@ -46,14 +46,6 @@ static void devm_netdev_release(struct device *dev, void *this)
unregister_netdev(res->ndev);
}
-static int netdev_devres_match(struct device *dev, void *this, void *match_data)
-{
- struct net_device_devres *res = this;
- struct net_device *ndev = match_data;
-
- return ndev == res->ndev;
-}
-
/**
* devm_register_netdev - resource managed variant of register_netdev()
* @dev: managing device for this netdev - usually the parent device
@@ -61,22 +53,13 @@ static int netdev_devres_match(struct device *dev, void *this, void *match_data)
*
* This is a devres variant of register_netdev() for which the unregister
* function will be call automatically when the managing device is
- * detached. Note: the net_device used must also be resource managed by
- * the same struct device.
+ * detached.
*/
int devm_register_netdev(struct device *dev, struct net_device *ndev)
{
struct net_device_devres *dr;
int ret;
- /* struct net_device must itself be managed. For now a managed netdev
- * can only be allocated by devm_alloc_etherdev_mqs() so the check is
- * straightforward.
- */
- if (WARN_ON(!devres_find(dev, devm_free_netdev,
- netdev_devres_match, ndev)))
- return -EINVAL;
-
dr = devres_alloc(devm_netdev_release, sizeof(*dr), GFP_KERNEL);
if (!dr)
return -ENOMEM;
--
2.26.1
Powered by blists - more mailing lists