summaryrefslogtreecommitdiff
path: root/include/linux/bitmap.h
diff options
context:
space:
mode:
authorTom Rini <trini@konsulko.com>2018-12-15 17:49:49 -0500
committerTom Rini <trini@konsulko.com>2018-12-15 17:49:57 -0500
commit401c2540445aad08816382c0dc208d2516d90d89 (patch)
tree89c26f23edfb8da3d7a517d07fedd61fa5faf769 /include/linux/bitmap.h
parent0dc526d98eb216003ea884739abc17f6eb05c0df (diff)
parent46a3f276549f3e5720b6e80278cda354c7fa859f (diff)
Merge branch 'master' of git://git.denx.de/u-boot-usb
- Second half of the USB Gadget DM conversion
Diffstat (limited to 'include/linux/bitmap.h')
-rw-r--r--include/linux/bitmap.h23
1 files changed, 23 insertions, 0 deletions
diff --git a/include/linux/bitmap.h b/include/linux/bitmap.h
new file mode 100644
index 00000000000..4a54ae05091
--- /dev/null
+++ b/include/linux/bitmap.h
@@ -0,0 +1,23 @@
+// SPDX-License-Identifier: GPL-2.0+
+#ifndef __LINUX_BITMAP_H
+#define __LINUX_BITMAP_H
+
+#include <asm/types.h>
+#include <linux/types.h>
+#include <linux/bitops.h>
+
+#define small_const_nbits(nbits) \
+ (__builtin_constant_p(nbits) && (nbits) <= BITS_PER_LONG)
+
+static inline void bitmap_zero(unsigned long *dst, int nbits)
+{
+ if (small_const_nbits(nbits)) {
+ *dst = 0UL;
+ } else {
+ int len = BITS_TO_LONGS(nbits) * sizeof(unsigned long);
+
+ memset(dst, 0, len);
+ }
+}
+
+#endif /* __LINUX_BITMAP_H */