From 3ac54b41f6a65e88da6d5ed6703778dc50a60590 Mon Sep 17 00:00:00 2001 From: Felix Fietkau Date: Sun, 16 Nov 2014 14:39:59 +0100 Subject: [PATCH] backports: backport devm_kmemdup Signed-off-by: Felix Fietkau Signed-off-by: Hauke Mehrtens --- backport/backport-include/linux/device.h | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/backport/backport-include/linux/device.h b/backport/backport-include/linux/device.h index 41f06c39d487..29dc07713091 100644 --- a/backport/backport-include/linux/device.h +++ b/backport/backport-include/linux/device.h @@ -177,4 +177,20 @@ static inline void *devm_kmalloc_array(struct device *dev, } #endif +#if LINUX_VERSION_CODE < KERNEL_VERSION(3,16,0) +#define devm_kmemdup LINUX_BACKPORT(devm_kmemdup) +static inline void *devm_kmemdup(struct device *dev, const void *src, + size_t len, gfp_t gfp) +{ + void *p; + + p = devm_kmalloc(dev, len, gfp); + if (p) + memcpy(p, src, len); + + return p; +} +#endif + + #endif /* __BACKPORT_DEVICE_H */ -- 2.30.2