lin_gadget_compat.h 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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. * This program is free software; you can redistribute it and/or
  8. * modify it under the terms of the GNU General Public License as
  9. * published by the Free Software Foundation; either version 2 of
  10. * the License, or (at your option) any later version.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program; if not, write to the Free Software
  19. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  20. * MA 02111-1307 USA
  21. */
  22. #ifndef __LIN_COMPAT_H__
  23. #define __LIN_COMPAT_H__
  24. #include <linux/compat.h>
  25. /* common */
  26. #define spin_lock_init(...)
  27. #define spin_lock(...)
  28. #define spin_lock_irqsave(lock, flags) do { debug("%lu\n", flags); } while (0)
  29. #define spin_unlock(...)
  30. #define spin_unlock_irqrestore(lock, flags) do {flags = 0; } while (0)
  31. #define disable_irq(...)
  32. #define enable_irq(...)
  33. #define mutex_init(...)
  34. #define mutex_lock(...)
  35. #define mutex_unlock(...)
  36. #define GFP_KERNEL 0
  37. #define IRQ_HANDLED 1
  38. #define ENOTSUPP 524 /* Operation is not supported */
  39. #define BITS_PER_BYTE 8
  40. #define BITS_TO_LONGS(nr) \
  41. DIV_ROUND_UP(nr, BITS_PER_BYTE * sizeof(long))
  42. #define DECLARE_BITMAP(name, bits) \
  43. unsigned long name[BITS_TO_LONGS(bits)]
  44. #define small_const_nbits(nbits) \
  45. (__builtin_constant_p(nbits) && (nbits) <= BITS_PER_LONG)
  46. static inline void bitmap_zero(unsigned long *dst, int nbits)
  47. {
  48. if (small_const_nbits(nbits))
  49. *dst = 0UL;
  50. else {
  51. int len = BITS_TO_LONGS(nbits) * sizeof(unsigned long);
  52. memset(dst, 0, len);
  53. }
  54. }
  55. #define dma_cache_maint(addr, size, mode) cache_flush()
  56. void cache_flush(void);
  57. #endif /* __LIN_COMPAT_H__ */