aboutsummaryrefslogtreecommitdiffstats
path: root/target/linux/layerscape/patches-4.9/303-add-devm_alloc_percpu-support.patch
diff options
context:
space:
mode:
authorMathew McBride <matt@traverse.com.au>2017-10-24 11:49:00 +1100
committerHauke Mehrtens <hauke@hauke-m.de>2017-10-29 16:16:35 +0100
commit1c4415a679f9858f9de628b650cdef32a2abf9bb (patch)
treefeab6c9f2e0bb69d0dfc594904aa83fa3c6f11e0 /target/linux/layerscape/patches-4.9/303-add-devm_alloc_percpu-support.patch
parent6a457749a46eaed82fef66d65bd6125eebf93aa0 (diff)
downloadupstream-1c4415a679f9858f9de628b650cdef32a2abf9bb.tar.gz
upstream-1c4415a679f9858f9de628b650cdef32a2abf9bb.tar.bz2
upstream-1c4415a679f9858f9de628b650cdef32a2abf9bb.zip
layerscape: reverse changes to ndo_get_stats64
The NXP LSDK kernel backported changes for interface ndo_get_stats64 functions from mainline, this causes a compile error with backports/mac80211, which expects the original 4.9 defintion. As reversing the ndo_get_stats64 change signifcantly reduces the size of patch 601, the patches that were aggregated into it have been disaggregated. Signed-off-by: Mathew McBride <matt@traverse.com.au>
Diffstat (limited to 'target/linux/layerscape/patches-4.9/303-add-devm_alloc_percpu-support.patch')
-rw-r--r--target/linux/layerscape/patches-4.9/303-add-devm_alloc_percpu-support.patch125
1 files changed, 125 insertions, 0 deletions
diff --git a/target/linux/layerscape/patches-4.9/303-add-devm_alloc_percpu-support.patch b/target/linux/layerscape/patches-4.9/303-add-devm_alloc_percpu-support.patch
new file mode 100644
index 0000000000..a8573cce00
--- /dev/null
+++ b/target/linux/layerscape/patches-4.9/303-add-devm_alloc_percpu-support.patch
@@ -0,0 +1,125 @@
+From d33bde3c487c722541ad359e1d22090a78df0c77 Mon Sep 17 00:00:00 2001
+From: Zhao Qiang <qiang.zhao@nxp.com>
+Date: Tue, 11 Jul 2017 16:47:18 +0800
+Subject: [PATCH] add devm_alloc_percpu support
+
+Signed-off-by: Zhao Qiang <qiang.zhao@nxp.com>
+---
+ drivers/base/devres.c | 66 ++++++++++++++++++++++++++++++++++++++++++++++++++
+ include/linux/device.h | 19 +++++++++++++++
+ 2 files changed, 85 insertions(+)
+
+diff --git a/drivers/base/devres.c b/drivers/base/devres.c
+index 8fc654f0807b..71d577025285 100644
+--- a/drivers/base/devres.c
++++ b/drivers/base/devres.c
+@@ -10,6 +10,7 @@
+ #include <linux/device.h>
+ #include <linux/module.h>
+ #include <linux/slab.h>
++#include <linux/percpu.h>
+
+ #include "base.h"
+
+@@ -985,3 +986,68 @@ void devm_free_pages(struct device *dev, unsigned long addr)
+ &devres));
+ }
+ EXPORT_SYMBOL_GPL(devm_free_pages);
++
++static void devm_percpu_release(struct device *dev, void *pdata)
++{
++ void __percpu *p;
++
++ p = *(void __percpu **)pdata;
++ free_percpu(p);
++}
++
++static int devm_percpu_match(struct device *dev, void *data, void *p)
++{
++ struct devres *devr = container_of(data, struct devres, data);
++
++ return *(void **)devr->data == p;
++}
++
++/**
++ * __devm_alloc_percpu - Resource-managed alloc_percpu
++ * @dev: Device to allocate per-cpu memory for
++ * @size: Size of per-cpu memory to allocate
++ * @align: Alignment of per-cpu memory to allocate
++ *
++ * Managed alloc_percpu. Per-cpu memory allocated with this function is
++ * automatically freed on driver detach.
++ *
++ * RETURNS:
++ * Pointer to allocated memory on success, NULL on failure.
++ */
++void __percpu *__devm_alloc_percpu(struct device *dev, size_t size,
++ size_t align)
++{
++ void *p;
++ void __percpu *pcpu;
++
++ pcpu = __alloc_percpu(size, align);
++ if (!pcpu)
++ return NULL;
++
++ p = devres_alloc(devm_percpu_release, sizeof(void *), GFP_KERNEL);
++ if (!p) {
++ free_percpu(pcpu);
++ return NULL;
++ }
++
++ *(void __percpu **)p = pcpu;
++
++ devres_add(dev, p);
++
++ return pcpu;
++}
++EXPORT_SYMBOL_GPL(__devm_alloc_percpu);
++
++/**
++ * devm_free_percpu - Resource-managed free_percpu
++ * @dev: Device this memory belongs to
++ * @pdata: Per-cpu memory to free
++ *
++ * Free memory allocated with devm_alloc_percpu().
++ */
++void devm_free_percpu(struct device *dev, void __percpu *pdata)
++{
++ WARN_ON(devres_destroy(dev, devm_percpu_release, devm_percpu_match,
++ (void *)pdata));
++}
++EXPORT_SYMBOL_GPL(devm_free_percpu);
+diff --git a/include/linux/device.h b/include/linux/device.h
+index bc41e87a969b..0a2135cbddc9 100644
+--- a/include/linux/device.h
++++ b/include/linux/device.h
+@@ -686,6 +686,25 @@ void __iomem *devm_ioremap_resource(struct device *dev, struct resource *res);
+ int devm_add_action(struct device *dev, void (*action)(void *), void *data);
+ void devm_remove_action(struct device *dev, void (*action)(void *), void *data);
+
++/**
++ * devm_alloc_percpu - Resource-managed alloc_percpu
++ * @dev: Device to allocate per-cpu memory for
++ * @type: Type to allocate per-cpu memory for
++ *
++ * Managed alloc_percpu. Per-cpu memory allocated with this function is
++ * automatically freed on driver detach.
++ *
++ * RETURNS:
++ * Pointer to allocated memory on success, NULL on failure.
++ */
++#define devm_alloc_percpu(dev, type) \
++ ((typeof(type) __percpu *)__devm_alloc_percpu((dev), sizeof(type), \
++ __alignof__(type)))
++
++void __percpu *__devm_alloc_percpu(struct device *dev, size_t size,
++ size_t align);
++void devm_free_percpu(struct device *dev, void __percpu *pdata);
++
+ static inline int devm_add_action_or_reset(struct device *dev,
+ void (*action)(void *), void *data)
+ {
+--
+2.11.1
+