new file mode 100644
@@ -0,0 +1,17 @@
+#ifndef __BP_LINUX_BITMAP_H
+#define __BP_LINUX_BITMAP_H
+#include_next <linux/bitmap.h>
+
+#if LINUX_VERSION_IS_LESS(5,13,0)
+/* Managed variants of the above. */
+#define devm_bitmap_alloc LINUX_BACKPORT(devm_bitmap_alloc)
+unsigned long *devm_bitmap_alloc(struct device *dev,
+ unsigned int nbits, gfp_t flags);
+
+#define devm_bitmap_zalloc LINUX_BACKPORT(devm_bitmap_zalloc)
+unsigned long *devm_bitmap_zalloc(struct device *dev,
+ unsigned int nbits, gfp_t flags);
+
+#endif
+
+#endif /* __BP_LINUX_BITMAP_H */
@@ -2,6 +2,8 @@
#include <linux/export.h>
#include <linux/interrupt.h>
+#include <linux/bitmap.h>
+#include <linux/device.h>
#if defined(CONFIG_SMP) || defined(CONFIG_PREEMPT_RT)
/*
@@ -28,3 +30,35 @@ void tasklet_unlock_spin_wait(struct tasklet_struct *t)
}
EXPORT_SYMBOL_GPL(tasklet_unlock_spin_wait);
#endif
+
+static void devm_bitmap_free(void *data)
+{
+ unsigned long *bitmap = data;
+
+ bitmap_free(bitmap);
+}
+
+unsigned long *devm_bitmap_alloc(struct device *dev,
+ unsigned int nbits, gfp_t flags)
+{
+ unsigned long *bitmap;
+ int ret;
+
+ bitmap = bitmap_alloc(nbits, flags);
+ if (!bitmap)
+ return NULL;
+
+ ret = devm_add_action_or_reset(dev, devm_bitmap_free, bitmap);
+ if (ret)
+ return NULL;
+
+ return bitmap;
+}
+EXPORT_SYMBOL_GPL(devm_bitmap_alloc);
+
+unsigned long *devm_bitmap_zalloc(struct device *dev,
+ unsigned int nbits, gfp_t flags)
+{
+ return devm_bitmap_alloc(dev, nbits, flags | __GFP_ZERO);
+}
+EXPORT_SYMBOL_GPL(devm_bitmap_zalloc);
The carl9170 driver is using devm_bitmap_zalloc() now. Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de> --- backport/backport-include/linux/bitmap.h | 17 ++++++++++++ backport/compat/backport-5.13.c | 34 ++++++++++++++++++++++++ 2 files changed, 51 insertions(+) create mode 100644 backport/backport-include/linux/bitmap.h