blob: e5dba473b7ac144882707544c35682bf6d600a8e [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001/* SPDX-License-Identifier: GPL-2.0+ */
Lukasz Majewskiac3c8312011-10-27 10:36:46 +02002/*
3 * Copyright (c) 2011 Samsung Electronics
4 * Lukasz Majewski <l.majewski@samsung.com>
5 *
6 * This is a Linux kernel compatibility layer for USB Gadget
Lukasz Majewskiac3c8312011-10-27 10:36:46 +02007 */
8
9#ifndef __LIN_COMPAT_H__
10#define __LIN_COMPAT_H__
11
Masahiro Yamada14fecf92017-11-22 02:38:11 +090012#include <linux/bitops.h>
Mike Frysinger1f19e3f2012-04-26 02:34:44 +000013#include <linux/compat.h>
14
Lukasz Majewskiac3c8312011-10-27 10:36:46 +020015/* common */
Lukasz Majewski1dc6a672012-05-02 17:47:02 +020016#define DECLARE_BITMAP(name, bits) \
17 unsigned long name[BITS_TO_LONGS(bits)]
18
19#define small_const_nbits(nbits) \
20 (__builtin_constant_p(nbits) && (nbits) <= BITS_PER_LONG)
21
22static inline void bitmap_zero(unsigned long *dst, int nbits)
23{
24 if (small_const_nbits(nbits))
25 *dst = 0UL;
26 else {
27 int len = BITS_TO_LONGS(nbits) * sizeof(unsigned long);
28 memset(dst, 0, len);
29 }
30}
31
Lukasz Majewskiac3c8312011-10-27 10:36:46 +020032#define dma_cache_maint(addr, size, mode) cache_flush()
33void cache_flush(void);
34
35#endif /* __LIN_COMPAT_H__ */