From ea3e02bb16db91fd97e4cad806e0d500d86babb1 Mon Sep 17 00:00:00 2001 From: Frank Mori Hess Date: Tue, 5 Feb 2002 01:19:26 +0000 Subject: [PATCH] changed pci_alloc_consistent compatibility function so it can allocate up to 2M. --- include/linux/pci.h | 29 ++++++++++++++++++++++------- 1 file changed, 22 insertions(+), 7 deletions(-) diff --git a/include/linux/pci.h b/include/linux/pci.h index 5a37e75f..7f01307b 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h @@ -36,16 +36,31 @@ struct pci_device_id { #include #define PCI_DMA_FROMDEVICE 0 #define PCI_DMA_TODEVICE 0 -static inline void *pci_alloc_consistent(struct pci_dev *hwdev, size_t size, - dma_addr_t *dma_handle) + +extern inline void *pci_alloc_consistent(struct pci_dev *hwdev, size_t size, + dma_addr_t *dma_handle) { - void *virt_ptr; + void *ret; + int gfp = GFP_KERNEL; + + if (hwdev == NULL) + gfp |= GFP_DMA; + ret = (void *) __get_free_pages(gfp, get_order(size)); + + if (ret != NULL) + { + memset(ret, 0, size); + *dma_handle = virt_to_bus(ret); + } + return ret; +} - virt_ptr = kmalloc(size, GFP_KERNEL); - *dma_handle = virt_to_bus(virt_ptr); - return virt_ptr; +extern inline void pci_free_consistent(struct pci_dev *hwdev, size_t size, + void *vaddr, dma_addr_t dma_handle) +{ + free_pages((unsigned long)vaddr, get_order(size)); } -#define pci_free_consistent(cookie, size, ptr, dma_ptr) kfree(ptr) + #define pci_map_single(cookie, address, size, dir) virt_to_bus(address) #define pci_unmap_single(cookie, address, size, dir) #define pci_dma_sync_single(cookie, address, size, dir) -- 2.26.2