lin_gadget_compat.h 936 B

12345678910111213141516171819202122232425262728293031323334353637383940
  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. *
  7. * SPDX-License-Identifier: GPL-2.0+
  8. */
  9. #ifndef __LIN_COMPAT_H__
  10. #define __LIN_COMPAT_H__
  11. #include <linux/compat.h>
  12. /* common */
  13. #define ENOTSUPP 524 /* Operation is not supported */
  14. #define BITS_PER_BYTE 8
  15. #define BITS_TO_LONGS(nr) \
  16. DIV_ROUND_UP(nr, BITS_PER_BYTE * sizeof(long))
  17. #define DECLARE_BITMAP(name, bits) \
  18. unsigned long name[BITS_TO_LONGS(bits)]
  19. #define small_const_nbits(nbits) \
  20. (__builtin_constant_p(nbits) && (nbits) <= BITS_PER_LONG)
  21. static inline void bitmap_zero(unsigned long *dst, int nbits)
  22. {
  23. if (small_const_nbits(nbits))
  24. *dst = 0UL;
  25. else {
  26. int len = BITS_TO_LONGS(nbits) * sizeof(unsigned long);
  27. memset(dst, 0, len);
  28. }
  29. }
  30. #define dma_cache_maint(addr, size, mode) cache_flush()
  31. void cache_flush(void);
  32. #endif /* __LIN_COMPAT_H__ */