diff options
author | Zhao Qiang <qiang.zhao@nxp.com> | 2017-07-11 08:47:18 (GMT) |
---|---|---|
committer | Xie Xiaobo <xiaobo.xie@nxp.com> | 2017-07-14 10:08:27 (GMT) |
commit | d33bde3c487c722541ad359e1d22090a78df0c77 (patch) | |
tree | 29aef6aa03d665a11113cd7184228b7af3a81b8e /include | |
parent | 9527ee5eb436ad773acc7320b372a5f4825a920d (diff) | |
download | linux-d33bde3c487c722541ad359e1d22090a78df0c77.tar.xz |
add devm_alloc_percpu support
Signed-off-by: Zhao Qiang <qiang.zhao@nxp.com>
Diffstat (limited to 'include')
-rw-r--r-- | include/linux/device.h | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/include/linux/device.h b/include/linux/device.h index bc41e87..0a2135c 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) { |