1 // SPDX-License-Identifier: GPL-2.0-or-later 2 /* 3 * This file contains all networking devres helpers. 4 */ 5 6 #include <linux/device.h> 7 #include <linux/etherdevice.h> 8 #include <linux/netdevice.h> 9 10 static void devm_free_netdev(struct device *dev, void *res) 11 { 12 free_netdev(*(struct net_device **)res); 13 } 14 15 struct net_device *devm_alloc_etherdev_mqs(struct device *dev, int sizeof_priv, 16 unsigned int txqs, unsigned int rxqs) 17 { 18 struct net_device **dr; 19 struct net_device *netdev; 20 21 dr = devres_alloc(devm_free_netdev, sizeof(*dr), GFP_KERNEL); 22 if (!dr) 23 return NULL; 24 25 netdev = alloc_etherdev_mqs(sizeof_priv, txqs, rxqs); 26 if (!netdev) { 27 devres_free(dr); 28 return NULL; 29 } 30 31 *dr = netdev; 32 devres_add(dev, dr); 33 34 return netdev; 35 } 36 EXPORT_SYMBOL(devm_alloc_etherdev_mqs); 37