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-02-13 16:35:12 +00:00
parent 4182ffcf3e
commit 9cdc138838
4 changed files with 52 additions and 0 deletions

View File

@ -105,6 +105,13 @@ __free_pages(struct page *m, unsigned int order)
kmem_free(kmem_arena, (vm_offset_t)page_address(m), size);
}
static inline void free_pages(uintptr_t addr, unsigned int order)
{
if (addr == 0)
return;
__free_pages(virt_to_page((void *)addr), order);
}
/*
* Alloc pages allocates directly from the buddy allocator on linux so
* order specifies a power of two bucket of pages and the results
@ -124,6 +131,16 @@ alloc_pages(gfp_t gfp_mask, unsigned int order)
return (virt_to_page(page));
}
static inline uintptr_t __get_free_pages(gfp_t gfp_mask, unsigned int order)
{
struct page *page;
page = alloc_pages(gfp_mask, order);
if (page == NULL)
return (0);
return ((uintptr_t)page_address(page));
}
#define alloc_pages_node(node, mask, order) alloc_pages(mask, order)
#define kmalloc_node(chunk, mask, node) kmalloc(chunk, mask)

View File

@ -68,6 +68,7 @@
#undef ALIGN
#define ALIGN(x, y) roundup2((x), (y))
#define DIV_ROUND_UP howmany
#define FIELD_SIZEOF(t, f) sizeof(((t *)0)->f)
#define printk(X...) printf(X)
@ -175,6 +176,7 @@
#define round_down(x, y) ((x) & ~__round_mask(x, y))
#define num_possible_cpus() mp_ncpus
#define num_online_cpus() mp_ncpus
typedef struct pm_message {
int event;

View File

@ -29,6 +29,7 @@
#ifndef _LINUX_KREF_H_
#define _LINUX_KREF_H_
#include <sys/types.h>
#include <sys/refcount.h>
struct kref {

View File

@ -269,6 +269,14 @@ pci_set_master(struct pci_dev *pdev)
return (0);
}
static inline int
pci_clear_master(struct pci_dev *pdev)
{
pci_disable_busmaster(pdev->dev.bsddev);
return (0);
}
static inline int
pci_request_region(struct pci_dev *pdev, int bar, const char *res_name)
{
@ -458,6 +466,30 @@ pci_enable_msix(struct pci_dev *pdev, struct msix_entry *entries, int nreq)
return (0);
}
#define pci_enable_msix_range linux_pci_enable_msix_range
static inline int
pci_enable_msix_range(struct pci_dev *dev, struct msix_entry *entries,
int minvec, int maxvec)
{
int nvec = maxvec;
int rc;
if (maxvec < minvec)
return (-ERANGE);
do {
rc = pci_enable_msix(dev, entries, nvec);
if (rc < 0) {
return (rc);
} else if (rc > 0) {
if (rc < minvec)
return (-ENOSPC);
nvec = rc;
}
} while (rc);
return (nvec);
}
static inline int pci_channel_offline(struct pci_dev *pdev)
{
return false;