Module Name:    src
Committed By:   thorpej
Date:           Sat Dec 19 21:27:52 UTC 2020

Modified Files:
        src/sys/arch/landisk/landisk: bus_dma.c intr.c

Log Message:
malloc(9) -> kmem(9)


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 src/sys/arch/landisk/landisk/bus_dma.c
cvs rdiff -u -r1.8 -r1.9 src/sys/arch/landisk/landisk/intr.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/landisk/landisk/bus_dma.c
diff -u src/sys/arch/landisk/landisk/bus_dma.c:1.15 src/sys/arch/landisk/landisk/bus_dma.c:1.16
--- src/sys/arch/landisk/landisk/bus_dma.c:1.15	Sat Mar 31 06:35:11 2012
+++ src/sys/arch/landisk/landisk/bus_dma.c	Sat Dec 19 21:27:52 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: bus_dma.c,v 1.15 2012/03/31 06:35:11 tsutsui Exp $	*/
+/*	$NetBSD: bus_dma.c,v 1.16 2020/12/19 21:27:52 thorpej Exp $	*/
 
 /*
  * Copyright (c) 2005 NONAKA Kimihiro
@@ -26,13 +26,13 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: bus_dma.c,v 1.15 2012/03/31 06:35:11 tsutsui Exp $");
+__KERNEL_RCSID(0, "$NetBSD: bus_dma.c,v 1.16 2020/12/19 21:27:52 thorpej Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
 #include <sys/kernel.h>
 #include <sys/device.h>
-#include <sys/malloc.h>
+#include <sys/kmem.h>
 #include <sys/mbuf.h>
 
 #include <uvm/uvm.h>
@@ -69,6 +69,14 @@ struct _bus_dma_tag landisk_bus_dma = {
 	._dmamem_mmap = _bus_dmamem_mmap,
 };
 
+static size_t 
+_bus_dmamap_mapsize(int const nsegments)
+{       
+	KASSERT(nsegments > 0);
+	return sizeof(struct _bus_dmamap)
+		+ (sizeof(bus_dma_segment_t) * (nsegments - 1));
+}
+
 /*
  * Create a DMA map.
  */
@@ -78,7 +86,6 @@ _bus_dmamap_create(bus_dma_tag_t t, bus_
 {
 	bus_dmamap_t map;
 	void *mapstore;
-	size_t mapsize;
 
 	DPRINTF(("%s: t = %p, size = %ld, nsegments = %d, maxsegsz = %ld,"
 		 " boundary = %ld, flags = %x\n",
@@ -94,10 +101,8 @@ _bus_dmamap_create(bus_dma_tag_t t, bus_
 	 * Preservation of ALLOCNOW notifies others that we've
 	 * reserved these resources, and they are not to be freed.
 	 */
-	mapsize = sizeof(struct _bus_dmamap)
-		+ (sizeof(bus_dma_segment_t) * (nsegments - 1));
-	mapstore = malloc(mapsize, M_DMAMAP, M_ZERO
-			  | ((flags & BUS_DMA_NOWAIT) ? M_NOWAIT : M_WAITOK));
+	mapstore = kmem_zalloc(_bus_dmamap_mapsize(nsegments),
+	    (flags & BUS_DMA_NOWAIT) ? KM_NOSLEEP : KM_SLEEP);
 	if (mapstore == NULL)
 		return ENOMEM;
 
@@ -126,7 +131,7 @@ _bus_dmamap_destroy(bus_dma_tag_t t, bus
 
 	DPRINTF(("%s: t = %p, map = %p\n", __func__, t, map));
 
-	free(map, M_DMAMAP);
+	kmem_free(map, _bus_dmamap_mapsize(map->_dm_segcnt));
 }
 
 static inline int

Index: src/sys/arch/landisk/landisk/intr.c
diff -u src/sys/arch/landisk/landisk/intr.c:1.8 src/sys/arch/landisk/landisk/intr.c:1.9
--- src/sys/arch/landisk/landisk/intr.c:1.8	Sun Nov 10 21:16:29 2019
+++ src/sys/arch/landisk/landisk/intr.c	Sat Dec 19 21:27:52 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: intr.c,v 1.8 2019/11/10 21:16:29 chs Exp $	*/
+/*	$NetBSD: intr.c,v 1.9 2020/12/19 21:27:52 thorpej Exp $	*/
 
 /*-
  * Copyright (C) 2005 NONAKA Kimihiro <[email protected]>
@@ -26,12 +26,12 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: intr.c,v 1.8 2019/11/10 21:16:29 chs Exp $");
+__KERNEL_RCSID(0, "$NetBSD: intr.c,v 1.9 2020/12/19 21:27:52 thorpej Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
 #include <sys/kernel.h>
-#include <sys/malloc.h>
+#include <sys/kmem.h>
 #include <sys/device.h>
 
 #include <sh3/exception.h>
@@ -143,7 +143,7 @@ extintr_establish(int irq, int level, in
 
 	KDASSERT(irq >= 5 && irq <= 12);
 
-	ih = malloc(sizeof(*ih), M_DEVBUF, M_WAITOK);
+	ih = kmem_alloc(sizeof(*ih), KM_SLEEP);
 
 	s = _cpu_intr_suspend();
 
@@ -234,7 +234,7 @@ extintr_disestablish(void *aux)
 
 	evcnt_detach(&ih->ih_evcnt);
 
-	free((void *)ih, M_DEVBUF);
+	kmem_free((void *)ih, sizeof(*ih));
 
 	if (--eih->eih_nih == 0) {
 		intc_intr_disestablish(eih->eih_func);

Reply via email to