Add more functions to the Linux kernel compatibility layer. Add some

missing includes which are needed when the header files are not
included in a particular order.

MFC after:	1 month
Sponsored by:	Mellanox Technologies
This commit is contained in:
Hans Petter Selasky 2015-01-19 20:39:48 +00:00
parent 98cd7a6655
commit 7c3892fc82
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=277396
9 changed files with 52 additions and 3 deletions

View File

@ -288,9 +288,15 @@ bitmap_empty(unsigned long *addr, int size)
#define NBLONG (NBBY * sizeof(long))
#define __set_bit(i, a) \
atomic_set_long(&((volatile long *)(a))[(i)/NBLONG], 1UL << ((i) % NBLONG))
#define set_bit(i, a) \
atomic_set_long(&((volatile long *)(a))[(i)/NBLONG], 1UL << ((i) % NBLONG))
#define __clear_bit(i, a) \
atomic_clear_long(&((volatile long *)(a))[(i)/NBLONG], 1UL << ((i) % NBLONG))
#define clear_bit(i, a) \
atomic_clear_long(&((volatile long *)(a))[(i)/NBLONG], 1UL << ((i) % NBLONG))

View File

@ -30,8 +30,7 @@
#ifndef _LINUX_CACHE_H_
#define _LINUX_CACHE_H_
#define cache_line_size() CACHE_LINE_SIZE
#define L1_CACHE_BYTES CACHE_LINE_SIZE
#endif /* _LINUX_CACHE_H_ */

View File

@ -139,6 +139,14 @@ dma_alloc_coherent(struct device *dev, size_t size, dma_addr_t *dma_handle,
*dma_handle = 0;
return (mem);
}
static inline void *
dma_zalloc_coherent(struct device *dev, size_t size, dma_addr_t *dma_handle,
gfp_t flag)
{
return (dma_alloc_coherent(dev, size, dma_handle, flag | __GFP_ZERO));
}
static inline void
dma_free_coherent(struct device *dev, size_t size, void *cpu_addr,

View File

@ -89,6 +89,9 @@ static inline bool is_valid_ether_addr(const u8 *addr)
return !is_multicast_ether_addr(addr) && !is_zero_ether_addr(addr);
}
static inline void ether_addr_copy(u8 *dst, const u8 *src)
{
memcpy(dst, src, 6);
}
#endif /* _LINUX_ETHERDEVICE */

View File

@ -30,6 +30,8 @@
#ifndef _LINUX_GFP_H_
#define _LINUX_GFP_H_
#include <sys/cdefs.h>
#include <sys/types.h>
#include <sys/systm.h>
#include <sys/malloc.h>

View File

@ -31,6 +31,7 @@
#define _LINUX_IO_H_
#include <machine/vm.h>
#include <sys/endian.h>
static inline uint32_t
__raw_readl(const volatile void *addr)
@ -89,6 +90,20 @@ writew(uint16_t b, void *addr)
*(volatile uint16_t *)addr = b;
}
#undef ioread32be
static inline uint32_t
ioread32be(const volatile void *addr)
{
return be32toh(*(const volatile uint32_t *)addr);
}
#undef iowrite32be
static inline void
iowrite32be(uint32_t v, volatile void *addr)
{
*(volatile uint32_t *)addr = htobe32(v);
}
void *_ioremap_attr(vm_paddr_t phys_addr, unsigned long size, int attr);
#define ioremap_nocache(addr, size) \
_ioremap_attr((addr), (size), VM_MEMATTR_UNCACHEABLE)

View File

@ -29,6 +29,8 @@
#ifndef _LINUX_KERNEL_H_
#define _LINUX_KERNEL_H_
#include <sys/cdefs.h>
#include <sys/types.h>
#include <sys/systm.h>
#include <sys/param.h>
#include <sys/libkern.h>
@ -57,6 +59,8 @@
#define KERN_INFO "<6>"
#define KERN_DEBUG "<7>"
#define BUILD_BUG_ON(x) CTASSERT(x)
#define BUG() panic("BUG")
#define BUG_ON(condition) do { if (condition) BUG(); } while(0)
#define WARN_ON BUG_ON
@ -84,6 +88,7 @@
#endif
#define udelay(t) DELAY(t)
#define usleep_range(min,max) DELAY(min)
#ifndef pr_fmt
#define pr_fmt(fmt) fmt

View File

@ -288,4 +288,13 @@ static inline s64 ktime_to_ns(const ktime_t kt)
#endif /* !((BITS_PER_LONG == 64) || defined(CONFIG_KTIME_SCALAR)) */
static inline s64 ktime_get_ns(void)
{
struct timespec ts;
ktime_t kt;
ktime_get_ts(&ts);
kt = timespec_to_ktime(ts);
return (ktime_to_ns(kt));
}
#endif /* _LINUX_KTIME_H */

View File

@ -40,6 +40,7 @@
MALLOC_DECLARE(M_KMALLOC);
#define kmalloc(size, flags) malloc((size), M_KMALLOC, (flags))
#define kvmalloc(size) kmalloc((size), 0)
#define kzalloc(size, flags) kmalloc((size), (flags) | M_ZERO)
#define kzalloc_node(size, flags, node) kzalloc(size, flags)
#define kfree(ptr) free(__DECONST(void *, (ptr)), M_KMALLOC)
@ -47,6 +48,7 @@ MALLOC_DECLARE(M_KMALLOC);
#define kcalloc(n, size, flags) kmalloc((n) * (size), flags | M_ZERO)
#define vzalloc(size) kzalloc(size, GFP_KERNEL | __GFP_NOWARN)
#define vfree(arg) kfree(arg)
#define kvfree(arg) kfree(arg)
#define vmalloc(size) kmalloc(size, GFP_KERNEL)
#define vmalloc_node(size, node) kmalloc(size, GFP_KERNEL)