ion: don't use phys_to_page or __phys_to_pfn
authorColin Cross <ccross@android.com>
Sat, 14 Dec 2013 03:26:13 +0000 (19:26 -0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 14 Dec 2013 16:57:19 +0000 (08:57 -0800)
phys_to_page and __phys_to_pfn don't exist on all platforms.
Use a combination of pfn_to_page, PFN_DOWN, page_to_pfn, and
virt_to_page to get the same results.

Signed-off-by: Colin Cross <ccross@android.com>
Signed-off-by: John Stultz <john.stultz@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/android/ion/ion_carveout_heap.c
drivers/staging/android/ion/ion_chunk_heap.c
drivers/staging/android/ion/ion_system_heap.c

index 051363a442dcd52a3d449ac739ad7e88b7a3a3f8..1d53e9120b90c2e72615fefaad19ca5d8b12aa30 100644 (file)
@@ -96,8 +96,8 @@ struct sg_table *ion_carveout_heap_map_dma(struct ion_heap *heap,
                kfree(table);
                return ERR_PTR(ret);
        }
-       sg_set_page(table->sgl, phys_to_page(buffer->priv_phys), buffer->size,
-                   0);
+       sg_set_page(table->sgl, pfn_to_page(PFN_DOWN(buffer->priv_phys)),
+                       buffer->size, 0);
        return table;
 }
 
index d3363d6088dbc2b35bef371cffe44580055120cd..fb1a7b9bf7526adc6a1ead70471e6bb9680aed96 100644 (file)
@@ -71,7 +71,8 @@ static int ion_chunk_heap_allocate(struct ion_heap *heap,
                                                     chunk_heap->chunk_size);
                if (!paddr)
                        goto err;
-               sg_set_page(sg, phys_to_page(paddr), chunk_heap->chunk_size, 0);
+               sg_set_page(sg, pfn_to_page(PFN_DOWN(paddr)),
+                               chunk_heap->chunk_size, 0);
                sg = sg_next(sg);
        }
 
@@ -167,7 +168,7 @@ struct ion_heap *ion_chunk_heap_create(struct ion_platform_heap *heap_data)
                goto error;
        }
        for (i = 0; i < chunk_heap->size; i += PAGE_SIZE) {
-               struct page *page = phys_to_page(chunk_heap->base + i);
+               struct page *page = pfn_to_page(PFN_DOWN(chunk_heap->base + i));
                struct page **pages = &page;
 
                ret = map_vm_area(vm_struct, pgprot, &pages);
index 62a07ec7d5bf40ddcfcd5be28bd490605de5e5da..3b2f420b945dbea31fc1e4f697525c5b38eec0e5 100644 (file)
@@ -426,7 +426,7 @@ int ion_system_contig_heap_map_user(struct ion_heap *heap,
                                    struct ion_buffer *buffer,
                                    struct vm_area_struct *vma)
 {
-       unsigned long pfn = __phys_to_pfn(virt_to_phys(buffer->priv_virt));
+       unsigned long pfn = page_to_pfn(virt_to_page(buffer->priv_virt));
        return remap_pfn_range(vma, vma->vm_start, pfn + vma->vm_pgoff,
                               vma->vm_end - vma->vm_start,
                               vma->vm_page_prot);