Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/arch/landisk/landisk malloc(9) -> kmem(9)
details: https://anonhg.NetBSD.org/src/rev/57e3a18ae5bc
branches: trunk
changeset: 979211:57e3a18ae5bc
user: thorpej <thorpej%NetBSD.org@localhost>
date: Sat Dec 19 21:27:52 2020 +0000
description:
malloc(9) -> kmem(9)
diffstat:
sys/arch/landisk/landisk/bus_dma.c | 23 ++++++++++++++---------
sys/arch/landisk/landisk/intr.c | 10 +++++-----
2 files changed, 19 insertions(+), 14 deletions(-)
diffs (112 lines):
diff -r 6783e58b2f30 -r 57e3a18ae5bc sys/arch/landisk/landisk/bus_dma.c
--- a/sys/arch/landisk/landisk/bus_dma.c Sat Dec 19 21:25:03 2020 +0000
+++ b/sys/arch/landisk/landisk/bus_dma.c Sat Dec 19 21:27:52 2020 +0000
@@ -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 @@
._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_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 @@
* 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 @@
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
diff -r 6783e58b2f30 -r 57e3a18ae5bc sys/arch/landisk/landisk/intr.c
--- a/sys/arch/landisk/landisk/intr.c Sat Dec 19 21:25:03 2020 +0000
+++ b/sys/arch/landisk/landisk/intr.c Sat Dec 19 21:27:52 2020 +0000
@@ -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 <nonaka%netbsd.org@localhost>
@@ -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 @@
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 @@
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);
Home |
Main Index |
Thread Index |
Old Index