blob: 29fb166934c8d5d71e09d080665ed555910fe7da [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 */
Lukasz Majewskiac3c8312011-10-27 10:36:46 +020016#define ENOTSUPP 524 /* Operation is not supported */
17
Lukasz Majewski1dc6a672012-05-02 17:47:02 +020018#define BITS_PER_BYTE 8
19#define BITS_TO_LONGS(nr) \
20 DIV_ROUND_UP(nr, BITS_PER_BYTE * sizeof(long))
21#define DECLARE_BITMAP(name, bits) \
22 unsigned long name[BITS_TO_LONGS(bits)]
23
24#define small_const_nbits(nbits) \
25 (__builtin_constant_p(nbits) && (nbits) <= BITS_PER_LONG)
26
27static inline void bitmap_zero(unsigned long *dst, int nbits)
28{
29 if (small_const_nbits(nbits))
30 *dst = 0UL;
31 else {
32 int len = BITS_TO_LONGS(nbits) * sizeof(unsigned long);
33 memset(dst, 0, len);
34 }
35}
36
Lukasz Majewskiac3c8312011-10-27 10:36:46 +020037#define dma_cache_maint(addr, size, mode) cache_flush()
38void cache_flush(void);
39
40#endif /* __LIN_COMPAT_H__ */