summaryrefslogtreecommitdiff
path: root/include/linux
diff options
context:
space:
mode:
Diffstat (limited to 'include/linux')
-rw-r--r--include/linux/bitmap.h23
-rw-r--r--include/linux/kernel.h12
-rw-r--r--include/linux/types.h3
-rw-r--r--include/linux/usb/composite.h2
4 files changed, 39 insertions, 1 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 */
diff --git a/include/linux/kernel.h b/include/linux/kernel.h
index bd88483b9f6..a85c15d8dc2 100644
--- a/include/linux/kernel.h
+++ b/include/linux/kernel.h
@@ -102,6 +102,18 @@
(((__x) - ((__d) / 2)) / (__d)); \
} \
)
+/*
+ * Same as above but for u64 dividends. divisor must be a 32-bit
+ * number.
+ */
+#define DIV_ROUND_CLOSEST_ULL(x, divisor)( \
+{ \
+ typeof(divisor) __d = divisor; \
+ unsigned long long _tmp = (x) + (__d) / 2; \
+ do_div(_tmp, __d); \
+ _tmp; \
+} \
+)
/*
* Multiplies an integer by a fraction, while avoiding unnecessary
diff --git a/include/linux/types.h b/include/linux/types.h
index 1f3cd63b8f2..cc6f7cb39ee 100644
--- a/include/linux/types.h
+++ b/include/linux/types.h
@@ -158,4 +158,7 @@ struct ustat {
char f_fpack[6];
};
+#define DECLARE_BITMAP(name, bits) \
+ unsigned long name[BITS_TO_LONGS(bits)]
+
#endif /* _LINUX_TYPES_H */
diff --git a/include/linux/usb/composite.h b/include/linux/usb/composite.h
index 30c464ce39d..a49a66f2f82 100644
--- a/include/linux/usb/composite.h
+++ b/include/linux/usb/composite.h
@@ -24,7 +24,7 @@
#include <common.h>
#include <linux/usb/ch9.h>
#include <linux/usb/gadget.h>
-#include <usb/lin_gadget_compat.h>
+#include <linux/bitmap.h>
/*
* USB function drivers should return USB_GADGET_DELAYED_STATUS if they