From: Johannes Berg <johannes.berg@xxxxxxxxx> Signed-off-by: Johannes Berg <johannes.berg@xxxxxxxxx> --- backport/backport-include/linux/bitmap.h | 10 ++++++++++ backport/compat/Makefile | 1 + backport/compat/backport-4.19.c | 15 +++++++++++++++ 3 files changed, 26 insertions(+) create mode 100644 backport/backport-include/linux/bitmap.h create mode 100644 backport/compat/backport-4.19.c diff --git a/backport/backport-include/linux/bitmap.h b/backport/backport-include/linux/bitmap.h new file mode 100644 index 000000000000..d7a0260b6001 --- /dev/null +++ b/backport/backport-include/linux/bitmap.h @@ -0,0 +1,10 @@ +#ifndef __BP_LINUX_BITMAP_H +#define __BP_LINUX_BITMAP_H +#include_next <linux/bitmap.h> + +#if LINUX_VERSION_IS_LESS(4,19,0) +unsigned long *bitmap_zalloc(unsigned int nbits, gfp_t flags); +void bitmap_free(const unsigned long *bitmap); +#endif /* < 4.19 */ + +#endif /* __BP_LINUX_BITMAP_H */ diff --git a/backport/compat/Makefile b/backport/compat/Makefile index bb6fb57edc7e..29a9b3d8faa3 100644 --- a/backport/compat/Makefile +++ b/backport/compat/Makefile @@ -8,6 +8,7 @@ compat-y += main.o # Kernel backport compatibility code compat-$(CPTCFG_KERNEL_4_18) += backport-4.18.o +compat-$(CPTCFG_KERNEL_4_19) += backport-4.19.o compat-$(CPTCFG_KERNEL_5_2) += backport-5.2.o backport-genetlink.o compat-$(CPTCFG_KERNEL_5_3) += backport-5.3.o compat-$(CPTCFG_KERNEL_5_5) += backport-5.5.o diff --git a/backport/compat/backport-4.19.c b/backport/compat/backport-4.19.c new file mode 100644 index 000000000000..2ea396757ed8 --- /dev/null +++ b/backport/compat/backport-4.19.c @@ -0,0 +1,15 @@ +#include <linux/bitmap.h> +#include <linux/slab.h> + +unsigned long * +bitmap_zalloc(unsigned int nbits, gfp_t flags) +{ + return kzalloc(BITS_TO_LONGS(nbits) * sizeof(unsigned long), flags); +} +EXPORT_SYMBOL(bitmap_zalloc); + +void bitmap_free(const unsigned long *bitmap) +{ + kfree(bitmap); +} +EXPORT_SYMBOL(bitmap_free); -- 2.45.1