Permalink
Browse files

busdma: Utilize kmalloc_powerof2()

  • Loading branch information...
1 parent 7b269c7 commit 8e469b97783c14679448b8ed428d169b234b5108 Sepherosa Ziehau committed Oct 7, 2012
Showing with 2 additions and 12 deletions.
  1. +1 −6 sys/platform/pc32/i386/busdma_machdep.c
  2. +1 −6 sys/platform/pc64/x86_64/busdma_machdep.c
@@ -573,13 +573,8 @@ bus_dmamem_alloc(bus_dma_tag_t dmat, void **vaddr, int flags,
*/
maxsize = check_kmalloc(dmat, *vaddr, 0);
if (maxsize) {
- size_t size;
-
kfree(*vaddr, M_DEVBUF);
- /* XXX check for overflow? */
- for (size = 1; size <= maxsize; size <<= 1)
- ;
- *vaddr = kmalloc(size, M_DEVBUF, mflags);
+ *vaddr = kmalloc_powerof2(maxsize, M_DEVBUF, mflags);
check_kmalloc(dmat, *vaddr, 1);
}
} else {
@@ -573,13 +573,8 @@ bus_dmamem_alloc(bus_dma_tag_t dmat, void **vaddr, int flags,
*/
maxsize = check_kmalloc(dmat, *vaddr, 0);
if (maxsize) {
- size_t size;
-
kfree(*vaddr, M_DEVBUF);
- /* XXX check for overflow? */
- for (size = 1; size <= maxsize; size <<= 1)
- ;
- *vaddr = kmalloc(size, M_DEVBUF, mflags);
+ *vaddr = kmalloc_powerof2(maxsize, M_DEVBUF, mflags);
check_kmalloc(dmat, *vaddr, 1);
}
} else {

0 comments on commit 8e469b9

Please sign in to comment.