Skip to content

Commit

Permalink
drivers: base: dma-mapping: use nth_page helper
Browse files Browse the repository at this point in the history
Use nth_page() helper instead of page_to_pfn() and pfn_to_page() to
simplify the code.

Signed-off-by: Geliang Tang <geliangtang@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
Geliang Tang authored and Greg Kroah-Hartman committed Apr 8, 2017
1 parent a2b6067 commit 0dd8911
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions drivers/base/dma-mapping.c
Original file line number Diff line number Diff line change
Expand Up @@ -309,14 +309,13 @@ void *dma_common_contiguous_remap(struct page *page, size_t size,
int i;
struct page **pages;
void *ptr;
unsigned long pfn;

pages = kmalloc(sizeof(struct page *) << get_order(size), GFP_KERNEL);
if (!pages)
return NULL;

for (i = 0, pfn = page_to_pfn(page); i < (size >> PAGE_SHIFT); i++)
pages[i] = pfn_to_page(pfn + i);
for (i = 0; i < (size >> PAGE_SHIFT); i++)
pages[i] = nth_page(page, i);

ptr = dma_common_pages_remap(pages, size, vm_flags, prot, caller);

Expand Down

0 comments on commit 0dd8911

Please sign in to comment.