Lukasz Majewski | 38517a7 | 2011-10-27 10:36:46 +0200 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2011 Samsung Electronics |
| 3 | * Lukasz Majewski <l.majewski@samsung.com> |
| 4 | * |
| 5 | * This is a Linux kernel compatibility layer for USB Gadget |
| 6 | * |
Wolfgang Denk | 1a45966 | 2013-07-08 09:37:19 +0200 | [diff] [blame] | 7 | * SPDX-License-Identifier: GPL-2.0+ |
Lukasz Majewski | 38517a7 | 2011-10-27 10:36:46 +0200 | [diff] [blame] | 8 | */ |
| 9 | |
| 10 | #ifndef __LIN_COMPAT_H__ |
| 11 | #define __LIN_COMPAT_H__ |
| 12 | |
Masahiro Yamada | ed3986c | 2017-11-22 02:38:11 +0900 | [diff] [blame] | 13 | #include <linux/bitops.h> |
Mike Frysinger | 6777a3c | 2012-04-26 02:34:44 +0000 | [diff] [blame] | 14 | #include <linux/compat.h> |
| 15 | |
Lukasz Majewski | 38517a7 | 2011-10-27 10:36:46 +0200 | [diff] [blame] | 16 | /* common */ |
Lukasz Majewski | 7010f5b | 2012-05-02 17:47:02 +0200 | [diff] [blame] | 17 | #define DECLARE_BITMAP(name, bits) \ |
| 18 | unsigned long name[BITS_TO_LONGS(bits)] |
| 19 | |
| 20 | #define small_const_nbits(nbits) \ |
| 21 | (__builtin_constant_p(nbits) && (nbits) <= BITS_PER_LONG) |
| 22 | |
| 23 | static inline void bitmap_zero(unsigned long *dst, int nbits) |
| 24 | { |
| 25 | if (small_const_nbits(nbits)) |
| 26 | *dst = 0UL; |
| 27 | else { |
| 28 | int len = BITS_TO_LONGS(nbits) * sizeof(unsigned long); |
| 29 | memset(dst, 0, len); |
| 30 | } |
| 31 | } |
| 32 | |
Lukasz Majewski | 38517a7 | 2011-10-27 10:36:46 +0200 | [diff] [blame] | 33 | #define dma_cache_maint(addr, size, mode) cache_flush() |
| 34 | void cache_flush(void); |
| 35 | |
| 36 | #endif /* __LIN_COMPAT_H__ */ |