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/c7426b6a0afb
branches:  trunk
changeset: 946256:c7426b6a0afb
user:      thorpej <thorpej%NetBSD.org@localhost>
date:      Sat Nov 21 21:07:38 2020 +0000

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

diffstat:

 sys/arch/hpc/hpc/config_hook.c             |  14 +++++++-------
 sys/arch/hpcsh/dev/hd64461/hd64461pcmcia.c |  17 ++++++++---------
 sys/arch/hpcsh/dev/hd64465/hd64465pcmcia.c |  15 +++++++--------
 sys/arch/hpcsh/hpcsh/bus_space.c           |  10 +++++-----
 4 files changed, 27 insertions(+), 29 deletions(-)

diffs (215 lines):

diff -r 5bb84f6bda2c -r c7426b6a0afb sys/arch/hpc/hpc/config_hook.c
--- a/sys/arch/hpc/hpc/config_hook.c    Sat Nov 21 21:04:25 2020 +0000
+++ b/sys/arch/hpc/hpc/config_hook.c    Sat Nov 21 21:07:38 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: config_hook.c,v 1.11 2019/11/10 21:16:27 chs Exp $     */
+/*     $NetBSD: config_hook.c,v 1.12 2020/11/21 21:08:32 thorpej Exp $ */
 
 /*-
  * Copyright (c) 1999-2001
@@ -35,11 +35,11 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: config_hook.c,v 1.11 2019/11/10 21:16:27 chs Exp $");
+__KERNEL_RCSID(0, "$NetBSD: config_hook.c,v 1.12 2020/11/21 21:08:32 thorpej Exp $");
 
 #include <sys/param.h>
 #include <sys/device.h>
-#include <sys/malloc.h>
+#include <sys/kmem.h>
 #include <sys/systm.h>
 #include <sys/kernel.h>
 
@@ -118,7 +118,7 @@
        }
 
        /* allocate new record */
-       hr = malloc(sizeof(*hr), M_DEVBUF, M_WAITOK);
+       hr = kmem_alloc(sizeof(*hr), KM_SLEEP);
        hr->hr_ctx = ctx;
        hr->hr_type = type;
        hr->hr_id = id;
@@ -165,7 +165,7 @@
                }
                splx(s);
        }
-       free(hr, M_DEVBUF);
+       kmem_free(hr, sizeof(*hr));
 }
 
 int
@@ -208,7 +208,7 @@
        }
 
        /* allocate new record */
-       cr = malloc(sizeof(*hr), M_DEVBUF, M_WAITOK);
+       cr = kmem_alloc(sizeof(*hr), KM_SLEEP);
        cr->hr_func = NULL;
        cr->hr_type = type;
        cr->hr_id = id;
@@ -243,7 +243,7 @@
        TAILQ_REMOVE(&call_list, cr, hr_link);
        splx(s);
 
-       free(cr, M_DEVBUF);
+       kmem_free(cr, sizeof(*cr));
 }
 
 int
diff -r 5bb84f6bda2c -r c7426b6a0afb sys/arch/hpcsh/dev/hd64461/hd64461pcmcia.c
--- a/sys/arch/hpcsh/dev/hd64461/hd64461pcmcia.c        Sat Nov 21 21:04:25 2020 +0000
+++ b/sys/arch/hpcsh/dev/hd64461/hd64461pcmcia.c        Sat Nov 21 21:07:38 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: hd64461pcmcia.c,v 1.51 2013/11/09 02:54:11 christos Exp $      */
+/*     $NetBSD: hd64461pcmcia.c,v 1.52 2020/11/21 21:07:38 thorpej Exp $       */
 
 /*-
  * Copyright (c) 2001, 2002, 2004 The NetBSD Foundation, Inc.
@@ -30,14 +30,14 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: hd64461pcmcia.c,v 1.51 2013/11/09 02:54:11 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: hd64461pcmcia.c,v 1.52 2020/11/21 21:07:38 thorpej Exp $");
 
 #include "opt_hd64461pcmcia.h"
 
 #include <sys/param.h>
 #include <sys/systm.h>
 #include <sys/device.h>
-#include <sys/malloc.h>
+#include <sys/kmem.h>
 #include <sys/kthread.h>
 #include <sys/boot_flag.h>
 #include <sys/bus.h>
@@ -615,10 +615,9 @@
        struct hd64461pcmcia_window_cookie *cookie;
        bus_addr_t ofs;
 
-       cookie = malloc(sizeof(struct hd64461pcmcia_window_cookie),
-           M_DEVBUF, M_NOWAIT);
-       KASSERT(cookie);
-       memset(cookie, 0, sizeof(struct hd64461pcmcia_window_cookie));
+       cookie = kmem_zalloc(sizeof(struct hd64461pcmcia_window_cookie),
+           KM_SLEEP);
+       KASSERT(cookie != NULL);
 
        /* Address */
        if ((kind & ~PCMCIA_WIDTH_MEM_MASK) == PCMCIA_MEM_ATTR) {
@@ -654,7 +653,7 @@
        return (0);
  bad:
        DPRINTF("%#lx-%#lx map failed.\n", card_addr, size);
-       free(cookie, M_DEVBUF);
+       kmem_free(cookie, sizeof(*cookie));
 
        return (1);
 }
@@ -668,7 +667,7 @@
                bus_space_unmap(cookie->wc_tag, cookie->wc_handle,
                    cookie->wc_size);
        DPRINTF("%#lx-%#x\n", cookie->wc_handle, cookie->wc_size);
-       free(cookie, M_DEVBUF);
+       kmem_free(cookie, sizeof(*cookie));
 }
 
 STATIC int
diff -r 5bb84f6bda2c -r c7426b6a0afb sys/arch/hpcsh/dev/hd64465/hd64465pcmcia.c
--- a/sys/arch/hpcsh/dev/hd64465/hd64465pcmcia.c        Sat Nov 21 21:04:25 2020 +0000
+++ b/sys/arch/hpcsh/dev/hd64465/hd64465pcmcia.c        Sat Nov 21 21:07:38 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: hd64465pcmcia.c,v 1.32 2012/10/29 13:46:26 chs Exp $   */
+/*     $NetBSD: hd64465pcmcia.c,v 1.33 2020/11/21 21:07:38 thorpej Exp $       */
 
 /*-
  * Copyright (c) 2001, 2002 The NetBSD Foundation, Inc.
@@ -30,12 +30,12 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: hd64465pcmcia.c,v 1.32 2012/10/29 13:46:26 chs Exp $");
+__KERNEL_RCSID(0, "$NetBSD: hd64465pcmcia.c,v 1.33 2020/11/21 21:07:38 thorpej Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
 #include <sys/device.h>
-#include <sys/malloc.h>
+#include <sys/kmem.h>
 #include <sys/kthread.h>
 #include <sys/boot_flag.h>
 #include <sys/bus.h>
@@ -536,10 +536,9 @@
        struct hd64465pcmcia_window_cookie *cookie;
        bus_addr_t ofs;
 
-       cookie = malloc(sizeof(struct hd64465pcmcia_window_cookie),
-           M_DEVBUF, M_NOWAIT);
+       cookie = kmem_zalloc(sizeof(struct hd64465pcmcia_window_cookie),
+           KM_SLEEP);
        KASSERT(cookie);
-       memset(cookie, 0, sizeof(struct hd64465pcmcia_window_cookie));
 
        /* Address */
        if ((kind & ~PCMCIA_WIDTH_MEM_MASK) == PCMCIA_MEM_ATTR) {
@@ -574,7 +573,7 @@
        return (0);
  bad:
        DPRINTF("%#lx-%#lx map failed.\n", card_addr, size);
-       free(cookie, M_DEVBUF);
+       kmem_free(cookie, sizeof(*cookie));
 
        return (1);
 }
@@ -588,7 +587,7 @@
                bus_space_unmap(cookie->wc_tag, cookie->wc_handle,
                    cookie->wc_size);
        DPRINTF("%#lx-%#x\n", cookie->wc_handle, cookie->wc_size);
-       free(cookie, M_DEVBUF);
+       kmem_free(cookie, sizeof(*cookie));
 }
 
 int
diff -r 5bb84f6bda2c -r c7426b6a0afb sys/arch/hpcsh/hpcsh/bus_space.c
--- a/sys/arch/hpcsh/hpcsh/bus_space.c  Sat Nov 21 21:04:25 2020 +0000
+++ b/sys/arch/hpcsh/hpcsh/bus_space.c  Sat Nov 21 21:07:38 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: bus_space.c,v 1.19 2012/01/27 18:52:57 para Exp $      */
+/*     $NetBSD: bus_space.c,v 1.20 2020/11/21 21:07:38 thorpej Exp $   */
 
 /*-
  * Copyright (c) 2001, 2002 The NetBSD Foundation, Inc.
@@ -27,13 +27,13 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: bus_space.c,v 1.19 2012/01/27 18:52:57 para Exp $");
+__KERNEL_RCSID(0, "$NetBSD: bus_space.c,v 1.20 2020/11/21 21:07:38 thorpej Exp $");
 
 #include "debug_hpcsh.h"
 
 #include <sys/param.h>
 #include <sys/systm.h>
-#include <sys/malloc.h>
+#include <sys/kmem.h>
 #include <sys/extent.h>
 #include <sys/bus.h>
 
@@ -141,7 +141,7 @@
 {
 
        if (hbs == NULL) {
-               hbs = malloc(sizeof(*hbs), M_DEVBUF, M_NOWAIT | M_ZERO);
+               hbs = kmem_zalloc(sizeof(*hbs), KM_SLEEP);
                hbs->hbs_flags = HBS_FLAGS_ALLOCATED;
        } else
                memset(hbs, 0, sizeof(*hbs));
@@ -176,7 +176,7 @@
                extent_destroy(ex);
 
        if (hbs->hbs_flags & HBS_FLAGS_ALLOCATED)
-               free(hbs, M_DEVBUF);
+               kmem_free(hbs, sizeof(*hbs));
 }
 
 /* default bus_space tag */



Home | Main Index | Thread Index | Old Index