malloc(9) -> kmem(9)

This commit is contained in:
thorpej 2020-12-19 21:48:04 +00:00
parent adf503e080
commit c2d090fa74
3 changed files with 20 additions and 18 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: macfb.c,v 1.20 2012/10/27 17:17:59 chs Exp $ */
/* $NetBSD: macfb.c,v 1.21 2020/12/19 21:48:04 thorpej Exp $ */
/*
* Copyright (c) 1998 Matt DeBergalis
* All rights reserved.
@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: macfb.c,v 1.20 2012/10/27 17:17:59 chs Exp $");
__KERNEL_RCSID(0, "$NetBSD: macfb.c,v 1.21 2020/12/19 21:48:04 thorpej Exp $");
#include "opt_wsdisplay_compat.h"
#include "grf.h"
@ -41,7 +41,7 @@ __KERNEL_RCSID(0, "$NetBSD: macfb.c,v 1.20 2012/10/27 17:17:59 chs Exp $");
#include <sys/systm.h>
#include <sys/kernel.h>
#include <sys/device.h>
#include <sys/malloc.h>
#include <sys/kmem.h>
#include <machine/cpu.h>
#include <machine/bus.h>
@ -206,7 +206,8 @@ macfb_attach(device_t parent, device_t self, void *aux)
sc->sc_dc = &macfb_console_dc;
sc->nscreens = 1;
} else {
sc->sc_dc = malloc(sizeof(struct macfb_devconfig), M_DEVBUF, M_WAITOK);
sc->sc_dc = kmem_alloc(sizeof(struct macfb_devconfig),
KM_SLEEP);
sc->sc_dc->dc_vaddr = (vaddr_t)gm->fbbase;
sc->sc_dc->dc_paddr = ga->ga_phys;
sc->sc_dc->dc_size = gm->fbsize;
@ -373,7 +374,7 @@ init_itefont(void)
return;
itefont_initted = 1;
/* XXX but we cannot use malloc here... */
/* XXX but we cannot use kmem_alloc here... */
gallant19.width = 6;
gallant19.height = 10;
gallant19.ascent = 0;

View File

@ -1,4 +1,4 @@
/* $NetBSD: cpi_nubus.c,v 1.10 2018/09/03 16:29:25 riastradh Exp $ */
/* $NetBSD: cpi_nubus.c,v 1.11 2020/12/19 21:48:04 thorpej Exp $ */
/*-
* Copyright (c) 2008 Hauke Fath
@ -25,12 +25,12 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: cpi_nubus.c,v 1.10 2018/09/03 16:29:25 riastradh Exp $");
__KERNEL_RCSID(0, "$NetBSD: cpi_nubus.c,v 1.11 2020/12/19 21:48:04 thorpej Exp $");
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/proc.h>
#include <sys/device.h>
#include <sys/malloc.h>
#include <sys/kmem.h>
#include <sys/event.h>
#include <sys/callout.h>
#include <sys/conf.h>
@ -392,7 +392,7 @@ cpi_open(dev_t device, int flag, int mode, struct lwp *l)
printf("\tcpi_open() allocating printer buffer...\n");
/* Allocate the driver's line buffer */
sc->sc_printbuf = malloc(CPI_BUFSIZE, M_DEVBUF, M_WAITOK);
sc->sc_printbuf = kmem_alloc(CPI_BUFSIZE, KM_SLEEP);
sc->sc_bufbytes = 0;
sc->sc_lpstate = LP_OPEN;
@ -441,7 +441,7 @@ cpi_close(dev_t device, int flag, int mode, struct lwp *l)
z8536_reg_set(sc->sc_bst, sc->sc_bsh, Z8536_PCSRA, PCSR_CLR_IP_IUS);
sc->sc_lpstate = LP_INITIAL;
free(sc->sc_printbuf, M_DEVBUF);
kmem_free(sc->sc_printbuf, CPI_BUFSIZE);
return 0;
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: iwm_fd.c,v 1.57 2019/11/12 13:17:43 msaitoh Exp $ */
/* $NetBSD: iwm_fd.c,v 1.58 2020/12/19 21:48:04 thorpej Exp $ */
/*
* Copyright (c) 1997, 1998 Hauke Fath. All rights reserved.
@ -32,7 +32,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: iwm_fd.c,v 1.57 2019/11/12 13:17:43 msaitoh Exp $");
__KERNEL_RCSID(0, "$NetBSD: iwm_fd.c,v 1.58 2020/12/19 21:48:04 thorpej Exp $");
#include "locators.h"
@ -42,7 +42,7 @@ __KERNEL_RCSID(0, "$NetBSD: iwm_fd.c,v 1.57 2019/11/12 13:17:43 msaitoh Exp $");
#include <sys/kernel.h>
#include <sys/file.h>
#include <sys/ioctl.h>
#include <sys/malloc.h>
#include <sys/kmem.h>
#include <sys/device.h>
#include <sys/event.h>
@ -669,8 +669,10 @@ fdclose(dev_t dev, int flags, int devType, struct lwp *l)
fdType = minor(dev) % MAXPARTITIONS;
fd = iwm->fd[fdUnit];
/* release cylinder cache memory */
if (fd->cbuf != NULL)
free(fd->cbuf, M_DEVBUF);
if (fd->cbuf != NULL) {
kmem_free(fd->cbuf,
IWM_MAX_GCR_SECTORS * fd->currentType->sectorSize);
}
partitionMask = (1 << fdType);
@ -1636,8 +1638,7 @@ initCylinderCache(fd_softc_t *fd)
secsize = fd->currentType->sectorSize;
fd->cachedSide = 0;
fd->cbuf = (unsigned char *) malloc(IWM_MAX_GCR_SECTORS
* secsize, M_DEVBUF, M_WAITOK);
fd->cbuf = kmem_alloc(IWM_MAX_GCR_SECTORS * secsize, KM_SLEEP);
if (NULL == fd->cbuf)
err = ENOMEM;
else