Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/arch malloc(9) -> kmem(9)



details:   https://anonhg.NetBSD.org/src/rev/0fbc83a05216
branches:  trunk
changeset: 946186:0fbc83a05216
user:      thorpej <thorpej%NetBSD.org@localhost>
date:      Sat Nov 21 00:27:52 2020 +0000

description:
malloc(9) -> kmem(9)

diffstat:

 sys/arch/sun2/dev/sc_mbmem.c        |  10 ++++------
 sys/arch/sun3/dev/cg4.c             |   8 ++++----
 sys/arch/sun3/dev/eeprom.c          |   8 ++++----
 sys/arch/sun3/dev/fd.c              |  13 ++++++-------
 sys/arch/sun3/dev/si.c              |  11 ++++-------
 sys/arch/sun3/dev/si_sebuf.c        |  10 ++++------
 sys/arch/sun3/dev/xd.c              |  10 +++++-----
 sys/arch/sun3/dev/xy.c              |  10 +++++-----
 sys/arch/sun68k/sun68k/bus.c        |  35 ++++++++++++++++++++---------------
 sys/arch/sun68k/sun68k/isr.c        |   8 ++++----
 sys/arch/sun68k/sun68k/vme_sun68k.c |   9 ++++-----
 11 files changed, 64 insertions(+), 68 deletions(-)

diffs (truncated from 490 to 300 lines):

diff -r 7eb73ffc9407 -r 0fbc83a05216 sys/arch/sun2/dev/sc_mbmem.c
--- a/sys/arch/sun2/dev/sc_mbmem.c      Fri Nov 20 20:01:16 2020 +0000
+++ b/sys/arch/sun2/dev/sc_mbmem.c      Sat Nov 21 00:27:52 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: sc_mbmem.c,v 1.14 2009/11/21 04:16:52 rmind Exp $      */
+/*     $NetBSD: sc_mbmem.c,v 1.15 2020/11/21 00:27:52 thorpej Exp $    */
 
 /*-
  * Copyright (c) 1996 The NetBSD Foundation, Inc.
@@ -59,13 +59,13 @@
  ****************************************************************/
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: sc_mbmem.c,v 1.14 2009/11/21 04:16:52 rmind Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sc_mbmem.c,v 1.15 2020/11/21 00:27:52 thorpej Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
 #include <sys/errno.h>
 #include <sys/kernel.h>
-#include <sys/malloc.h>
+#include <sys/kmem.h>
 #include <sys/device.h>
 #include <sys/buf.h>
 #include <sys/proc.h>
@@ -164,9 +164,7 @@
        
        /* Allocate DMA handles. */
        i = SUNSCPAL_OPENINGS * sizeof(struct sunscpal_dma_handle);
-       sc->sc_dma_handles = malloc(i, M_DEVBUF, M_WAITOK);
-       if (sc->sc_dma_handles == NULL)
-               panic("sc: DMA handles malloc failed");
+       sc->sc_dma_handles = kmem_alloc(i, KM_SLEEP);
        for (i = 0; i < SUNSCPAL_OPENINGS; i++)
                if (bus_dmamap_create(sc->sunscpal_dmat, SUNSCPAL_MAX_DMA_LEN,
                    1, SUNSCPAL_MAX_DMA_LEN,
diff -r 7eb73ffc9407 -r 0fbc83a05216 sys/arch/sun3/dev/cg4.c
--- a/sys/arch/sun3/dev/cg4.c   Fri Nov 20 20:01:16 2020 +0000
+++ b/sys/arch/sun3/dev/cg4.c   Sat Nov 21 00:27:52 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: cg4.c,v 1.41 2014/07/25 08:10:35 dholland Exp $        */
+/*     $NetBSD: cg4.c,v 1.42 2020/11/21 00:27:52 thorpej Exp $ */
 
 /*
  * Copyright (c) 1992, 1993
@@ -55,14 +55,14 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: cg4.c,v 1.41 2014/07/25 08:10:35 dholland Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cg4.c,v 1.42 2020/11/21 00:27:52 thorpej Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
 #include <sys/conf.h>
 #include <sys/device.h>
 #include <sys/ioctl.h>
-#include <sys/malloc.h>
+#include <sys/kmem.h>
 #include <sys/mman.h>
 #include <sys/proc.h>
 #include <sys/tty.h>
@@ -573,7 +573,7 @@
        int i;
 
        /* Need a buffer for colormap format translation. */
-       btcm = malloc(sizeof(*btcm), M_DEVBUF, M_WAITOK);
+       btcm = kmem_alloc(sizeof(*btcm), KM_SLEEP);
        sc->sc_btcm = btcm;
 
        /*
diff -r 7eb73ffc9407 -r 0fbc83a05216 sys/arch/sun3/dev/eeprom.c
--- a/sys/arch/sun3/dev/eeprom.c        Fri Nov 20 20:01:16 2020 +0000
+++ b/sys/arch/sun3/dev/eeprom.c        Sat Nov 21 00:27:52 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: eeprom.c,v 1.33 2019/11/10 21:16:33 chs Exp $  */
+/*     $NetBSD: eeprom.c,v 1.34 2020/11/21 00:27:52 thorpej Exp $      */
 
 /*-
  * Copyright (c) 1996 The NetBSD Foundation, Inc.
@@ -38,14 +38,14 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: eeprom.c,v 1.33 2019/11/10 21:16:33 chs Exp $");
+__KERNEL_RCSID(0, "$NetBSD: eeprom.c,v 1.34 2020/11/21 00:27:52 thorpej Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
 #include <sys/device.h>
 #include <sys/conf.h>
 #include <sys/buf.h>
-#include <sys/malloc.h>
+#include <sys/kmem.h>
 #include <sys/proc.h>
 #include <sys/kernel.h>
 
@@ -105,7 +105,7 @@
                panic("%s: can't map va", __func__);
 
        /* Keep a "soft" copy of the EEPROM to make access simpler. */
-       eeprom_copy = malloc(ee_size, M_DEVBUF, M_WAITOK);
+       eeprom_copy = kmem_alloc(ee_size, KM_SLEEP);
 
        /*
         * On the 3/80, do not touch the last 40 bytes!
diff -r 7eb73ffc9407 -r 0fbc83a05216 sys/arch/sun3/dev/fd.c
--- a/sys/arch/sun3/dev/fd.c    Fri Nov 20 20:01:16 2020 +0000
+++ b/sys/arch/sun3/dev/fd.c    Sat Nov 21 00:27:52 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: fd.c,v 1.83 2019/11/10 21:16:33 chs Exp $      */
+/*     $NetBSD: fd.c,v 1.84 2020/11/21 00:27:52 thorpej Exp $  */
 
 /*-
  * Copyright (c) 1990 The Regents of the University of California.
@@ -72,7 +72,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: fd.c,v 1.83 2019/11/10 21:16:33 chs Exp $");
+__KERNEL_RCSID(0, "$NetBSD: fd.c,v 1.84 2020/11/21 00:27:52 thorpej Exp $");
 
 #include "opt_ddb.h"
 
@@ -88,7 +88,7 @@
 #include <sys/fdio.h>
 #include <sys/buf.h>
 #include <sys/bufq.h>
-#include <sys/malloc.h>
+#include <sys/kmem.h>
 #include <sys/proc.h>
 #include <sys/uio.h>
 #include <sys/stat.h>
@@ -1733,8 +1733,7 @@
                        return EINVAL;
                }
 
-               fd_formb = malloc(sizeof(struct ne7_fd_formb),
-                   M_TEMP, M_WAITOK);
+               fd_formb = kmem_alloc(sizeof(*fd_formb), KM_SLEEP);
                fd_formb->head = form_cmd->head;
                fd_formb->cyl = form_cmd->cylinder;
                fd_formb->transfer_rate = fd->sc_type->rate;
@@ -1758,7 +1757,7 @@
                }
 
                error = fdformat(dev, fd_formb, l->l_proc);
-               free(fd_formb, M_TEMP);
+               kmem_free(fd_formb, sizeof(*fd_formb));
                return error;
 
        case FDIOCGETOPTS:              /* get drive options */
@@ -1985,7 +1984,7 @@
 
        dev = makedev(cdevsw_lookup_major(&fd_cdevsw), 0);      /* XXX */
 
-       addr = malloc(FDMICROROOTSIZE, M_DEVBUF, M_WAITOK);
+       addr = kmem_alloc(FDMICROROOTSIZE, KM_SLEEP);
        *addrp = addr;
 
        if (fdopen(dev, 0, S_IFCHR, NULL))
diff -r 7eb73ffc9407 -r 0fbc83a05216 sys/arch/sun3/dev/si.c
--- a/sys/arch/sun3/dev/si.c    Fri Nov 20 20:01:16 2020 +0000
+++ b/sys/arch/sun3/dev/si.c    Sat Nov 21 00:27:52 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: si.c,v 1.63 2009/11/21 04:16:52 rmind Exp $    */
+/*     $NetBSD: si.c,v 1.64 2020/11/21 00:27:52 thorpej Exp $  */
 
 /*-
  * Copyright (c) 1996 The NetBSD Foundation, Inc.
@@ -70,13 +70,13 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: si.c,v 1.63 2009/11/21 04:16:52 rmind Exp $");
+__KERNEL_RCSID(0, "$NetBSD: si.c,v 1.64 2020/11/21 00:27:52 thorpej Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
 #include <sys/errno.h>
 #include <sys/kernel.h>
-#include <sys/malloc.h>
+#include <sys/kmem.h>
 #include <sys/device.h>
 #include <sys/buf.h>
 #include <sys/proc.h>
@@ -164,10 +164,7 @@
         * Allocate DMA handles.
         */
        i = SCI_OPENINGS * sizeof(struct si_dma_handle);
-       sc->sc_dma = (struct si_dma_handle *)
-               malloc(i, M_DEVBUF, M_WAITOK);
-       if (sc->sc_dma == NULL)
-               panic("si: dvma_malloc failed");
+       sc->sc_dma = kmem_alloc(i, KM_SLEEP);
        for (i = 0; i < SCI_OPENINGS; i++)
                sc->sc_dma[i].dh_flags = 0;
 
diff -r 7eb73ffc9407 -r 0fbc83a05216 sys/arch/sun3/dev/si_sebuf.c
--- a/sys/arch/sun3/dev/si_sebuf.c      Fri Nov 20 20:01:16 2020 +0000
+++ b/sys/arch/sun3/dev/si_sebuf.c      Sat Nov 21 00:27:52 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: si_sebuf.c,v 1.29 2013/11/07 17:50:18 christos Exp $   */
+/*     $NetBSD: si_sebuf.c,v 1.30 2020/11/21 00:27:52 thorpej Exp $    */
 
 /*-
  * Copyright (c) 1996 The NetBSD Foundation, Inc.
@@ -37,13 +37,13 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: si_sebuf.c,v 1.29 2013/11/07 17:50:18 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: si_sebuf.c,v 1.30 2020/11/21 00:27:52 thorpej Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
 #include <sys/errno.h>
 #include <sys/kernel.h>
-#include <sys/malloc.h>
+#include <sys/kmem.h>
 #include <sys/device.h>
 #include <sys/buf.h>
 #include <sys/proc.h>
@@ -250,9 +250,7 @@
         * Allocate DMA handles.
         */
        i = SCI_OPENINGS * sizeof(struct se_dma_handle);
-       sc->sc_dma = malloc(i, M_DEVBUF, M_WAITOK);
-       if (sc->sc_dma == NULL)
-               panic("se: dma_malloc failed");
+       sc->sc_dma = kmem_alloc(i, KM_SLEEP);
        for (i = 0; i < SCI_OPENINGS; i++)
                sc->sc_dma[i].dh_flags = 0;
 
diff -r 7eb73ffc9407 -r 0fbc83a05216 sys/arch/sun3/dev/xd.c
--- a/sys/arch/sun3/dev/xd.c    Fri Nov 20 20:01:16 2020 +0000
+++ b/sys/arch/sun3/dev/xd.c    Sat Nov 21 00:27:52 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: xd.c,v 1.74 2019/11/10 21:16:33 chs Exp $      */
+/*     $NetBSD: xd.c,v 1.75 2020/11/21 00:27:52 thorpej Exp $  */
 
 /*
  * Copyright (c) 1995 Charles D. Cranor
@@ -46,7 +46,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: xd.c,v 1.74 2019/11/10 21:16:33 chs Exp $");
+__KERNEL_RCSID(0, "$NetBSD: xd.c,v 1.75 2020/11/21 00:27:52 thorpej Exp $");
 
 #undef XDC_DEBUG               /* full debug */
 #define XDC_DIAG               /* extra sanity checks */
@@ -64,7 +64,7 @@
 #include <sys/buf.h>
 #include <sys/bufq.h>
 #include <sys/uio.h>
-#include <sys/malloc.h>
+#include <sys/kmem.h>
 #include <sys/device.h>
 #include <sys/disklabel.h>
 #include <sys/disk.h>
@@ -446,8 +446,8 @@
        memset(xdc->iopbase, 0, XDC_MAXIOPB * sizeof(struct xd_iopb));
        xdc->dvmaiopb = (struct xd_iopb *)dvma_kvtopa(xdc->iopbase,
            xdc->bustype);
-       xdc->reqs = malloc(XDC_MAXIOPB * sizeof(struct xd_iorq),
-           M_DEVBUF, M_WAITOK | M_ZERO);
+       xdc->reqs = kmem_zalloc(XDC_MAXIOPB * sizeof(struct xd_iorq),
+           KM_SLEEP);
 
        /* init free list, iorq to iopb pointers, and non-zero fields in the
         * iopb which never change. */
diff -r 7eb73ffc9407 -r 0fbc83a05216 sys/arch/sun3/dev/xy.c
--- a/sys/arch/sun3/dev/xy.c    Fri Nov 20 20:01:16 2020 +0000
+++ b/sys/arch/sun3/dev/xy.c    Sat Nov 21 00:27:52 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: xy.c,v 1.79 2019/11/10 21:16:33 chs Exp $      */
+/*     $NetBSD: xy.c,v 1.80 2020/11/21 00:27:52 thorpej Exp $  */
 
 /*
  * Copyright (c) 1995 Charles D. Cranor
@@ -46,7 +46,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: xy.c,v 1.79 2019/11/10 21:16:33 chs Exp $");
+__KERNEL_RCSID(0, "$NetBSD: xy.c,v 1.80 2020/11/21 00:27:52 thorpej Exp $");
 
 #undef XYC_DEBUG               /* full debug */
 #undef XYC_DIAG                        /* extra sanity checks */
@@ -64,7 +64,7 @@
 #include <sys/buf.h>
 #include <sys/bufq.h>
 #include <sys/uio.h>
-#include <sys/malloc.h>
+#include <sys/kmem.h>
 #include <sys/device.h>
 #include <sys/disklabel.h>
 #include <sys/disk.h>
@@ -390,8 +390,8 @@



Home | Main Index | Thread Index | Old Index