[MIPS] Bullet proof uaccess.h against 4.0.1 miss-compilation.
[safe/jmp/linux-2.6] / lib / swiotlb.c
index c2fc470..0af497b 100644 (file)
@@ -142,8 +142,7 @@ swiotlb_init_with_default_size (size_t default_size)
        /*
         * Get IO TLB memory from the low pages
         */
-       io_tlb_start = alloc_bootmem_low_pages(io_tlb_nslabs *
-                                              (1 << IO_TLB_SHIFT));
+       io_tlb_start = alloc_bootmem_low_pages(io_tlb_nslabs * (1 << IO_TLB_SHIFT));
        if (!io_tlb_start)
                panic("Cannot allocate SWIOTLB buffer");
        io_tlb_end = io_tlb_start + io_tlb_nslabs * (1 << IO_TLB_SHIFT);
@@ -433,7 +432,7 @@ sync_single(struct device *hwdev, char *dma_addr, size_t size,
 
 void *
 swiotlb_alloc_coherent(struct device *hwdev, size_t size,
-                      dma_addr_t *dma_handle, int flags)
+                      dma_addr_t *dma_handle, gfp_t flags)
 {
        unsigned long dev_addr;
        void *ret;
@@ -464,7 +463,7 @@ swiotlb_alloc_coherent(struct device *hwdev, size_t size,
                 */
                dma_addr_t handle;
                handle = swiotlb_map_single(NULL, NULL, size, DMA_FROM_DEVICE);
-               if (dma_mapping_error(handle))
+               if (swiotlb_dma_mapping_error(handle))
                        return NULL;
 
                ret = phys_to_virt(handle);
@@ -704,8 +703,9 @@ swiotlb_map_sg(struct device *hwdev, struct scatterlist *sg, int nelems,
                addr = SG_ENT_VIRT_ADDRESS(sg);
                dev_addr = virt_to_phys(addr);
                if (swiotlb_force || address_needs_mapping(hwdev, dev_addr)) {
-                       sg->dma_address = (dma_addr_t) virt_to_phys(map_single(hwdev, addr, sg->length, dir));
-                       if (!sg->dma_address) {
+                       void *map = map_single(hwdev, addr, sg->length, dir);
+                       sg->dma_address = virt_to_bus(map);
+                       if (!map) {
                                /* Don't panic here, we expect map_sg users
                                   to do proper error handling. */
                                swiotlb_full(hwdev, sg->length, dir, 0);