backports: backport devm_kmemdup
authorFelix Fietkau <nbd@openwrt.org>
Sun, 16 Nov 2014 13:39:59 +0000 (14:39 +0100)
committerHauke Mehrtens <hauke@hauke-m.de>
Sun, 16 Nov 2014 15:09:17 +0000 (16:09 +0100)
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
backport/backport-include/linux/device.h

index 41f06c39d48743f3ea7874e7afabf2ca79995a0e..29dc077130918bac7429d2ae83cc3f39b111d4d6 100644 (file)
@@ -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 */