Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/arch/mvme68k/mvme68k malloc(9) -> kmem(9)
details: https://anonhg.NetBSD.org/src/rev/a4075610c395
branches: trunk
changeset: 957202:a4075610c395
user: thorpej <thorpej%NetBSD.org@localhost>
date: Sat Nov 21 17:59:13 2020 +0000
description:
malloc(9) -> kmem(9)
diffstat:
sys/arch/mvme68k/mvme68k/bus_dma.c | 24 ++++++++++++++----------
sys/arch/mvme68k/mvme68k/isr.c | 8 ++++----
2 files changed, 18 insertions(+), 14 deletions(-)
diffs (105 lines):
diff -r 5a6ede1219e3 -r a4075610c395 sys/arch/mvme68k/mvme68k/bus_dma.c
--- a/sys/arch/mvme68k/mvme68k/bus_dma.c Sat Nov 21 17:48:26 2020 +0000
+++ b/sys/arch/mvme68k/mvme68k/bus_dma.c Sat Nov 21 17:59:13 2020 +0000
@@ -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 @@
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 @@
{
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 @@
* 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 @@
_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));
}
/*
diff -r 5a6ede1219e3 -r a4075610c395 sys/arch/mvme68k/mvme68k/isr.c
--- a/sys/arch/mvme68k/mvme68k/isr.c Sat Nov 21 17:48:26 2020 +0000
+++ b/sys/arch/mvme68k/mvme68k/isr.c Sat Nov 21 17:59:13 2020 +0000
@@ -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 @@
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;
Home |
Main Index |
Thread Index |
Old Index