busdma: Utilize kmalloc_powerof2()
authorSepherosa Ziehau <sephe@dragonflybsd.org>
Sun, 7 Oct 2012 04:40:57 +0000 (12:40 +0800)
committerSepherosa Ziehau <sephe@dragonflybsd.org>
Sun, 7 Oct 2012 04:40:57 +0000 (12:40 +0800)
sys/platform/pc32/i386/busdma_machdep.c
sys/platform/pc64/x86_64/busdma_machdep.c

index a8cff4e..35be77b 100644 (file)
@@ -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 {
index b94f358..151f9bf 100644 (file)
@@ -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 {