2011-10-27 08:36:46 +00:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2011 Samsung Electronics
|
|
|
|
* Lukasz Majewski <l.majewski@samsung.com>
|
|
|
|
*
|
|
|
|
* This is a Linux kernel compatibility layer for USB Gadget
|
|
|
|
*
|
2013-07-08 07:37:19 +00:00
|
|
|
* SPDX-License-Identifier: GPL-2.0+
|
2011-10-27 08:36:46 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __LIN_COMPAT_H__
|
|
|
|
#define __LIN_COMPAT_H__
|
|
|
|
|
2012-04-26 02:34:44 +00:00
|
|
|
#include <linux/compat.h>
|
|
|
|
|
2011-10-27 08:36:46 +00:00
|
|
|
/* common */
|
|
|
|
#define ENOTSUPP 524 /* Operation is not supported */
|
|
|
|
|
2012-05-02 15:47:02 +00:00
|
|
|
#define BITS_PER_BYTE 8
|
|
|
|
#define BITS_TO_LONGS(nr) \
|
|
|
|
DIV_ROUND_UP(nr, BITS_PER_BYTE * sizeof(long))
|
|
|
|
#define DECLARE_BITMAP(name, bits) \
|
|
|
|
unsigned long name[BITS_TO_LONGS(bits)]
|
|
|
|
|
|
|
|
#define small_const_nbits(nbits) \
|
|
|
|
(__builtin_constant_p(nbits) && (nbits) <= BITS_PER_LONG)
|
|
|
|
|
|
|
|
static inline void bitmap_zero(unsigned long *dst, int nbits)
|
|
|
|
{
|
|
|
|
if (small_const_nbits(nbits))
|
|
|
|
*dst = 0UL;
|
|
|
|
else {
|
|
|
|
int len = BITS_TO_LONGS(nbits) * sizeof(unsigned long);
|
|
|
|
memset(dst, 0, len);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-10-27 08:36:46 +00:00
|
|
|
#define dma_cache_maint(addr, size, mode) cache_flush()
|
|
|
|
void cache_flush(void);
|
|
|
|
|
|
|
|
#endif /* __LIN_COMPAT_H__ */
|