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/6dfd79b2aba3
branches:  trunk
changeset: 946223:6dfd79b2aba3
user:      thorpej <thorpej%NetBSD.org@localhost>
date:      Sat Nov 21 17:09:34 2020 +0000

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

diffstat:

 sys/arch/ews4800mips/dev/ewskbd.c          |  10 +++++-----
 sys/arch/ews4800mips/ews4800mips/bus_dma.c |  24 ++++++++++++++----------
 sys/arch/ews4800mips/sbd/fb_sbdio.c        |  11 +++++------
 sys/arch/sgimips/dev/int.c                 |  10 +++++-----
 sys/arch/sgimips/dev/zs_kbd.c              |  12 +++++-------
 sys/arch/sgimips/gio/grtwo.c               |  12 +++++-------
 sys/arch/sgimips/gio/light.c               |  12 +++++-------
 sys/arch/sgimips/gio/newport.c             |  12 +++++-------
 sys/arch/sgimips/hpc/pckbc_hpc.c           |   9 ++++-----
 9 files changed, 53 insertions(+), 59 deletions(-)

diffs (truncated from 368 to 300 lines):

diff -r 062c3e913a07 -r 6dfd79b2aba3 sys/arch/ews4800mips/dev/ewskbd.c
--- a/sys/arch/ews4800mips/dev/ewskbd.c Sat Nov 21 15:52:32 2020 +0000
+++ b/sys/arch/ews4800mips/dev/ewskbd.c Sat Nov 21 17:09:34 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ewskbd.c,v 1.10 2012/10/13 06:08:30 tsutsui Exp $      */
+/*     $NetBSD: ewskbd.c,v 1.11 2020/11/21 17:09:34 thorpej Exp $      */
 
 /*-
  * Copyright (c) 2005 Izumi Tsutsui.  All rights reserved.
@@ -59,10 +59,10 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ewskbd.c,v 1.10 2012/10/13 06:08:30 tsutsui Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ewskbd.c,v 1.11 2020/11/21 17:09:34 thorpej Exp $");
 
 #include <sys/param.h>
-#include <sys/malloc.h>
+#include <sys/kmem.h>
 #include <sys/systm.h>
 #include <sys/conf.h>
 #include <sys/device.h>
@@ -220,8 +220,8 @@
        } else {
                wskaa.console = 0;
 
-               sc->sc_dc = malloc(sizeof(struct ewskbd_devconfig), M_DEVBUF,
-                   M_WAITOK | M_ZERO);
+               sc->sc_dc = kmem_zalloc(sizeof(struct ewskbd_devconfig),
+                   KM_SLEEP);
                if (sc->sc_dc == NULL) {
                        printf(": can't allocate memory\n");
                        return;
diff -r 062c3e913a07 -r 6dfd79b2aba3 sys/arch/ews4800mips/ews4800mips/bus_dma.c
--- a/sys/arch/ews4800mips/ews4800mips/bus_dma.c        Sat Nov 21 15:52:32 2020 +0000
+++ b/sys/arch/ews4800mips/ews4800mips/bus_dma.c        Sat Nov 21 17:09:34 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: bus_dma.c,v 1.15 2015/06/23 21:00:23 matt Exp $        */
+/*     $NetBSD: bus_dma.c,v 1.16 2020/11/21 17:09:34 thorpej Exp $     */
 
 /*
  * Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -31,13 +31,13 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: bus_dma.c,v 1.15 2015/06/23 21:00:23 matt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: bus_dma.c,v 1.16 2020/11/21 17:09:34 thorpej Exp $");
 
 #define        _EWS4800MIPS_BUS_DMA_PRIVATE
 /* #define     BUS_DMA_DEBUG */
 
 #include <sys/param.h>
-#include <sys/malloc.h>
+#include <sys/kmem.h>
 #include <sys/bus.h>
 #include <sys/mbuf.h>
 #include <sys/proc.h>
@@ -71,6 +71,14 @@
        _bus_dmamem_mmap,
 };
 
+static size_t
+_bus_dmamap_mapsize(int const nsegments)
+{
+       KASSERT(nsegments > 0);
+       return sizeof(struct ews4800mips_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.
@@ -81,7 +89,6 @@
 {
        struct ews4800mips_bus_dmamap *map;
        void *mapstore;
-       size_t mapsize;
 
        /*
         * Allcoate and initialize the DMA map.  The end of the map
@@ -95,13 +102,10 @@
         * The bus_dmamap_t includes one bus_dma_segment_t, hence
         * the (nsegments - 1).
         */
-       mapsize = sizeof(struct ews4800mips_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 ews4800mips_bus_dmamap *)mapstore;
        map->_dm_size = size;
        map->_dm_segcnt = nsegments;
@@ -125,7 +129,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 062c3e913a07 -r 6dfd79b2aba3 sys/arch/ews4800mips/sbd/fb_sbdio.c
--- a/sys/arch/ews4800mips/sbd/fb_sbdio.c       Sat Nov 21 15:52:32 2020 +0000
+++ b/sys/arch/ews4800mips/sbd/fb_sbdio.c       Sat Nov 21 17:09:34 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: fb_sbdio.c,v 1.17 2019/11/10 21:16:27 chs Exp $        */
+/*     $NetBSD: fb_sbdio.c,v 1.18 2020/11/21 17:09:34 thorpej Exp $    */
 
 /*-
  * Copyright (c) 2004, 2005 The NetBSD Foundation, Inc.
@@ -32,11 +32,11 @@
 #define WIRED_FB_TLB
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: fb_sbdio.c,v 1.17 2019/11/10 21:16:27 chs Exp $");
+__KERNEL_RCSID(0, "$NetBSD: fb_sbdio.c,v 1.18 2020/11/21 17:09:34 thorpej Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
-#include <sys/malloc.h>
+#include <sys/kmem.h>
 #include <dev/cons.h>
 
 #include <uvm/uvm_extern.h>     /* pmap function to remap FB */
@@ -145,9 +145,8 @@
                sc->sc_ga = &fb_console_ga;
                sc->sc_nscreens = 1;
        } else {
-               ri = malloc(sizeof(struct rasops_info), M_DEVBUF,
-                   M_WAITOK | M_ZERO);
-               ga = malloc(sizeof(struct ga), M_DEVBUF, M_WAITOK | M_ZERO);
+               ri = kmem_zalloc(sizeof(struct rasops_info), KM_SLEEP);
+               ga = kmem_zalloc(sizeof(struct ga), KM_SLEEP);
                ga->reg_paddr = sa->sa_addr2;
                ga->flags = sa->sa_flags;
                fb_pmap_enter(sa->sa_addr1, sa->sa_addr2,
diff -r 062c3e913a07 -r 6dfd79b2aba3 sys/arch/sgimips/dev/int.c
--- a/sys/arch/sgimips/dev/int.c        Sat Nov 21 15:52:32 2020 +0000
+++ b/sys/arch/sgimips/dev/int.c        Sat Nov 21 17:09:34 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: int.c,v 1.31 2020/05/29 12:30:40 rin Exp $     */
+/*     $NetBSD: int.c,v 1.32 2020/11/21 17:18:31 thorpej Exp $ */
 
 /*
  * Copyright (c) 2009 Stephen M. Rumble 
@@ -33,7 +33,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: int.c,v 1.31 2020/05/29 12:30:40 rin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: int.c,v 1.32 2020/11/21 17:18:31 thorpej Exp $");
 
 #define __INTR_PRIVATE
 #include "opt_cputype.h"
@@ -44,7 +44,7 @@
 #include <sys/timetc.h>
 #include <sys/kernel.h>
 #include <sys/device.h>
-#include <sys/malloc.h>
+#include <sys/kmem.h>
 
 #include <dev/ic/i8253reg.h>
 #include <machine/sysconf.h>
@@ -368,7 +368,7 @@
        } else {
                struct sgimips_intrhand *n, *ih;
 
-               ih = malloc(sizeof *ih, M_DEVBUF, M_WAITOK);
+               ih = kmem_alloc(sizeof *ih, KM_SLEEP);
                ih->ih_fun = handler;
                ih->ih_arg = arg;
                ih->ih_next = NULL;
@@ -407,7 +407,7 @@
        } else {
                struct sgimips_intrhand *n, *ih;
 
-               ih = malloc(sizeof *ih, M_DEVBUF, M_WAITOK);
+               ih = kmem_alloc(sizeof *ih, KM_SLEEP);
                ih->ih_fun = handler;
                ih->ih_arg = arg;
                ih->ih_next = NULL;
diff -r 062c3e913a07 -r 6dfd79b2aba3 sys/arch/sgimips/dev/zs_kbd.c
--- a/sys/arch/sgimips/dev/zs_kbd.c     Sat Nov 21 15:52:32 2020 +0000
+++ b/sys/arch/sgimips/dev/zs_kbd.c     Sat Nov 21 17:09:34 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: zs_kbd.c,v 1.10 2012/10/29 12:51:38 chs Exp $  */
+/*     $NetBSD: zs_kbd.c,v 1.11 2020/11/21 17:18:31 thorpej Exp $      */
 
 /*
  * Copyright (c) 2004 Steve Rumble
@@ -33,10 +33,10 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: zs_kbd.c,v 1.10 2012/10/29 12:51:38 chs Exp $");
+__KERNEL_RCSID(0, "$NetBSD: zs_kbd.c,v 1.11 2020/11/21 17:18:31 thorpej Exp $");
 
 #include <sys/param.h>
-#include <sys/malloc.h>
+#include <sys/kmem.h>
 #include <sys/systm.h>
 #include <sys/conf.h>
 #include <sys/device.h>
@@ -213,10 +213,8 @@
        } else {
                wskaa.console = 0;
 
-               sc->sc_dc = malloc(sizeof(struct zskbd_devconfig), M_DEVBUF,
-                   M_WAITOK);
-               if (sc->sc_dc == NULL)
-                       panic("zskbd out of memory");
+               sc->sc_dc = kmem_alloc(sizeof(struct zskbd_devconfig),
+                   KM_SLEEP);
 
                sc->sc_dc->enabled = 0;
        }
diff -r 062c3e913a07 -r 6dfd79b2aba3 sys/arch/sgimips/gio/grtwo.c
--- a/sys/arch/sgimips/gio/grtwo.c      Sat Nov 21 15:52:32 2020 +0000
+++ b/sys/arch/sgimips/gio/grtwo.c      Sat Nov 21 17:09:34 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: grtwo.c,v 1.15 2018/09/03 16:29:27 riastradh Exp $  */
+/* $NetBSD: grtwo.c,v 1.16 2020/11/21 17:18:31 thorpej Exp $    */
 
 /*
  * Copyright (c) 2004 Christopher SEKIYA
@@ -35,12 +35,12 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: grtwo.c,v 1.15 2018/09/03 16:29:27 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: grtwo.c,v 1.16 2020/11/21 17:18:31 thorpej Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
 #include <sys/device.h>
-#include <sys/malloc.h>
+#include <sys/kmem.h>
 
 #include <machine/sysconf.h>
 
@@ -507,10 +507,8 @@
                sc->sc_dc = &grtwo_console_dc;
        } else {
                wa.console = 0;
-               sc->sc_dc = malloc(sizeof(struct grtwo_devconfig),
-                                  M_DEVBUF, M_WAITOK | M_ZERO);
-               if (sc->sc_dc == NULL)
-                       panic("grtwo_attach: out of memory");
+               sc->sc_dc = kmem_zalloc(sizeof(struct grtwo_devconfig),
+                                  KM_SLEEP);
 
                grtwo_attach_common(sc->sc_dc, ga);
        }
diff -r 062c3e913a07 -r 6dfd79b2aba3 sys/arch/sgimips/gio/light.c
--- a/sys/arch/sgimips/gio/light.c      Sat Nov 21 15:52:32 2020 +0000
+++ b/sys/arch/sgimips/gio/light.c      Sat Nov 21 17:09:34 2020 +0000
@@ -1,4 +1,4 @@
-/*     $Id: light.c,v 1.7 2012/10/27 17:18:09 chs Exp $        */
+/*     $Id: light.c,v 1.8 2020/11/21 17:18:31 thorpej Exp $    */
 
 /*
  * Copyright (c) 2006 Stephen M. Rumble
@@ -43,12 +43,12 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: light.c,v 1.7 2012/10/27 17:18:09 chs Exp $");
+__KERNEL_RCSID(0, "$NetBSD: light.c,v 1.8 2020/11/21 17:18:31 thorpej Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
 #include <sys/device.h>
-#include <sys/malloc.h>
+#include <sys/kmem.h>
 
 #include <machine/sysconf.h>
 
@@ -320,10 +320,8 @@
                sc->sc_dc = &light_console_dc;
        } else {
                wa.console = 0;
-               sc->sc_dc = malloc(sizeof(struct light_devconfig), M_DEVBUF,
-                   M_WAITOK | M_ZERO);
-               if (sc->sc_dc == NULL)
-                       panic("light_attach: out of memory");
+               sc->sc_dc = kmem_zalloc(sizeof(struct light_devconfig),
+                   KM_SLEEP);
 
                light_attach_common(sc->sc_dc, ga);
        }
diff -r 062c3e913a07 -r 6dfd79b2aba3 sys/arch/sgimips/gio/newport.c
--- a/sys/arch/sgimips/gio/newport.c    Sat Nov 21 15:52:32 2020 +0000
+++ b/sys/arch/sgimips/gio/newport.c    Sat Nov 21 17:09:34 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: newport.c,v 1.20 2019/05/10 23:21:42 macallan Exp $    */



Home | Main Index | Thread Index | Old Index