diff options
author | Kristoffer Glembo <kristoffer@gaisler.com> | 2011-01-17 23:10:24 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2011-03-16 21:18:57 -0400 |
commit | 5c8345bbe8e7cfd5bfa59f0e1fcef2e12a28e430 (patch) | |
tree | e8df018f2dec2be8d891c3b641b1514f6a60fa6c /arch/sparc | |
parent | 4c5811bf463b0ef82fabbd1708f8bb2d753aeb18 (diff) |
sparc: Replace open coded page alignment with PAGE_ALIGN macro.
Signed-off-by: Kristoffer Glembo <kristoffer@gaisler.com>
Acked-by: Sam Ravnborg <sam@ravnborg.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'arch/sparc')
-rw-r--r-- | arch/sparc/kernel/ioport.c | 25 |
1 files changed, 11 insertions, 14 deletions
diff --git a/arch/sparc/kernel/ioport.c b/arch/sparc/kernel/ioport.c index 41f7e4e0f72a..cea49c0756d2 100644 --- a/arch/sparc/kernel/ioport.c +++ b/arch/sparc/kernel/ioport.c | |||
@@ -254,7 +254,7 @@ static void *sbus_alloc_coherent(struct device *dev, size_t len, | |||
254 | dma_addr_t *dma_addrp, gfp_t gfp) | 254 | dma_addr_t *dma_addrp, gfp_t gfp) |
255 | { | 255 | { |
256 | struct platform_device *op = to_platform_device(dev); | 256 | struct platform_device *op = to_platform_device(dev); |
257 | unsigned long len_total = (len + PAGE_SIZE-1) & PAGE_MASK; | 257 | unsigned long len_total = PAGE_ALIGN(len); |
258 | unsigned long va; | 258 | unsigned long va; |
259 | struct resource *res; | 259 | struct resource *res; |
260 | int order; | 260 | int order; |
@@ -281,6 +281,7 @@ static void *sbus_alloc_coherent(struct device *dev, size_t len, | |||
281 | goto err_nova; | 281 | goto err_nova; |
282 | } | 282 | } |
283 | mmu_inval_dma_area(va, len_total); | 283 | mmu_inval_dma_area(va, len_total); |
284 | |||
284 | // XXX The mmu_map_dma_area does this for us below, see comments. | 285 | // XXX The mmu_map_dma_area does this for us below, see comments. |
285 | // sparc_mapiorange(0, virt_to_phys(va), res->start, len_total); | 286 | // sparc_mapiorange(0, virt_to_phys(va), res->start, len_total); |
286 | /* | 287 | /* |
@@ -321,7 +322,7 @@ static void sbus_free_coherent(struct device *dev, size_t n, void *p, | |||
321 | return; | 322 | return; |
322 | } | 323 | } |
323 | 324 | ||
324 | n = (n + PAGE_SIZE-1) & PAGE_MASK; | 325 | n = PAGE_ALIGN(n); |
325 | if ((res->end-res->start)+1 != n) { | 326 | if ((res->end-res->start)+1 != n) { |
326 | printk("sbus_free_consistent: region 0x%lx asked 0x%zx\n", | 327 | printk("sbus_free_consistent: region 0x%lx asked 0x%zx\n", |
327 | (long)((res->end-res->start)+1), n); | 328 | (long)((res->end-res->start)+1), n); |
@@ -430,7 +431,7 @@ arch_initcall(sparc_register_ioport); | |||
430 | static void *pci32_alloc_coherent(struct device *dev, size_t len, | 431 | static void *pci32_alloc_coherent(struct device *dev, size_t len, |
431 | dma_addr_t *pba, gfp_t gfp) | 432 | dma_addr_t *pba, gfp_t gfp) |
432 | { | 433 | { |
433 | unsigned long len_total = (len + PAGE_SIZE-1) & PAGE_MASK; | 434 | unsigned long len_total = PAGE_ALIGN(len); |
434 | unsigned long va; | 435 | unsigned long va; |
435 | struct resource *res; | 436 | struct resource *res; |
436 | int order; | 437 | int order; |
@@ -463,10 +464,6 @@ static void *pci32_alloc_coherent(struct device *dev, size_t len, | |||
463 | return NULL; | 464 | return NULL; |
464 | } | 465 | } |
465 | mmu_inval_dma_area(va, len_total); | 466 | mmu_inval_dma_area(va, len_total); |
466 | #if 0 | ||
467 | /* P3 */ printk("pci_alloc_consistent: kva %lx uncva %lx phys %lx size %lx\n", | ||
468 | (long)va, (long)res->start, (long)virt_to_phys(va), len_total); | ||
469 | #endif | ||
470 | sparc_mapiorange(0, virt_to_phys(va), res->start, len_total); | 467 | sparc_mapiorange(0, virt_to_phys(va), res->start, len_total); |
471 | 468 | ||
472 | *pba = virt_to_phys(va); /* equals virt_to_bus (R.I.P.) for us. */ | 469 | *pba = virt_to_phys(va); /* equals virt_to_bus (R.I.P.) for us. */ |
@@ -498,7 +495,7 @@ static void pci32_free_coherent(struct device *dev, size_t n, void *p, | |||
498 | return; | 495 | return; |
499 | } | 496 | } |
500 | 497 | ||
501 | n = (n + PAGE_SIZE-1) & PAGE_MASK; | 498 | n = PAGE_ALIGN(n); |
502 | if ((res->end-res->start)+1 != n) { | 499 | if ((res->end-res->start)+1 != n) { |
503 | printk("pci_free_consistent: region 0x%lx asked 0x%lx\n", | 500 | printk("pci_free_consistent: region 0x%lx asked 0x%lx\n", |
504 | (long)((res->end-res->start)+1), (long)n); | 501 | (long)((res->end-res->start)+1), (long)n); |
@@ -574,7 +571,7 @@ static void pci32_unmap_sg(struct device *dev, struct scatterlist *sgl, | |||
574 | BUG_ON(page_address(sg_page(sg)) == NULL); | 571 | BUG_ON(page_address(sg_page(sg)) == NULL); |
575 | mmu_inval_dma_area( | 572 | mmu_inval_dma_area( |
576 | (unsigned long) page_address(sg_page(sg)), | 573 | (unsigned long) page_address(sg_page(sg)), |
577 | (sg->length + PAGE_SIZE-1) & PAGE_MASK); | 574 | PAGE_ALIGN(sg->length)); |
578 | } | 575 | } |
579 | } | 576 | } |
580 | } | 577 | } |
@@ -594,7 +591,7 @@ static void pci32_sync_single_for_cpu(struct device *dev, dma_addr_t ba, | |||
594 | { | 591 | { |
595 | if (dir != PCI_DMA_TODEVICE) { | 592 | if (dir != PCI_DMA_TODEVICE) { |
596 | mmu_inval_dma_area((unsigned long)phys_to_virt(ba), | 593 | mmu_inval_dma_area((unsigned long)phys_to_virt(ba), |
597 | (size + PAGE_SIZE-1) & PAGE_MASK); | 594 | PAGE_ALIGN(size)); |
598 | } | 595 | } |
599 | } | 596 | } |
600 | 597 | ||
@@ -603,7 +600,7 @@ static void pci32_sync_single_for_device(struct device *dev, dma_addr_t ba, | |||
603 | { | 600 | { |
604 | if (dir != PCI_DMA_TODEVICE) { | 601 | if (dir != PCI_DMA_TODEVICE) { |
605 | mmu_inval_dma_area((unsigned long)phys_to_virt(ba), | 602 | mmu_inval_dma_area((unsigned long)phys_to_virt(ba), |
606 | (size + PAGE_SIZE-1) & PAGE_MASK); | 603 | PAGE_ALIGN(size)); |
607 | } | 604 | } |
608 | } | 605 | } |
609 | 606 | ||
@@ -624,7 +621,7 @@ static void pci32_sync_sg_for_cpu(struct device *dev, struct scatterlist *sgl, | |||
624 | BUG_ON(page_address(sg_page(sg)) == NULL); | 621 | BUG_ON(page_address(sg_page(sg)) == NULL); |
625 | mmu_inval_dma_area( | 622 | mmu_inval_dma_area( |
626 | (unsigned long) page_address(sg_page(sg)), | 623 | (unsigned long) page_address(sg_page(sg)), |
627 | (sg->length + PAGE_SIZE-1) & PAGE_MASK); | 624 | PAGE_ALIGN(sg->length)); |
628 | } | 625 | } |
629 | } | 626 | } |
630 | } | 627 | } |
@@ -640,7 +637,7 @@ static void pci32_sync_sg_for_device(struct device *device, struct scatterlist * | |||
640 | BUG_ON(page_address(sg_page(sg)) == NULL); | 637 | BUG_ON(page_address(sg_page(sg)) == NULL); |
641 | mmu_inval_dma_area( | 638 | mmu_inval_dma_area( |
642 | (unsigned long) page_address(sg_page(sg)), | 639 | (unsigned long) page_address(sg_page(sg)), |
643 | (sg->length + PAGE_SIZE-1) & PAGE_MASK); | 640 | PAGE_ALIGN(sg->length)); |
644 | } | 641 | } |
645 | } | 642 | } |
646 | } | 643 | } |
@@ -717,7 +714,7 @@ static const struct file_operations sparc_io_proc_fops = { | |||
717 | static struct resource *_sparc_find_resource(struct resource *root, | 714 | static struct resource *_sparc_find_resource(struct resource *root, |
718 | unsigned long hit) | 715 | unsigned long hit) |
719 | { | 716 | { |
720 | struct resource *tmp; | 717 | struct resource *tmp; |
721 | 718 | ||
722 | for (tmp = root->child; tmp != 0; tmp = tmp->sibling) { | 719 | for (tmp = root->child; tmp != 0; tmp = tmp->sibling) { |
723 | if (tmp->start <= hit && tmp->end >= hit) | 720 | if (tmp->start <= hit && tmp->end >= hit) |