summaryrefslogtreecommitdiff
path: root/sys/dev/usb
diff options
context:
space:
mode:
Diffstat (limited to 'sys/dev/usb')
-rw-r--r--sys/dev/usb/ehci.c6
-rw-r--r--sys/dev/usb/uaudio.c20
-rw-r--r--sys/dev/usb/udl.c4
-rw-r--r--sys/dev/usb/uhci.c5
-rw-r--r--sys/dev/usb/uhub.c6
-rw-r--r--sys/dev/usb/umidi.c30
-rw-r--r--sys/dev/usb/usb_subr.c8
7 files changed, 38 insertions, 41 deletions
diff --git a/sys/dev/usb/ehci.c b/sys/dev/usb/ehci.c
index d46fa003ba0..704f3da76d2 100644
--- a/sys/dev/usb/ehci.c
+++ b/sys/dev/usb/ehci.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ehci.c,v 1.170 2014/11/18 02:37:30 tedu Exp $ */
+/* $OpenBSD: ehci.c,v 1.171 2014/12/09 07:05:06 doug Exp $ */
/* $NetBSD: ehci.c,v 1.66 2004/06/30 03:11:56 mycroft Exp $ */
/*
@@ -362,8 +362,8 @@ ehci_init(struct ehci_softc *sc)
EOWRITE4(sc, EHCI_PERIODICLISTBASE, DMAADDR(&sc->sc_fldma, 0));
- sc->sc_softitds = malloc(sc->sc_flsize * sizeof(struct ehci_soft_itd *),
- M_USB, M_NOWAIT | M_ZERO);
+ sc->sc_softitds = mallocarray(sc->sc_flsize,
+ sizeof(struct ehci_soft_itd *), M_USB, M_NOWAIT | M_ZERO);
if (sc->sc_softitds == NULL)
return (ENOMEM);
LIST_INIT(&sc->sc_freeitds);
diff --git a/sys/dev/usb/uaudio.c b/sys/dev/usb/uaudio.c
index 062d519cc17..893190dd1ae 100644
--- a/sys/dev/usb/uaudio.c
+++ b/sys/dev/usb/uaudio.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: uaudio.c,v 1.106 2014/11/18 23:55:01 krw Exp $ */
+/* $OpenBSD: uaudio.c,v 1.107 2014/12/09 07:05:06 doug Exp $ */
/* $NetBSD: uaudio.c,v 1.90 2004/10/29 17:12:53 kent Exp $ */
/*
@@ -1443,8 +1443,8 @@ uaudio_io_terminaltype(int outtype, struct io_terminal *iot, int id)
return NULL;
case UDESCSUB_AC_MIXER:
it->inputs_size = 0;
- it->inputs = malloc(sizeof(struct terminal_list *)
- * it->d.mu->bNrInPins, M_TEMP, M_NOWAIT);
+ it->inputs = mallocarray(it->d.mu->bNrInPins,
+ sizeof(struct terminal_list *), M_TEMP, M_NOWAIT);
if (it->inputs == NULL) {
printf("uaudio_io_terminaltype: no memory\n");
return NULL;
@@ -1458,8 +1458,8 @@ uaudio_io_terminaltype(int outtype, struct io_terminal *iot, int id)
return uaudio_merge_terminal_list(it);
case UDESCSUB_AC_SELECTOR:
it->inputs_size = 0;
- it->inputs = malloc(sizeof(struct terminal_list *)
- * it->d.su->bNrInPins, M_TEMP, M_NOWAIT);
+ it->inputs = mallocarray(it->d.su->bNrInPins,
+ sizeof(struct terminal_list *), M_TEMP, M_NOWAIT);
if (it->inputs == NULL) {
printf("uaudio_io_terminaltype: no memory\n");
return NULL;
@@ -1473,8 +1473,8 @@ uaudio_io_terminaltype(int outtype, struct io_terminal *iot, int id)
return uaudio_merge_terminal_list(it);
case UDESCSUB_AC_PROCESSING:
it->inputs_size = 0;
- it->inputs = malloc(sizeof(struct terminal_list *)
- * it->d.pu->bNrInPins, M_TEMP, M_NOWAIT);
+ it->inputs = mallocarray(it->d.pu->bNrInPins,
+ sizeof(struct terminal_list *), M_TEMP, M_NOWAIT);
if (it->inputs == NULL) {
printf("uaudio_io_terminaltype: no memory\n");
return NULL;
@@ -1488,8 +1488,8 @@ uaudio_io_terminaltype(int outtype, struct io_terminal *iot, int id)
return uaudio_merge_terminal_list(it);
case UDESCSUB_AC_EXTENSION:
it->inputs_size = 0;
- it->inputs = malloc(sizeof(struct terminal_list *)
- * it->d.eu->bNrInPins, M_TEMP, M_NOWAIT);
+ it->inputs = mallocarray(it->d.eu->bNrInPins,
+ sizeof(struct terminal_list *), M_TEMP, M_NOWAIT);
if (it->inputs == NULL) {
printf("uaudio_io_terminaltype: no memory\n");
return NULL;
@@ -1562,7 +1562,7 @@ uaudio_create_encodings(struct uaudio_softc *sc)
}
sc->sc_nencs = 0;
- sc->sc_encs = malloc(sizeof(struct audio_encoding) * nencs,
+ sc->sc_encs = mallocarray(nencs, sizeof(struct audio_encoding),
M_USBDEV, M_NOWAIT);
if (sc->sc_encs == NULL) {
printf("%s: no memory\n", __func__);
diff --git a/sys/dev/usb/udl.c b/sys/dev/usb/udl.c
index abe5400f833..167648e2cb2 100644
--- a/sys/dev/usb/udl.c
+++ b/sys/dev/usb/udl.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: udl.c,v 1.80 2014/07/12 18:48:52 tedu Exp $ */
+/* $OpenBSD: udl.c,v 1.81 2014/12/09 07:05:06 doug Exp $ */
/*
* Copyright (c) 2009 Marcus Glocker <mglocker@openbsd.org>
@@ -652,7 +652,7 @@ udl_alloc_screen(void *v, const struct wsscreen_descr *type,
*curyp = 0;
/* allocate character backing store */
- sc->sc_cbs = malloc((sc->sc_ri.ri_rows * sc->sc_ri.ri_cols) *
+ sc->sc_cbs = mallocarray(sc->sc_ri.ri_rows, sc->sc_ri.ri_cols *
sizeof(*sc->sc_cbs), M_DEVBUF, M_NOWAIT|M_ZERO);
if (sc->sc_cbs == NULL) {
printf("%s: can't allocate mem for character backing store!\n",
diff --git a/sys/dev/usb/uhci.c b/sys/dev/usb/uhci.c
index 5d5a990d0b4..bcccbd5b444 100644
--- a/sys/dev/usb/uhci.c
+++ b/sys/dev/usb/uhci.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: uhci.c,v 1.132 2014/10/30 23:50:25 mpi Exp $ */
+/* $OpenBSD: uhci.c,v 1.133 2014/12/09 07:05:06 doug Exp $ */
/* $NetBSD: uhci.c,v 1.172 2003/02/23 04:19:26 simonb Exp $ */
/* $FreeBSD: src/sys/dev/usb/uhci.c,v 1.33 1999/11/17 22:33:41 n_hibma Exp $ */
@@ -2610,7 +2610,8 @@ uhci_device_setintr(struct uhci_softc *sc, struct uhci_pipe *upipe, int ival)
npoll = (UHCI_VFRAMELIST_COUNT + ival - 1) / ival;
DPRINTFN(2, ("uhci_device_setintr: ival=%d npoll=%d\n", ival, npoll));
- qhs = malloc(npoll * sizeof(struct uhci_soft_qh *), M_USBHC, M_NOWAIT);
+ qhs = mallocarray(npoll, sizeof(struct uhci_soft_qh *), M_USBHC,
+ M_NOWAIT);
if (qhs == NULL)
return (USBD_NOMEM);
diff --git a/sys/dev/usb/uhub.c b/sys/dev/usb/uhub.c
index abec212b8a8..593ea693a8f 100644
--- a/sys/dev/usb/uhub.c
+++ b/sys/dev/usb/uhub.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: uhub.c,v 1.80 2014/11/23 12:19:08 mpi Exp $ */
+/* $OpenBSD: uhub.c,v 1.81 2014/12/09 07:05:06 doug Exp $ */
/* $NetBSD: uhub.c,v 1.64 2003/02/08 03:32:51 ichiro Exp $ */
/* $FreeBSD: src/sys/dev/usb/uhub.c,v 1.18 1999/11/17 22:33:43 n_hibma Exp $ */
@@ -209,7 +209,7 @@ uhub_attach(struct device *parent, struct device *self, void *aux)
hub = malloc(sizeof(*hub), M_USBDEV, M_NOWAIT);
if (hub == NULL)
return;
- hub->ports = malloc(sizeof(struct usbd_port) * nports,
+ hub->ports = mallocarray(nports, sizeof(struct usbd_port),
M_USBDEV, M_NOWAIT);
if (hub->ports == NULL) {
free(hub, M_USBDEV, 0);
@@ -288,7 +288,7 @@ uhub_attach(struct device *parent, struct device *self, void *aux)
*/
if (UHUB_IS_HIGH_SPEED(sc)) {
- tts = malloc((UHUB_IS_SINGLE_TT(sc) ? 1 : nports) *
+ tts = mallocarray((UHUB_IS_SINGLE_TT(sc) ? 1 : nports),
sizeof (struct usbd_tt), M_USBDEV, M_NOWAIT);
if (!tts)
goto bad;
diff --git a/sys/dev/usb/umidi.c b/sys/dev/usb/umidi.c
index 141cef9a86f..1b567e89bd6 100644
--- a/sys/dev/usb/umidi.c
+++ b/sys/dev/usb/umidi.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: umidi.c,v 1.39 2014/07/12 18:48:52 tedu Exp $ */
+/* $OpenBSD: umidi.c,v 1.40 2014/12/09 07:05:06 doug Exp $ */
/* $NetBSD: umidi.c,v 1.16 2002/07/11 21:14:32 augustss Exp $ */
/*
* Copyright (c) 2001 The NetBSD Foundation, Inc.
@@ -449,10 +449,9 @@ alloc_all_endpoints_fixed_ep(struct umidi_softc *sc)
sc->sc_in_num_jacks = 0;
sc->sc_out_num_endpoints = fp->num_out_ep;
sc->sc_in_num_endpoints = fp->num_in_ep;
- sc->sc_endpoints = malloc(sizeof(*sc->sc_out_ep)*
- (sc->sc_out_num_endpoints+
- sc->sc_in_num_endpoints),
- M_USBDEV, M_WAITOK | M_CANFAIL);
+ sc->sc_endpoints = mallocarray(sc->sc_out_num_endpoints +
+ sc->sc_in_num_endpoints, sizeof(*sc->sc_out_ep), M_USBDEV,
+ M_WAITOK | M_CANFAIL);
if (!sc->sc_endpoints) {
return USBD_NOMEM;
}
@@ -592,10 +591,9 @@ alloc_all_endpoints_yamaha(struct umidi_softc *sc)
sc->sc_in_num_endpoints = 0;
sc->sc_in_num_jacks = 0;
}
- sc->sc_endpoints = malloc(sizeof(struct umidi_endpoint)*
- (sc->sc_out_num_endpoints+
- sc->sc_in_num_endpoints),
- M_USBDEV, M_WAITOK | M_CANFAIL);
+ sc->sc_endpoints = mallocarray(sc->sc_out_num_endpoints +
+ sc->sc_in_num_endpoints, sizeof(struct umidi_endpoint),
+ M_USBDEV, M_WAITOK | M_CANFAIL);
if (!sc->sc_endpoints)
return USBD_NOMEM;
if (sc->sc_out_num_endpoints) {
@@ -636,8 +634,8 @@ alloc_all_endpoints_genuine(struct umidi_softc *sc)
interface_desc = usbd_get_interface_descriptor(sc->sc_iface);
num_ep = interface_desc->bNumEndpoints;
- sc->sc_endpoints = p = malloc(sizeof(struct umidi_endpoint) * num_ep,
- M_USBDEV, M_WAITOK | M_CANFAIL);
+ sc->sc_endpoints = p = mallocarray(num_ep,
+ sizeof(struct umidi_endpoint), M_USBDEV, M_WAITOK | M_CANFAIL);
if (!p)
return USBD_NOMEM;
@@ -727,10 +725,8 @@ alloc_all_jacks(struct umidi_softc *sc)
struct umidi_jack *jack, **rjack;
/* allocate/initialize structures */
- sc->sc_jacks =
- malloc(sizeof(*sc->sc_out_jacks)*(sc->sc_in_num_jacks+
- sc->sc_out_num_jacks),
- M_USBDEV, M_WAITOK | M_CANFAIL);
+ sc->sc_jacks = mallocarray(sc->sc_in_num_jacks + sc->sc_out_num_jacks,
+ sizeof(*sc->sc_out_jacks), M_USBDEV, M_WAITOK | M_CANFAIL);
if (!sc->sc_jacks)
return USBD_NOMEM;
sc->sc_out_jacks =
@@ -968,8 +964,8 @@ static usbd_status
alloc_all_mididevs(struct umidi_softc *sc, int nmidi)
{
sc->sc_num_mididevs = nmidi;
- sc->sc_mididevs = malloc(sizeof(*sc->sc_mididevs)*nmidi, M_USBDEV,
- M_WAITOK | M_CANFAIL | M_ZERO);
+ sc->sc_mididevs = mallocarray(nmidi, sizeof(*sc->sc_mididevs),
+ M_USBDEV, M_WAITOK | M_CANFAIL | M_ZERO);
if (!sc->sc_mididevs)
return USBD_NOMEM;
diff --git a/sys/dev/usb/usb_subr.c b/sys/dev/usb/usb_subr.c
index 63819d8e092..c9f48b13ccb 100644
--- a/sys/dev/usb/usb_subr.c
+++ b/sys/dev/usb/usb_subr.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: usb_subr.c,v 1.113 2014/11/10 11:01:13 mpi Exp $ */
+/* $OpenBSD: usb_subr.c,v 1.114 2014/12/09 07:05:06 doug Exp $ */
/* $NetBSD: usb_subr.c,v 1.103 2003/01/10 11:19:13 augustss Exp $ */
/* $FreeBSD: src/sys/dev/usb/usb_subr.c,v 1.18 1999/11/17 22:33:47 n_hibma Exp $ */
@@ -491,8 +491,8 @@ usbd_fill_iface_data(struct usbd_device *dev, int ifaceidx, int altidx)
nendpt = ifc->idesc->bNumEndpoints;
DPRINTFN(4,("usbd_fill_iface_data: found idesc nendpt=%d\n", nendpt));
if (nendpt != 0) {
- ifc->endpoints = malloc(nendpt * sizeof(struct usbd_endpoint),
- M_USB, M_NOWAIT);
+ ifc->endpoints = mallocarray(nendpt,
+ sizeof(struct usbd_endpoint), M_USB, M_NOWAIT);
if (ifc->endpoints == NULL)
return (USBD_NOMEM);
} else
@@ -744,7 +744,7 @@ usbd_set_config_index(struct usbd_device *dev, int index, int msg)
/* Allocate and fill interface data. */
nifc = cdp->bNumInterface;
- dev->ifaces = malloc(nifc * sizeof(struct usbd_interface),
+ dev->ifaces = mallocarray(nifc, sizeof(struct usbd_interface),
M_USB, M_NOWAIT | M_ZERO);
if (dev->ifaces == NULL) {
err = USBD_NOMEM;