aboutsummaryrefslogtreecommitdiffstats
path: root/target/linux/generic/backport-4.9/022-net-add-devm-version-of-alloc_etherdev_mqs-function.patch
diff options
context:
space:
mode:
authorJohn Crispin <john@phrozen.org>2016-12-25 20:11:34 +0100
committerJohn Crispin <john@phrozen.org>2017-08-05 08:46:36 +0200
commit74d00a8c3849c1340efd713eb94b786e304c201f (patch)
treede481743de61c34da96ab5f9dba3af3edcfb8260 /target/linux/generic/backport-4.9/022-net-add-devm-version-of-alloc_etherdev_mqs-function.patch
parentde350550ef648d9728351b986b0516fa29465c45 (diff)
downloadupstream-74d00a8c3849c1340efd713eb94b786e304c201f.tar.gz
upstream-74d00a8c3849c1340efd713eb94b786e304c201f.tar.bz2
upstream-74d00a8c3849c1340efd713eb94b786e304c201f.zip
kernel: split patches folder up into backport, pending and hack folders
* properly format/comment all patches * merge debloat patches * merge Kconfig patches * merge swconfig patches * merge hotplug patches * drop 200-fix_localversion.patch - upstream * drop 222-arm_zimage_none.patch - unused * drop 252-mv_cesa_depends.patch - no longer required * drop 410-mtd-move-forward-declaration-of-struct-mtd_info.patch - unused * drop 661-fq_codel_keep_dropped_stats.patch - outdated * drop 702-phy_add_aneg_done_function.patch - upstream * drop 840-rtc7301.patch - unused * drop 841-rtc_pt7c4338.patch - upstream * drop 921-use_preinit_as_init.patch - unused * drop spio-gpio-old and gpio-mmc - unused Signed-off-by: John Crispin <john@phrozen.org>
Diffstat (limited to 'target/linux/generic/backport-4.9/022-net-add-devm-version-of-alloc_etherdev_mqs-function.patch')
-rw-r--r--target/linux/generic/backport-4.9/022-net-add-devm-version-of-alloc_etherdev_mqs-function.patch69
1 files changed, 69 insertions, 0 deletions
diff --git a/target/linux/generic/backport-4.9/022-net-add-devm-version-of-alloc_etherdev_mqs-function.patch b/target/linux/generic/backport-4.9/022-net-add-devm-version-of-alloc_etherdev_mqs-function.patch
new file mode 100644
index 0000000000..c5d65b7105
--- /dev/null
+++ b/target/linux/generic/backport-4.9/022-net-add-devm-version-of-alloc_etherdev_mqs-function.patch
@@ -0,0 +1,69 @@
+From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= <rafal@milecki.pl>
+Date: Sat, 28 Jan 2017 15:15:42 +0100
+Subject: [PATCH] net: add devm version of alloc_etherdev_mqs function
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+This patch adds devm_alloc_etherdev_mqs function and devm_alloc_etherdev
+macro. These can be used for simpler netdev allocation without having to
+care about calling free_netdev.
+
+Thanks to this change drivers, their error paths and removal paths may
+get simpler by a bit.
+
+Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
+Signed-off-by: David S. Miller <davem@davemloft.net>
+---
+
+--- a/include/linux/etherdevice.h
++++ b/include/linux/etherdevice.h
+@@ -54,6 +54,11 @@ struct net_device *alloc_etherdev_mqs(in
+ #define alloc_etherdev(sizeof_priv) alloc_etherdev_mq(sizeof_priv, 1)
+ #define alloc_etherdev_mq(sizeof_priv, count) alloc_etherdev_mqs(sizeof_priv, count, count)
+
++struct net_device *devm_alloc_etherdev_mqs(struct device *dev, int sizeof_priv,
++ unsigned int txqs,
++ unsigned int rxqs);
++#define devm_alloc_etherdev(dev, sizeof_priv) devm_alloc_etherdev_mqs(dev, sizeof_priv, 1, 1)
++
+ struct sk_buff **eth_gro_receive(struct sk_buff **head,
+ struct sk_buff *skb);
+ int eth_gro_complete(struct sk_buff *skb, int nhoff);
+--- a/net/ethernet/eth.c
++++ b/net/ethernet/eth.c
+@@ -391,6 +391,34 @@ struct net_device *alloc_etherdev_mqs(in
+ }
+ EXPORT_SYMBOL(alloc_etherdev_mqs);
+
++static void devm_free_netdev(struct device *dev, void *res)
++{
++ free_netdev(*(struct net_device **)res);
++}
++
++struct net_device *devm_alloc_etherdev_mqs(struct device *dev, int sizeof_priv,
++ unsigned int txqs, unsigned int rxqs)
++{
++ struct net_device **dr;
++ struct net_device *netdev;
++
++ dr = devres_alloc(devm_free_netdev, sizeof(*dr), GFP_KERNEL);
++ if (!dr)
++ return NULL;
++
++ netdev = alloc_etherdev_mqs(sizeof_priv, txqs, rxqs);
++ if (!netdev) {
++ devres_free(dr);
++ return NULL;
++ }
++
++ *dr = netdev;
++ devres_add(dev, dr);
++
++ return netdev;
++}
++EXPORT_SYMBOL(devm_alloc_etherdev_mqs);
++
+ ssize_t sysfs_format_mac(char *buf, const unsigned char *addr, int len)
+ {
+ return scnprintf(buf, PAGE_SIZE, "%*phC\n", len, addr);