Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/dev/ieee1394 Use kmem(9) instead of malloc(9).
details: https://anonhg.NetBSD.org/src/rev/a23371289d21
branches: trunk
changeset: 754725:a23371289d21
user: kiyohara <kiyohara%NetBSD.org@localhost>
date: Mon May 10 12:17:32 2010 +0000
description:
Use kmem(9) instead of malloc(9).
diffstat:
sys/dev/ieee1394/firewire.c | 84 ++++++++++++++++++++------------------------
sys/dev/ieee1394/fwdev.c | 31 ++++++++--------
sys/dev/ieee1394/fwdma.c | 15 ++++---
sys/dev/ieee1394/fwmem.c | 12 ++---
sys/dev/ieee1394/fwohci.c | 22 +++++-----
sys/dev/ieee1394/if_fwip.c | 17 ++++----
sys/dev/ieee1394/sbp.c | 37 +++++++++----------
7 files changed, 106 insertions(+), 112 deletions(-)
diffs (truncated from 726 to 300 lines):
diff -r 5b970deaa8d9 -r a23371289d21 sys/dev/ieee1394/firewire.c
--- a/sys/dev/ieee1394/firewire.c Mon May 10 06:39:30 2010 +0000
+++ b/sys/dev/ieee1394/firewire.c Mon May 10 12:17:32 2010 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: firewire.c,v 1.30 2010/04/06 10:45:15 reinoud Exp $ */
+/* $NetBSD: firewire.c,v 1.31 2010/05/10 12:17:32 kiyohara Exp $ */
/*-
* Copyright (c) 2003 Hidetoshi Shimokawa
* Copyright (c) 1998-2002 Katsushi Kobayashi and Hidetoshi Shimokawa
@@ -37,7 +37,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: firewire.c,v 1.30 2010/04/06 10:45:15 reinoud Exp $");
+__KERNEL_RCSID(0, "$NetBSD: firewire.c,v 1.31 2010/05/10 12:17:32 kiyohara Exp $");
#include <sys/param.h>
#include <sys/bus.h>
@@ -48,7 +48,7 @@
#include <sys/errno.h>
#include <sys/kernel.h>
#include <sys/kthread.h>
-#include <sys/malloc.h>
+#include <sys/kmem.h>
#include <sys/queue.h>
#include <sys/sysctl.h>
#include <sys/systm.h>
@@ -217,28 +217,24 @@
if (fc->nisodma > FWMAXNDMA)
fc->nisodma = FWMAXNDMA;
- fc->crom_src_buf =
- (struct crom_src_buf *)malloc(sizeof(struct crom_src_buf),
- M_FW, M_NOWAIT | M_ZERO);
+ fc->crom_src_buf = kmem_zalloc(sizeof(struct crom_src_buf), KM_NOSLEEP);
if (fc->crom_src_buf == NULL) {
- aprint_error_dev(fc->bdev, "Malloc Failure crom src buff\n");
+ aprint_error_dev(fc->bdev,
+ "kmem alloc failure crom src buff\n");
return;
}
fc->topology_map =
- (struct fw_topology_map *)malloc(sizeof(struct fw_topology_map),
- M_FW, M_NOWAIT | M_ZERO);
+ kmem_zalloc(sizeof(struct fw_topology_map), KM_NOSLEEP);
if (fc->topology_map == NULL) {
aprint_error_dev(fc->dev, "Malloc Failure topology map\n");
- free(fc->crom_src_buf, M_FW);
+ kmem_free(fc->crom_src_buf, sizeof(struct crom_src_buf));
return;
}
- fc->speed_map =
- (struct fw_speed_map *)malloc(sizeof(struct fw_speed_map),
- M_FW, M_NOWAIT | M_ZERO);
+ fc->speed_map = kmem_zalloc(sizeof(struct fw_speed_map), KM_NOSLEEP);
if (fc->speed_map == NULL) {
aprint_error_dev(fc->dev, "Malloc Failure speed map\n");
- free(fc->crom_src_buf, M_FW);
- free(fc->topology_map, M_FW);
+ kmem_free(fc->crom_src_buf, sizeof(struct crom_src_buf));
+ kmem_free(fc->topology_map, sizeof(struct fw_topology_map));
return;
}
@@ -262,7 +258,7 @@
aprint_error_dev(self, "kthread_create failed\n");
config_pending_incr();
- devlist = malloc(sizeof(struct firewire_dev_list), M_DEVBUF, M_NOWAIT);
+ devlist = kmem_alloc(sizeof(struct firewire_dev_list), KM_NOSLEEP);
if (devlist == NULL) {
aprint_error_dev(self, "device list allocation failed\n");
return;
@@ -273,7 +269,7 @@
faa.fwdev = NULL;
devlist->dev = config_found(sc->dev, &faa, firewire_print);
if (devlist->dev == NULL)
- free(devlist, M_DEVBUF);
+ kmem_free(devlist, sizeof(struct firewire_dev_list));
else
SLIST_INSERT_HEAD(&sc->devlist, devlist, link);
@@ -315,7 +311,7 @@
if ((err = config_detach(devlist->dev, flags)) != 0)
return err;
SLIST_REMOVE(&sc->devlist, devlist, firewire_dev_list, link);
- free(devlist, M_DEVBUF);
+ kmem_free(devlist, sizeof(struct firewire_dev_list));
}
callout_stop(&fc->timeout_callout);
@@ -326,11 +322,11 @@
for (fwdev = STAILQ_FIRST(&fc->devices); fwdev != NULL;
fwdev = fwdev_next) {
fwdev_next = STAILQ_NEXT(fwdev, link);
- free(fwdev, M_FW);
+ kmem_free(fwdev, sizeof(struct fw_device));
}
- free(fc->topology_map, M_FW);
- free(fc->speed_map, M_FW);
- free(fc->crom_src_buf, M_FW);
+ kmem_free(fc->topology_map, sizeof(struct fw_topology_map));
+ kmem_free(fc->speed_map, sizeof(struct fw_speed_map));
+ kmem_free(fc->crom_src_buf, sizeof(struct crom_src_buf));
cv_destroy(&fc->fc_cv);
mutex_destroy(&fc->wait_lock);
@@ -586,7 +582,7 @@
* Configuration ROM.
*/
#define FW_MAX_GENERATION 0xF
- newrom = malloc(CROMSIZE, M_FW, M_NOWAIT | M_ZERO);
+ newrom = kmem_zalloc(CROMSIZE, KM_NOSLEEP);
src = &fc->crom_src_buf->src;
crom_load(src, newrom, CROMSIZE);
if (memcmp(newrom, fc->config_rom, CROMSIZE) != 0) {
@@ -594,7 +590,7 @@
src->businfo.generation = FW_GENERATION_CHANGEABLE;
memcpy((void *)fc->config_rom, newrom, CROMSIZE);
}
- free(newrom, M_FW);
+ kmem_free(newrom, CROMSIZE);
}
/* Call once after reboot */
@@ -810,7 +806,7 @@
{
struct fw_xfer *xfer;
- xfer = malloc(sizeof(struct fw_xfer), type, M_NOWAIT | M_ZERO);
+ xfer = kmem_zalloc(sizeof(struct fw_xfer), KM_NOSLEEP);
if (xfer == NULL)
return xfer;
@@ -831,17 +827,17 @@
xfer->send.pay_len = send_len;
xfer->recv.pay_len = recv_len;
if (send_len > 0) {
- xfer->send.payload = malloc(send_len, type, M_NOWAIT | M_ZERO);
+ xfer->send.payload = kmem_zalloc(send_len, KM_NOSLEEP);
if (xfer->send.payload == NULL) {
fw_xfer_free(xfer);
return NULL;
}
}
if (recv_len > 0) {
- xfer->recv.payload = malloc(recv_len, type, M_NOWAIT);
+ xfer->recv.payload = kmem_alloc(recv_len, KM_NOSLEEP);
if (xfer->recv.payload == NULL) {
if (xfer->send.payload != NULL)
- free(xfer->send.payload, type);
+ kmem_free(xfer->send.payload, send_len);
fw_xfer_free(xfer);
return NULL;
}
@@ -912,7 +908,7 @@
}
fw_xfer_unload(xfer);
cv_destroy(&xfer->cv);
- free(xfer, xfer->malloc);
+ kmem_free(xfer, sizeof(struct fw_xfer));
}
void
@@ -924,14 +920,12 @@
return;
}
fw_xfer_unload(xfer);
- if (xfer->send.payload != NULL) {
- free(xfer->send.payload, xfer->malloc);
- }
- if (xfer->recv.payload != NULL) {
- free(xfer->recv.payload, xfer->malloc);
- }
+ if (xfer->send.payload != NULL)
+ kmem_free(xfer->send.payload, xfer->send.pay_len);
+ if (xfer->recv.payload != NULL)
+ kmem_free(xfer->recv.payload, xfer->recv.pay_len);
cv_destroy(&xfer->cv);
- free(xfer, xfer->malloc);
+ kmem_free(xfer, sizeof(struct fw_xfer));
}
void
@@ -1769,8 +1763,7 @@
mutex_exit(&fc->fc_mtx);
if (fwdev == NULL) {
/* new device */
- fwdev =
- malloc(sizeof(struct fw_device), M_FW, M_NOWAIT | M_ZERO);
+ fwdev = kmem_zalloc(sizeof(struct fw_device), KM_NOSLEEP);
if (fwdev == NULL) {
if (firewire_debug)
printf("node%d: no memory\n", node);
@@ -1887,7 +1880,7 @@
char nodes[63];
todo = 0;
- dfwdev = malloc(sizeof(*dfwdev), M_TEMP, M_NOWAIT);
+ dfwdev = kmem_alloc(sizeof(struct fw_device), KM_NOSLEEP);
if (dfwdev == NULL)
return;
/* setup dummy fwdev */
@@ -1928,7 +1921,7 @@
}
todo = todo2;
}
- free(dfwdev, M_TEMP);
+ kmem_free(dfwdev, sizeof(struct fw_device));
}
static void
@@ -1982,8 +1975,8 @@
mutex_exit(&fc->fc_mtx);
switch (fwdev->status) {
case FWDEVNEW:
- devlist = malloc(sizeof(struct firewire_dev_list),
- M_DEVBUF, M_NOWAIT);
+ devlist = kmem_alloc(sizeof(struct firewire_dev_list),
+ KM_NOSLEEP);
if (devlist == NULL) {
aprint_error_dev(fc->bdev,
"memory allocation failed\n");
@@ -1997,7 +1990,8 @@
fwdev->sbp = config_found_sm_loc(sc->dev, "ieee1394if",
locs, &fwa, firewire_print, config_stdsubmatch);
if (fwdev->sbp == NULL) {
- free(devlist, M_DEVBUF);
+ kmem_free(devlist,
+ sizeof(struct firewire_dev_list));
break;
}
@@ -2058,13 +2052,13 @@
SLIST_REMOVE(&sc->devlist, devlist, firewire_dev_list,
link);
- free(devlist, M_DEVBUF);
+ kmem_free(devlist, sizeof(struct firewire_dev_list));
if (config_detach(fwdev->sbp, DETACH_FORCE) != 0)
return;
STAILQ_REMOVE(&fc->devices, fwdev, fw_device, link);
- free(fwdev, M_FW);
+ kmem_free(fwdev, sizeof(struct fw_device));
}
}
diff -r 5b970deaa8d9 -r a23371289d21 sys/dev/ieee1394/fwdev.c
--- a/sys/dev/ieee1394/fwdev.c Mon May 10 06:39:30 2010 +0000
+++ b/sys/dev/ieee1394/fwdev.c Mon May 10 12:17:32 2010 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: fwdev.c,v 1.19 2010/04/29 06:53:48 kiyohara Exp $ */
+/* $NetBSD: fwdev.c,v 1.20 2010/05/10 12:17:32 kiyohara Exp $ */
/*-
* Copyright (c) 2003 Hidetoshi Shimokawa
* Copyright (c) 1998-2002 Katsushi Kobayashi and Hidetoshi Shimokawa
@@ -37,7 +37,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: fwdev.c,v 1.19 2010/04/29 06:53:48 kiyohara Exp $");
+__KERNEL_RCSID(0, "$NetBSD: fwdev.c,v 1.20 2010/05/10 12:17:32 kiyohara Exp $");
#include <sys/param.h>
#include <sys/device.h>
@@ -46,7 +46,7 @@
#include <sys/bus.h>
#include <sys/conf.h>
#include <sys/kernel.h>
-#include <sys/malloc.h>
+#include <sys/kmem.h>
#include <sys/mbuf.h>
#include <sys/poll.h>
#include <sys/proc.h>
@@ -91,7 +91,7 @@
static int fwdev_allocbuf(struct firewire_comm *, struct fw_xferq *,
struct fw_bufspec *);
-static int fwdev_freebuf(struct fw_xferq *);
+static int fwdev_freebuf(struct fw_xferq *, struct fw_bufspec *);
static int fw_read_async(struct fw_drv1 *, struct uio *, int);
static int fw_write_async(struct fw_drv1 *, struct uio *, int);
static void fw_hand(struct fw_xfer *);
@@ -120,7 +120,7 @@
sc->si_drv1 = (void *)-1;
mutex_exit(&sc->fc->fc_mtx);
- sc->si_drv1 = malloc(sizeof(struct fw_drv1), M_FW, M_WAITOK | M_ZERO);
+ sc->si_drv1 = kmem_zalloc(sizeof(struct fw_drv1), KM_SLEEP);
if (sc->si_drv1 == NULL)
return ENOMEM;
@@ -170,7 +170,7 @@
fc->irx_disable(fc, ir->dmach);
}
/* free extbuf */
- fwdev_freebuf(ir);
+ fwdev_freebuf(ir, &d->bufreq.rx);
Home |
Main Index |
Thread Index |
Old Index