2 * Copyright (c) 2011 Samsung Electronics
3 * Lukasz Majewski <l.majewski@samsung.com>
5 * This is a Linux kernel compatibility layer for USB Gadget
7 * SPDX-License-Identifier: GPL-2.0+
10 #ifndef __LIN_COMPAT_H__
11 #define __LIN_COMPAT_H__
13 #include <linux/compat.h>
16 #define ENOTSUPP 524 /* Operation is not supported */
18 #define BITS_PER_BYTE 8
19 #define BITS_TO_LONGS(nr) \
20 DIV_ROUND_UP(nr, BITS_PER_BYTE * sizeof(long))
21 #define DECLARE_BITMAP(name, bits) \
22 unsigned long name[BITS_TO_LONGS(bits)]
24 #define small_const_nbits(nbits) \
25 (__builtin_constant_p(nbits) && (nbits) <= BITS_PER_LONG)
27 static inline void bitmap_zero(unsigned long *dst, int nbits)
29 if (small_const_nbits(nbits))
32 int len = BITS_TO_LONGS(nbits) * sizeof(unsigned long);
37 #define dma_cache_maint(addr, size, mode) cache_flush()
38 void cache_flush(void);
40 #endif /* __LIN_COMPAT_H__ */