Module Name:    src
Committed By:   thorpej
Date:           Sat Nov 21 17:59:13 UTC 2020

Modified Files:
        src/sys/arch/mvme68k/mvme68k: bus_dma.c isr.c

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


To generate a diff of this commit:
cvs rdiff -u -r1.37 -r1.38 src/sys/arch/mvme68k/mvme68k/bus_dma.c
cvs rdiff -u -r1.34 -r1.35 src/sys/arch/mvme68k/mvme68k/isr.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/mvme68k/mvme68k/bus_dma.c
diff -u src/sys/arch/mvme68k/mvme68k/bus_dma.c:1.37 src/sys/arch/mvme68k/mvme68k/bus_dma.c:1.38
--- src/sys/arch/mvme68k/mvme68k/bus_dma.c:1.37	Fri Nov 12 13:18:58 2010
+++ src/sys/arch/mvme68k/mvme68k/bus_dma.c	Sat Nov 21 17:59:13 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: bus_dma.c,v 1.37 2010/11/12 13:18:58 uebayasi Exp $	*/
+/* $NetBSD: bus_dma.c,v 1.38 2020/11/21 17:59:13 thorpej Exp $	*/
 
 /*
  * This file was taken from from next68k/dev/bus_dma.c, which was originally
@@ -39,13 +39,13 @@
 
 #include <sys/cdefs.h>			/* RCS ID & Copyright macro defns */
 
-__KERNEL_RCSID(0, "$NetBSD: bus_dma.c,v 1.37 2010/11/12 13:18:58 uebayasi Exp $");
+__KERNEL_RCSID(0, "$NetBSD: bus_dma.c,v 1.38 2020/11/21 17:59:13 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/proc.h>
 #include <sys/mbuf.h>
 #include <sys/kcore.h>
@@ -64,6 +64,14 @@ int	_bus_dmamap_load_buffer_direct_commo
 	    bus_dmamap_t, void *, bus_size_t, struct vmspace *, int,
 	    paddr_t *, int *, int);
 
+static size_t
+_bus_dmamap_mapsize(int const nsegments)
+{
+	KASSERT(nsegments > 0);
+	return sizeof(struct mvme68k_bus_dmamap) +
+	   (sizeof(bus_dma_segment_t) * (nsegments - 1));
+}
+
 /*
  * Common function for DMA map creation.  May be called by bus-specific
  * DMA map creation functions.
@@ -74,7 +82,6 @@ _bus_dmamap_create(bus_dma_tag_t t, bus_
 {
 	struct mvme68k_bus_dmamap *map;
 	void *mapstore;
-	size_t mapsize;
 
 	/*
 	 * Allocate and initialize the DMA map.  The end of the map
@@ -88,13 +95,10 @@ _bus_dmamap_create(bus_dma_tag_t t, bus_
 	 * The bus_dmamap_t includes one bus_dma_segment_t, hence
 	 * the (nsegments - 1).
 	 */
-	mapsize = sizeof(struct mvme68k_bus_dmamap) +
-	    (sizeof(bus_dma_segment_t) * (nsegments - 1));
-	if ((mapstore = malloc(mapsize, M_DMAMAP,
-	    (flags & BUS_DMA_NOWAIT) ? M_NOWAIT : M_WAITOK)) == NULL)
+	if ((mapstore = kmem_zalloc(_bus_dmamap_mapsize(nsegments),
+	    (flags & BUS_DMA_NOWAIT) ? KM_NOSLEEP : KM_SLEEP)) == NULL)
 		return ENOMEM;
 
-	memset(mapstore, 0, mapsize);
 	map = (struct mvme68k_bus_dmamap *)mapstore;
 	map->_dm_size = size;
 	map->_dm_segcnt = nsegments;
@@ -117,7 +121,7 @@ void
 _bus_dmamap_destroy(bus_dma_tag_t t, bus_dmamap_t map)
 {
 
-	free(map, M_DMAMAP);
+	kmem_free(map, _bus_dmamap_mapsize(map->_dm_segcnt));
 }
 
 /*

Index: src/sys/arch/mvme68k/mvme68k/isr.c
diff -u src/sys/arch/mvme68k/mvme68k/isr.c:1.34 src/sys/arch/mvme68k/mvme68k/isr.c:1.35
--- src/sys/arch/mvme68k/mvme68k/isr.c:1.34	Sun Nov 10 21:16:30 2019
+++ src/sys/arch/mvme68k/mvme68k/isr.c	Sat Nov 21 17:59:13 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: isr.c,v 1.34 2019/11/10 21:16:30 chs Exp $	*/
+/*	$NetBSD: isr.c,v 1.35 2020/11/21 17:59:13 thorpej Exp $	*/
 
 /*-
  * Copyright (c) 1996 The NetBSD Foundation, Inc.
@@ -34,11 +34,11 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: isr.c,v 1.34 2019/11/10 21:16:30 chs Exp $");
+__KERNEL_RCSID(0, "$NetBSD: isr.c,v 1.35 2020/11/21 17:59:13 thorpej Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
-#include <sys/malloc.h>
+#include <sys/kmem.h>
 #include <sys/vmmeter.h>
 #include <sys/device.h>
 #include <sys/cpu.h>
@@ -105,7 +105,7 @@ isrlink_autovec(int (*func)(void *), voi
 		panic("%s: bad ipl %d", __func__, ipl);
 #endif
 
-	newisr = malloc(sizeof(struct isr_autovec), M_DEVBUF, M_WAITOK);
+	newisr = kmem_alloc(sizeof(*newisr), KM_SLEEP);
 	newisr->isr_func = func;
 	newisr->isr_arg = arg;
 	newisr->isr_ipl = ipl;

Reply via email to