Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/nick-nhusb]: src/sys/dev/usb Move from usbd_{alloc, free}_xfer and usbd_{...
details: https://anonhg.NetBSD.org/src/rev/be4399de4376
branches: nick-nhusb
changeset: 334259:be4399de4376
user: skrll <skrll%NetBSD.org@localhost>
date: Tue Oct 06 21:32:15 2015 +0000
description:
Move from usbd_{alloc,free}_xfer and usbd_{alloc,free}_buffer to
usbd_{create,destroy}_xfer. The API change will allow future changes
to HCDs to simplify the transfer resource allocation and activation.
Several devices tested including ucom, umass, smsc, uvideo, and uaudio.
diffstat:
sys/dev/usb/aubtfwl.c | 22 +--
sys/dev/usb/auvitek.c | 28 +-----
sys/dev/usb/auvitek_dtv.c | 39 ++++++-
sys/dev/usb/auvitek_video.c | 25 +---
sys/dev/usb/emdtv_dtv.c | 51 +++++-----
sys/dev/usb/if_athn_usb.c | 94 ++++++++-----------
sys/dev/usb/if_atu.c | 73 +++++++-------
sys/dev/usb/if_aue.c | 86 ++++++++---------
sys/dev/usb/if_axe.c | 84 +++++++----------
sys/dev/usb/if_axen.c | 86 +++++++----------
sys/dev/usb/if_cdce.c | 72 +++++++--------
sys/dev/usb/if_cue.c | 79 +++++++---------
sys/dev/usb/if_kue.c | 91 ++++++++----------
sys/dev/usb/if_otus.c | 80 ++++++----------
sys/dev/usb/if_rum.c | 63 +++++-------
sys/dev/usb/if_run.c | 45 +++-----
sys/dev/usb/if_smsc.c | 78 +++++++---------
sys/dev/usb/if_udav.c | 98 ++++++++-----------
sys/dev/usb/if_upgt.c | 65 +++++--------
sys/dev/usb/if_upl.c | 81 +++++++----------
sys/dev/usb/if_ural.c | 94 +++++++------------
sys/dev/usb/if_url.c | 96 ++++++++-----------
sys/dev/usb/if_urndis.c | 81 +++++++---------
sys/dev/usb/if_urtw.c | 127 ++++++++++++--------------
sys/dev/usb/if_urtwn.c | 184 +++++++++++++++++++++------------------
sys/dev/usb/if_urtwnvar.h | 8 +-
sys/dev/usb/if_urtwreg.h | 8 +-
sys/dev/usb/if_zyd.c | 71 ++++++--------
sys/dev/usb/irmce.c | 81 +++++++++-------
sys/dev/usb/pseye.c | 39 ++++----
sys/dev/usb/stuirda.c | 56 +++++------
sys/dev/usb/u3g.c | 13 +-
sys/dev/usb/uaudio.c | 53 +++++-----
sys/dev/usb/ubt.c | 93 +++++++------------
sys/dev/usb/ucom.c | 188 +++++++++++++++++----------------------
sys/dev/usb/ucycom.c | 10 +-
sys/dev/usb/udl.c | 25 ++---
sys/dev/usb/udsir.c | 52 ++++------
sys/dev/usb/ugen.c | 138 +++++++++++-----------------
sys/dev/usb/uhidev.c | 18 +-
sys/dev/usb/uhidev.h | 4 +-
sys/dev/usb/uhso.c | 94 +++++++++----------
sys/dev/usb/uirda.c | 95 ++++++++-----------
sys/dev/usb/ulpt.c | 51 +++-------
sys/dev/usb/umass.c | 207 ++++++++++++++++++++++++++++++-------------
sys/dev/usb/umassvar.h | 41 ++++----
sys/dev/usb/umidi.c | 44 +++-----
sys/dev/usb/urio.c | 31 ++----
sys/dev/usb/usbdi.c | 92 ++++++++++++------
sys/dev/usb/usbdi.h | 34 +++---
sys/dev/usb/usbdi_util.c | 14 +-
sys/dev/usb/uscanner.c | 42 ++++----
sys/dev/usb/usscanner.c | 114 ++++++++++++-----------
sys/dev/usb/ustir.c | 54 ++++-------
sys/dev/usb/utoppy.c | 89 ++++++++----------
sys/dev/usb/uvideo.c | 65 +++++--------
56 files changed, 1781 insertions(+), 2065 deletions(-)
diffs (truncated from 7925 to 300 lines):
diff -r d5e4887c0ae7 -r be4399de4376 sys/dev/usb/aubtfwl.c
--- a/sys/dev/usb/aubtfwl.c Sun Oct 04 10:45:37 2015 +0000
+++ b/sys/dev/usb/aubtfwl.c Tue Oct 06 21:32:15 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: aubtfwl.c,v 1.5.10.7 2015/09/29 11:38:28 skrll Exp $ */
+/* $NetBSD: aubtfwl.c,v 1.5.10.8 2015/10/06 21:32:15 skrll Exp $ */
/*
* Copyright (c) 2011 Jonathan A. Kollasch
@@ -27,7 +27,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: aubtfwl.c,v 1.5.10.7 2015/09/29 11:38:28 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: aubtfwl.c,v 1.5.10.8 2015/10/06 21:32:15 skrll Exp $");
#include <sys/param.h>
#include <dev/usb/usb.h>
@@ -149,19 +149,13 @@
goto out_firmware;
}
- xfer = usbd_alloc_xfer(sc->sc_udev);
- if (xfer == NULL) {
- aprint_error_dev(self, "failed to alloc xfer\n");
- error = 1;
+ error = usbd_create_xfer(pipe, AR3K_FIRMWARE_CHUNK_SIZE, 0, 0, &xfer);
+ if (error) {
+ aprint_verbose_dev(self, "cannot create xfer(%d)\n",
+ error);
goto out_pipe;
}
-
- buf = usbd_alloc_buffer(xfer, AR3K_FIRMWARE_CHUNK_SIZE);
- if (buf == NULL) {
- aprint_error_dev(self, "failed to alloc buffer\n");
- error = 1;
- goto out_xfer;
- }
+ buf = usbd_get_buffer(xfer);
error = firmware_read(fwh, fwo, buf, AR3K_FIRMWARE_HEADER_SIZE);
if (error != 0) {
@@ -204,7 +198,7 @@
aprint_verbose_dev(self, "firmware load complete\n");
out_xfer:
- usbd_free_xfer(xfer);
+ usbd_destroy_xfer(xfer);
out_pipe:
usbd_close_pipe(pipe);
out_firmware:
diff -r d5e4887c0ae7 -r be4399de4376 sys/dev/usb/auvitek.c
--- a/sys/dev/usb/auvitek.c Sun Oct 04 10:45:37 2015 +0000
+++ b/sys/dev/usb/auvitek.c Tue Oct 06 21:32:15 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: auvitek.c,v 1.9.4.2 2015/03/21 11:33:37 skrll Exp $ */
+/* $NetBSD: auvitek.c,v 1.9.4.3 2015/10/06 21:32:15 skrll Exp $ */
/*-
* Copyright (c) 2010 Jared D. McNeill <jmcneill%invisible.ca@localhost>
@@ -31,7 +31,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: auvitek.c,v 1.9.4.2 2015/03/21 11:33:37 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: auvitek.c,v 1.9.4.3 2015/10/06 21:32:15 skrll Exp $");
#include <sys/types.h>
#include <sys/param.h>
@@ -219,24 +219,6 @@
return;
}
- for (i = 0; i < AUVITEK_NBULK_XFERS; i++) {
- sc->sc_ab.ab_bx[i].bx_sc = sc;
- sc->sc_ab.ab_bx[i].bx_xfer = usbd_alloc_xfer(sc->sc_udev);
- if (sc->sc_ab.ab_bx[i].bx_xfer == NULL) {
- aprint_error_dev(self, "couldn't allocate xfer\n");
- sc->sc_dying = 1;
- return;
- }
- sc->sc_ab.ab_bx[i].bx_buffer = usbd_alloc_buffer(
- sc->sc_ab.ab_bx[i].bx_xfer, AUVITEK_BULK_BUFLEN);
- if (sc->sc_ab.ab_bx[i].bx_buffer == NULL) {
- aprint_error_dev(self,
- "couldn't allocate xfer buffer\n");
- sc->sc_dying = 1;
- return;
- }
- }
-
aprint_debug_dev(self, "bulk endpoint 0x%02x size %d\n",
sc->sc_ab.ab_endpt, AUVITEK_BULK_BUFLEN);
@@ -278,7 +260,6 @@
auvitek_detach(device_t self, int flags)
{
struct auvitek_softc *sc = device_private(self);
- unsigned int i;
sc->sc_dying = 1;
@@ -297,11 +278,6 @@
mutex_destroy(&sc->sc_subdev_lock);
- for (i = 0; i < AUVITEK_NBULK_XFERS; i++) {
- if (sc->sc_ab.ab_bx[i].bx_xfer)
- usbd_free_xfer(sc->sc_ab.ab_bx[i].bx_xfer);
- }
-
return 0;
}
diff -r d5e4887c0ae7 -r be4399de4376 sys/dev/usb/auvitek_dtv.c
--- a/sys/dev/usb/auvitek_dtv.c Sun Oct 04 10:45:37 2015 +0000
+++ b/sys/dev/usb/auvitek_dtv.c Tue Oct 06 21:32:15 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: auvitek_dtv.c,v 1.6.14.3 2015/03/19 17:26:42 skrll Exp $ */
+/* $NetBSD: auvitek_dtv.c,v 1.6.14.4 2015/10/06 21:32:15 skrll Exp $ */
/*-
* Copyright (c) 2011 Jared D. McNeill <jmcneill%invisible.ca@localhost>
@@ -31,7 +31,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: auvitek_dtv.c,v 1.6.14.3 2015/03/19 17:26:42 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: auvitek_dtv.c,v 1.6.14.4 2015/10/06 21:32:15 skrll Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -152,7 +152,26 @@
if (sc->sc_xc5k == NULL)
return ENXIO;
- return auvitek_dtv_init_pipes(sc);
+ int err = auvitek_dtv_init_pipes(sc);
+ if (err)
+ return err;
+
+ for (size_t i = 0; i < AUVITEK_NBULK_XFERS; i++) {
+ sc->sc_ab.ab_bx[i].bx_sc = sc;
+ err = usbd_create_xfer(sc->sc_ab.ab_pipe,
+ AUVITEK_BULK_BUFLEN, 0, 0, &sc->sc_ab.ab_bx[i].bx_xfer);
+ if (err) {
+ aprint_error_dev(sc->sc_dev,
+ "couldn't allocate xfer\n");
+ sc->sc_dying = 1;
+ return err;
+ }
+ sc->sc_ab.ab_bx[i].bx_buffer = usbd_get_buffer(
+ sc->sc_ab.ab_bx[i].bx_xfer);
+ }
+
+
+ return 0;
}
static void
@@ -163,6 +182,11 @@
auvitek_dtv_stop_transfer(sc);
auvitek_dtv_close_pipes(sc);
+ for (size_t i = 0; i < AUVITEK_NBULK_XFERS; i++) {
+ if (sc->sc_ab.ab_bx[i].bx_xfer)
+ usbd_destroy_xfer(sc->sc_ab.ab_bx[i].bx_xfer);
+ }
+
sc->sc_dtvsubmitcb = NULL;
sc->sc_dtvsubmitarg = NULL;
}
@@ -344,13 +368,10 @@
auvitek_dtv_bulk_start1(struct auvitek_bulk_xfer *bx)
{
struct auvitek_softc *sc = bx->bx_sc;
- struct auvitek_bulk *ab = &sc->sc_ab;
- int err;
+ usbd_status err;
- usbd_setup_xfer(bx->bx_xfer, ab->ab_pipe, bx,
- bx->bx_buffer, AUVITEK_BULK_BUFLEN,
- //USBD_SHORT_XFER_OK, USBD_NO_TIMEOUT,
- 0, 100,
+ usbd_setup_xfer(bx->bx_xfer, bx, bx->bx_buffer, AUVITEK_BULK_BUFLEN,
+ 0 /* USBD_SHORT_XFER_OK */, 100 /* USBD_NO_TIMEOUT */,
auvitek_dtv_bulk_cb);
KERNEL_LOCK(1, curlwp);
diff -r d5e4887c0ae7 -r be4399de4376 sys/dev/usb/auvitek_video.c
--- a/sys/dev/usb/auvitek_video.c Sun Oct 04 10:45:37 2015 +0000
+++ b/sys/dev/usb/auvitek_video.c Tue Oct 06 21:32:15 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: auvitek_video.c,v 1.6.32.3 2015/03/19 17:26:42 skrll Exp $ */
+/* $NetBSD: auvitek_video.c,v 1.6.32.4 2015/10/06 21:32:15 skrll Exp $ */
/*-
* Copyright (c) 2010 Jared D. McNeill <jmcneill%invisible.ca@localhost>
@@ -31,7 +31,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: auvitek_video.c,v 1.6.32.3 2015/03/19 17:26:42 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: auvitek_video.c,v 1.6.32.4 2015/10/06 21:32:15 skrll Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -584,20 +584,15 @@
for (i = 0; i < AUVITEK_NISOC_XFERS; i++) {
struct auvitek_isoc *isoc = &ax->ax_i[i];
- isoc->i_xfer = usbd_alloc_xfer(sc->sc_udev);
- if (isoc->i_xfer == NULL) {
+ int error = usbd_create_xfer(ax->ax_pipe,
+ nframes * uframe_len, 0, ax->ax_nframes, &isoc->i_xfer);
+ if (error) {
aprint_error_dev(sc->sc_dev,
- "couldn't allocate usb xfer\n");
- return ENOMEM;
+ "couldn't create usb xfer\n");
+ return error;
}
- isoc->i_buf = usbd_alloc_buffer(isoc->i_xfer,
- nframes * uframe_len);
- if (isoc->i_buf == NULL) {
- aprint_error_dev(sc->sc_dev,
- "couldn't allocate usb xfer buffer\n");
- return ENOMEM;
- }
+ isoc->i_buf = usbd_get_buffer(isoc->i_xfer);
}
return auvitek_isoc_start(sc);
@@ -619,8 +614,7 @@
for (i = 0; i < AUVITEK_NISOC_XFERS; i++) {
struct auvitek_isoc *isoc = &ax->ax_i[i];
if (isoc->i_xfer != NULL) {
- usbd_free_buffer(isoc->i_xfer);
- usbd_free_xfer(isoc->i_xfer);
+ usbd_destroy_xfer(isoc->i_xfer);
isoc->i_xfer = NULL;
}
if (isoc->i_frlengths != NULL) {
@@ -675,7 +669,6 @@
isoc->i_frlengths[i] = ax->ax_uframe_len;
usbd_setup_isoc_xfer(isoc->i_xfer,
- ax->ax_pipe,
isoc,
isoc->i_frlengths,
ax->ax_nframes,
diff -r d5e4887c0ae7 -r be4399de4376 sys/dev/usb/emdtv_dtv.c
--- a/sys/dev/usb/emdtv_dtv.c Sun Oct 04 10:45:37 2015 +0000
+++ b/sys/dev/usb/emdtv_dtv.c Tue Oct 06 21:32:15 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: emdtv_dtv.c,v 1.10.14.3 2015/04/06 15:18:13 skrll Exp $ */
+/* $NetBSD: emdtv_dtv.c,v 1.10.14.4 2015/10/06 21:32:15 skrll Exp $ */
/*-
* Copyright (c) 2008, 2011 Jared D. McNeill <jmcneill%invisible.ca@localhost>
@@ -27,7 +27,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: emdtv_dtv.c,v 1.10.14.3 2015/04/06 15:18:13 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: emdtv_dtv.c,v 1.10.14.4 2015/10/06 21:32:15 skrll Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -182,6 +182,20 @@
if (sc->sc_dying)
return ENXIO;
+ aprint_debug_dev(sc->sc_dev, "allocating isoc xfers (pktsz %d)\n",
+ sc->sc_isoc_maxpacketsize);
+
+ for (size_t i = 0; i < EMDTV_NXFERS; i++) {
+ int error = usbd_create_xfer(sc->sc_isoc_pipe,
+ sc->sc_isoc_buflen, USBD_SHORT_XFER_OK, EMDTV_NFRAMES,
+ &sc->sc_ix[i].ix_xfer);
+ if (error)
+ return error;
+ sc->sc_ix[i].ix_buf = usbd_get_buffer(sc->sc_ix[i].ix_xfer);
+ aprint_debug_dev(sc->sc_dev, " ix[%zu] xfer %p buf %p\n",
+ i, sc->sc_ix[i].ix_xfer, sc->sc_ix[i].ix_buf);
+ }
+
switch (sc->sc_board->eb_tuner) {
case EMDTV_TUNER_XC3028:
if (sc->sc_xc3028 == NULL) {
@@ -234,6 +248,15 @@
static void
emdtv_dtv_close(void *priv)
{
+ struct emdtv_softc *sc = priv;
+
+ for (size_t i = 0; i < EMDTV_NXFERS; i++)
+ if (sc->sc_ix[i].ix_xfer) {
Home |
Main Index |
Thread Index |
Old Index