include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit...
[linux-3.10.git] / drivers / infiniband / hw / amso1100 / c2_alloc.c
index 028a60b..d4f5f5d 100644 (file)
@@ -32,7 +32,6 @@
  */
 
 #include <linux/errno.h>
-#include <linux/slab.h>
 #include <linux/bitmap.h>
 
 #include "c2.h"
@@ -42,13 +41,14 @@ static int c2_alloc_mqsp_chunk(struct c2_dev *c2dev, gfp_t gfp_mask,
 {
        int i;
        struct sp_chunk *new_head;
+       dma_addr_t dma_addr;
 
-       new_head = (struct sp_chunk *) __get_free_page(gfp_mask);
+       new_head = dma_alloc_coherent(&c2dev->pcidev->dev, PAGE_SIZE,
+                                     &dma_addr, gfp_mask);
        if (new_head == NULL)
                return -ENOMEM;
 
-       new_head->dma_addr = dma_map_single(c2dev->ibdev.dma_device, new_head,
-                                           PAGE_SIZE, DMA_FROM_DEVICE);
+       new_head->dma_addr = dma_addr;
        pci_unmap_addr_set(new_head, mapping, new_head->dma_addr);
 
        new_head->next = NULL;
@@ -80,16 +80,14 @@ void c2_free_mqsp_pool(struct c2_dev *c2dev, struct sp_chunk *root)
 
        while (root) {
                next = root->next;
-               dma_unmap_single(c2dev->ibdev.dma_device,
-                                pci_unmap_addr(root, mapping), PAGE_SIZE,
-                                DMA_FROM_DEVICE);
-               __free_page((struct page *) root);
+               dma_free_coherent(&c2dev->pcidev->dev, PAGE_SIZE, root,
+                                 pci_unmap_addr(root, mapping));
                root = next;
        }
 }
 
-u16 *c2_alloc_mqsp(struct c2_dev *c2dev, struct sp_chunk *head,
-                  dma_addr_t *dma_addr, gfp_t gfp_mask)
+__be16 *c2_alloc_mqsp(struct c2_dev *c2dev, struct sp_chunk *head,
+                     dma_addr_t *dma_addr, gfp_t gfp_mask)
 {
        u16 mqsp;
 
@@ -114,14 +112,14 @@ u16 *c2_alloc_mqsp(struct c2_dev *c2dev, struct sp_chunk *head,
                *dma_addr = head->dma_addr +
                            ((unsigned long) &(head->shared_ptr[mqsp]) -
                             (unsigned long) head);
-               pr_debug("%s addr %p dma_addr %llx\n", __FUNCTION__,
+               pr_debug("%s addr %p dma_addr %llx\n", __func__,
                         &(head->shared_ptr[mqsp]), (unsigned long long) *dma_addr);
-               return &(head->shared_ptr[mqsp]);
+               return (__force __be16 *) &(head->shared_ptr[mqsp]);
        }
        return NULL;
 }
 
-void c2_free_mqsp(u16 * mqsp)
+void c2_free_mqsp(__be16 *mqsp)
 {
        struct sp_chunk *head;
        u16 idx;
@@ -130,7 +128,7 @@ void c2_free_mqsp(u16 * mqsp)
        head = (struct sp_chunk *) ((unsigned long) mqsp & PAGE_MASK);
 
        /* Link head to new mqsp */
-       *mqsp = head->head;
+       *mqsp = (__force __be16) head->head;
 
        /* Compute the shared_ptr index */
        idx = ((unsigned long) mqsp & ~PAGE_MASK) >> 1;