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) (easy, straight-forward cases ...



details:   https://anonhg.NetBSD.org/src/rev/74ebffd3ba2a
branches:  trunk
changeset: 946268:74ebffd3ba2a
user:      thorpej <thorpej%NetBSD.org@localhost>
date:      Sun Nov 22 03:55:33 2020 +0000

description:
malloc(9) -> kmem(9) (easy, straight-forward cases only, for now)

diffstat:

 sys/arch/shark/isa/isa_irqhandler.c      |  12 ++++----
 sys/arch/shark/isa/isa_shark_machdep.c   |   8 +++---
 sys/arch/shark/ofw/if_cs_ofisa_machdep.c |   8 +++---
 sys/arch/shark/ofw/igsfb_ofbus.c         |  10 ++++----
 sys/arch/sparc/dev/bootbus.c             |   8 +++---
 sys/arch/sparc/dev/ebus.c                |   8 +++---
 sys/arch/sparc/dev/fd.c                  |  13 ++++-----
 sys/arch/sparc/dev/pckbc_js.c            |   9 +++----
 sys/arch/sparc/dev/sbus.c                |   7 +++--
 sys/arch/sparc/dev/sw.c                  |   8 +++---
 sys/arch/sparc/dev/vme_machdep.c         |  10 ++++----
 sys/arch/sparc/sparc/clock.c             |  15 ++++--------
 sys/arch/sparc/sparc/cpuunit.c           |   7 +++--
 sys/arch/sparc/sparc/intr.c              |  10 ++++----
 sys/arch/sparc/sparc/machdep.c           |  40 +++++++++++++++++--------------
 sys/arch/sparc/sparc/msiiep.c            |   8 +++---
 16 files changed, 90 insertions(+), 91 deletions(-)

diffs (truncated from 714 to 300 lines):

diff -r 2dc71c17e96d -r 74ebffd3ba2a sys/arch/shark/isa/isa_irqhandler.c
--- a/sys/arch/shark/isa/isa_irqhandler.c       Sat Nov 21 23:51:28 2020 +0000
+++ b/sys/arch/shark/isa/isa_irqhandler.c       Sun Nov 22 03:55:33 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: isa_irqhandler.c,v 1.28 2019/11/10 21:16:32 chs Exp $  */
+/*     $NetBSD: isa_irqhandler.c,v 1.29 2020/11/22 03:57:19 thorpej Exp $      */
 
 /*
  * Copyright 1997
@@ -75,12 +75,12 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: isa_irqhandler.c,v 1.28 2019/11/10 21:16:32 chs Exp $");
+__KERNEL_RCSID(0, "$NetBSD: isa_irqhandler.c,v 1.29 2020/11/22 03:57:19 thorpej Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
 #include <sys/syslog.h>
-#include <sys/malloc.h>
+#include <sys/kmem.h>
 #include <sys/intr.h>
 
 #include <arm/locore.h>
@@ -311,14 +311,14 @@
 {
        irqhandler_t *ih;
 
-       ih = malloc(sizeof(*ih), M_DEVBUF, M_WAITOK | M_ZERO);
+       ih = kmem_zalloc(sizeof(*ih), KM_SLEEP);
        ih->ih_level = level;
        ih->ih_func = ih_func;
        ih->ih_arg = ih_arg;
        ih->ih_flags = 0;
 
        if (irq_claim(irq, ih, group, name) != 0) {
-               free(ih, M_DEVBUF);
+               kmem_free(ih, sizeof(*ih));
                return(NULL);
        }
 
@@ -331,7 +331,7 @@
        irqhandler_t *ih = (irqhandler_t *)arg;
 
        if (irq_release(ih->ih_num, ih) == 0) {
-               free(ih, M_DEVBUF);
+               kmem_free(ih, sizeof(*ih));
                return(0);
        }
        return(1);
diff -r 2dc71c17e96d -r 74ebffd3ba2a sys/arch/shark/isa/isa_shark_machdep.c
--- a/sys/arch/shark/isa/isa_shark_machdep.c    Sat Nov 21 23:51:28 2020 +0000
+++ b/sys/arch/shark/isa/isa_shark_machdep.c    Sun Nov 22 03:55:33 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: isa_shark_machdep.c,v 1.17 2019/11/10 21:16:32 chs Exp $       */
+/*     $NetBSD: isa_shark_machdep.c,v 1.18 2020/11/22 03:57:19 thorpej Exp $   */
 
 /*
  * Copyright 1997
@@ -34,14 +34,14 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: isa_shark_machdep.c,v 1.17 2019/11/10 21:16:32 chs Exp $");
+__KERNEL_RCSID(0, "$NetBSD: isa_shark_machdep.c,v 1.18 2020/11/22 03:57:19 thorpej Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
 #include <sys/kernel.h>
 #include <sys/syslog.h>
 #include <sys/device.h>
-#include <sys/malloc.h>
+#include <sys/kmem.h>
 
 #include <machine/intr.h>
 #include <machine/irqhandler.h>
@@ -167,7 +167,7 @@
 {
        irqhandler_t *ih;
 
-       ih = malloc(sizeof *ih, M_DEVBUF, M_ZERO | M_WAITOK);
+       ih = kmem_zalloc(sizeof *ih, KM_SLEEP);
 
        if (!LEGAL_IRQ(irq) || type == IST_NONE)
                panic("intr_establish: bogus irq or type");
diff -r 2dc71c17e96d -r 74ebffd3ba2a sys/arch/shark/ofw/if_cs_ofisa_machdep.c
--- a/sys/arch/shark/ofw/if_cs_ofisa_machdep.c  Sat Nov 21 23:51:28 2020 +0000
+++ b/sys/arch/shark/ofw/if_cs_ofisa_machdep.c  Sun Nov 22 03:55:33 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_cs_ofisa_machdep.c,v 1.13 2019/11/10 21:16:32 chs Exp $     */
+/*     $NetBSD: if_cs_ofisa_machdep.c,v 1.14 2020/11/22 03:57:19 thorpej Exp $ */
 
 /*
  * Copyright 1998
@@ -38,14 +38,14 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_cs_ofisa_machdep.c,v 1.13 2019/11/10 21:16:32 chs Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_cs_ofisa_machdep.c,v 1.14 2020/11/22 03:57:19 thorpej Exp $");
 
 #include "opt_compat_old_ofw.h"
 
 #include <sys/param.h>
 #include <sys/device.h>
 #include <sys/systm.h>
-#include <sys/malloc.h>
+#include <sys/kmem.h>
 #include <sys/socket.h>
 #include <sys/bus.h>
 #include <sys/rndsource.h>
@@ -141,7 +141,7 @@
 
        if (1) {                /* XXX old firmware compat enabled */
                if (media == NULL) {
-                       media = malloc(2 * sizeof(int), M_TEMP, M_WAITOK);
+                       media = kmem_alloc(2 * sizeof(int), KM_SLEEP);
                        media[0] = IFM_ETHER | IFM_10_T;
                        media[1] = IFM_ETHER | IFM_10_T | IFM_FDX;
                        *nmediap = 2;
diff -r 2dc71c17e96d -r 74ebffd3ba2a sys/arch/shark/ofw/igsfb_ofbus.c
--- a/sys/arch/shark/ofw/igsfb_ofbus.c  Sat Nov 21 23:51:28 2020 +0000
+++ b/sys/arch/shark/ofw/igsfb_ofbus.c  Sun Nov 22 03:55:33 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: igsfb_ofbus.c,v 1.18 2019/11/10 21:16:32 chs Exp $ */
+/*     $NetBSD: igsfb_ofbus.c,v 1.19 2020/11/22 03:57:19 thorpej Exp $ */
 
 /*
  * Copyright (c) 2006 Michael Lorenz
@@ -31,13 +31,13 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: igsfb_ofbus.c,v 1.18 2019/11/10 21:16:32 chs Exp $");
+__KERNEL_RCSID(0, "$NetBSD: igsfb_ofbus.c,v 1.19 2020/11/22 03:57:19 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/buf.h>
 #include <sys/bus.h>
 #include <uvm/uvm.h>
@@ -229,8 +229,8 @@
                sc->sc_dc = &igsfb_console_dc;
        } else {
                isconsole = 0;
-               sc->sc_dc = malloc(sizeof(struct igsfb_devconfig),
-                                  M_DEVBUF, M_WAITOK | M_ZERO);
+               sc->sc_dc = kmem_zalloc(sizeof(struct igsfb_devconfig),
+                                  KM_SLEEP);
                if (OF_getprop(oba->oba_phandle, "reg",
                               regs, sizeof(regs)) <= 0)
                {
diff -r 2dc71c17e96d -r 74ebffd3ba2a sys/arch/sparc/dev/bootbus.c
--- a/sys/arch/sparc/dev/bootbus.c      Sat Nov 21 23:51:28 2020 +0000
+++ b/sys/arch/sparc/dev/bootbus.c      Sun Nov 22 03:55:33 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: bootbus.c,v 1.19 2011/07/18 00:31:13 mrg Exp $ */
+/*     $NetBSD: bootbus.c,v 1.20 2020/11/22 03:55:33 thorpej Exp $     */
 
 /*-
  * Copyright (c) 2002 The NetBSD Foundation, Inc.
@@ -34,10 +34,11 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: bootbus.c,v 1.19 2011/07/18 00:31:13 mrg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: bootbus.c,v 1.20 2020/11/22 03:55:33 thorpej Exp $");
 
 #include <sys/param.h>
 #include <sys/malloc.h>
+#include <sys/kmem.h>
 #include <sys/systm.h>
 #include <sys/device.h>
 
@@ -95,8 +96,7 @@
        /*
         * Initialize the bus space tag we pass on to our children.
         */
-       sc->sc_bustag = malloc(sizeof(*sc->sc_bustag), M_DEVBUF,
-           M_WAITOK|M_ZERO);
+       sc->sc_bustag = kmem_zalloc(sizeof(*sc->sc_bustag), KM_SLEEP);
        sc->sc_bustag->cookie = sc;
        sc->sc_bustag->parent = sc->sc_st;
        sc->sc_bustag->sparc_bus_map = sc->sc_st->sparc_bus_map;
diff -r 2dc71c17e96d -r 74ebffd3ba2a sys/arch/sparc/dev/ebus.c
--- a/sys/arch/sparc/dev/ebus.c Sat Nov 21 23:51:28 2020 +0000
+++ b/sys/arch/sparc/dev/ebus.c Sun Nov 22 03:55:33 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ebus.c,v 1.37 2019/11/10 21:16:32 chs Exp $ */
+/*     $NetBSD: ebus.c,v 1.38 2020/11/22 03:55:33 thorpej Exp $ */
 
 /*
  * Copyright (c) 1999, 2000 Matthew R. Green
@@ -32,7 +32,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ebus.c,v 1.37 2019/11/10 21:16:32 chs Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ebus.c,v 1.38 2020/11/22 03:55:33 thorpej Exp $");
 
 #if defined(DEBUG) && !defined(EBUS_DEBUG)
 #define EBUS_DEBUG
@@ -56,6 +56,7 @@
 #include <sys/device.h>
 #include <sys/errno.h>
 #include <sys/malloc.h>
+#include <sys/kmem.h>
 #include <sys/callout.h>
 #include <sys/kernel.h>
 
@@ -421,8 +422,7 @@
 {
        bus_dma_tag_t dt;
 
-       dt = (bus_dma_tag_t)
-               malloc(sizeof(struct sparc_bus_dma_tag), M_DEVBUF, M_WAITOK | M_ZERO);
+       dt = kmem_zalloc(sizeof(*dt), KM_SLEEP);
        dt->_cookie = sc;
 #define PCOPY(x)       dt->x = pdt->x
        PCOPY(_dmamap_create);
diff -r 2dc71c17e96d -r 74ebffd3ba2a sys/arch/sparc/dev/fd.c
--- a/sys/arch/sparc/dev/fd.c   Sat Nov 21 23:51:28 2020 +0000
+++ b/sys/arch/sparc/dev/fd.c   Sun Nov 22 03:55:33 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: fd.c,v 1.160 2019/11/10 21:16:32 chs Exp $     */
+/*     $NetBSD: fd.c,v 1.161 2020/11/22 03:55:33 thorpej Exp $ */
 
 /*-
  * Copyright (c) 2000 The NetBSD Foundation, Inc.
@@ -101,7 +101,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: fd.c,v 1.160 2019/11/10 21:16:32 chs Exp $");
+__KERNEL_RCSID(0, "$NetBSD: fd.c,v 1.161 2020/11/22 03:55:33 thorpej Exp $");
 
 #include "opt_ddb.h"
 #include "opt_md.h"
@@ -118,7 +118,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>
@@ -2100,8 +2100,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;
@@ -2125,7 +2124,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 */
@@ -2350,7 +2349,7 @@
 
        dev = makedev(54,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 2dc71c17e96d -r 74ebffd3ba2a sys/arch/sparc/dev/pckbc_js.c
--- a/sys/arch/sparc/dev/pckbc_js.c     Sat Nov 21 23:51:28 2020 +0000
+++ b/sys/arch/sparc/dev/pckbc_js.c     Sun Nov 22 03:55:33 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: pckbc_js.c,v 1.19 2012/10/13 17:58:54 jdc Exp $ */
+/*     $NetBSD: pckbc_js.c,v 1.20 2020/11/22 03:55:33 thorpej Exp $ */
 
 /*
  * Copyright (c) 2002 Valeriy E. Ushakov
@@ -28,13 +28,13 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: pckbc_js.c,v 1.19 2012/10/13 17:58:54 jdc Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pckbc_js.c,v 1.20 2020/11/22 03:55:33 thorpej Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
 #include <sys/kernel.h>
 #include <sys/device.h>
-#include <sys/malloc.h>



Home | Main Index | Thread Index | Old Index