Module Name: src
Committed By: thorpej
Date: Sat Dec 19 21:39:24 UTC 2020
Modified Files:
src/sys/arch/m68k/m68k: bus_dma.c
Log Message:
malloc(9) -> kmem(9)
To generate a diff of this commit:
cvs rdiff -u -r1.35 -r1.36 src/sys/arch/m68k/m68k/bus_dma.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/m68k/m68k/bus_dma.c
diff -u src/sys/arch/m68k/m68k/bus_dma.c:1.35 src/sys/arch/m68k/m68k/bus_dma.c:1.36
--- src/sys/arch/m68k/m68k/bus_dma.c:1.35 Fri Oct 25 09:46:10 2013
+++ src/sys/arch/m68k/m68k/bus_dma.c Sat Dec 19 21:39:24 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: bus_dma.c,v 1.35 2013/10/25 09:46:10 martin Exp $ */
+/* $NetBSD: bus_dma.c,v 1.36 2020/12/19 21:39:24 thorpej Exp $ */
/*
* This file was taken from from alpha/common/bus_dma.c
@@ -41,13 +41,13 @@
#include <sys/cdefs.h> /* RCS ID & Copyright macro defns */
-__KERNEL_RCSID(0, "$NetBSD: bus_dma.c,v 1.35 2013/10/25 09:46:10 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: bus_dma.c,v 1.36 2020/12/19 21:39:24 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>
@@ -63,6 +63,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 m68k_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.
@@ -73,7 +81,6 @@ _bus_dmamap_create(bus_dma_tag_t t, bus_
{
struct m68k_bus_dmamap *map;
void *mapstore;
- size_t mapsize;
/*
* Allocate and initialize the DMA map. The end of the map
@@ -87,13 +94,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 m68k_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 m68k_bus_dmamap *)mapstore;
map->_dm_size = size;
map->_dm_segcnt = nsegments;
@@ -119,7 +123,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));
}
/*