blob: a25e9d9ef3bc8fb10acfdb94e3b54f6299800f52 [file] [log] [blame]
Lukasz Majewskiac3c8312011-10-27 10:36:46 +02001/*
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 Denkd79de1d2013-07-08 09:37:19 +02007 * SPDX-License-Identifier: GPL-2.0+
Lukasz Majewskiac3c8312011-10-27 10:36:46 +02008 */
9
10#ifndef __LIN_COMPAT_H__
11#define __LIN_COMPAT_H__
12
Mike Frysinger1f19e3f2012-04-26 02:34:44 +000013#include <linux/compat.h>
14
Lukasz Majewskiac3c8312011-10-27 10:36:46 +020015/* common */
16#define spin_lock_init(...)
17#define spin_lock(...)
Anatolij Gustschine63ce4f2011-12-19 04:20:35 +000018#define spin_lock_irqsave(lock, flags) do { debug("%lu\n", flags); } while (0)
Lukasz Majewskiac3c8312011-10-27 10:36:46 +020019#define spin_unlock(...)
20#define spin_unlock_irqrestore(lock, flags) do {flags = 0; } while (0)
21#define disable_irq(...)
22#define enable_irq(...)
23
24#define mutex_init(...)
25#define mutex_lock(...)
26#define mutex_unlock(...)
27
Lukasz Majewskiac3c8312011-10-27 10:36:46 +020028#define GFP_KERNEL 0
29
30#define IRQ_HANDLED 1
31
32#define ENOTSUPP 524 /* Operation is not supported */
33
Lukasz Majewski1dc6a672012-05-02 17:47:02 +020034#define BITS_PER_BYTE 8
35#define BITS_TO_LONGS(nr) \
36 DIV_ROUND_UP(nr, BITS_PER_BYTE * sizeof(long))
37#define DECLARE_BITMAP(name, bits) \
38 unsigned long name[BITS_TO_LONGS(bits)]
39
40#define small_const_nbits(nbits) \
41 (__builtin_constant_p(nbits) && (nbits) <= BITS_PER_LONG)
42
43static inline void bitmap_zero(unsigned long *dst, int nbits)
44{
45 if (small_const_nbits(nbits))
46 *dst = 0UL;
47 else {
48 int len = BITS_TO_LONGS(nbits) * sizeof(unsigned long);
49 memset(dst, 0, len);
50 }
51}
52
Lukasz Majewskiac3c8312011-10-27 10:36:46 +020053#define dma_cache_maint(addr, size, mode) cache_flush()
54void cache_flush(void);
55
56#endif /* __LIN_COMPAT_H__ */