Source-Changes-HG archive

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

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



details:   https://anonhg.NetBSD.org/src/rev/22e511c9fdf3
branches:  trunk
changeset: 949192:22e511c9fdf3
user:      thorpej <thorpej%NetBSD.org@localhost>
date:      Mon Jan 04 17:35:12 2021 +0000

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

diffstat:

 sys/arch/mips/alchemy/au_himem_space.c |   9 ++++-----
 sys/arch/mips/alchemy/au_icu.c         |  10 +++++-----
 sys/arch/mips/alchemy/au_wired_space.c |   9 ++++-----
 sys/arch/mips/atheros/ar_intr.c        |  14 +++++++-------
 sys/arch/mips/atheros/dev/arspi.c      |  16 +++++++---------
 sys/arch/mips/atheros/dev/athflash.c   |   8 ++++----
 6 files changed, 31 insertions(+), 35 deletions(-)

diffs (275 lines):

diff -r b80bed6d1b7d -r 22e511c9fdf3 sys/arch/mips/alchemy/au_himem_space.c
--- a/sys/arch/mips/alchemy/au_himem_space.c    Mon Jan 04 17:22:59 2021 +0000
+++ b/sys/arch/mips/alchemy/au_himem_space.c    Mon Jan 04 17:35:12 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: au_himem_space.c,v 1.15 2019/11/10 21:16:29 chs Exp $ */
+/* $NetBSD: au_himem_space.c,v 1.16 2021/01/04 17:35:12 thorpej Exp $ */
 
 /*-
  * Copyright (c) 2006 Itronix Inc.
@@ -61,7 +61,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: au_himem_space.c,v 1.15 2019/11/10 21:16:29 chs Exp $");
+__KERNEL_RCSID(0, "$NetBSD: au_himem_space.c,v 1.16 2021/01/04 17:35:12 thorpej Exp $");
 
 /*
  * This provides mappings for the upper I/O regions used on some
@@ -73,7 +73,7 @@
 #include <sys/param.h>
 #include <sys/systm.h>
 #include <sys/extent.h>
-#include <sys/malloc.h>
+#include <sys/kmem.h>
 #include <sys/endian.h>
 #include <uvm/uvm.h>
 
@@ -692,8 +692,7 @@
 {
        au_himem_cookie_t       *c;
 
-       c = malloc(sizeof (struct au_himem_cookie), M_DEVBUF,
-           M_WAITOK | M_ZERO);
+       c = kmem_zalloc(sizeof (struct au_himem_cookie), KM_SLEEP);
        c->c_name = name;
        c->c_start = start;
        c->c_end = end;
diff -r b80bed6d1b7d -r 22e511c9fdf3 sys/arch/mips/alchemy/au_icu.c
--- a/sys/arch/mips/alchemy/au_icu.c    Mon Jan 04 17:22:59 2021 +0000
+++ b/sys/arch/mips/alchemy/au_icu.c    Mon Jan 04 17:35:12 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: au_icu.c,v 1.30 2019/11/10 21:16:29 chs Exp $  */
+/*     $NetBSD: au_icu.c,v 1.31 2021/01/04 17:35:12 thorpej Exp $      */
 
 /*-
  * Copyright (c) 2006 Itronix Inc.
@@ -68,7 +68,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: au_icu.c,v 1.30 2019/11/10 21:16:29 chs Exp $");
+__KERNEL_RCSID(0, "$NetBSD: au_icu.c,v 1.31 2021/01/04 17:35:12 thorpej Exp $");
 
 #include "opt_ddb.h"
 #define __INTR_PRIVATE
@@ -78,7 +78,7 @@
 #include <sys/device.h>
 #include <sys/intr.h>
 #include <sys/kernel.h>
-#include <sys/malloc.h>
+#include <sys/kmem.h>
 #include <sys/systm.h>
 
 #include <mips/locore.h>
@@ -199,7 +199,7 @@
        if (req > 1)
                panic("au_intr_establish: bogus request %d", req);
 
-       ih = malloc(sizeof(*ih), M_DEVBUF, M_WAITOK);
+       ih = kmem_alloc(sizeof(*ih), KM_SLEEP);
        ih->ih_func = func;
        ih->ih_arg = arg;
        ih->ih_irq = irq;
@@ -305,7 +305,7 @@
 
        splx(s);
 
-       free(ih, M_DEVBUF);
+       kmem_free(ih, sizeof(*ih));
 }
 
 void
diff -r b80bed6d1b7d -r 22e511c9fdf3 sys/arch/mips/alchemy/au_wired_space.c
--- a/sys/arch/mips/alchemy/au_wired_space.c    Mon Jan 04 17:22:59 2021 +0000
+++ b/sys/arch/mips/alchemy/au_wired_space.c    Mon Jan 04 17:35:12 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: au_wired_space.c,v 1.10 2019/11/10 21:16:29 chs Exp $ */
+/* $NetBSD: au_wired_space.c,v 1.11 2021/01/04 17:35:12 thorpej Exp $ */
 
 /*-
  * Copyright (c) 2006 Itronix Inc.
@@ -61,7 +61,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: au_wired_space.c,v 1.10 2019/11/10 21:16:29 chs Exp $");
+__KERNEL_RCSID(0, "$NetBSD: au_wired_space.c,v 1.11 2021/01/04 17:35:12 thorpej Exp $");
 
 /*
  * This provides mappings for the upper I/O regions used on some
@@ -72,7 +72,7 @@
 #include <sys/param.h>
 #include <sys/systm.h>
 #include <sys/extent.h>
-#include <sys/malloc.h>
+#include <sys/kmem.h>
 #include <sys/endian.h>
 
 #include <sys/bus.h>
@@ -632,8 +632,7 @@
 {
        au_wired_cookie_t       *c;
 
-       c = malloc(sizeof (struct au_wired_cookie), M_DEVBUF,
-           M_WAITOK | M_ZERO);
+       c = kmem_zalloc(sizeof (struct au_wired_cookie), KM_SLEEP);
        c->c_pbase = paddr;
        c->c_name = name;
        c->c_start = start;
diff -r b80bed6d1b7d -r 22e511c9fdf3 sys/arch/mips/atheros/ar_intr.c
--- a/sys/arch/mips/atheros/ar_intr.c   Mon Jan 04 17:22:59 2021 +0000
+++ b/sys/arch/mips/atheros/ar_intr.c   Mon Jan 04 17:35:12 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ar_intr.c,v 1.6 2019/11/10 21:16:29 chs Exp $ */
+/* $NetBSD: ar_intr.c,v 1.7 2021/01/04 17:42:29 thorpej Exp $ */
 /*
  * Copyright (c) 2006 Urbana-Champaign Independent Media Center.
  * Copyright (c) 2006 Garrett D'Amore.
@@ -41,7 +41,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ar_intr.c,v 1.6 2019/11/10 21:16:29 chs Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ar_intr.c,v 1.7 2021/01/04 17:42:29 thorpej Exp $");
 
 #define __INTR_PRIVATE
 
@@ -49,7 +49,7 @@
 #include <sys/intr.h>
 #include <sys/cpu.h>
 #include <sys/kernel.h>
-#include <sys/malloc.h>
+#include <sys/kmem.h>
 
 #include <mips/cpuregs.h>
 #include <mips/locore.h>
@@ -110,7 +110,7 @@
 {
        struct atheros_intrhand *ih;
 
-       ih = malloc(sizeof(*ih), M_DEVBUF, M_WAITOK);
+       ih = kmem_alloc(sizeof(*ih), KM_SLEEP);
        ih->ih_func = func;
        ih->ih_arg = arg;
        ih->ih_irq = intr;
@@ -138,7 +138,7 @@
        LIST_REMOVE(ih, ih_q);
 
        splx(s);
-       free(ih, M_DEVBUF);
+       kmem_free(ih, sizeof(*ih));
 }
 
 static void *
@@ -150,7 +150,7 @@
        int s;
 
 
-       ih = malloc(sizeof(*ih), M_DEVBUF, M_WAITOK);
+       ih = kmem_alloc(sizeof(*ih), KM_SLEEP);
        ih->ih_func = func;
        ih->ih_arg = arg;
        ih->ih_irq = irq;
@@ -188,7 +188,7 @@
        }
 
        splx(s);
-       free(ih, M_DEVBUF);
+       kmem_free(ih, sizeof(*ih));
 }
 
 
diff -r b80bed6d1b7d -r 22e511c9fdf3 sys/arch/mips/atheros/dev/arspi.c
--- a/sys/arch/mips/atheros/dev/arspi.c Mon Jan 04 17:22:59 2021 +0000
+++ b/sys/arch/mips/atheros/dev/arspi.c Mon Jan 04 17:35:12 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: arspi.c,v 1.12 2019/08/13 17:03:11 tnn Exp $ */
+/* $NetBSD: arspi.c,v 1.13 2021/01/04 17:42:29 thorpej Exp $ */
 
 /*-
  * Copyright (c) 2006 Urbana-Champaign Independent Media Center.
@@ -42,7 +42,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: arspi.c,v 1.12 2019/08/13 17:03:11 tnn Exp $");
+__KERNEL_RCSID(0, "$NetBSD: arspi.c,v 1.13 2021/01/04 17:42:29 thorpej Exp $");
 
 #include "locators.h"
 
@@ -52,7 +52,7 @@
 #include <sys/device.h>
 #include <sys/errno.h>
 #include <sys/kernel.h>
-#include <sys/malloc.h>
+#include <sys/kmem.h>
 #include <sys/proc.h>
 #include <sys/systm.h>
 
@@ -260,8 +260,9 @@
        st->st_busprivate = NULL;
        if ((rv = arspi_make_job(st)) != 0) {
                if (st->st_busprivate) {
-                       free(st->st_busprivate, M_DEVBUF);
+                       struct arspi_job *job = st->st_busprivate;
                        st->st_busprivate = NULL;
+                       kmem_free(job, sizeof(*job));
                }
                spi_done(st, rv);
                return rv;
@@ -382,7 +383,7 @@
                        sc->sc_transfer = NULL;
                        st->st_busprivate = NULL;
                        spi_done(st, err);
-                       free(job, M_DEVBUF);
+                       kmem_free(job, sizeof(*job));
                }
        }
 done:
@@ -470,10 +471,7 @@
        uint8_t byte;
        int i, rv;
 
-       job = malloc(sizeof (struct arspi_job), M_DEVBUF, M_ZERO);
-       if (job == NULL) {
-               return ENOMEM;
-       }
+       job = kmem_zalloc(sizeof (struct arspi_job), KM_SLEEP);
 
        st->st_busprivate = job;
 
diff -r b80bed6d1b7d -r 22e511c9fdf3 sys/arch/mips/atheros/dev/athflash.c
--- a/sys/arch/mips/atheros/dev/athflash.c      Mon Jan 04 17:22:59 2021 +0000
+++ b/sys/arch/mips/atheros/dev/athflash.c      Mon Jan 04 17:35:12 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: athflash.c,v 1.11 2019/11/10 21:16:30 chs Exp $ */
+/* $NetBSD: athflash.c,v 1.12 2021/01/04 17:42:29 thorpej Exp $ */
 
 /*
  * Copyright (c) 2006 Urbana-Champaign Independent Media Center.
@@ -82,13 +82,13 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: athflash.c,v 1.11 2019/11/10 21:16:30 chs Exp $");
+__KERNEL_RCSID(0, "$NetBSD: athflash.c,v 1.12 2021/01/04 17:42:29 thorpej Exp $");
 
 #include <sys/param.h>
 #include <sys/conf.h>
 #include <sys/device.h>
 #include <sys/kernel.h>
-#include <sys/malloc.h>
+#include <sys/kmem.h>
 #include <sys/proc.h>
 #include <sys/systm.h>
 
@@ -251,7 +251,7 @@
        sc->sc_size = flash_ids[i].flash_size;
        sc->sc_sector_size = flash_ids[i].sector_size;
 
-       sc->sc_buf = malloc(sc->sc_sector_size, M_DEVBUF, M_WAITOK);
+       sc->sc_buf = kmem_alloc(sc->sc_sector_size, KM_SLEEP);
 
        printf("\n");
 }



Home | Main Index | Thread Index | Old Index