changed pci_alloc_consistent compatibility function so it can allocate up
authorFrank Mori Hess <fmhess@speakeasy.net>
Tue, 5 Feb 2002 01:19:26 +0000 (01:19 +0000)
committerFrank Mori Hess <fmhess@speakeasy.net>
Tue, 5 Feb 2002 01:19:26 +0000 (01:19 +0000)
to 2M.

include/linux/pci.h

index 5a37e75f70da6e834654709a37b44b3baea66e28..7f01307b6dfaacf68483116736a850e85267800b 100644 (file)
@@ -36,16 +36,31 @@ struct pci_device_id {
 #include <linux/malloc.h>
 #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)