blob: 4a01585f809427e9d06ed8c50d7fafd97a766f12 [file] [log] [blame]
Lukasz Majewski38517a72011-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 Denk1a459662013-07-08 09:37:19 +02007 * SPDX-License-Identifier: GPL-2.0+
Lukasz Majewski38517a72011-10-27 10:36:46 +02008 */
9
10#ifndef __LIN_COMPAT_H__
11#define __LIN_COMPAT_H__
12
Mike Frysinger6777a3c2012-04-26 02:34:44 +000013#include <linux/compat.h>
14
Lukasz Majewski38517a72011-10-27 10:36:46 +020015/* common */
Lukasz Majewski7010f5b2012-05-02 17:47:02 +020016#define BITS_PER_BYTE 8
17#define BITS_TO_LONGS(nr) \
18 DIV_ROUND_UP(nr, BITS_PER_BYTE * sizeof(long))
19#define DECLARE_BITMAP(name, bits) \
20 unsigned long name[BITS_TO_LONGS(bits)]
21
22#define small_const_nbits(nbits) \
23 (__builtin_constant_p(nbits) && (nbits) <= BITS_PER_LONG)
24
25static inline void bitmap_zero(unsigned long *dst, int nbits)
26{
27 if (small_const_nbits(nbits))
28 *dst = 0UL;
29 else {
30 int len = BITS_TO_LONGS(nbits) * sizeof(unsigned long);
31 memset(dst, 0, len);
32 }
33}
34
Lukasz Majewski38517a72011-10-27 10:36:46 +020035#define dma_cache_maint(addr, size, mode) cache_flush()
36void cache_flush(void);
37
38#endif /* __LIN_COMPAT_H__ */