Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/nick-nhusb]: src/sys Replace malloc(9) with kmem(9)
details: https://anonhg.NetBSD.org/src/rev/6cc6a187eb88
branches: nick-nhusb
changeset: 334067:6cc6a187eb88
user: skrll <skrll%NetBSD.org@localhost>
date: Wed Dec 03 14:18:07 2014 +0000
description:
Replace malloc(9) with kmem(9)
diffstat:
sys/arch/mips/adm5120/dev/ahci.c | 12 ++--
sys/dev/ic/sl811hs.c | 10 ++--
sys/dev/usb/hid.c | 18 ++++---
sys/dev/usb/if_athn_usb.c | 20 +++++----
sys/dev/usb/if_athn_usb.h | 3 +-
sys/dev/usb/if_kue.c | 13 +++--
sys/dev/usb/if_otus.c | 19 ++++----
sys/dev/usb/if_otusvar.h | 3 +-
sys/dev/usb/if_zyd.c | 16 +++---
sys/dev/usb/if_zydreg.h | 3 +-
sys/dev/usb/u3g.c | 12 +++--
sys/dev/usb/uaudio.c | 23 ++++++----
sys/dev/usb/ubsa.c | 8 +-
sys/dev/usb/ubsa_common.c | 10 ++--
sys/dev/usb/ubt.c | 10 ++--
sys/dev/usb/uchcom.c | 10 ++--
sys/dev/usb/ucycom.c | 10 ++--
sys/dev/usb/udsir.c | 10 ++--
sys/dev/usb/uep.c | 12 ++--
sys/dev/usb/ugen.c | 86 +++++++++++++++++++++------------------
sys/dev/usb/uhid.c | 10 ++--
sys/dev/usb/uhidev.c | 36 ++++++++--------
sys/dev/usb/uhmodem.c | 10 ++--
sys/dev/usb/uhub.c | 39 ++++++++++-------
sys/dev/usb/umct.c | 10 ++--
sys/dev/usb/uplcom.c | 12 ++--
sys/dev/usb/urio.c | 10 ++--
sys/dev/usb/usb.c | 23 +++++-----
sys/dev/usb/usb.h | 6 +--
sys/dev/usb/usb_subr.c | 81 +++++++++++++++++++------------------
sys/dev/usb/usbdi.c | 12 +++--
sys/dev/usb/usbdi_util.c | 13 ++---
sys/dev/usb/usbdi_util.h | 4 +-
sys/dev/usb/uscanner.c | 14 +++---
sys/dev/usb/ustir.c | 10 ++--
sys/dev/usb/utoppy.c | 14 +++---
sys/dev/usb/uvscom.c | 12 ++--
sys/dev/usb/uyurex.c | 10 ++--
sys/dev/usb/xhci.c | 6 +-
39 files changed, 333 insertions(+), 307 deletions(-)
diffs (truncated from 2444 to 300 lines):
diff -r ff53cdaa18e3 -r 6cc6a187eb88 sys/arch/mips/adm5120/dev/ahci.c
--- a/sys/arch/mips/adm5120/dev/ahci.c Wed Dec 03 13:30:51 2014 +0000
+++ b/sys/arch/mips/adm5120/dev/ahci.c Wed Dec 03 14:18:07 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ahci.c,v 1.12.6.7 2014/12/03 13:19:38 skrll Exp $ */
+/* $NetBSD: ahci.c,v 1.12.6.8 2014/12/03 14:18:07 skrll Exp $ */
/*-
* Copyright (c) 2007 Ruslan Ermilov and Vsevolod Lobko.
@@ -64,14 +64,14 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ahci.c,v 1.12.6.7 2014/12/03 13:19:38 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ahci.c,v 1.12.6.8 2014/12/03 14:18:07 skrll Exp $");
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/kernel.h>
#include <sys/proc.h>
#include <sys/device.h>
-#include <sys/malloc.h>
+#include <sys/kmem.h>
#include <sys/bus.h>
#include <machine/cpu.h>
@@ -483,7 +483,7 @@
}
#endif
} else {
- xfer = malloc(sizeof(*xfer), M_USB, M_NOWAIT);
+ xfer = kmem_alloc(sizeof(*xfer), KM_SLEEP);
}
if (xfer) {
@@ -1235,7 +1235,7 @@
DPRINTF(D_TRACE, ("INTRstart "));
- sx = malloc(sizeof(*sx), M_USB, M_NOWAIT);
+ sx = kmem_intr_alloc(sizeof(*sx), KM_NOSLEEP);
if (sx == NULL)
goto reterr;
memset(sx, 0, sizeof(*sx));
@@ -1302,7 +1302,7 @@
sx = xfer->ux_hcpriv;
if (sx) {
callout_stop(&sx->sx_callout_t);
- free(sx, M_USB);
+ kmem_intr_free(sx, sizeof(*sx));
xfer->ux_hcpriv = NULL;
} else {
printf("%s: sx == NULL!\n", __func__);
diff -r ff53cdaa18e3 -r 6cc6a187eb88 sys/dev/ic/sl811hs.c
--- a/sys/dev/ic/sl811hs.c Wed Dec 03 13:30:51 2014 +0000
+++ b/sys/dev/ic/sl811hs.c Wed Dec 03 14:18:07 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: sl811hs.c,v 1.47.6.6 2014/12/03 13:19:38 skrll Exp $ */
+/* $NetBSD: sl811hs.c,v 1.47.6.7 2014/12/03 14:18:07 skrll Exp $ */
/*
* Not (c) 2007 Matthew Orgass
@@ -68,7 +68,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: sl811hs.c,v 1.47.6.6 2014/12/03 13:19:38 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sl811hs.c,v 1.47.6.7 2014/12/03 14:18:07 skrll Exp $");
#include "opt_slhci.h"
@@ -78,7 +78,7 @@
#include <sys/kernel.h>
#include <sys/proc.h>
#include <sys/device.h>
-#include <sys/malloc.h>
+#include <sys/kmem.h>
#include <sys/queue.h>
#include <sys/gcq.h>
#include <sys/intr.h>
@@ -761,7 +761,7 @@
{
struct usbd_xfer *xfer;
- xfer = malloc(sizeof(*xfer), M_USB, M_NOWAIT|M_ZERO);
+ xfer = kmem_zalloc(sizeof(*xfer), KM_SLEEP);
DLOG(D_MEM, "allocx %p", xfer, 0,0,0);
@@ -796,7 +796,7 @@
xfer->ux_state = XFER_FREE;
#endif
- free(xfer, M_USB);
+ kmem_free(xfer, sizeof(*xfer));
}
static void
diff -r ff53cdaa18e3 -r 6cc6a187eb88 sys/dev/usb/hid.c
--- a/sys/dev/usb/hid.c Wed Dec 03 13:30:51 2014 +0000
+++ b/sys/dev/usb/hid.c Wed Dec 03 14:18:07 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: hid.c,v 1.35.16.1 2014/11/30 12:18:58 skrll Exp $ */
+/* $NetBSD: hid.c,v 1.35.16.2 2014/12/03 14:18:07 skrll Exp $ */
/* $FreeBSD: src/sys/dev/usb/hid.c,v 1.11 1999/11/17 22:33:39 n_hibma Exp $ */
/*
@@ -32,12 +32,12 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: hid.c,v 1.35.16.1 2014/11/30 12:18:58 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: hid.c,v 1.35.16.2 2014/12/03 14:18:07 skrll Exp $");
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/kernel.h>
-#include <sys/malloc.h>
+#include <sys/kmem.h>
#include <dev/usb/usb.h>
#include <dev/usb/usbhid.h>
@@ -91,7 +91,9 @@
{
struct hid_data *s;
- s = malloc(sizeof *s, M_TEMP, M_WAITOK|M_ZERO);
+ s = kmem_zalloc(sizeof(*s), KM_SLEEP);
+ if (s == NULL)
+ return s;
s->start = s->p = d;
s->end = (const char *)d + len;
s->kind = kind;
@@ -104,10 +106,10 @@
while (s->cur.next != NULL) {
struct hid_item *hi = s->cur.next->next;
- free(s->cur.next, M_TEMP);
+ kmem_free(s->cur.next, sizeof(*s->cur.next));
s->cur.next = hi;
}
- free(s, M_TEMP);
+ kmem_free(s, sizeof(*s));
}
int
@@ -289,7 +291,7 @@
c->loc.count = dval;
break;
case 10: /* Push */
- hi = malloc(sizeof *hi, M_TEMP, M_WAITOK);
+ hi = kmem_alloc(sizeof(*hi), KM_SLEEP);
*hi = *c;
c->next = hi;
break;
@@ -298,7 +300,7 @@
oldpos = c->loc.pos;
*c = *hi;
c->loc.pos = oldpos;
- free(hi, M_TEMP);
+ kmem_free(hi, sizeof(*hi));
break;
default:
printf("Global bTag=%d\n", bTag);
diff -r ff53cdaa18e3 -r 6cc6a187eb88 sys/dev/usb/if_athn_usb.c
--- a/sys/dev/usb/if_athn_usb.c Wed Dec 03 13:30:51 2014 +0000
+++ b/sys/dev/usb/if_athn_usb.c Wed Dec 03 14:18:07 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: if_athn_usb.c,v 1.6.8.1 2014/12/02 09:00:33 skrll Exp $ */
+/* $NetBSD: if_athn_usb.c,v 1.6.8.2 2014/12/03 14:18:07 skrll Exp $ */
/* $OpenBSD: if_athn_usb.c,v 1.12 2013/01/14 09:50:31 jsing Exp $ */
/*-
@@ -22,7 +22,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_athn_usb.c,v 1.6.8.1 2014/12/02 09:00:33 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_athn_usb.c,v 1.6.8.2 2014/12/03 14:18:07 skrll Exp $");
#ifdef _KERNEL_OPT
#include "opt_inet.h"
@@ -39,6 +39,7 @@
#include <sys/socket.h>
#include <sys/sockio.h>
#include <sys/systm.h>
+#include <sys/kmem.h>
#include <sys/bus.h>
#include <sys/endian.h>
@@ -481,7 +482,7 @@
athn_usb_open_pipes(struct athn_usb_softc *usc)
{
usb_endpoint_descriptor_t *ed;
- int isize, error;
+ int error;
DPRINTFN(DBG_FN, usc, "\n");
@@ -507,21 +508,22 @@
"could not retrieve Rx intr pipe descriptor\n");
goto fail;
}
- isize = UGETW(ed->wMaxPacketSize);
- if (isize == 0) {
+ usc->usc_ibufsize = UGETW(ed->wMaxPacketSize);
+ if (usc->usc_ibufsize == 0) {
aprint_error_dev(usc->usc_dev,
"invalid Rx intr pipe descriptor\n");
goto fail;
}
- usc->usc_ibuf = malloc(isize, M_USBDEV, M_NOWAIT);
+ usc->usc_ibuf = kmem_alloc(usc->usc_ibufsize, KM_SLEEP);
if (usc->usc_ibuf == NULL) {
aprint_error_dev(usc->usc_dev,
"could not allocate Rx intr buffer\n");
goto fail;
}
+
error = usbd_open_pipe_intr(usc->usc_iface, AR_PIPE_RX_INTR,
- USBD_SHORT_XFER_OK, &usc->usc_rx_intr_pipe, usc, usc->usc_ibuf, isize,
- athn_usb_intr, USBD_DEFAULT_INTERVAL);
+ USBD_SHORT_XFER_OK, &usc->usc_rx_intr_pipe, usc, usc->usc_ibuf,
+ usc->usc_ibufsize, athn_usb_intr, USBD_DEFAULT_INTERVAL);
if (error != 0) {
aprint_error_dev(usc->usc_dev,
"could not open Rx intr pipe\n");
@@ -566,7 +568,7 @@
athn_usb_kill_pipe(&usc->usc_rx_intr_pipe);
ibuf = atomic_swap_ptr(&usc->usc_ibuf, NULL);
if (ibuf != NULL)
- free(ibuf, M_USBDEV);
+ kmem_free(ibuf, usc->usc_ibufsize);
}
Static int
diff -r ff53cdaa18e3 -r 6cc6a187eb88 sys/dev/usb/if_athn_usb.h
--- a/sys/dev/usb/if_athn_usb.h Wed Dec 03 13:30:51 2014 +0000
+++ b/sys/dev/usb/if_athn_usb.h Wed Dec 03 14:18:07 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: if_athn_usb.h,v 1.2 2013/03/30 14:14:31 christos Exp $ */
+/* $NetBSD: if_athn_usb.h,v 1.2.16.1 2014/12/03 14:18:07 skrll Exp $ */
/* $OpenBSD: if_athn_usb.h,v 1.3 2012/11/10 14:35:06 mikeb Exp $ */
/*-
@@ -463,6 +463,7 @@
usbd_pipe_handle usc_rx_intr_pipe;
usbd_pipe_handle usc_tx_intr_pipe;
uint8_t *usc_ibuf;
+ size_t usc_ibufsize;
struct ar_wmi_cmd_reg_write usc_wbuf[AR_MAX_WRITE_COUNT];
int usc_wcount;
diff -r ff53cdaa18e3 -r 6cc6a187eb88 sys/dev/usb/if_kue.c
--- a/sys/dev/usb/if_kue.c Wed Dec 03 13:30:51 2014 +0000
+++ b/sys/dev/usb/if_kue.c Wed Dec 03 14:18:07 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: if_kue.c,v 1.81.4.1 2014/12/02 09:00:33 skrll Exp $ */
+/* $NetBSD: if_kue.c,v 1.81.4.2 2014/12/03 14:18:07 skrll Exp $ */
/*
* Copyright (c) 1997, 1998, 1999, 2000
@@ -71,7 +71,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_kue.c,v 1.81.4.1 2014/12/02 09:00:33 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_kue.c,v 1.81.4.2 2014/12/03 14:18:07 skrll Exp $");
#ifdef _KERNEL_OPT
#include "opt_inet.h"
@@ -81,7 +81,7 @@
#include <sys/systm.h>
#include <sys/sockio.h>
#include <sys/mbuf.h>
-#include <sys/malloc.h>
+#include <sys/kmem.h>
#include <sys/kernel.h>
#include <sys/socket.h>
#include <sys/device.h>
@@ -475,8 +475,8 @@
return;
}
- sc->kue_mcfilters = malloc(KUE_MCFILTCNT(sc) * ETHER_ADDR_LEN,
- M_USBDEV, M_NOWAIT);
+ sc->kue_mcfilters = kmem_alloc(KUE_MCFILTCNT(sc) * ETHER_ADDR_LEN,
+ KM_SLEEP);
if (sc->kue_mcfilters == NULL) {
aprint_error_dev(self,
"no memory for multicast filter buffer\n");
@@ -528,7 +528,8 @@
s = splusb(); /* XXX why? */
if (sc->kue_mcfilters != NULL) {
- free(sc->kue_mcfilters, M_USBDEV);
+ kmem_free(sc->kue_mcfilters,
+ KUE_MCFILTCNT(sc) * ETHER_ADDR_LEN);
sc->kue_mcfilters = NULL;
}
Home |
Main Index |
Thread Index |
Old Index