Lukasz Majewski | ac3c831 | 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 | * |
| 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 | |
| 23 | #ifndef __LIN_COMPAT_H__ |
| 24 | #define __LIN_COMPAT_H__ |
| 25 | |
Mike Frysinger | 1f19e3f | 2012-04-26 02:34:44 +0000 | [diff] [blame] | 26 | #include <linux/compat.h> |
| 27 | |
Lukasz Majewski | ac3c831 | 2011-10-27 10:36:46 +0200 | [diff] [blame] | 28 | /* common */ |
| 29 | #define spin_lock_init(...) |
| 30 | #define spin_lock(...) |
Anatolij Gustschin | e63ce4f | 2011-12-19 04:20:35 +0000 | [diff] [blame] | 31 | #define spin_lock_irqsave(lock, flags) do { debug("%lu\n", flags); } while (0) |
Lukasz Majewski | ac3c831 | 2011-10-27 10:36:46 +0200 | [diff] [blame] | 32 | #define spin_unlock(...) |
| 33 | #define spin_unlock_irqrestore(lock, flags) do {flags = 0; } while (0) |
| 34 | #define disable_irq(...) |
| 35 | #define enable_irq(...) |
| 36 | |
| 37 | #define mutex_init(...) |
| 38 | #define mutex_lock(...) |
| 39 | #define mutex_unlock(...) |
| 40 | |
Lukasz Majewski | ac3c831 | 2011-10-27 10:36:46 +0200 | [diff] [blame] | 41 | #define GFP_KERNEL 0 |
| 42 | |
| 43 | #define IRQ_HANDLED 1 |
| 44 | |
| 45 | #define ENOTSUPP 524 /* Operation is not supported */ |
| 46 | |
Lukasz Majewski | 1dc6a67 | 2012-05-02 17:47:02 +0200 | [diff] [blame] | 47 | #define BITS_PER_BYTE 8 |
| 48 | #define BITS_TO_LONGS(nr) \ |
| 49 | DIV_ROUND_UP(nr, BITS_PER_BYTE * sizeof(long)) |
| 50 | #define DECLARE_BITMAP(name, bits) \ |
| 51 | unsigned long name[BITS_TO_LONGS(bits)] |
| 52 | |
| 53 | #define small_const_nbits(nbits) \ |
| 54 | (__builtin_constant_p(nbits) && (nbits) <= BITS_PER_LONG) |
| 55 | |
| 56 | static inline void bitmap_zero(unsigned long *dst, int nbits) |
| 57 | { |
| 58 | if (small_const_nbits(nbits)) |
| 59 | *dst = 0UL; |
| 60 | else { |
| 61 | int len = BITS_TO_LONGS(nbits) * sizeof(unsigned long); |
| 62 | memset(dst, 0, len); |
| 63 | } |
| 64 | } |
| 65 | |
Lukasz Majewski | ac3c831 | 2011-10-27 10:36:46 +0200 | [diff] [blame] | 66 | #define dma_cache_maint(addr, size, mode) cache_flush() |
| 67 | void cache_flush(void); |
| 68 | |
| 69 | #endif /* __LIN_COMPAT_H__ */ |