summaryrefslogtreecommitdiff
path: root/sys/dev/usb
diff options
context:
space:
mode:
authoraugustss <augustss@NetBSD.org>1999-11-12 00:34:57 +0000
committeraugustss <augustss@NetBSD.org>1999-11-12 00:34:57 +0000
commit0d2fabdf26fec9670f7cdf19ed0affe8cdc6a3e7 (patch)
treee2bff9b985890027ab025cd62b5f6c850ec1b777 /sys/dev/usb
parentc8ad47986a4222cd815107dcf4333e1b2317445c (diff)
A number of stylistic changes to increase readability (many suggested
by Nick Hibma): use NULL not 0 declare all local definitions static rename s/usbd_request/usbd_xfer/ s/reqh/xfer/ rename s/r/err/ use implicit test for no err KNF
Diffstat (limited to 'sys/dev/usb')
-rw-r--r--sys/dev/usb/TODO7
-rw-r--r--sys/dev/usb/hid.c16
-rw-r--r--sys/dev/usb/ohci.c782
-rw-r--r--sys/dev/usb/ohcivar.h6
-rw-r--r--sys/dev/usb/uaudio.c316
-rw-r--r--sys/dev/usb/ucom.c4
-rw-r--r--sys/dev/usb/ugen.c249
-rw-r--r--sys/dev/usb/uhci.c810
-rw-r--r--sys/dev/usb/uhcivar.h6
-rw-r--r--sys/dev/usb/uhid.c78
-rw-r--r--sys/dev/usb/uhub.c107
-rw-r--r--sys/dev/usb/ukbd.c52
-rw-r--r--sys/dev/usb/ulpt.c69
-rw-r--r--sys/dev/usb/umass.c37
-rw-r--r--sys/dev/usb/umodem.c44
-rw-r--r--sys/dev/usb/ums.c48
-rw-r--r--sys/dev/usb/usb.c46
-rw-r--r--sys/dev/usb/usb_mem.c26
-rw-r--r--sys/dev/usb/usb_quirks.c8
-rw-r--r--sys/dev/usb/usb_subr.c215
-rw-r--r--sys/dev/usb/usbdi.c573
-rw-r--r--sys/dev/usb/usbdi.h28
-rw-r--r--sys/dev/usb/usbdi_util.c128
-rw-r--r--sys/dev/usb/usbdi_util.h4
-rw-r--r--sys/dev/usb/usbdivar.h24
25 files changed, 1846 insertions, 1837 deletions
diff --git a/sys/dev/usb/TODO b/sys/dev/usb/TODO
index e2e87db45fb..e50bf7a15cc 100644
--- a/sys/dev/usb/TODO
+++ b/sys/dev/usb/TODO
@@ -41,15 +41,10 @@ uaudio problems:
test with more devices
Stylistic changes:
- use NULL not 0
- declare all local definitions static
- rename s/request/xfer/
use usb_ and usbd_ consistently
- rename s/r/err/
- use implicit test for no err
- indent continuation lines according to KNF
rearrange the contents and names of some files (Nick)
Document device driver API.
Document HC driver API.
+
diff --git a/sys/dev/usb/hid.c b/sys/dev/usb/hid.c
index c3a854ec103..4c42042a82c 100644
--- a/sys/dev/usb/hid.c
+++ b/sys/dev/usb/hid.c
@@ -1,4 +1,4 @@
-/* $NetBSD: hid.c,v 1.9 1999/10/13 08:10:55 augustss Exp $ */
+/* $NetBSD: hid.c,v 1.10 1999/11/12 00:34:57 augustss Exp $ */
/*
* Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -111,7 +111,7 @@ void
hid_end_parse(s)
struct hid_data *s;
{
- while (s->cur.next) {
+ while (s->cur.next != NULL) {
struct hid_item *hi = s->cur.next->next;
free(s->cur.next, M_TEMP);
s->cur.next = hi;
@@ -133,7 +133,7 @@ hid_get_item(s, h)
int i;
top:
- if (s->multimax) {
+ if (s->multimax != 0) {
if (s->multi < s->multimax) {
c->usage = s->usages[min(s->multi, s->nu-1)];
s->multi++;
@@ -367,7 +367,7 @@ hid_get_item(s, h)
}
}
-int
+int
hid_report_size(buf, len, k, idp)
void *buf;
int len;
@@ -380,11 +380,11 @@ hid_report_size(buf, len, k, idp)
id = 0;
for (d = hid_start_parse(buf, len, 1<<k); hid_get_item(d, &h); )
- if (h.report_ID)
+ if (h.report_ID != 0)
id = h.report_ID;
hid_end_parse(d);
size = h.loc.pos;
- if (id) {
+ if (id != 0) {
size += 8;
*idp = id; /* XXX wrong */
} else
@@ -406,9 +406,9 @@ hid_locate(desc, size, u, k, loc, flags)
for (d = hid_start_parse(desc, size, 1<<k); hid_get_item(d, &h); ) {
if (h.kind == k && !(h.flags & HIO_CONST) && h.usage == u) {
- if (loc)
+ if (loc != NULL)
*loc = h.loc;
- if (flags)
+ if (flags != NULL)
*flags = h.flags;
hid_end_parse(d);
return (1);
diff --git a/sys/dev/usb/ohci.c b/sys/dev/usb/ohci.c
index 3765c9860b0..d9ab44c6ce9 100644
--- a/sys/dev/usb/ohci.c
+++ b/sys/dev/usb/ohci.c
@@ -1,4 +1,4 @@
-/* $NetBSD: ohci.c,v 1.52 1999/10/13 08:10:55 augustss Exp $ */
+/* $NetBSD: ohci.c,v 1.53 1999/11/12 00:34:57 augustss Exp $ */
/*
* Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -104,94 +104,103 @@ int ohcidebug = 0;
struct ohci_pipe;
-ohci_soft_ed_t *ohci_alloc_sed __P((ohci_softc_t *));
-void ohci_free_sed __P((ohci_softc_t *, ohci_soft_ed_t *));
-
-ohci_soft_td_t *ohci_alloc_std __P((ohci_softc_t *));
-void ohci_free_std __P((ohci_softc_t *, ohci_soft_td_t *));
-
-void ohci_free_std_chain __P((ohci_softc_t *,
- ohci_soft_td_t *, ohci_soft_td_t *));
-usbd_status ohci_alloc_std_chain __P((struct ohci_pipe *, ohci_softc_t *,
- int, int, int, usb_dma_t *,
- ohci_soft_td_t *,
- ohci_soft_td_t **));
-
-void ohci_power __P((int, void *));
-usbd_status ohci_open __P((usbd_pipe_handle));
-void ohci_poll __P((struct usbd_bus *));
-void ohci_waitintr __P((ohci_softc_t *, usbd_request_handle));
-void ohci_rhsc __P((ohci_softc_t *, usbd_request_handle));
-void ohci_process_done __P((ohci_softc_t *, ohci_physaddr_t));
-
-usbd_status ohci_device_request __P((usbd_request_handle reqh));
-void ohci_add_ed __P((ohci_soft_ed_t *, ohci_soft_ed_t *));
-void ohci_rem_ed __P((ohci_soft_ed_t *, ohci_soft_ed_t *));
-void ohci_hash_add_td __P((ohci_softc_t *, ohci_soft_td_t *));
-void ohci_hash_rem_td __P((ohci_softc_t *, ohci_soft_td_t *));
-ohci_soft_td_t *ohci_hash_find_td __P((ohci_softc_t *, ohci_physaddr_t));
-
-usbd_status ohci_allocm __P((struct usbd_bus *, usb_dma_t *, u_int32_t));
-void ohci_freem __P((struct usbd_bus *, usb_dma_t *));
-
-usbd_status ohci_root_ctrl_transfer __P((usbd_request_handle));
-usbd_status ohci_root_ctrl_start __P((usbd_request_handle));
-void ohci_root_ctrl_abort __P((usbd_request_handle));
-void ohci_root_ctrl_close __P((usbd_pipe_handle));
-
-usbd_status ohci_root_intr_transfer __P((usbd_request_handle));
-usbd_status ohci_root_intr_start __P((usbd_request_handle));
-void ohci_root_intr_abort __P((usbd_request_handle));
-void ohci_root_intr_close __P((usbd_pipe_handle));
-void ohci_root_intr_done __P((usbd_request_handle));
-
-usbd_status ohci_device_ctrl_transfer __P((usbd_request_handle));
-usbd_status ohci_device_ctrl_start __P((usbd_request_handle));
-void ohci_device_ctrl_abort __P((usbd_request_handle));
-void ohci_device_ctrl_close __P((usbd_pipe_handle));
-void ohci_device_ctrl_done __P((usbd_request_handle));
-
-usbd_status ohci_device_bulk_transfer __P((usbd_request_handle));
-usbd_status ohci_device_bulk_start __P((usbd_request_handle));
-void ohci_device_bulk_abort __P((usbd_request_handle));
-void ohci_device_bulk_close __P((usbd_pipe_handle));
-void ohci_device_bulk_done __P((usbd_request_handle));
-
-usbd_status ohci_device_intr_transfer __P((usbd_request_handle));
-usbd_status ohci_device_intr_start __P((usbd_request_handle));
-void ohci_device_intr_abort __P((usbd_request_handle));
-void ohci_device_intr_close __P((usbd_pipe_handle));
-void ohci_device_intr_done __P((usbd_request_handle));
-
-usbd_status ohci_device_isoc_transfer __P((usbd_request_handle));
-usbd_status ohci_device_isoc_start __P((usbd_request_handle));
-void ohci_device_isoc_abort __P((usbd_request_handle));
-void ohci_device_isoc_close __P((usbd_pipe_handle));
-void ohci_device_isoc_done __P((usbd_request_handle));
-
-usbd_status ohci_device_setintr __P((ohci_softc_t *sc,
- struct ohci_pipe *pipe, int ival));
-
-int ohci_str __P((usb_string_descriptor_t *, int, char *));
-
-void ohci_timeout __P((void *));
-void ohci_rhsc_able __P((ohci_softc_t *, int));
-
-void ohci_close_pipe __P((usbd_pipe_handle pipe,
- ohci_soft_ed_t *head));
-void ohci_abort_req __P((usbd_request_handle reqh,
- usbd_status status));
-void ohci_abort_req_end __P((void *));
-
-void ohci_device_clear_toggle __P((usbd_pipe_handle pipe));
-void ohci_noop __P((usbd_pipe_handle pipe));
+static ohci_soft_ed_t *ohci_alloc_sed __P((ohci_softc_t *));
+static void ohci_free_sed __P((ohci_softc_t *, ohci_soft_ed_t *));
+
+static ohci_soft_td_t *ohci_alloc_std __P((ohci_softc_t *));
+static void ohci_free_std __P((ohci_softc_t *, ohci_soft_td_t *));
+
+#if 0
+static void ohci_free_std_chain __P((ohci_softc_t *,
+ ohci_soft_td_t *, ohci_soft_td_t *));
+#endif
+static usbd_status ohci_alloc_std_chain __P((struct ohci_pipe *,
+ ohci_softc_t *, int, int, int, usb_dma_t *,
+ ohci_soft_td_t *, ohci_soft_td_t **));
+
+static void ohci_power __P((int, void *));
+static usbd_status ohci_open __P((usbd_pipe_handle));
+static void ohci_poll __P((struct usbd_bus *));
+static void ohci_waitintr __P((ohci_softc_t *,
+ usbd_xfer_handle));
+static void ohci_rhsc __P((ohci_softc_t *, usbd_xfer_handle));
+static void ohci_process_done __P((ohci_softc_t *,
+ ohci_physaddr_t));
+
+static usbd_status ohci_device_request __P((usbd_xfer_handle xfer));
+static void ohci_add_ed __P((ohci_soft_ed_t *, ohci_soft_ed_t *));
+static void ohci_rem_ed __P((ohci_soft_ed_t *, ohci_soft_ed_t *));
+static void ohci_hash_add_td __P((ohci_softc_t *,
+ ohci_soft_td_t *));
+static void ohci_hash_rem_td __P((ohci_softc_t *,
+ ohci_soft_td_t *));
+static ohci_soft_td_t *ohci_hash_find_td __P((ohci_softc_t *,
+ ohci_physaddr_t));
+
+static usbd_status ohci_allocm __P((struct usbd_bus *, usb_dma_t *,
+ u_int32_t));
+static void ohci_freem __P((struct usbd_bus *, usb_dma_t *));
+
+static usbd_status ohci_root_ctrl_transfer __P((usbd_xfer_handle));
+static usbd_status ohci_root_ctrl_start __P((usbd_xfer_handle));
+static void ohci_root_ctrl_abort __P((usbd_xfer_handle));
+static void ohci_root_ctrl_close __P((usbd_pipe_handle));
+
+static usbd_status ohci_root_intr_transfer __P((usbd_xfer_handle));
+static usbd_status ohci_root_intr_start __P((usbd_xfer_handle));
+static void ohci_root_intr_abort __P((usbd_xfer_handle));
+static void ohci_root_intr_close __P((usbd_pipe_handle));
+static void ohci_root_intr_done __P((usbd_xfer_handle));
+
+static usbd_status ohci_device_ctrl_transfer __P((usbd_xfer_handle));
+static usbd_status ohci_device_ctrl_start __P((usbd_xfer_handle));
+static void ohci_device_ctrl_abort __P((usbd_xfer_handle));
+static void ohci_device_ctrl_close __P((usbd_pipe_handle));
+static void ohci_device_ctrl_done __P((usbd_xfer_handle));
+
+static usbd_status ohci_device_bulk_transfer __P((usbd_xfer_handle));
+static usbd_status ohci_device_bulk_start __P((usbd_xfer_handle));
+static void ohci_device_bulk_abort __P((usbd_xfer_handle));
+static void ohci_device_bulk_close __P((usbd_pipe_handle));
+static void ohci_device_bulk_done __P((usbd_xfer_handle));
+
+static usbd_status ohci_device_intr_transfer __P((usbd_xfer_handle));
+static usbd_status ohci_device_intr_start __P((usbd_xfer_handle));
+static void ohci_device_intr_abort __P((usbd_xfer_handle));
+static void ohci_device_intr_close __P((usbd_pipe_handle));
+static void ohci_device_intr_done __P((usbd_xfer_handle));
+
+#if 0
+static usbd_status ohci_device_isoc_transfer __P((usbd_xfer_handle));
+static usbd_status ohci_device_isoc_start __P((usbd_xfer_handle));
+static void ohci_device_isoc_abort __P((usbd_xfer_handle));
+static void ohci_device_isoc_close __P((usbd_pipe_handle));
+static void ohci_device_isoc_done __P((usbd_xfer_handle));
+#endif
+
+static usbd_status ohci_device_setintr __P((ohci_softc_t *sc,
+ struct ohci_pipe *pipe, int ival));
+
+static int ohci_str __P((usb_string_descriptor_t *, int, char *));
+
+static void ohci_timeout __P((void *));
+static void ohci_rhsc_able __P((ohci_softc_t *, int));
+
+static void ohci_close_pipe __P((usbd_pipe_handle pipe,
+ ohci_soft_ed_t *head));
+static void ohci_abort_req __P((usbd_xfer_handle xfer,
+ usbd_status status));
+static void ohci_abort_req_end __P((void *));
+
+static void ohci_device_clear_toggle __P((usbd_pipe_handle pipe));
+static void ohci_noop __P((usbd_pipe_handle pipe));
#ifdef OHCI_DEBUG
-ohci_softc_t *thesc;
-void ohci_dumpregs __P((ohci_softc_t *));
-void ohci_dump_tds __P((ohci_soft_td_t *));
-void ohci_dump_td __P((ohci_soft_td_t *));
-void ohci_dump_ed __P((ohci_soft_ed_t *));
+static ohci_softc_t *thesc;
+static void ohci_dumpregs __P((ohci_softc_t *));
+static void ohci_dump_tds __P((ohci_soft_td_t *));
+static void ohci_dump_td __P((ohci_soft_td_t *));
+static void ohci_dump_ed __P((ohci_soft_ed_t *));
#endif
#define OWRITE4(sc, r, x) bus_space_write_4((sc)->iot, (sc)->ioh, (r), (x))
@@ -236,14 +245,14 @@ struct ohci_pipe {
#define OHCI_INTR_ENDPT 1
-struct usbd_bus_methods ohci_bus_methods = {
+static struct usbd_bus_methods ohci_bus_methods = {
ohci_open,
ohci_poll,
ohci_allocm,
ohci_freem,
};
-struct usbd_pipe_methods ohci_root_ctrl_methods = {
+static struct usbd_pipe_methods ohci_root_ctrl_methods = {
ohci_root_ctrl_transfer,
ohci_root_ctrl_start,
ohci_root_ctrl_abort,
@@ -252,7 +261,7 @@ struct usbd_pipe_methods ohci_root_ctrl_methods = {
0,
};
-struct usbd_pipe_methods ohci_root_intr_methods = {
+static struct usbd_pipe_methods ohci_root_intr_methods = {
ohci_root_intr_transfer,
ohci_root_intr_start,
ohci_root_intr_abort,
@@ -261,7 +270,7 @@ struct usbd_pipe_methods ohci_root_intr_methods = {
ohci_root_intr_done,
};
-struct usbd_pipe_methods ohci_device_ctrl_methods = {
+static struct usbd_pipe_methods ohci_device_ctrl_methods = {
ohci_device_ctrl_transfer,
ohci_device_ctrl_start,
ohci_device_ctrl_abort,
@@ -270,7 +279,7 @@ struct usbd_pipe_methods ohci_device_ctrl_methods = {
ohci_device_ctrl_done,
};
-struct usbd_pipe_methods ohci_device_intr_methods = {
+static struct usbd_pipe_methods ohci_device_intr_methods = {
ohci_device_intr_transfer,
ohci_device_intr_start,
ohci_device_intr_abort,
@@ -279,7 +288,7 @@ struct usbd_pipe_methods ohci_device_intr_methods = {
ohci_device_intr_done,
};
-struct usbd_pipe_methods ohci_device_bulk_methods = {
+static struct usbd_pipe_methods ohci_device_bulk_methods = {
ohci_device_bulk_transfer,
ohci_device_bulk_start,
ohci_device_bulk_abort,
@@ -289,7 +298,7 @@ struct usbd_pipe_methods ohci_device_bulk_methods = {
};
#if 0
-struct usbd_pipe_methods ohci_device_isoc_methods = {
+static struct usbd_pipe_methods ohci_device_isoc_methods = {
ohci_device_isoc_transfer,
ohci_device_isoc_start,
ohci_device_isoc_abort,
@@ -344,15 +353,15 @@ ohci_alloc_sed(sc)
ohci_softc_t *sc;
{
ohci_soft_ed_t *sed;
- usbd_status r;
+ usbd_status err;
int i, offs;
usb_dma_t dma;
- if (!sc->sc_freeeds) {
+ if (sc->sc_freeeds == NULL) {
DPRINTFN(2, ("ohci_alloc_sed: allocating chunk\n"));
- r = usb_allocmem(&sc->sc_bus, OHCI_SED_SIZE * OHCI_SED_CHUNK,
- OHCI_ED_ALIGN, &dma);
- if (r != USBD_NORMAL_COMPLETION)
+ err = usb_allocmem(&sc->sc_bus, OHCI_SED_SIZE * OHCI_SED_CHUNK,
+ OHCI_ED_ALIGN, &dma);
+ if (err)
return (0);
for(i = 0; i < OHCI_SED_CHUNK; i++) {
offs = i * OHCI_SED_SIZE;
@@ -383,15 +392,15 @@ ohci_alloc_std(sc)
ohci_softc_t *sc;
{
ohci_soft_td_t *std;
- usbd_status r;
+ usbd_status err;
int i, offs;
usb_dma_t dma;
- if (!sc->sc_freetds) {
+ if (sc->sc_freetds == NULL) {
DPRINTFN(2, ("ohci_alloc_std: allocating chunk\n"));
- r = usb_allocmem(&sc->sc_bus, OHCI_STD_SIZE * OHCI_STD_CHUNK,
- OHCI_TD_ALIGN, &dma);
- if (r != USBD_NORMAL_COMPLETION)
+ err = usb_allocmem(&sc->sc_bus, OHCI_STD_SIZE * OHCI_STD_CHUNK,
+ OHCI_TD_ALIGN, &dma);
+ if (err)
return (0);
for(i = 0; i < OHCI_STD_CHUNK; i++) {
offs = i * OHCI_STD_SIZE;
@@ -482,7 +491,8 @@ ohci_alloc_std_chain(upipe, sc, len, rd, shortok, dma, sp, ep)
return (USBD_NORMAL_COMPLETION);
}
-void
+#if 0
+static void
ohci_free_std_chain(sc, std, stdend)
ohci_softc_t *sc;
ohci_soft_td_t *std;
@@ -495,13 +505,14 @@ ohci_free_std_chain(sc, std, stdend)
ohci_free_std(sc, std);
}
}
+#endif
usbd_status
ohci_init(sc)
ohci_softc_t *sc;
{
ohci_soft_ed_t *sed, *psed;
- usbd_status r;
+ usbd_status err;
int rev;
int i;
u_int32_t s, ctl, ival, hcr, fm, per;
@@ -525,25 +536,25 @@ ohci_init(sc)
LIST_INIT(&sc->sc_hash_tds[i]);
/* Allocate the HCCA area. */
- r = usb_allocmem(&sc->sc_bus, OHCI_HCCA_SIZE,
+ err = usb_allocmem(&sc->sc_bus, OHCI_HCCA_SIZE,
OHCI_HCCA_ALIGN, &sc->sc_hccadma);
- if (r != USBD_NORMAL_COMPLETION)
- return (r);
+ if (err)
+ return (err);
sc->sc_hcca = (struct ohci_hcca *)KERNADDR(&sc->sc_hccadma);
memset(sc->sc_hcca, 0, OHCI_HCCA_SIZE);
sc->sc_eintrs = OHCI_NORMAL_INTRS;
sc->sc_ctrl_head = ohci_alloc_sed(sc);
- if (!sc->sc_ctrl_head) {
- r = USBD_NOMEM;
+ if (sc->sc_ctrl_head == NULL) {
+ err = USBD_NOMEM;
goto bad1;
}
sc->sc_ctrl_head->ed.ed_flags |= LE(OHCI_ED_SKIP);
sc->sc_bulk_head = ohci_alloc_sed(sc);
- if (!sc->sc_bulk_head) {
- r = USBD_NOMEM;
+ if (sc->sc_bulk_head == NULL) {
+ err = USBD_NOMEM;
goto bad2;
}
sc->sc_bulk_head->ed.ed_flags |= LE(OHCI_ED_SKIP);
@@ -551,10 +562,10 @@ ohci_init(sc)
/* Allocate all the dummy EDs that make up the interrupt tree. */
for (i = 0; i < OHCI_NO_EDS; i++) {
sed = ohci_alloc_sed(sc);
- if (!sed) {
+ if (sed == NULL) {
while (--i >= 0)
ohci_free_sed(sc, sc->sc_eds[i]);
- r = USBD_NOMEM;
+ err = USBD_NOMEM;
goto bad3;
}
/* All ED fields are set to 0. */
@@ -582,7 +593,7 @@ ohci_init(sc)
s = OREAD4(sc, OHCI_COMMAND_STATUS);
OWRITE4(sc, OHCI_COMMAND_STATUS, s | OHCI_OCR);
for (i = 0; i < 100 && (ctl & OHCI_IR); i++) {
- delay(1000);
+ usb_delay_ms(&sc->sc_bus, 1);
ctl = OREAD4(sc, OHCI_CONTROL);
}
if ((ctl & OHCI_IR) == 0) {
@@ -596,13 +607,13 @@ ohci_init(sc)
DPRINTF(("ohci_init: BIOS active\n"));
if ((ctl & OHCI_HCFS_MASK) != OHCI_HCFS_OPERATIONAL) {
OWRITE4(sc, OHCI_CONTROL, OHCI_HCFS_OPERATIONAL);
- delay(USB_RESUME_DELAY * 1000);
+ usb_delay_ms(&sc->sc_bus, USB_RESUME_DELAY);
}
} else {
DPRINTF(("ohci_init: cold started\n"));
reset:
/* Controller was cold started. */
- delay(USB_BUS_RESET_DELAY * 1000);
+ usb_delay_ms(&sc->sc_bus, USB_BUS_RESET_DELAY);
}
/*
@@ -626,7 +637,7 @@ ohci_init(sc)
}
if (hcr) {
printf("%s: reset timeout\n", USBDEVNAME(sc->sc_bus.bdev));
- r = USBD_IOERROR;
+ err = USBD_IOERROR;
goto bad3;
}
#ifdef OHCI_DEBUG
@@ -684,7 +695,7 @@ ohci_init(sc)
ohci_free_sed(sc, sc->sc_bulk_head);
bad1:
usb_freemem(&sc->sc_bus, &sc->sc_hccadma);
- return (r);
+ return (err);
}
usbd_status
@@ -773,11 +784,25 @@ ohci_dumpregs(sc)
}
#endif
+int ohci_intr1 __P((ohci_softc_t *));
+
int
ohci_intr(p)
void *p;
{
ohci_softc_t *sc = p;
+
+ /* If we get an interrupt while polling, then just ignore it. */
+ if (sc->sc_bus.use_polling)
+ return (0);
+
+ return (ohci_intr1(sc));
+}
+
+int
+ohci_intr1(sc)
+ ohci_softc_t *sc;
+{
u_int32_t intrs, eintrs;
ohci_physaddr_t done;
@@ -833,7 +858,7 @@ ohci_intr(p)
/* XXX what else */
}
if (eintrs & OHCI_RHSC) {
- ohci_rhsc(sc, sc->sc_intrreqh);
+ ohci_rhsc(sc, sc->sc_intrxfer);
intrs &= ~OHCI_RHSC;
/*
@@ -891,7 +916,7 @@ ohci_process_done(sc, done)
ohci_physaddr_t done;
{
ohci_soft_td_t *std, *sdone, *stdnext;
- usbd_request_handle reqh;
+ usbd_xfer_handle xfer;
int len, cc;
DPRINTFN(10,("ohci_process_done: done=0x%08lx\n", (u_long)done));
@@ -911,16 +936,16 @@ ohci_process_done(sc, done)
#endif
for (std = sdone; std; std = stdnext) {
- reqh = std->reqh;
+ xfer = std->xfer;
stdnext = std->dnext;
- DPRINTFN(10, ("ohci_process_done: std=%p reqh=%p hcpriv=%p\n",
- std, reqh, reqh->hcpriv));
+ DPRINTFN(10, ("ohci_process_done: std=%p xfer=%p hcpriv=%p\n",
+ std, xfer, xfer->hcpriv));
cc = OHCI_TD_GET_CC(LE(std->td.td_flags));
- usb_untimeout(ohci_timeout, reqh, reqh->timo_handle);
- if (reqh->status == USBD_CANCELLED ||
- reqh->status == USBD_TIMEOUT) {
+ usb_untimeout(ohci_timeout, xfer, xfer->timo_handle);
+ if (xfer->status == USBD_CANCELLED ||
+ xfer->status == USBD_TIMEOUT) {
DPRINTF(("ohci_process_done: cancel/timeout %p\n",
- reqh));
+ xfer));
/* Handled by abort routine. */
} else if (cc == OHCI_CC_NO_ERROR) {
len = std->len;
@@ -928,10 +953,10 @@ ohci_process_done(sc, done)
len -= LE(std->td.td_be) -
LE(std->td.td_cbp) + 1;
if (std->flags & OHCI_ADD_LEN)
- reqh->actlen += len;
+ xfer->actlen += len;
if (std->flags & OHCI_CALL_DONE) {
- reqh->status = USBD_NORMAL_COMPLETION;
- usb_transfer_complete(reqh);
+ xfer->status = USBD_NORMAL_COMPLETION;
+ usb_transfer_complete(xfer);
}
ohci_hash_rem_td(sc, std);
ohci_free_std(sc, std);
@@ -943,14 +968,14 @@ ohci_process_done(sc, done)
*/
ohci_soft_td_t *p, *n;
struct ohci_pipe *opipe =
- (struct ohci_pipe *)reqh->pipe;
+ (struct ohci_pipe *)xfer->pipe;
DPRINTFN(-1,("ohci_process_done: error cc=%d (%s)\n",
- OHCI_TD_GET_CC(LE(std->td.td_flags)),
- ohci_cc_strs[OHCI_TD_GET_CC(LE(std->td.td_flags))]));
+ OHCI_TD_GET_CC(LE(std->td.td_flags)),
+ ohci_cc_strs[OHCI_TD_GET_CC(LE(std->td.td_flags))]));
/* remove TDs */
- for (p = std; p->reqh == reqh; p = n) {
+ for (p = std; p->xfer == xfer; p = n) {
n = p->nexttd;
ohci_hash_rem_td(sc, p);
ohci_free_std(sc, p);
@@ -961,66 +986,66 @@ ohci_process_done(sc, done)
OWRITE4(sc, OHCI_COMMAND_STATUS, OHCI_CLF);
if (cc == OHCI_CC_STALL)
- reqh->status = USBD_STALLED;
+ xfer->status = USBD_STALLED;
else
- reqh->status = USBD_IOERROR;
- usb_transfer_complete(reqh);
+ xfer->status = USBD_IOERROR;
+ usb_transfer_complete(xfer);
}
}
}
void
-ohci_device_ctrl_done(reqh)
- usbd_request_handle reqh;
+ohci_device_ctrl_done(xfer)
+ usbd_xfer_handle xfer;
{
- DPRINTFN(10,("ohci_ctrl_done: reqh=%p\n", reqh));
+ DPRINTFN(10,("ohci_ctrl_done: xfer=%p\n", xfer));
#ifdef DIAGNOSTIC
- if (!(reqh->rqflags & URQ_REQUEST)) {
+ if (!(xfer->rqflags & URQ_REQUEST)) {
panic("ohci_ctrl_done: not a request\n");
}
#endif
- reqh->hcpriv = 0;
+ xfer->hcpriv = 0;
}
void
-ohci_device_intr_done(reqh)
- usbd_request_handle reqh;
+ohci_device_intr_done(xfer)
+ usbd_xfer_handle xfer;
{
- struct ohci_pipe *opipe = (struct ohci_pipe *)reqh->pipe;
+ struct ohci_pipe *opipe = (struct ohci_pipe *)xfer->pipe;
ohci_softc_t *sc = (ohci_softc_t *)opipe->pipe.device->bus;
ohci_soft_ed_t *sed = opipe->sed;
ohci_soft_td_t *data, *tail;
- DPRINTFN(10,("ohci_intr_done: reqh=%p, actlen=%d\n",
- reqh, reqh->actlen));
+ DPRINTFN(10,("ohci_intr_done: xfer=%p, actlen=%d\n",
+ xfer, xfer->actlen));
- reqh->hcpriv = 0;
+ xfer->hcpriv = 0;
- if (reqh->pipe->repeat) {
+ if (xfer->pipe->repeat) {
data = opipe->tail;
tail = ohci_alloc_std(sc); /* XXX should reuse TD */
- if (!tail) {
- reqh->status = USBD_NOMEM;
+ if (tail == NULL) {
+ xfer->status = USBD_NOMEM;
return;
}
- tail->reqh = 0;
+ tail->xfer = 0;
data->td.td_flags = LE(
OHCI_TD_IN | OHCI_TD_NOCC |
OHCI_TD_SET_DI(1) | OHCI_TD_TOGGLE_CARRY);
- if (reqh->flags & USBD_SHORT_XFER_OK)
+ if (xfer->flags & USBD_SHORT_XFER_OK)
data->td.td_flags |= LE(OHCI_TD_R);
- data->td.td_cbp = LE(DMAADDR(&reqh->dmabuf));
+ data->td.td_cbp = LE(DMAADDR(&xfer->dmabuf));
data->nexttd = tail;
data->td.td_nexttd = LE(tail->physaddr);
- data->td.td_be = LE(LE(data->td.td_cbp) + reqh->length - 1);
- data->len = reqh->length;
- data->reqh = reqh;
+ data->td.td_be = LE(LE(data->td.td_cbp) + xfer->length - 1);
+ data->len = xfer->length;
+ data->xfer = xfer;
data->flags = OHCI_CALL_DONE | OHCI_ADD_LEN;
- reqh->hcpriv = data;
- reqh->actlen = 0;
+ xfer->hcpriv = data;
+ xfer->actlen = 0;
ohci_hash_add_td(sc, data);
sed->ed.ed_tailp = LE(tail->physaddr);
@@ -1029,19 +1054,19 @@ ohci_device_intr_done(reqh)
}
void
-ohci_device_bulk_done(reqh)
- usbd_request_handle reqh;
+ohci_device_bulk_done(xfer)
+ usbd_xfer_handle xfer;
{
- DPRINTFN(10,("ohci_bulk_done: reqh=%p, actlen=%d\n",
- reqh, reqh->actlen));
+ DPRINTFN(10,("ohci_bulk_done: xfer=%p, actlen=%d\n",
+ xfer, xfer->actlen));
- reqh->hcpriv = 0;
+ xfer->hcpriv = NULL;
}
void
-ohci_rhsc(sc, reqh)
+ohci_rhsc(sc, xfer)
ohci_softc_t *sc;
- usbd_request_handle reqh;
+ usbd_xfer_handle xfer;
{
usbd_pipe_handle pipe;
struct ohci_pipe *opipe;
@@ -1050,36 +1075,36 @@ ohci_rhsc(sc, reqh)
int hstatus;
hstatus = OREAD4(sc, OHCI_RH_STATUS);
- DPRINTF(("ohci_rhsc: sc=%p reqh=%p hstatus=0x%08x\n",
- sc, reqh, hstatus));
+ DPRINTF(("ohci_rhsc: sc=%p xfer=%p hstatus=0x%08x\n",
+ sc, xfer, hstatus));
- if (reqh == 0) {
+ if (xfer == NULL) {
/* Just ignore the change. */
return;
}
- pipe = reqh->pipe;
+ pipe = xfer->pipe;
opipe = (struct ohci_pipe *)pipe;
- p = KERNADDR(&reqh->dmabuf);
- m = min(sc->sc_noport, reqh->length * 8 - 1);
- memset(p, 0, reqh->length);
+ p = KERNADDR(&xfer->dmabuf);
+ m = min(sc->sc_noport, xfer->length * 8 - 1);
+ memset(p, 0, xfer->length);
for (i = 1; i <= m; i++) {
if (OREAD4(sc, OHCI_RH_PORT_STATUS(i)) >> 16)
p[i/8] |= 1 << (i%8);
}
DPRINTF(("ohci_rhsc: change=0x%02x\n", *p));
- reqh->actlen = reqh->length;
- reqh->status = USBD_NORMAL_COMPLETION;
+ xfer->actlen = xfer->length;
+ xfer->status = USBD_NORMAL_COMPLETION;
- usb_transfer_complete(reqh);
+ usb_transfer_complete(xfer);
}
void
-ohci_root_intr_done(reqh)
- usbd_request_handle reqh;
+ohci_root_intr_done(xfer)
+ usbd_xfer_handle xfer;
{
- reqh->hcpriv = 0;
+ xfer->hcpriv = NULL;
}
/*
@@ -1088,15 +1113,15 @@ ohci_root_intr_done(reqh)
* too long.
*/
void
-ohci_waitintr(sc, reqh)
+ohci_waitintr(sc, xfer)
ohci_softc_t *sc;
- usbd_request_handle reqh;
+ usbd_xfer_handle xfer;
{
- int timo = reqh->timeout;
+ int timo = xfer->timeout;
int usecs;
u_int32_t intrs;
- reqh->status = USBD_IN_PROGRESS;
+ xfer->status = USBD_IN_PROGRESS;
for (usecs = timo * 1000000 / hz; usecs > 0; usecs -= 1000) {
usb_delay_ms(&sc->sc_bus, 1);
intrs = OREAD4(sc, OHCI_INTERRUPT_STATUS) & sc->sc_eintrs;
@@ -1106,16 +1131,16 @@ ohci_waitintr(sc, reqh)
ohci_dumpregs(sc);
#endif
if (intrs) {
- ohci_intr(sc);
- if (reqh->status != USBD_IN_PROGRESS)
+ ohci_intr1(sc);
+ if (xfer->status != USBD_IN_PROGRESS)
return;
}
}
/* Timeout */
DPRINTF(("ohci_waitintr: timeout\n"));
- reqh->status = USBD_TIMEOUT;
- usb_transfer_complete(reqh);
+ xfer->status = USBD_TIMEOUT;
+ usb_transfer_complete(xfer);
/* XXX should free TD */
}
@@ -1126,15 +1151,15 @@ ohci_poll(bus)
ohci_softc_t *sc = (ohci_softc_t *)bus;
if (OREAD4(sc, OHCI_INTERRUPT_STATUS) & sc->sc_eintrs)
- ohci_intr(sc);
+ ohci_intr1(sc);
}
usbd_status
-ohci_device_request(reqh)
- usbd_request_handle reqh;
+ohci_device_request(xfer)
+ usbd_xfer_handle xfer;
{
- struct ohci_pipe *opipe = (struct ohci_pipe *)reqh->pipe;
- usb_device_request_t *req = &reqh->request;
+ struct ohci_pipe *opipe = (struct ohci_pipe *)xfer->pipe;
+ usb_device_request_t *req = &xfer->request;
usbd_device_handle dev = opipe->pipe.device;
ohci_softc_t *sc = (ohci_softc_t *)dev->bus;
int addr = dev->address;
@@ -1142,7 +1167,7 @@ ohci_device_request(reqh)
ohci_soft_ed_t *sed;
int isread;
int len;
- usbd_status r;
+ usbd_status err;
int s;
isread = req->bmRequestType & UT_READ;
@@ -1156,16 +1181,16 @@ ohci_device_request(reqh)
setup = opipe->tail;
stat = ohci_alloc_std(sc);
- if (!stat) {
- r = USBD_NOMEM;
+ if (stat == NULL) {
+ err = USBD_NOMEM;
goto bad1;
}
tail = ohci_alloc_std(sc);
- if (!tail) {
- r = USBD_NOMEM;
+ if (tail == NULL) {
+ err = USBD_NOMEM;
goto bad2;
}
- tail->reqh = 0;
+ tail->xfer = 0;
sed = opipe->sed;
opipe->u.ctl.length = len;
@@ -1180,20 +1205,20 @@ ohci_device_request(reqh)
/* Set up data transaction */
if (len != 0) {
data = ohci_alloc_std(sc);
- if (!data) {
- r = USBD_NOMEM;
+ if (data == NULL) {
+ err = USBD_NOMEM;
goto bad3;
}
data->td.td_flags = LE(
(isread ? OHCI_TD_IN : OHCI_TD_OUT) | OHCI_TD_NOCC |
OHCI_TD_TOGGLE_1 | OHCI_TD_NOINTR |
- (reqh->flags & USBD_SHORT_XFER_OK ? OHCI_TD_R : 0));
- data->td.td_cbp = LE(DMAADDR(&reqh->dmabuf));
+ (xfer->flags & USBD_SHORT_XFER_OK ? OHCI_TD_R : 0));
+ data->td.td_cbp = LE(DMAADDR(&xfer->dmabuf));
data->nexttd = stat;
data->td.td_nexttd = LE(stat->physaddr);
data->td.td_be = LE(LE(data->td.td_cbp) + len - 1);
data->len = len;
- data->reqh = reqh;
+ data->xfer = xfer;
data->flags = OHCI_ADD_LEN;
next = data;
@@ -1213,9 +1238,9 @@ ohci_device_request(reqh)
setup->td.td_nexttd = LE(next->physaddr);
setup->td.td_be = LE(LE(setup->td.td_cbp) + sizeof *req - 1);
setup->len = 0; /* XXX The number of byte we count */
- setup->reqh = reqh;
+ setup->xfer = xfer;
setup->flags = 0;
- reqh->hcpriv = setup;
+ xfer->hcpriv = setup;
stat->td.td_flags = LE(
(isread ? OHCI_TD_OUT : OHCI_TD_IN) | OHCI_TD_NOCC |
@@ -1225,7 +1250,7 @@ ohci_device_request(reqh)
stat->td.td_nexttd = LE(tail->physaddr);
stat->td.td_be = 0;
stat->len = 0;
- stat->reqh = reqh;
+ stat->xfer = xfer;
#ifdef OHCI_DEBUG
if (ohcidebug > 5) {
@@ -1244,9 +1269,9 @@ ohci_device_request(reqh)
sed->ed.ed_tailp = LE(tail->physaddr);
opipe->tail = tail;
OWRITE4(sc, OHCI_COMMAND_STATUS, OHCI_CLF);
- if (reqh->timeout && !sc->sc_bus.use_polling) {
- usb_timeout(ohci_timeout, reqh,
- MS_TO_TICKS(reqh->timeout), reqh->timo_handle);
+ if (xfer->timeout && !sc->sc_bus.use_polling) {
+ usb_timeout(ohci_timeout, xfer,
+ MS_TO_TICKS(xfer->timeout), xfer->timo_handle);
}
splx(s);
@@ -1267,7 +1292,7 @@ ohci_device_request(reqh)
bad2:
ohci_free_std(sc, stat);
bad1:
- return (r);
+ return (err);
}
/*
@@ -1350,7 +1375,7 @@ ohci_hash_find_td(sc, a)
ohci_soft_td_t *std;
for (std = LIST_FIRST(&sc->sc_hash_tds[h]);
- std != 0;
+ std != NULL;
std = LIST_NEXT(std, hnext))
if (std->physaddr == a)
return (std);
@@ -1361,15 +1386,15 @@ void
ohci_timeout(addr)
void *addr;
{
- usbd_request_handle reqh = addr;
+ usbd_xfer_handle xfer = addr;
int s;
- DPRINTF(("ohci_timeout: reqh=%p\n", reqh));
+ DPRINTF(("ohci_timeout: xfer=%p\n", xfer));
s = splusb();
- reqh->device->bus->intr_context++;
- ohci_abort_req(reqh, USBD_TIMEOUT);
- reqh->device->bus->intr_context--;
+ xfer->device->bus->intr_context++;
+ ohci_abort_req(xfer, USBD_TIMEOUT);
+ xfer->device->bus->intr_context--;
splx(s);
}
@@ -1428,7 +1453,7 @@ ohci_open(pipe)
u_int8_t addr = dev->address;
ohci_soft_ed_t *sed;
ohci_soft_td_t *std;
- usbd_status r;
+ usbd_status err;
int s;
DPRINTFN(1, ("ohci_open: pipe=%p, addr=%d, endpt=%d (%d)\n",
@@ -1446,10 +1471,10 @@ ohci_open(pipe)
}
} else {
sed = ohci_alloc_sed(sc);
- if (sed == 0)
+ if (sed == NULL)
goto bad0;
std = ohci_alloc_std(sc);
- if (std == 0)
+ if (std == NULL)
goto bad1;
opipe->sed = sed;
opipe->tail = std;
@@ -1466,10 +1491,10 @@ ohci_open(pipe)
switch (ed->bmAttributes & UE_XFERTYPE) {
case UE_CONTROL:
pipe->methods = &ohci_device_ctrl_methods;
- r = usb_allocmem(&sc->sc_bus,
- sizeof(usb_device_request_t),
- 0, &opipe->u.ctl.reqdma);
- if (r != USBD_NORMAL_COMPLETION)
+ err = usb_allocmem(&sc->sc_bus,
+ sizeof(usb_device_request_t),
+ 0, &opipe->u.ctl.reqdma);
+ if (err)
goto bad;
s = splusb();
ohci_add_ed(sed, sc->sc_ctrl_head);
@@ -1522,7 +1547,7 @@ ohci_close_pipe(pipe, head)
ohci_physaddr_t td = sed->ed.ed_headp;
ohci_soft_td_t *std;
for (std = LIST_FIRST(&sc->sc_hash_tds[HASH(td)]);
- std != 0;
+ std != NULL;
std = LIST_NEXT(std, hnext))
if (std->physaddr == td)
break;
@@ -1553,29 +1578,29 @@ ohci_close_pipe(pipe, head)
* interrupt processing to process it.
*/
void
-ohci_abort_req(reqh, status)
- usbd_request_handle reqh;
+ohci_abort_req(xfer, status)
+ usbd_xfer_handle xfer;
usbd_status status;
{
- struct ohci_pipe *opipe = (struct ohci_pipe *)reqh->pipe;
+ struct ohci_pipe *opipe = (struct ohci_pipe *)xfer->pipe;
ohci_soft_ed_t *sed;
- DPRINTF(("ohci_abort_req: reqh=%p pipe=%p\n", reqh, opipe));
+ DPRINTF(("ohci_abort_req: xfer=%p pipe=%p\n", xfer, opipe));
- reqh->status = status;
+ xfer->status = status;
- usb_untimeout(ohci_timeout, reqh, reqh->timo_handle);
+ usb_untimeout(ohci_timeout, xfer, xfer->timo_handle);
sed = opipe->sed;
DPRINTFN(1,("ohci_abort_req: stop ed=%p\n", sed));
sed->ed.ed_flags |= LE(OHCI_ED_SKIP); /* force hardware skip */
- if (reqh->device->bus->intr_context) {
+ if (xfer->device->bus->intr_context) {
/* We have no process context, so we can't use tsleep(). */
- timeout(ohci_abort_req_end, reqh, hz / USB_FRAMES_PER_SECOND);
+ timeout(ohci_abort_req_end, xfer, hz / USB_FRAMES_PER_SECOND);
} else {
usb_delay_ms(opipe->pipe.device->bus, 1);
- ohci_abort_req_end(reqh);
+ ohci_abort_req_end(xfer);
}
}
@@ -1583,8 +1608,8 @@ void
ohci_abort_req_end(v)
void *v;
{
- usbd_request_handle reqh = v;
- struct ohci_pipe *opipe = (struct ohci_pipe *)reqh->pipe;
+ usbd_xfer_handle xfer = v;
+ struct ohci_pipe *opipe = (struct ohci_pipe *)xfer->pipe;
ohci_softc_t *sc = (ohci_softc_t *)opipe->pipe.device->bus;
ohci_soft_ed_t *sed;
ohci_soft_td_t *p, *n;
@@ -1592,14 +1617,14 @@ ohci_abort_req_end(v)
s = splusb();
- p = reqh->hcpriv;
+ p = xfer->hcpriv;
#ifdef DIAGNOSTIC
if (!p) {
printf("ohci_abort_req: hcpriv==0\n");
return;
}
#endif
- for (; p->reqh == reqh; p = n) {
+ for (; p->xfer == xfer; p = n) {
n = p->nexttd;
ohci_hash_rem_td(sc, p);
ohci_free_std(sc, p);
@@ -1611,7 +1636,7 @@ ohci_abort_req_end(v)
sed->ed.ed_headp = p->physaddr; /* unlink TDs */
sed->ed.ed_flags &= LE(~OHCI_ED_SKIP); /* remove hardware skip */
- usb_transfer_complete(reqh);
+ usb_transfer_complete(xfer);
splx(s);
}
@@ -1619,7 +1644,7 @@ ohci_abort_req_end(v)
/*
* Data structures and routines to emulate the root hub.
*/
-usb_device_descriptor_t ohci_devd = {
+static usb_device_descriptor_t ohci_devd = {
USB_DEVICE_DESCRIPTOR_SIZE,
UDESC_DEVICE, /* type */
{0x00, 0x01}, /* USB version */
@@ -1632,7 +1657,7 @@ usb_device_descriptor_t ohci_devd = {
1 /* # of configurations */
};
-usb_config_descriptor_t ohci_confd = {
+static usb_config_descriptor_t ohci_confd = {
USB_CONFIG_DESCRIPTOR_SIZE,
UDESC_CONFIG,
{USB_CONFIG_DESCRIPTOR_SIZE +
@@ -1645,7 +1670,7 @@ usb_config_descriptor_t ohci_confd = {
0 /* max power */
};
-usb_interface_descriptor_t ohci_ifcd = {
+static usb_interface_descriptor_t ohci_ifcd = {
USB_INTERFACE_DESCRIPTOR_SIZE,
UDESC_INTERFACE,
0,
@@ -1657,7 +1682,7 @@ usb_interface_descriptor_t ohci_ifcd = {
0
};
-usb_endpoint_descriptor_t ohci_endpd = {
+static usb_endpoint_descriptor_t ohci_endpd = {
USB_ENDPOINT_DESCRIPTOR_SIZE,
UDESC_ENDPOINT,
UE_DIR_IN | OHCI_INTR_ENDPT,
@@ -1666,7 +1691,7 @@ usb_endpoint_descriptor_t ohci_endpd = {
255
};
-usb_hub_descriptor_t ohci_hubd = {
+static usb_hub_descriptor_t ohci_hubd = {
USB_HUB_DESCRIPTOR_SIZE,
UDESC_HUB,
0,
@@ -1700,40 +1725,40 @@ ohci_str(p, l, s)
* Simulate a hardware hub by handling all the necessary requests.
*/
usbd_status
-ohci_root_ctrl_transfer(reqh)
- usbd_request_handle reqh;
+ohci_root_ctrl_transfer(xfer)
+ usbd_xfer_handle xfer;
{
- usbd_status r;
+ usbd_status err;
/* Insert last in queue. */
- r = usb_insert_transfer(reqh);
- if (r != USBD_NORMAL_COMPLETION)
- return (r);
+ err = usb_insert_transfer(xfer);
+ if (err)
+ return (err);
/* Pipe isn't running, start first */
- return (ohci_root_ctrl_start(SIMPLEQ_FIRST(&reqh->pipe->queue)));
+ return (ohci_root_ctrl_start(SIMPLEQ_FIRST(&xfer->pipe->queue)));
}
usbd_status
-ohci_root_ctrl_start(reqh)
- usbd_request_handle reqh;
+ohci_root_ctrl_start(xfer)
+ usbd_xfer_handle xfer;
{
- ohci_softc_t *sc = (ohci_softc_t *)reqh->pipe->device->bus;
+ ohci_softc_t *sc = (ohci_softc_t *)xfer->pipe->device->bus;
usb_device_request_t *req;
void *buf = NULL;
int port, i;
int s, len, value, index, l, totlen = 0;
usb_port_status_t ps;
usb_hub_descriptor_t hubd;
- usbd_status r;
+ usbd_status err;
u_int32_t v;
#ifdef DIAGNOSTIC
- if (!(reqh->rqflags & URQ_REQUEST))
+ if (!(xfer->rqflags & URQ_REQUEST))
/* XXX panic */
return (USBD_INVAL);
#endif
- req = &reqh->request;
+ req = &xfer->request;
DPRINTFN(4,("ohci_root_ctrl_control type=0x%02x request=%02x\n",
req->bmRequestType, req->bRequest));
@@ -1743,7 +1768,7 @@ ohci_root_ctrl_start(reqh)
index = UGETW(req->wIndex);
if (len != 0)
- buf = KERNADDR(&reqh->dmabuf);
+ buf = KERNADDR(&xfer->dmabuf);
#define C(x,y) ((x) | ((y) << 8))
switch(C(req->bRequest, req->bmRequestType)) {
@@ -1766,7 +1791,7 @@ ohci_root_ctrl_start(reqh)
switch(value >> 8) {
case UDESC_DEVICE:
if ((value & 0xff) != 0) {
- r = USBD_IOERROR;
+ err = USBD_IOERROR;
goto ret;
}
totlen = l = min(len, USB_DEVICE_DESCRIPTOR_SIZE);
@@ -1775,7 +1800,7 @@ ohci_root_ctrl_start(reqh)
break;
case UDESC_CONFIG:
if ((value & 0xff) != 0) {
- r = USBD_IOERROR;
+ err = USBD_IOERROR;
goto ret;
}
totlen = l = min(len, USB_CONFIG_DESCRIPTOR_SIZE);
@@ -1806,7 +1831,7 @@ ohci_root_ctrl_start(reqh)
}
break;
default:
- r = USBD_IOERROR;
+ err = USBD_IOERROR;
goto ret;
}
break;
@@ -1831,14 +1856,14 @@ ohci_root_ctrl_start(reqh)
break;
case C(UR_SET_ADDRESS, UT_WRITE_DEVICE):
if (value >= USB_MAX_DEVICES) {
- r = USBD_IOERROR;
+ err = USBD_IOERROR;
goto ret;
}
sc->sc_addr = value;
break;
case C(UR_SET_CONFIG, UT_WRITE_DEVICE):
if (value != 0 && value != 1) {
- r = USBD_IOERROR;
+ err = USBD_IOERROR;
goto ret;
}
sc->sc_conf = value;
@@ -1848,7 +1873,7 @@ ohci_root_ctrl_start(reqh)
case C(UR_SET_FEATURE, UT_WRITE_DEVICE):
case C(UR_SET_FEATURE, UT_WRITE_INTERFACE):
case C(UR_SET_FEATURE, UT_WRITE_ENDPOINT):
- r = USBD_IOERROR;
+ err = USBD_IOERROR;
goto ret;
case C(UR_SET_INTERFACE, UT_WRITE_INTERFACE):
break;
@@ -1862,7 +1887,7 @@ ohci_root_ctrl_start(reqh)
"port=%d feature=%d\n",
index, value));
if (index < 1 || index > sc->sc_noport) {
- r = USBD_IOERROR;
+ err = USBD_IOERROR;
goto ret;
}
port = OHCI_RH_PORT_STATUS(index);
@@ -1892,7 +1917,7 @@ ohci_root_ctrl_start(reqh)
OWRITE4(sc, port, UPS_C_PORT_RESET << 16);
break;
default:
- r = USBD_IOERROR;
+ err = USBD_IOERROR;
goto ret;
}
switch(value) {
@@ -1911,7 +1936,7 @@ ohci_root_ctrl_start(reqh)
break;
case C(UR_GET_DESCRIPTOR, UT_READ_CLASS_DEVICE):
if (value != 0) {
- r = USBD_IOERROR;
+ err = USBD_IOERROR;
goto ret;
}
v = OREAD4(sc, OHCI_RH_DESCRIPTOR_A);
@@ -1933,7 +1958,7 @@ ohci_root_ctrl_start(reqh)
break;
case C(UR_GET_STATUS, UT_READ_CLASS_DEVICE):
if (len != 4) {
- r = USBD_IOERROR;
+ err = USBD_IOERROR;
goto ret;
}
memset(buf, 0, len); /* ? XXX */
@@ -1943,11 +1968,11 @@ ohci_root_ctrl_start(reqh)
DPRINTFN(8,("ohci_root_ctrl_transfer: get port status i=%d\n",
index));
if (index < 1 || index > sc->sc_noport) {
- r = USBD_IOERROR;
+ err = USBD_IOERROR;
goto ret;
}
if (len != 4) {
- r = USBD_IOERROR;
+ err = USBD_IOERROR;
goto ret;
}
v = OREAD4(sc, OHCI_RH_PORT_STATUS(index));
@@ -1960,13 +1985,13 @@ ohci_root_ctrl_start(reqh)
totlen = l;
break;
case C(UR_SET_DESCRIPTOR, UT_WRITE_CLASS_DEVICE):
- r = USBD_IOERROR;
+ err = USBD_IOERROR;
goto ret;
case C(UR_SET_FEATURE, UT_WRITE_CLASS_DEVICE):
break;
case C(UR_SET_FEATURE, UT_WRITE_CLASS_OTHER):
if (index < 1 || index > sc->sc_noport) {
- r = USBD_IOERROR;
+ err = USBD_IOERROR;
goto ret;
}
port = OHCI_RH_PORT_STATUS(index);
@@ -1995,28 +2020,28 @@ ohci_root_ctrl_start(reqh)
OWRITE4(sc, port, UPS_PORT_POWER);
break;
default:
- r = USBD_IOERROR;
+ err = USBD_IOERROR;
goto ret;
}
break;
default:
- r = USBD_IOERROR;
+ err = USBD_IOERROR;
goto ret;
}
- reqh->actlen = totlen;
- r = USBD_NORMAL_COMPLETION;
+ xfer->actlen = totlen;
+ err = USBD_NORMAL_COMPLETION;
ret:
- reqh->status = r;
+ xfer->status = err;
s = splusb();
- usb_transfer_complete(reqh);
+ usb_transfer_complete(xfer);
splx(s);
return (USBD_IN_PROGRESS);
}
/* Abort a root control request. */
void
-ohci_root_ctrl_abort(reqh)
- usbd_request_handle reqh;
+ohci_root_ctrl_abort(xfer)
+ usbd_xfer_handle xfer;
{
/* Nothing to do, all transfers are synchronous. */
}
@@ -2031,43 +2056,47 @@ ohci_root_ctrl_close(pipe)
}
usbd_status
-ohci_root_intr_transfer(reqh)
- usbd_request_handle reqh;
+ohci_root_intr_transfer(xfer)
+ usbd_xfer_handle xfer;
{
- usbd_status r;
+ usbd_status err;
/* Insert last in queue. */
- r = usb_insert_transfer(reqh);
- if (r != USBD_NORMAL_COMPLETION)
- return (r);
+ err = usb_insert_transfer(xfer);
+ if (err)
+ return (err);
/* Pipe isn't running, start first */
- return (ohci_root_intr_start(SIMPLEQ_FIRST(&reqh->pipe->queue)));
+ return (ohci_root_intr_start(SIMPLEQ_FIRST(&xfer->pipe->queue)));
}
usbd_status
-ohci_root_intr_start(reqh)
- usbd_request_handle reqh;
+ohci_root_intr_start(xfer)
+ usbd_xfer_handle xfer;
{
- usbd_pipe_handle pipe = reqh->pipe;
+ usbd_pipe_handle pipe = xfer->pipe;
ohci_softc_t *sc = (ohci_softc_t *)pipe->device->bus;
- sc->sc_intrreqh = reqh;
+ sc->sc_intrxfer = xfer;
return (USBD_IN_PROGRESS);
}
/* Abort a root interrupt request. */
void
-ohci_root_intr_abort(reqh)
- usbd_request_handle reqh;
+ohci_root_intr_abort(xfer)
+ usbd_xfer_handle xfer;
{
- if (reqh->pipe->intrreqh == reqh) {
+ int s;
+
+ if (xfer->pipe->intrxfer == xfer) {
DPRINTF(("ohci_root_intr_abort: remove\n"));
- reqh->pipe->intrreqh = 0;
+ xfer->pipe->intrxfer = NULL;
}
- reqh->status = USBD_CANCELLED;
- usb_transfer_complete(reqh);
+ xfer->status = USBD_CANCELLED;
+ s = splusb();
+ usb_transfer_complete(xfer);
+ splx(s);
}
/* Close the root pipe. */
@@ -2079,57 +2108,57 @@ ohci_root_intr_close(pipe)
DPRINTF(("ohci_root_intr_close\n"));
- sc->sc_intrreqh = 0;
+ sc->sc_intrxfer = NULL;
}
/************************/
usbd_status
-ohci_device_ctrl_transfer(reqh)
- usbd_request_handle reqh;
+ohci_device_ctrl_transfer(xfer)
+ usbd_xfer_handle xfer;
{
- usbd_status r;
+ usbd_status err;
/* Insert last in queue. */
- r = usb_insert_transfer(reqh);
- if (r != USBD_NORMAL_COMPLETION)
- return (r);
+ err = usb_insert_transfer(xfer);
+ if (err)
+ return (err);
/* Pipe isn't running, start first */
- return (ohci_device_ctrl_start(SIMPLEQ_FIRST(&reqh->pipe->queue)));
+ return (ohci_device_ctrl_start(SIMPLEQ_FIRST(&xfer->pipe->queue)));
}
usbd_status
-ohci_device_ctrl_start(reqh)
- usbd_request_handle reqh;
+ohci_device_ctrl_start(xfer)
+ usbd_xfer_handle xfer;
{
- ohci_softc_t *sc = (ohci_softc_t *)reqh->pipe->device->bus;
- usbd_status r;
+ ohci_softc_t *sc = (ohci_softc_t *)xfer->pipe->device->bus;
+ usbd_status err;
#ifdef DIAGNOSTIC
- if (!(reqh->rqflags & URQ_REQUEST)) {
+ if (!(xfer->rqflags & URQ_REQUEST)) {
/* XXX panic */
printf("ohci_device_ctrl_transfer: not a request\n");
return (USBD_INVAL);
}
#endif
- r = ohci_device_request(reqh);
- if (r != USBD_NORMAL_COMPLETION)
- return (r);
+ err = ohci_device_request(xfer);
+ if (err)
+ return (err);
if (sc->sc_bus.use_polling)
- ohci_waitintr(sc, reqh);
+ ohci_waitintr(sc, xfer);
return (USBD_IN_PROGRESS);
}
/* Abort a device control request. */
void
-ohci_device_ctrl_abort(reqh)
- usbd_request_handle reqh;
+ohci_device_ctrl_abort(xfer)
+ usbd_xfer_handle xfer;
{
- DPRINTF(("ohci_device_ctrl_abort: reqh=%p\n", reqh));
- ohci_abort_req(reqh, USBD_CANCELLED);
+ DPRINTF(("ohci_device_ctrl_abort: xfer=%p\n", xfer));
+ ohci_abort_req(xfer, USBD_CANCELLED);
}
/* Close a device control pipe. */
@@ -2161,48 +2190,48 @@ ohci_noop(pipe)
}
usbd_status
-ohci_device_bulk_transfer(reqh)
- usbd_request_handle reqh;
+ohci_device_bulk_transfer(xfer)
+ usbd_xfer_handle xfer;
{
- usbd_status r;
+ usbd_status err;
/* Insert last in queue. */
- r = usb_insert_transfer(reqh);
- if (r != USBD_NORMAL_COMPLETION)
- return (r);
+ err = usb_insert_transfer(xfer);
+ if (err)
+ return (err);
/* Pipe isn't running, start first */
- return (ohci_device_bulk_start(SIMPLEQ_FIRST(&reqh->pipe->queue)));
+ return (ohci_device_bulk_start(SIMPLEQ_FIRST(&xfer->pipe->queue)));
}
usbd_status
-ohci_device_bulk_start(reqh)
- usbd_request_handle reqh;
+ohci_device_bulk_start(xfer)
+ usbd_xfer_handle xfer;
{
- struct ohci_pipe *opipe = (struct ohci_pipe *)reqh->pipe;
+ struct ohci_pipe *opipe = (struct ohci_pipe *)xfer->pipe;
usbd_device_handle dev = opipe->pipe.device;
ohci_softc_t *sc = (ohci_softc_t *)dev->bus;
int addr = dev->address;
ohci_soft_td_t *data, *tail, *tdp;
ohci_soft_ed_t *sed;
int s, len, isread, endpt;
- usbd_status r;
+ usbd_status err;
#ifdef DIAGNOSTIC
- if (reqh->rqflags & URQ_REQUEST) {
+ if (xfer->rqflags & URQ_REQUEST) {
/* XXX panic */
printf("ohci_device_bulk_start: a request\n");
return (USBD_INVAL);
}
#endif
- len = reqh->length;
- endpt = reqh->pipe->endpoint->edesc->bEndpointAddress;
+ len = xfer->length;
+ endpt = xfer->pipe->endpoint->edesc->bEndpointAddress;
isread = UE_GET_DIR(endpt) == UE_DIR_IN;
sed = opipe->sed;
- DPRINTFN(4,("ohci_device_bulk_start: reqh=%p len=%d isread=%d "
- "flags=%d endpt=%d\n", reqh, len, isread, reqh->flags,
+ DPRINTFN(4,("ohci_device_bulk_start: xfer=%p len=%d isread=%d "
+ "flags=%d endpt=%d\n", xfer, len, isread, xfer->flags,
endpt));
opipe->u.bulk.isread = isread;
@@ -2215,14 +2244,14 @@ ohci_device_bulk_start(reqh)
/* Allocate a chain of new TDs (including a new tail). */
data = opipe->tail;
- r = ohci_alloc_std_chain(opipe, sc, len, isread,
- reqh->flags & USBD_SHORT_XFER_OK,
- &reqh->dmabuf, data, &tail);
- if (r != USBD_NORMAL_COMPLETION)
- return (r);
+ err = ohci_alloc_std_chain(opipe, sc, len, isread,
+ xfer->flags & USBD_SHORT_XFER_OK,
+ &xfer->dmabuf, data, &tail);
+ if (err)
+ return (err);
- tail->reqh = 0;
- reqh->hcpriv = data;
+ tail->xfer = NULL;
+ xfer->hcpriv = data;
DPRINTFN(4,("ohci_device_bulk_start: ed_flags=0x%08x td_flags=0x%08x "
"td_cbp=0x%08x td_be=0x%08x\n",
@@ -2239,16 +2268,16 @@ ohci_device_bulk_start(reqh)
/* Insert ED in schedule */
s = splusb();
for (tdp = data; tdp != tail; tdp = tdp->nexttd) {
- tdp->reqh = reqh;
+ tdp->xfer = xfer;
ohci_hash_add_td(sc, tdp);
}
sed->ed.ed_tailp = LE(tail->physaddr);
opipe->tail = tail;
sed->ed.ed_flags &= LE(~OHCI_ED_SKIP);
OWRITE4(sc, OHCI_COMMAND_STATUS, OHCI_BLF);
- if (reqh->timeout && !sc->sc_bus.use_polling) {
- usb_timeout(ohci_timeout, reqh,
- MS_TO_TICKS(reqh->timeout), reqh->timo_handle);
+ if (xfer->timeout && !sc->sc_bus.use_polling) {
+ usb_timeout(ohci_timeout, xfer,
+ MS_TO_TICKS(xfer->timeout), xfer->timo_handle);
}
#if 0
@@ -2268,11 +2297,11 @@ ohci_device_bulk_start(reqh)
}
void
-ohci_device_bulk_abort(reqh)
- usbd_request_handle reqh;
+ohci_device_bulk_abort(xfer)
+ usbd_xfer_handle xfer;
{
- DPRINTF(("ohci_device_bulk_abort: reqh=%p\n", reqh));
- ohci_abort_req(reqh, USBD_CANCELLED);
+ DPRINTF(("ohci_device_bulk_abort: xfer=%p\n", xfer));
+ ohci_abort_req(xfer, USBD_CANCELLED);
}
/*
@@ -2291,25 +2320,25 @@ ohci_device_bulk_close(pipe)
/************************/
usbd_status
-ohci_device_intr_transfer(reqh)
- usbd_request_handle reqh;
+ohci_device_intr_transfer(xfer)
+ usbd_xfer_handle xfer;
{
- usbd_status r;
+ usbd_status err;
/* Insert last in queue. */
- r = usb_insert_transfer(reqh);
- if (r != USBD_NORMAL_COMPLETION)
- return (r);
+ err = usb_insert_transfer(xfer);
+ if (err)
+ return (err);
/* Pipe isn't running, start first */
- return (ohci_device_intr_start(SIMPLEQ_FIRST(&reqh->pipe->queue)));
+ return (ohci_device_intr_start(SIMPLEQ_FIRST(&xfer->pipe->queue)));
}
usbd_status
-ohci_device_intr_start(reqh)
- usbd_request_handle reqh;
+ohci_device_intr_start(xfer)
+ usbd_xfer_handle xfer;
{
- struct ohci_pipe *opipe = (struct ohci_pipe *)reqh->pipe;
+ struct ohci_pipe *opipe = (struct ohci_pipe *)xfer->pipe;
usbd_device_handle dev = opipe->pipe.device;
ohci_softc_t *sc = (ohci_softc_t *)dev->bus;
ohci_soft_ed_t *sed = opipe->sed;
@@ -2317,36 +2346,36 @@ ohci_device_intr_start(reqh)
int len;
int s;
- DPRINTFN(3, ("ohci_device_intr_transfer: reqh=%p len=%d "
+ DPRINTFN(3, ("ohci_device_intr_transfer: xfer=%p len=%d "
"flags=%d priv=%p\n",
- reqh, reqh->length, reqh->flags, reqh->priv));
+ xfer, xfer->length, xfer->flags, xfer->priv));
#ifdef DIAGNOSTIC
- if (reqh->rqflags & URQ_REQUEST)
+ if (xfer->rqflags & URQ_REQUEST)
panic("ohci_device_intr_transfer: a request\n");
#endif
- len = reqh->length;
+ len = xfer->length;
data = opipe->tail;
tail = ohci_alloc_std(sc);
if (!tail)
return (USBD_NOMEM);
- tail->reqh = 0;
+ tail->xfer = NULL;
data->td.td_flags = LE(
OHCI_TD_IN | OHCI_TD_NOCC |
OHCI_TD_SET_DI(1) | OHCI_TD_TOGGLE_CARRY);
- if (reqh->flags & USBD_SHORT_XFER_OK)
+ if (xfer->flags & USBD_SHORT_XFER_OK)
data->td.td_flags |= LE(OHCI_TD_R);
- data->td.td_cbp = LE(DMAADDR(&reqh->dmabuf));
+ data->td.td_cbp = LE(DMAADDR(&xfer->dmabuf));
data->nexttd = tail;
data->td.td_nexttd = LE(tail->physaddr);
data->td.td_be = LE(LE(data->td.td_cbp) + len - 1);
data->len = len;
- data->reqh = reqh;
+ data->xfer = xfer;
data->flags = OHCI_CALL_DONE | OHCI_ADD_LEN;
- reqh->hcpriv = data;
+ xfer->hcpriv = data;
#ifdef OHCI_DEBUG
if (ohcidebug > 5) {
@@ -2384,14 +2413,14 @@ ohci_device_intr_start(reqh)
/* Abort a device control request. */
void
-ohci_device_intr_abort(reqh)
- usbd_request_handle reqh;
+ohci_device_intr_abort(xfer)
+ usbd_xfer_handle xfer;
{
- if (reqh->pipe->intrreqh == reqh) {
+ if (xfer->pipe->intrxfer == xfer) {
DPRINTF(("ohci_device_intr_abort: remove\n"));
- reqh->pipe->intrreqh = 0;
+ xfer->pipe->intrxfer = 0;
}
- ohci_abort_req(reqh, USBD_CANCELLED);
+ ohci_abort_req(xfer, USBD_CANCELLED);
}
/* Close a device interrupt pipe. */
@@ -2417,8 +2446,10 @@ ohci_device_intr_close(pipe)
for (p = sc->sc_eds[pos]; p && p->next != sed; p = p->next)
;
- if (!p)
+#ifdef DIAGNOSTIC
+ if (p == NULL)
panic("ohci_device_intr_close: ED not found\n");
+#endif
p->next = sed->next;
p->ed.ed_nexted = sed->ed.ed_nexted;
splx(s);
@@ -2494,4 +2525,3 @@ ohci_device_setintr(sc, opipe, ival)
DPRINTFN(5, ("ohci_setintr: returns %p\n", opipe));
return (USBD_NORMAL_COMPLETION);
}
-
diff --git a/sys/dev/usb/ohcivar.h b/sys/dev/usb/ohcivar.h
index 4f533b1ed76..63722250ab0 100644
--- a/sys/dev/usb/ohcivar.h
+++ b/sys/dev/usb/ohcivar.h
@@ -1,4 +1,4 @@
-/* $NetBSD: ohcivar.h,v 1.13 1999/10/13 08:10:55 augustss Exp $ */
+/* $NetBSD: ohcivar.h,v 1.14 1999/11/12 00:34:57 augustss Exp $ */
/*
* Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -51,7 +51,7 @@ typedef struct ohci_soft_td {
struct ohci_soft_td *dnext; /* next in done list */
ohci_physaddr_t physaddr;
LIST_ENTRY(ohci_soft_td) hnext;
- usbd_request_handle reqh;
+ usbd_xfer_handle xfer;
u_int16_t len;
u_int16_t flags;
#define OHCI_CALL_DONE 0x0001
@@ -87,7 +87,7 @@ typedef struct ohci_softc {
ohci_soft_ed_t *sc_freeeds;
ohci_soft_td_t *sc_freetds;
- usbd_request_handle sc_intrreqh;
+ usbd_xfer_handle sc_intrxfer;
char sc_vendor[16];
int sc_id_vendor;
diff --git a/sys/dev/usb/uaudio.c b/sys/dev/usb/uaudio.c
index 348eee70313..3e8601e051c 100644
--- a/sys/dev/usb/uaudio.c
+++ b/sys/dev/usb/uaudio.c
@@ -1,4 +1,4 @@
-/* $NetBSD: uaudio.c,v 1.8 1999/11/09 16:52:14 augustss Exp $ */
+/* $NetBSD: uaudio.c,v 1.9 1999/11/12 00:34:57 augustss Exp $ */
/*
* Copyright (c) 1999 The NetBSD Foundation, Inc.
@@ -131,7 +131,7 @@ struct chan {
int curchanbuf;
struct chanbuf {
struct chan *chan;
- usbd_request_handle reqh;
+ usbd_xfer_handle xfer;
u_char *buffer;
u_int16_t sizes[UAUDIO_NFRAMES];
u_int16_t size;
@@ -179,93 +179,102 @@ struct uaudio_softc {
#define UAC_INPUT 1
#define UAC_EQUAL 2
-usbd_status uaudio_identify_ac __P((struct uaudio_softc *sc,
- usb_config_descriptor_t *cdesc));
-usbd_status uaudio_identify_as __P((struct uaudio_softc *sc,
- usb_config_descriptor_t *cdesc));
-usbd_status uaudio_process_as __P((struct uaudio_softc *sc, char *buf,
- int *offsp, int size,
- usb_interface_descriptor_t *id));
+static usbd_status uaudio_identify_ac __P((struct uaudio_softc *sc,
+ usb_config_descriptor_t *cdesc));
+static usbd_status uaudio_identify_as __P((struct uaudio_softc *sc,
+ usb_config_descriptor_t *cdesc));
+static usbd_status uaudio_process_as __P((struct uaudio_softc *sc,
+ char *buf, int *offsp, int size,
+ usb_interface_descriptor_t *id));
-void uaudio_add_alt __P((struct uaudio_softc *sc, struct as_info *ai));
+static void uaudio_add_alt __P((struct uaudio_softc *sc,
+ struct as_info *ai));
-usb_interface_descriptor_t *uaudio_find_iface
+static usb_interface_descriptor_t *uaudio_find_iface
__P((char *buf, int size, int *offsp, int subtype));
-void uaudio_mixer_add_ctl __P((struct uaudio_softc *sc, struct mixerctl *mp));
-char *uaudio_id_name __P((struct uaudio_softc *sc, usb_descriptor_t **dps,
- int id));
-struct usb_audio_cluster uaudio_get_cluster __P((int id,
- usb_descriptor_t **dps));
-void uaudio_add_input __P((struct uaudio_softc *sc, usb_descriptor_t *v,
- usb_descriptor_t **dps));
-void uaudio_add_output __P((struct uaudio_softc *sc, usb_descriptor_t *v,
+static void uaudio_mixer_add_ctl __P((struct uaudio_softc *sc,
+ struct mixerctl *mp));
+static char *uaudio_id_name __P((struct uaudio_softc *sc,
+ usb_descriptor_t **dps, int id));
+static struct usb_audio_cluster uaudio_get_cluster __P((int id,
usb_descriptor_t **dps));
-void uaudio_add_mixer __P((struct uaudio_softc *sc, usb_descriptor_t *v,
- usb_descriptor_t **dps));
-void uaudio_add_selector __P((struct uaudio_softc *sc, usb_descriptor_t *v,
- usb_descriptor_t **dps));
-void uaudio_add_feature __P((struct uaudio_softc *sc, usb_descriptor_t *v,
- usb_descriptor_t **dps));
-void uaudio_add_processing __P((struct uaudio_softc *sc, usb_descriptor_t *v,
- usb_descriptor_t **dps));
-void uaudio_add_extension __P((struct uaudio_softc *sc, usb_descriptor_t *v,
- usb_descriptor_t **dps));
-usbd_status uaudio_identify __P((struct uaudio_softc *sc,
- usb_config_descriptor_t *cdesc));
-
-int uaudio_signext __P((int type, int val));
-int uaudio_value2bsd __P((struct mixerctl *mc, int val));
-int uaudio_bsd2value __P((struct mixerctl *mc, int val));
-int uaudio_get __P((struct uaudio_softc *sc, int type, int which, int wValue,
- int wIndex, int len));
-int uaudio_ctl_get __P((struct uaudio_softc *sc, int which,
- struct mixerctl *mc, int chan));
-void uaudio_set __P((struct uaudio_softc *sc, int type, int which, int wValue,
- int wIndex, int len, int val));
-void uaudio_ctl_set __P((struct uaudio_softc *sc, int which,
- struct mixerctl *mc, int chan, int val));
-
-usbd_status uaudio_set_speed __P((struct uaudio_softc *, int, u_int));
-
-usbd_status uaudio_chan_open __P((struct uaudio_softc *sc, struct chan *ch));
-void uaudio_chan_close __P((struct uaudio_softc *sc, struct chan *ch));
-usbd_status uaudio_chan_alloc_buffers __P((struct uaudio_softc *, struct chan *));
-void uaudio_chan_free_buffers __P((struct uaudio_softc *, struct chan *));
-void uaudio_chan_set_param __P((struct chan *ch, struct audio_params *param,
- u_char *start, u_char *end, int blksize));
-void uaudio_chan_ptransfer __P((struct chan *ch));
-void uaudio_chan_pintr __P((usbd_request_handle reqh,
- usbd_private_handle priv, usbd_status status));
-
-void uaudio_chan_rtransfer __P((struct chan *ch));
-void uaudio_chan_rintr __P((usbd_request_handle reqh,
- usbd_private_handle priv, usbd_status status));
-
-
-
-int uaudio_open __P((void *, int));
-void uaudio_close __P((void *));
-int uaudio_drain __P((void *));
-int uaudio_query_encoding __P((void *, struct audio_encoding *));
-int uaudio_set_params __P((void *, int, int,
- struct audio_params *, struct audio_params *));
-int uaudio_round_blocksize __P((void *, int));
-int uaudio_trigger_output __P((void *, void *, void *, int,
- void (*)(void *), void *,
- struct audio_params *));
-int uaudio_trigger_input __P((void *, void *, void *, int,
- void (*)(void *), void *,
- struct audio_params *));
-int uaudio_halt_in_dma __P((void *));
-int uaudio_halt_out_dma __P((void *));
-int uaudio_getdev __P((void *, struct audio_device *));
-int uaudio_mixer_set_port __P((void *, mixer_ctrl_t *));
-int uaudio_mixer_get_port __P((void *, mixer_ctrl_t *));
-int uaudio_query_devinfo __P((void *, mixer_devinfo_t *));
-int uaudio_get_props __P((void *));
-
-struct audio_hw_if uaudio_hw_if = {
+static void uaudio_add_input __P((struct uaudio_softc *sc,
+ usb_descriptor_t *v, usb_descriptor_t **dps));
+static void uaudio_add_output __P((struct uaudio_softc *sc,
+ usb_descriptor_t *v, usb_descriptor_t **dps));
+static void uaudio_add_mixer __P((struct uaudio_softc *sc,
+ usb_descriptor_t *v, usb_descriptor_t **dps));
+static void uaudio_add_selector __P((struct uaudio_softc *sc,
+ usb_descriptor_t *v, usb_descriptor_t **dps));
+static void uaudio_add_feature __P((struct uaudio_softc *sc,
+ usb_descriptor_t *v, usb_descriptor_t **dps));
+static void uaudio_add_processing __P((struct uaudio_softc *sc,
+ usb_descriptor_t *v, usb_descriptor_t **dps));
+static void uaudio_add_extension __P((struct uaudio_softc *sc,
+ usb_descriptor_t *v, usb_descriptor_t **dps));
+static usbd_status uaudio_identify __P((struct uaudio_softc *sc,
+ usb_config_descriptor_t *cdesc));
+
+static int uaudio_signext __P((int type, int val));
+static int uaudio_value2bsd __P((struct mixerctl *mc, int val));
+static int uaudio_bsd2value __P((struct mixerctl *mc, int val));
+static int uaudio_get __P((struct uaudio_softc *sc, int type,
+ int which, int wValue, int wIndex, int len));
+static int uaudio_ctl_get __P((struct uaudio_softc *sc, int which,
+ struct mixerctl *mc, int chan));
+static void uaudio_set __P((struct uaudio_softc *sc, int type,
+ int which, int wValue, int wIndex, int l, int v));
+static void uaudio_ctl_set __P((struct uaudio_softc *sc, int which,
+ struct mixerctl *mc, int chan, int val));
+
+static usbd_status uaudio_set_speed __P((struct uaudio_softc *, int,
+ u_int));
+
+static usbd_status uaudio_chan_open __P((struct uaudio_softc *sc,
+ struct chan *ch));
+static void uaudio_chan_close __P((struct uaudio_softc *sc,
+ struct chan *ch));
+static usbd_status uaudio_chan_alloc_buffers __P((struct uaudio_softc *,
+ struct chan *));
+static void uaudio_chan_free_buffers __P((struct uaudio_softc *,
+ struct chan *));
+static void uaudio_chan_set_param __P((struct chan *ch,
+ struct audio_params *param, u_char *start,
+ u_char *end, int blksize));
+static void uaudio_chan_ptransfer __P((struct chan *ch));
+static void uaudio_chan_pintr __P((usbd_xfer_handle xfer,
+ usbd_private_handle priv, usbd_status status));
+
+static void uaudio_chan_rtransfer __P((struct chan *ch));
+static void uaudio_chan_rintr __P((usbd_xfer_handle xfer,
+ usbd_private_handle priv, usbd_status status));
+
+
+
+static int uaudio_open __P((void *, int));
+static void uaudio_close __P((void *));
+static int uaudio_drain __P((void *));
+static int uaudio_query_encoding __P((void *,
+ struct audio_encoding *));
+static int uaudio_set_params __P((void *, int, int,
+ struct audio_params *, struct audio_params *));
+static int uaudio_round_blocksize __P((void *, int));
+static int uaudio_trigger_output __P((void *, void *, void *,
+ int, void (*)(void *), void *,
+ struct audio_params *));
+static int uaudio_trigger_input __P((void *, void *, void *,
+ int, void (*)(void *), void *,
+ struct audio_params *));
+static int uaudio_halt_in_dma __P((void *));
+static int uaudio_halt_out_dma __P((void *));
+static int uaudio_getdev __P((void *, struct audio_device *));
+static int uaudio_mixer_set_port __P((void *, mixer_ctrl_t *));
+static int uaudio_mixer_get_port __P((void *, mixer_ctrl_t *));
+static int uaudio_query_devinfo __P((void *, mixer_devinfo_t *));
+static int uaudio_get_props __P((void *));
+
+static struct audio_hw_if uaudio_hw_if = {
uaudio_open,
uaudio_close,
uaudio_drain,
@@ -294,7 +303,7 @@ struct audio_hw_if uaudio_hw_if = {
uaudio_trigger_input,
};
-struct audio_device uaudio_device = {
+static struct audio_device uaudio_device = {
"USB audio",
"",
"uaudio"
@@ -307,12 +316,12 @@ USB_MATCH(uaudio)
USB_MATCH_START(uaudio, uaa);
usb_interface_descriptor_t *id;
- if (!uaa->iface)
+ if (uaa->iface == NULL)
return (UMATCH_NONE);
id = usbd_get_interface_descriptor(uaa->iface);
/* Trigger on the control interface. */
- if (!id ||
+ if (id == NULL ||
id->bInterfaceClass != UCLASS_AUDIO ||
id->bInterfaceSubClass != USUBCLASS_AUDIOCONTROL)
return (UMATCH_NONE);
@@ -326,7 +335,7 @@ USB_ATTACH(uaudio)
usb_interface_descriptor_t *id;
usb_config_descriptor_t *cdesc;
char devinfo[1024];
- usbd_status r;
+ usbd_status err;
int i;
usbd_devinfo(uaa->device, 0, devinfo);
@@ -335,20 +344,20 @@ USB_ATTACH(uaudio)
sc->sc_udev = uaa->device;
cdesc = usbd_get_config_descriptor(sc->sc_udev);
- if (!cdesc)
+ if (cdesc == NULL)
USB_ATTACH_ERROR_RETURN;
- r = uaudio_identify(sc, cdesc);
- if (r != USBD_NORMAL_COMPLETION) {
+ err = uaudio_identify(sc, cdesc);
+ if (err) {
printf("%s: audio descriptors make no sense, error=%d\n",
- USBDEVNAME(sc->sc_dev), r);
+ USBDEVNAME(sc->sc_dev), err);
USB_ATTACH_ERROR_RETURN;
}
sc->sc_ac_ifaceh = uaa->iface;
/* Pick up the AS interface. */
for (i = 0; i < uaa->nifaces; i++) {
- if (uaa->ifaces[i]) {
+ if (uaa->ifaces[i] != NULL) {
id = usbd_get_interface_descriptor(uaa->ifaces[i]);
if (id->bInterfaceNumber == sc->sc_as_iface) {
sc->sc_as_ifaceh = uaa->ifaces[i];
@@ -358,7 +367,7 @@ USB_ATTACH(uaudio)
}
}
- if (!sc->sc_as_ifaceh) {
+ if (sc->sc_as_ifaceh == NULL) {
printf("%s: missing AS interface(s)\n",USBDEVNAME(sc->sc_dev));
USB_ATTACH_ERROR_RETURN;
}
@@ -408,7 +417,7 @@ uaudio_detach(self, flags)
/* Wait for outstanding requests to complete. */
usbd_delay_ms(sc->sc_udev, UAUDIO_NCHANBUFS * UAUDIO_NFRAMES);
- if (sc->sc_audiodev)
+ if (sc->sc_audiodev != NULL)
rv = config_detach(sc->sc_audiodev, flags);
return (rv);
@@ -624,7 +633,7 @@ uaudio_get_cluster(id, dps)
bad:
printf("uaudio_get_cluster: bad data\n");
memset(&r, 0, sizeof r);
- return r;
+ return (r);
}
@@ -920,11 +929,11 @@ uaudio_identify(sc, cdesc)
struct uaudio_softc *sc;
usb_config_descriptor_t *cdesc;
{
- usbd_status r;
+ usbd_status err;
- r = uaudio_identify_ac(sc, cdesc);
- if (r != USBD_NORMAL_COMPLETION)
- return (r);
+ err = uaudio_identify_ac(sc, cdesc);
+ if (err)
+ return (err);
return (uaudio_identify_as(sc, cdesc));
}
@@ -1072,7 +1081,7 @@ uaudio_identify_as(sc, cdesc)
usb_config_descriptor_t *cdesc;
{
usb_interface_descriptor_t *id;
- usbd_status r;
+ usbd_status err;
char *buf;
int size, offs;
@@ -1082,7 +1091,7 @@ uaudio_identify_as(sc, cdesc)
/* Locate the AudioStreaming interface descriptor. */
offs = 0;
id = uaudio_find_iface(buf, size, &offs, USUBCLASS_AUDIOSTREAM);
- if (!id)
+ if (id == NULL)
return (USBD_INVAL);
sc->sc_as_iface = id->bInterfaceNumber;
DPRINTF(("uaudio_identify_as: AS interface is %d\n", sc->sc_as_iface));
@@ -1098,7 +1107,7 @@ uaudio_identify_as(sc, cdesc)
sc->sc_nullalt = id->bAlternateSetting;
break;
case 1:
- r = uaudio_process_as(sc, buf, &offs, size, id);
+ err = uaudio_process_as(sc, buf, &offs, size, id);
break;
default:
#ifdef AUDIO_DEBUG
@@ -1109,7 +1118,7 @@ uaudio_identify_as(sc, cdesc)
break;
}
id = uaudio_find_iface(buf, size, &offs,USUBCLASS_AUDIOSTREAM);
- if (!id)
+ if (id == NULL)
break;
}
if (offs > size)
@@ -1426,9 +1435,6 @@ uaudio_get_props(addr)
{
struct uaudio_softc *sc = addr;
- if (sc->sc_dying)
- return (EIO);
-
return (sc->sc_props);
}
@@ -1439,7 +1445,7 @@ uaudio_get(sc, which, type, wValue, wIndex, len)
{
usb_device_request_t req;
u_int8_t data[4];
- usbd_status r;
+ usbd_status err;
int val;
if (wValue == -1)
@@ -1453,9 +1459,9 @@ uaudio_get(sc, which, type, wValue, wIndex, len)
DPRINTFN(2,("uaudio_get: type=0x%02x req=0x%02x wValue=0x%04x "
"wIndex=0x%04x len=%d\n",
type, which, wValue, wIndex, len));
- r = usbd_do_request(sc->sc_udev, &req, &data);
- if (r != USBD_NORMAL_COMPLETION) {
- DPRINTF(("uaudio_get: r=%d\n", r));
+ err = usbd_do_request(sc->sc_udev, &req, &data);
+ if (err) {
+ DPRINTF(("uaudio_get: err=%d\n", err));
return (-1);
}
switch (len) {
@@ -1480,7 +1486,7 @@ uaudio_set(sc, which, type, wValue, wIndex, len, val)
{
usb_device_request_t req;
u_int8_t data[4];
- usbd_status r;
+ usbd_status err;
if (wValue == -1)
return;
@@ -1504,10 +1510,10 @@ uaudio_set(sc, which, type, wValue, wIndex, len, val)
DPRINTFN(2,("uaudio_set: type=0x%02x req=0x%02x wValue=0x%04x "
"wIndex=0x%04x len=%d, val=%d\n",
type, which, wValue, wIndex, len, val & 0xffff));
- r = usbd_do_request(sc->sc_udev, &req, &data);
+ err = usbd_do_request(sc->sc_udev, &req, &data);
#ifdef UAUDIO_DEBUG
- if (r != USBD_NORMAL_COMPLETION)
- DPRINTF(("uaudio_set: r=%d\n", r));
+ if (err != USBD_NORMAL_COMPLETION)
+ DPRINTF(("uaudio_set: err=%d\n", err));
#endif
}
@@ -1676,7 +1682,7 @@ uaudio_trigger_input(addr, start, end, blksize, intr, arg, param)
{
struct uaudio_softc *sc = addr;
struct chan *ch = &sc->sc_chan;
- usbd_status r;
+ usbd_status err;
int i, s;
if (sc->sc_dying)
@@ -1690,12 +1696,12 @@ uaudio_trigger_input(addr, start, end, blksize, intr, arg, param)
"fraction=0.%03d\n", ch->sample_size, ch->bytes_per_frame,
ch->fraction));
- r = uaudio_chan_alloc_buffers(sc, ch);
- if (r != USBD_NORMAL_COMPLETION)
+ err = uaudio_chan_alloc_buffers(sc, ch);
+ if (err)
return (EIO);
- r = uaudio_chan_open(sc, ch);
- if (r != USBD_NORMAL_COMPLETION) {
+ err = uaudio_chan_open(sc, ch);
+ if (err) {
uaudio_chan_free_buffers(sc, ch);
return (EIO);
}
@@ -1722,7 +1728,7 @@ uaudio_trigger_output(addr, start, end, blksize, intr, arg, param)
{
struct uaudio_softc *sc = addr;
struct chan *ch = &sc->sc_chan;
- usbd_status r;
+ usbd_status err;
int i, s;
if (sc->sc_dying)
@@ -1736,12 +1742,12 @@ uaudio_trigger_output(addr, start, end, blksize, intr, arg, param)
"fraction=0.%03d\n", ch->sample_size, ch->bytes_per_frame,
ch->fraction));
- r = uaudio_chan_alloc_buffers(sc, ch);
- if (r != USBD_NORMAL_COMPLETION)
+ err = uaudio_chan_alloc_buffers(sc, ch);
+ if (err)
return (EIO);
- r = uaudio_chan_open(sc, ch);
- if (r != USBD_NORMAL_COMPLETION) {
+ err = uaudio_chan_open(sc, ch);
+ if (err) {
uaudio_chan_free_buffers(sc, ch);
return (EIO);
}
@@ -1765,29 +1771,29 @@ uaudio_chan_open(sc, ch)
{
struct as_info *as = &sc->sc_alts[sc->sc_curaltidx];
int endpt = as->edesc->bEndpointAddress;
- usbd_status r;
+ usbd_status err;
DPRINTF(("uaudio_open_chan: endpt=0x%02x, speed=%d, alt=%d\n",
endpt, ch->sample_rate, as->alt));
/* Set alternate interface corresponding to the mode. */
- r = usbd_set_interface(sc->sc_as_ifaceh, as->alt);
- if (r != USBD_NORMAL_COMPLETION)
- return (r);
+ err = usbd_set_interface(sc->sc_as_ifaceh, as->alt);
+ if (err)
+ return (err);
/* Some devices do not support this request, so ignore errors. */
#ifdef UAUDIO_DEBUG
- r = uaudio_set_speed(sc, endpt, ch->sample_rate);
- if (r != USBD_NORMAL_COMPLETION)
- DPRINTF(("uaudio_chan_open: set_speed failed r=%s\n",
- usbd_errstr(r)));
+ err = uaudio_set_speed(sc, endpt, ch->sample_rate);
+ if (err)
+ DPRINTF(("uaudio_chan_open: set_speed failed err=%s\n",
+ usbd_errstr(err)));
#else
(void)uaudio_set_speed(sc, endpt, ch->sample_rate);
#endif
DPRINTF(("uaudio_open_chan: create pipe to 0x%02x\n", endpt));
- r = usbd_open_pipe(sc->sc_as_ifaceh, endpt, 0, &ch->pipe);
- return (r);
+ err = usbd_open_pipe(sc->sc_as_ifaceh, endpt, 0, &ch->pipe);
+ return (err);
}
void
@@ -1809,17 +1815,17 @@ uaudio_chan_alloc_buffers(sc, ch)
struct uaudio_softc *sc;
struct chan *ch;
{
- usbd_request_handle reqh;
+ usbd_xfer_handle xfer;
void *buf;
int i, size;
size = (ch->bytes_per_frame + ch->sample_size) * UAUDIO_NFRAMES;
for (i = 0; i < UAUDIO_NCHANBUFS; i++) {
- reqh = usbd_alloc_request(sc->sc_udev);
- if (reqh == 0)
+ xfer = usbd_alloc_request(sc->sc_udev);
+ if (xfer == 0)
goto bad;
- ch->chanbufs[i].reqh = reqh;
- buf = usbd_alloc_buffer(reqh, size);
+ ch->chanbufs[i].xfer = xfer;
+ buf = usbd_alloc_buffer(xfer, size);
if (buf == 0) {
i++;
goto bad;
@@ -1833,7 +1839,7 @@ uaudio_chan_alloc_buffers(sc, ch)
bad:
while (--i >= 0)
/* implicit buffer free */
- usbd_free_request(ch->chanbufs[i].reqh);
+ usbd_free_request(ch->chanbufs[i].xfer);
return (USBD_NOMEM);
}
@@ -1845,7 +1851,7 @@ uaudio_chan_free_buffers(sc, ch)
int i;
for (i = 0; i < UAUDIO_NCHANBUFS; i++)
- usbd_free_request(ch->chanbufs[i].reqh);
+ usbd_free_request(ch->chanbufs[i].xfer);
}
/* Called at splusb() */
@@ -1905,18 +1911,18 @@ uaudio_chan_ptransfer(ch)
}
#endif
- DPRINTFN(5,("uaudio_chan_transfer: ptransfer reqh=%p\n", cb->reqh));
+ DPRINTFN(5,("uaudio_chan_transfer: ptransfer xfer=%p\n", cb->xfer));
/* Fill the request */
- usbd_setup_isoc_request(cb->reqh, ch->pipe, cb, cb->sizes,
+ usbd_setup_isoc_request(cb->xfer, ch->pipe, cb, cb->sizes,
UAUDIO_NFRAMES, USBD_NO_COPY,
uaudio_chan_pintr);
- (void)usbd_transfer(cb->reqh);
+ (void)usbd_transfer(cb->xfer);
}
void
-uaudio_chan_pintr(reqh, priv, status)
- usbd_request_handle reqh;
+uaudio_chan_pintr(xfer, priv, status)
+ usbd_xfer_handle xfer;
usbd_private_handle priv;
usbd_status status;
{
@@ -1929,7 +1935,7 @@ uaudio_chan_pintr(reqh, priv, status)
if (status == USBD_CANCELLED)
return;
- usbd_get_request_status(reqh, 0, 0, &count, 0);
+ usbd_get_request_status(xfer, 0, 0, &count, 0);
DPRINTFN(5,("uaudio_chan_pintr: count=%d, transferred=%d\n",
count, ch->transferred));
#ifdef DIAGNOSTIC
@@ -1996,18 +2002,18 @@ uaudio_chan_rtransfer(ch)
}
#endif
- DPRINTFN(5,("uaudio_chan_rtransfer: transfer reqh=%p\n", cb->reqh));
+ DPRINTFN(5,("uaudio_chan_rtransfer: transfer xfer=%p\n", cb->xfer));
/* Fill the request */
- usbd_setup_isoc_request(cb->reqh, ch->pipe, cb, cb->sizes,
+ usbd_setup_isoc_request(cb->xfer, ch->pipe, cb, cb->sizes,
UAUDIO_NFRAMES, USBD_NO_COPY,
uaudio_chan_rintr);
- (void)usbd_transfer(cb->reqh);
+ (void)usbd_transfer(cb->xfer);
}
void
-uaudio_chan_rintr(reqh, priv, status)
- usbd_request_handle reqh;
+uaudio_chan_rintr(xfer, priv, status)
+ usbd_xfer_handle xfer;
usbd_private_handle priv;
usbd_status status;
{
@@ -2020,7 +2026,7 @@ uaudio_chan_rintr(reqh, priv, status)
if (status == USBD_CANCELLED)
return;
- usbd_get_request_status(reqh, 0, 0, &count, 0);
+ usbd_get_request_status(xfer, 0, 0, &count, 0);
DPRINTFN(5,("uaudio_chan_rintr: count=%d, transferred=%d\n",
count, ch->transferred));
#ifdef DIAGNOSTIC
@@ -2100,7 +2106,7 @@ uaudio_set_params(addr, setmode, usemode, p, r)
if (sc->sc_dying)
return (EIO);
- if (sc->sc_chan.pipe)
+ if (sc->sc_chan.pipe != NULL)
return (EBUSY);
pswcode = rswcode = 0;
diff --git a/sys/dev/usb/ucom.c b/sys/dev/usb/ucom.c
index d9a2b7c4783..a36a8ff62c8 100644
--- a/sys/dev/usb/ucom.c
+++ b/sys/dev/usb/ucom.c
@@ -1,4 +1,4 @@
-/* $NetBSD: ucom.c,v 1.10 1999/09/09 12:26:44 augustss Exp $ */
+/* $NetBSD: ucom.c,v 1.11 1999/11/12 00:34:57 augustss Exp $ */
/*
* Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -80,7 +80,7 @@ struct ucom_softc {
usbd_interface_handle sc_iface; /* interface */
};
-void ucom_intr __P((usbd_request_handle, usbd_private_handle, usbd_status));
+void ucom_intr __P((usbd_xfer_handle, usbd_private_handle, usbd_status));
void ucom_disco __P((void *));
USB_DECLARE_DRIVER(ucom);
diff --git a/sys/dev/usb/ugen.c b/sys/dev/usb/ugen.c
index 98847916dca..a909630fbdc 100644
--- a/sys/dev/usb/ugen.c
+++ b/sys/dev/usb/ugen.c
@@ -1,4 +1,4 @@
-/* $NetBSD: ugen.c,v 1.27 1999/10/28 12:08:38 augustss Exp $ */
+/* $NetBSD: ugen.c,v 1.28 1999/11/12 00:34:57 augustss Exp $ */
/*
* Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -140,18 +140,18 @@ static struct cdevsw ugen_cdevsw = {
};
#endif
-void ugenintr __P((usbd_request_handle reqh, usbd_private_handle addr,
- usbd_status status));
+static void ugenintr __P((usbd_xfer_handle xfer, usbd_private_handle addr,
+ usbd_status status));
-int ugen_do_read __P((struct ugen_softc *, int, struct uio *, int));
-int ugen_do_write __P((struct ugen_softc *, int, struct uio *, int));
-int ugen_do_ioctl __P((struct ugen_softc *, int, u_long,
- caddr_t, int, struct proc *));
-int ugen_set_config __P((struct ugen_softc *sc, int configno));
-usb_config_descriptor_t *ugen_get_cdesc __P((struct ugen_softc *sc, int index,
- int *lenp));
-usbd_status ugen_set_interface __P((struct ugen_softc *, int, int));
-int ugen_get_alt_index __P((struct ugen_softc *sc, int ifaceidx));
+static int ugen_do_read __P((struct ugen_softc *, int, struct uio *, int));
+static int ugen_do_write __P((struct ugen_softc *, int, struct uio *, int));
+static int ugen_do_ioctl __P((struct ugen_softc *, int, u_long,
+ caddr_t, int, struct proc *));
+static int ugen_set_config __P((struct ugen_softc *sc, int configno));
+static usb_config_descriptor_t *ugen_get_cdesc __P((struct ugen_softc *sc,
+ int index, int *lenp));
+static usbd_status ugen_set_interface __P((struct ugen_softc *, int, int));
+static int ugen_get_alt_index __P((struct ugen_softc *sc, int ifaceidx));
#define UGENUNIT(n) ((minor(n) >> 4) & 0xf)
#define UGENENDPOINT(n) (minor(n) & 0xf)
@@ -173,7 +173,7 @@ USB_ATTACH(ugen)
{
USB_ATTACH_START(ugen, sc, uaa);
char devinfo[1024];
- usbd_status r;
+ usbd_status err;
int conf;
usbd_devinfo(uaa->device, 0, devinfo);
@@ -182,8 +182,8 @@ USB_ATTACH(ugen)
sc->sc_udev = uaa->device;
conf = 1; /* XXX should not hard code 1 */
- r = ugen_set_config(sc, conf);
- if (r != USBD_NORMAL_COMPLETION) {
+ err = ugen_set_config(sc, conf);
+ if (err) {
printf("%s: setting configuration %d failed\n",
USBDEVNAME(sc->sc_dev), conf);
sc->sc_dying = 1;
@@ -203,30 +203,30 @@ ugen_set_config(sc, configno)
struct ugen_endpoint *sce;
u_int8_t niface, nendpt;
int ifaceno, endptno, endpt;
- usbd_status r;
+ usbd_status err;
int dir;
DPRINTFN(1,("ugen_set_config: %s to configno %d, sc=%p\n",
USBDEVNAME(sc->sc_dev), configno, sc));
if (usbd_get_config_descriptor(dev)->bConfigurationValue != configno) {
/* Avoid setting the current value. */
- r = usbd_set_config_no(dev, configno, 0);
- if (r != USBD_NORMAL_COMPLETION)
- return (r);
+ err = usbd_set_config_no(dev, configno, 0);
+ if (err)
+ return (err);
}
- r = usbd_interface_count(dev, &niface);
- if (r != USBD_NORMAL_COMPLETION)
- return (r);
+ err = usbd_interface_count(dev, &niface);
+ if (err)
+ return (err);
memset(sc->sc_endpoints, 0, sizeof sc->sc_endpoints);
for (ifaceno = 0; ifaceno < niface; ifaceno++) {
DPRINTFN(1,("ugen_set_config: ifaceno %d\n", ifaceno));
- r = usbd_device2interface_handle(dev, ifaceno, &iface);
- if (r != USBD_NORMAL_COMPLETION)
- return (r);
- r = usbd_endpoint_count(iface, &nendpt);
- if (r != USBD_NORMAL_COMPLETION)
- return (r);
+ err = usbd_device2interface_handle(dev, ifaceno, &iface);
+ if (err)
+ return (err);
+ err = usbd_endpoint_count(iface, &nendpt);
+ if (err)
+ return (err);
for (endptno = 0; endptno < nendpt; endptno++) {
ed = usbd_interface2endpoint_descriptor(iface,endptno);
endpt = ed->bEndpointAddress;
@@ -257,7 +257,7 @@ ugenopen(dev, flag, mode, p)
usb_endpoint_descriptor_t *edesc;
struct ugen_endpoint *sce;
int dir, isize;
- usbd_status r;
+ usbd_status err;
USB_GET_SC_OPEN(ugen, unit, sc);
DPRINTFN(5, ("ugenopen: flag=%d, mode=%d, unit=%d endpt=%d\n",
@@ -303,11 +303,11 @@ ugenopen(dev, flag, mode, p)
endpt, isize));
if (clalloc(&sce->q, UGEN_IBSIZE, 0) == -1)
return (ENOMEM);
- r = usbd_open_pipe_intr(sce->iface,
- edesc->bEndpointAddress,
- USBD_SHORT_XFER_OK, &sce->pipeh, sce,
- sce->ibuf, isize, ugenintr);
- if (r != USBD_NORMAL_COMPLETION) {
+ err = usbd_open_pipe_intr(sce->iface,
+ edesc->bEndpointAddress,
+ USBD_SHORT_XFER_OK, &sce->pipeh, sce,
+ sce->ibuf, isize, ugenintr);
+ if (err) {
free(sce->ibuf, M_USBDEV);
clfree(&sce->q);
return (EIO);
@@ -315,10 +315,9 @@ ugenopen(dev, flag, mode, p)
DPRINTFN(5, ("ugenopen: interrupt open done\n"));
break;
case UE_BULK:
- r = usbd_open_pipe(sce->iface,
- edesc->bEndpointAddress, 0,
- &sce->pipeh);
- if (r != USBD_NORMAL_COMPLETION)
+ err = usbd_open_pipe(sce->iface,
+ edesc->bEndpointAddress, 0, &sce->pipeh);
+ if (err)
return (EIO);
break;
case UE_CONTROL:
@@ -370,9 +369,9 @@ ugenclose(dev, flag, mode, p)
usbd_abort_pipe(sce->pipeh);
usbd_close_pipe(sce->pipeh);
- sce->pipeh = 0;
+ sce->pipeh = NULL;
- if (sce->ibuf) {
+ if (sce->ibuf != NULL) {
free(sce->ibuf, M_USBDEV);
sce->ibuf = 0;
clfree(&sce->q);
@@ -393,8 +392,8 @@ ugen_do_read(sc, endpt, uio, flag)
struct ugen_endpoint *sce = &sc->sc_endpoints[endpt][IN];
u_int32_t n, tn;
char buf[UGEN_BBSIZE];
- usbd_request_handle reqh;
- usbd_status r;
+ usbd_xfer_handle xfer;
+ usbd_status err;
int s;
int error = 0;
u_char buffer[UGEN_CHUNK];
@@ -410,11 +409,11 @@ ugen_do_read(sc, endpt, uio, flag)
return (ENODEV);
#ifdef DIAGNOSTIC
- if (!sce->edesc) {
+ if (sce->edesc == NULL) {
printf("ugenread: no edesc\n");
return (EIO);
}
- if (!sce->pipeh) {
+ if (sce->pipeh == NULL) {
printf("ugenread: no pipe\n");
return (EIO);
}
@@ -459,21 +458,21 @@ ugen_do_read(sc, endpt, uio, flag)
}
break;
case UE_BULK:
- reqh = usbd_alloc_request(sc->sc_udev);
- if (reqh == 0)
+ xfer = usbd_alloc_request(sc->sc_udev);
+ if (xfer == 0)
return (ENOMEM);
while ((n = min(UGEN_BBSIZE, uio->uio_resid)) != 0) {
DPRINTFN(1, ("ugenread: start transfer %d bytes\n",n));
tn = n;
- r = usbd_bulk_transfer(
- reqh, sce->pipeh,
- sce->state & UGEN_SHORT_OK ?
- USBD_SHORT_XFER_OK : 0,
- sce->timeout, buf, &tn, "ugenrb");
- if (r != USBD_NORMAL_COMPLETION) {
- if (r == USBD_INTERRUPTED)
+ err = usbd_bulk_transfer(
+ xfer, sce->pipeh,
+ sce->state & UGEN_SHORT_OK ?
+ USBD_SHORT_XFER_OK : 0,
+ sce->timeout, buf, &tn, "ugenrb");
+ if (err != USBD_NORMAL_COMPLETION) {
+ if (err == USBD_INTERRUPTED)
error = EINTR;
- else if (r == USBD_TIMEOUT)
+ else if (err == USBD_TIMEOUT)
error = ETIMEDOUT;
else
error = EIO;
@@ -484,7 +483,7 @@ ugen_do_read(sc, endpt, uio, flag)
if (error || tn < n)
break;
}
- usbd_free_request(reqh);
+ usbd_free_request(xfer);
break;
default:
return (ENXIO);
@@ -521,8 +520,8 @@ ugen_do_write(sc, endpt, uio, flag)
u_int32_t n;
int error = 0;
char buf[UGEN_BBSIZE];
- usbd_request_handle reqh;
- usbd_status r;
+ usbd_xfer_handle xfer;
+ usbd_status err;
#ifdef __NetBSD__
DPRINTFN(5, ("ugenwrite: %d:%d\n", sc->sc_dev.dv_unit, endpt));
@@ -535,11 +534,11 @@ ugen_do_write(sc, endpt, uio, flag)
return (ENODEV);
#ifdef DIAGNOSTIC
- if (!sce->edesc) {
+ if (sce->edesc == NULL) {
printf("ugenwrite: no edesc\n");
return (EIO);
}
- if (!sce->pipeh) {
+ if (sce->pipeh == NULL) {
printf("ugenwrite: no pipe\n");
return (EIO);
}
@@ -547,25 +546,25 @@ ugen_do_write(sc, endpt, uio, flag)
switch (sce->edesc->bmAttributes & UE_XFERTYPE) {
case UE_BULK:
- reqh = usbd_alloc_request(sc->sc_udev);
- if (reqh == 0)
+ xfer = usbd_alloc_request(sc->sc_udev);
+ if (xfer == 0)
return (EIO);
while ((n = min(UGEN_BBSIZE, uio->uio_resid)) != 0) {
error = uiomove(buf, n, uio);
if (error)
break;
DPRINTFN(1, ("ugenwrite: transfer %d bytes\n", n));
- r = usbd_bulk_transfer(reqh, sce->pipeh, 0,
- sce->timeout, buf, &n,"ugenwb");
- if (r != USBD_NORMAL_COMPLETION) {
- if (r == USBD_INTERRUPTED)
+ err = usbd_bulk_transfer(xfer, sce->pipeh, 0,
+ sce->timeout, buf, &n,"ugenwb");
+ if (err) {
+ if (err == USBD_INTERRUPTED)
error = EINTR;
else
error = EIO;
break;
}
}
- usbd_free_request(reqh);
+ usbd_free_request(xfer);
break;
default:
return (ENXIO);
@@ -663,8 +662,8 @@ USB_DETACH(ugen)
}
void
-ugenintr(reqh, addr, status)
- usbd_request_handle reqh;
+ugenintr(xfer, addr, status)
+ usbd_xfer_handle xfer;
usbd_private_handle addr;
usbd_status status;
{
@@ -682,11 +681,11 @@ ugenintr(reqh, addr, status)
return;
}
- usbd_get_request_status(reqh, 0, 0, &count, 0);
+ usbd_get_request_status(xfer, 0, 0, &count, 0);
ibuf = sce->ibuf;
- DPRINTFN(5, ("ugenintr: reqh=%p status=%d count=%d\n",
- reqh, status, count));
+ DPRINTFN(5, ("ugenintr: xfer=%p status=%d count=%d\n",
+ xfer, status, count));
DPRINTFN(5, (" data = %02x %02x %02x\n",
ibuf[0], ibuf[1], ibuf[2]));
@@ -707,25 +706,25 @@ ugen_set_interface(sc, ifaceidx, altno)
{
usbd_interface_handle iface;
usb_endpoint_descriptor_t *ed;
- usbd_status r;
+ usbd_status err;
struct ugen_endpoint *sce;
u_int8_t niface, nendpt, endptno, endpt;
int dir;
DPRINTFN(15, ("ugen_set_interface %d %d\n", ifaceidx, altno));
- r = usbd_interface_count(sc->sc_udev, &niface);
- if (r != USBD_NORMAL_COMPLETION)
- return (r);
+ err = usbd_interface_count(sc->sc_udev, &niface);
+ if (err)
+ return (err);
if (ifaceidx < 0 || ifaceidx >= niface)
return (USBD_INVAL);
- r = usbd_device2interface_handle(sc->sc_udev, ifaceidx, &iface);
- if (r != USBD_NORMAL_COMPLETION)
- return (r);
- r = usbd_endpoint_count(iface, &nendpt);
- if (r != USBD_NORMAL_COMPLETION)
- return (r);
+ err = usbd_device2interface_handle(sc->sc_udev, ifaceidx, &iface);
+ if (err)
+ return (err);
+ err = usbd_endpoint_count(iface, &nendpt);
+ if (err)
+ return (err);
for (endptno = 0; endptno < nendpt; endptno++) {
ed = usbd_interface2endpoint_descriptor(iface,endptno);
endpt = ed->bEndpointAddress;
@@ -737,13 +736,13 @@ ugen_set_interface(sc, ifaceidx, altno)
}
/* change setting */
- r = usbd_set_interface(iface, altno);
- if (r != USBD_NORMAL_COMPLETION)
- return (r);
+ err = usbd_set_interface(iface, altno);
+ if (err)
+ return (err);
- r = usbd_endpoint_count(iface, &nendpt);
- if (r != USBD_NORMAL_COMPLETION)
- return (r);
+ err = usbd_endpoint_count(iface, &nendpt);
+ if (err)
+ return (err);
for (endptno = 0; endptno < nendpt; endptno++) {
ed = usbd_interface2endpoint_descriptor(iface,endptno);
endpt = ed->bEndpointAddress;
@@ -765,7 +764,7 @@ ugen_get_cdesc(sc, index, lenp)
{
usb_config_descriptor_t *cdesc, *tdesc, cdescr;
int len;
- usbd_status r;
+ usbd_status err;
if (index == USB_CURRENT_CONFIG_INDEX) {
tdesc = usbd_get_config_descriptor(sc->sc_udev);
@@ -776,16 +775,16 @@ ugen_get_cdesc(sc, index, lenp)
memcpy(cdesc, tdesc, len);
DPRINTFN(5,("ugen_get_cdesc: current, len=%d\n", len));
} else {
- r = usbd_get_config_desc(sc->sc_udev, index, &cdescr);
- if (r != USBD_NORMAL_COMPLETION)
+ err = usbd_get_config_desc(sc->sc_udev, index, &cdescr);
+ if (err)
return (0);
len = UGETW(cdescr.wTotalLength);
DPRINTFN(5,("ugen_get_cdesc: index=%d, len=%d\n", index, len));
if (lenp)
*lenp = len;
cdesc = malloc(len, M_TEMP, M_WAITOK);
- r = usbd_get_config_desc_full(sc->sc_udev, index, cdesc, len);
- if (r != USBD_NORMAL_COMPLETION) {
+ err = usbd_get_config_desc_full(sc->sc_udev, index, cdesc,len);
+ if (err) {
free(cdesc, M_TEMP);
return (0);
}
@@ -799,10 +798,10 @@ ugen_get_alt_index(sc, ifaceidx)
int ifaceidx;
{
usbd_interface_handle iface;
- usbd_status r;
+ usbd_status err;
- r = usbd_device2interface_handle(sc->sc_udev, ifaceidx, &iface);
- if (r != USBD_NORMAL_COMPLETION)
+ err = usbd_device2interface_handle(sc->sc_udev, ifaceidx, &iface);
+ if (err)
return (-1);
return (usbd_get_interface_altindex(iface));
}
@@ -817,7 +816,7 @@ ugen_do_ioctl(sc, endpt, cmd, addr, flag, p)
struct proc *p;
{
struct ugen_endpoint *sce;
- usbd_status r;
+ usbd_status err;
usbd_interface_handle iface;
struct usb_config_desc *cd;
usb_config_descriptor_t *cdesc;
@@ -845,7 +844,7 @@ ugen_do_ioctl(sc, endpt, cmd, addr, flag, p)
if (sce == NULL)
return (EINVAL);
#ifdef DIAGNOSTIC
- if (!sce->pipeh) {
+ if (sce->pipeh == NULL) {
printf("ugenioctl: USB_SET_SHORT_XFER, no pipe\n");
return (EIO);
}
@@ -860,7 +859,7 @@ ugen_do_ioctl(sc, endpt, cmd, addr, flag, p)
if (sce == NULL)
return (EINVAL);
#ifdef DIAGNOSTIC
- if (!sce->pipeh) {
+ if (sce->pipeh == NULL) {
printf("ugenioctl: USB_SET_TIMEOUT, no pipe\n");
return (EIO);
}
@@ -881,26 +880,26 @@ ugen_do_ioctl(sc, endpt, cmd, addr, flag, p)
break;
#endif
case USB_GET_CONFIG:
- r = usbd_get_config(sc->sc_udev, &conf);
- if (r != USBD_NORMAL_COMPLETION)
+ err = usbd_get_config(sc->sc_udev, &conf);
+ if (err)
return (EIO);
*(int *)addr = conf;
break;
case USB_SET_CONFIG:
if (!(flag & FWRITE))
return (EPERM);
- r = ugen_set_config(sc, *(int *)addr);
- if (r != USBD_NORMAL_COMPLETION)
+ err = ugen_set_config(sc, *(int *)addr);
+ if (err)
return (EIO);
break;
case USB_GET_ALTINTERFACE:
ai = (struct usb_alt_interface *)addr;
- r = usbd_device2interface_handle(sc->sc_udev,
- ai->interface_index, &iface);
- if (r != USBD_NORMAL_COMPLETION)
+ err = usbd_device2interface_handle(sc->sc_udev,
+ ai->interface_index, &iface);
+ if (err)
return (EINVAL);
idesc = usbd_get_interface_descriptor(iface);
- if (!idesc)
+ if (idesc == NULL)
return (EIO);
ai->alt_no = idesc->bAlternateSetting;
break;
@@ -908,21 +907,21 @@ ugen_do_ioctl(sc, endpt, cmd, addr, flag, p)
if (!(flag & FWRITE))
return (EPERM);
ai = (struct usb_alt_interface *)addr;
- r = usbd_device2interface_handle(sc->sc_udev,
- ai->interface_index, &iface);
- if (r != USBD_NORMAL_COMPLETION)
+ err = usbd_device2interface_handle(sc->sc_udev,
+ ai->interface_index, &iface);
+ if (err)
return (EINVAL);
- r = ugen_set_interface(sc, ai->interface_index, ai->alt_no);
- if (r != USBD_NORMAL_COMPLETION)
+ err = ugen_set_interface(sc, ai->interface_index, ai->alt_no);
+ if (err)
return (EINVAL);
break;
case USB_GET_NO_ALT:
ai = (struct usb_alt_interface *)addr;
cdesc = ugen_get_cdesc(sc, ai->config_index, 0);
- if (!cdesc)
+ if (cdesc == NULL)
return (EINVAL);
idesc = usbd_find_idesc(cdesc, ai->interface_index, 0);
- if (!idesc) {
+ if (idesc == NULL) {
free(cdesc, M_TEMP);
return (EINVAL);
}
@@ -936,7 +935,7 @@ ugen_do_ioctl(sc, endpt, cmd, addr, flag, p)
case USB_GET_CONFIG_DESC:
cd = (struct usb_config_desc *)addr;
cdesc = ugen_get_cdesc(sc, cd->config_index, 0);
- if (!cdesc)
+ if (cdesc == NULL)
return (EINVAL);
cd->desc = *cdesc;
free(cdesc, M_TEMP);
@@ -944,7 +943,7 @@ ugen_do_ioctl(sc, endpt, cmd, addr, flag, p)
case USB_GET_INTERFACE_DESC:
id = (struct usb_interface_desc *)addr;
cdesc = ugen_get_cdesc(sc, id->config_index, 0);
- if (!cdesc)
+ if (cdesc == NULL)
return (EINVAL);
if (id->config_index == USB_CURRENT_CONFIG_INDEX &&
id->alt_index == USB_CURRENT_ALT_INDEX)
@@ -952,7 +951,7 @@ ugen_do_ioctl(sc, endpt, cmd, addr, flag, p)
else
alt = id->alt_index;
idesc = usbd_find_idesc(cdesc, id->interface_index, alt);
- if (!idesc) {
+ if (idesc == NULL) {
free(cdesc, M_TEMP);
return (EINVAL);
}
@@ -962,7 +961,7 @@ ugen_do_ioctl(sc, endpt, cmd, addr, flag, p)
case USB_GET_ENDPOINT_DESC:
ed = (struct usb_endpoint_desc *)addr;
cdesc = ugen_get_cdesc(sc, ed->config_index, 0);
- if (!cdesc)
+ if (cdesc == NULL)
return (EINVAL);
if (ed->config_index == USB_CURRENT_CONFIG_INDEX &&
ed->alt_index == USB_CURRENT_ALT_INDEX)
@@ -971,7 +970,7 @@ ugen_do_ioctl(sc, endpt, cmd, addr, flag, p)
alt = ed->alt_index;
edesc = usbd_find_edesc(cdesc, ed->interface_index,
alt, ed->endpoint_index);
- if (!edesc) {
+ if (edesc == NULL) {
free(cdesc, M_TEMP);
return (EINVAL);
}
@@ -1004,9 +1003,9 @@ ugen_do_ioctl(sc, endpt, cmd, addr, flag, p)
}
case USB_GET_STRING_DESC:
si = (struct usb_string_desc *)addr;
- r = usbd_get_string_desc(sc->sc_udev, si->string_index,
- si->language_id, &si->desc);
- if (r != USBD_NORMAL_COMPLETION)
+ err = usbd_get_string_desc(sc->sc_udev, si->string_index,
+ si->language_id, &si->desc);
+ if (err)
return (EINVAL);
break;
case USB_DO_REQUEST:
@@ -1016,7 +1015,7 @@ ugen_do_ioctl(sc, endpt, cmd, addr, flag, p)
struct iovec iov;
struct uio uio;
void *ptr = 0;
- usbd_status r;
+ usbd_status err;
int error = 0;
if (!(flag & FWRITE))
@@ -1051,9 +1050,9 @@ ugen_do_ioctl(sc, endpt, cmd, addr, flag, p)
goto ret;
}
}
- r = usbd_do_request_flags(sc->sc_udev, &ur->request,
- ptr, ur->flags, &ur->actlen);
- if (r != USBD_NORMAL_COMPLETION) {
+ err = usbd_do_request_flags(sc->sc_udev, &ur->request,
+ ptr, ur->flags, &ur->actlen);
+ if (err) {
error = EIO;
goto ret;
}
diff --git a/sys/dev/usb/uhci.c b/sys/dev/usb/uhci.c
index fac7dce55c6..e5b0519e1ea 100644
--- a/sys/dev/usb/uhci.c
+++ b/sys/dev/usb/uhci.c
@@ -1,4 +1,4 @@
-/* $NetBSD: uhci.c,v 1.62 1999/10/23 00:21:01 augustss Exp $ */
+/* $NetBSD: uhci.c,v 1.63 1999/11/12 00:34:57 augustss Exp $ */
/*
* Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -147,104 +147,105 @@ struct uhci_pipe {
*/
LIST_HEAD(, uhci_intr_info) uhci_ii_free;
-void uhci_busreset __P((uhci_softc_t *));
-void uhci_power __P((int, void *));
-usbd_status uhci_run __P((uhci_softc_t *, int run));
-uhci_soft_td_t *uhci_alloc_std __P((uhci_softc_t *));
-void uhci_free_std __P((uhci_softc_t *, uhci_soft_td_t *));
-uhci_soft_qh_t *uhci_alloc_sqh __P((uhci_softc_t *));
-void uhci_free_sqh __P((uhci_softc_t *, uhci_soft_qh_t *));
-uhci_intr_info_t *uhci_alloc_intr_info __P((uhci_softc_t *));
-void uhci_free_intr_info __P((uhci_intr_info_t *ii));
+static void uhci_busreset __P((uhci_softc_t *));
+static void uhci_power __P((int, void *));
+static usbd_status uhci_run __P((uhci_softc_t *, int run));
+static uhci_soft_td_t *uhci_alloc_std __P((uhci_softc_t *));
+static void uhci_free_std __P((uhci_softc_t *, uhci_soft_td_t *));
+static uhci_soft_qh_t *uhci_alloc_sqh __P((uhci_softc_t *));
+static void uhci_free_sqh __P((uhci_softc_t *, uhci_soft_qh_t *));
+static uhci_intr_info_t *uhci_alloc_intr_info __P((uhci_softc_t *));
+static void uhci_free_intr_info __P((uhci_intr_info_t *ii));
#if 0
-void uhci_enter_ctl_q __P((uhci_softc_t *, uhci_soft_qh_t *,
+static void uhci_enter_ctl_q __P((uhci_softc_t *, uhci_soft_qh_t *,
uhci_intr_info_t *));
-void uhci_exit_ctl_q __P((uhci_softc_t *, uhci_soft_qh_t *));
+static void uhci_exit_ctl_q __P((uhci_softc_t *, hci_soft_qh_t *));
#endif
-void uhci_free_std_chain __P((uhci_softc_t *,
+static void uhci_free_std_chain __P((uhci_softc_t *,
uhci_soft_td_t *, uhci_soft_td_t *));
-usbd_status uhci_alloc_std_chain __P((struct uhci_pipe *, uhci_softc_t *,
- int, int, int, usb_dma_t *,
- uhci_soft_td_t **,
- uhci_soft_td_t **));
-void uhci_timo __P((void *));
-void uhci_waitintr __P((uhci_softc_t *, usbd_request_handle));
-void uhci_check_intr __P((uhci_softc_t *, uhci_intr_info_t *));
-void uhci_idone __P((uhci_intr_info_t *));
-void uhci_abort_req __P((usbd_request_handle, usbd_status status));
-void uhci_abort_req_end __P((void *v));
-void uhci_timeout __P((void *));
-void uhci_wakeup_ctrl __P((void *, int, int, void *, int));
-void uhci_lock_frames __P((uhci_softc_t *));
-void uhci_unlock_frames __P((uhci_softc_t *));
-void uhci_add_ctrl __P((uhci_softc_t *, uhci_soft_qh_t *));
-void uhci_add_bulk __P((uhci_softc_t *, uhci_soft_qh_t *));
-void uhci_remove_ctrl __P((uhci_softc_t *, uhci_soft_qh_t *));
-void uhci_remove_bulk __P((uhci_softc_t *, uhci_soft_qh_t *));
-int uhci_str __P((usb_string_descriptor_t *, int, char *));
-usbd_status uhci_setup_isoc __P((usbd_pipe_handle pipe));
-void uhci_device_isoc_enter __P((usbd_request_handle));
-
-void uhci_wakeup_cb __P((usbd_request_handle reqh));
-
-usbd_status uhci_allocm __P((struct usbd_bus *, usb_dma_t *, u_int32_t));
-void uhci_freem __P((struct usbd_bus *, usb_dma_t *));
-
-usbd_status uhci_device_ctrl_transfer __P((usbd_request_handle));
-usbd_status uhci_device_ctrl_start __P((usbd_request_handle));
-void uhci_device_ctrl_abort __P((usbd_request_handle));
-void uhci_device_ctrl_close __P((usbd_pipe_handle));
-void uhci_device_ctrl_done __P((usbd_request_handle));
-
-usbd_status uhci_device_intr_transfer __P((usbd_request_handle));
-usbd_status uhci_device_intr_start __P((usbd_request_handle));
-void uhci_device_intr_abort __P((usbd_request_handle));
-void uhci_device_intr_close __P((usbd_pipe_handle));
-void uhci_device_intr_done __P((usbd_request_handle));
-
-usbd_status uhci_device_bulk_transfer __P((usbd_request_handle));
-usbd_status uhci_device_bulk_start __P((usbd_request_handle));
-void uhci_device_bulk_abort __P((usbd_request_handle));
-void uhci_device_bulk_close __P((usbd_pipe_handle));
-void uhci_device_bulk_done __P((usbd_request_handle));
-
-usbd_status uhci_device_isoc_transfer __P((usbd_request_handle));
-usbd_status uhci_device_isoc_start __P((usbd_request_handle));
-void uhci_device_isoc_abort __P((usbd_request_handle));
-void uhci_device_isoc_close __P((usbd_pipe_handle));
-void uhci_device_isoc_done __P((usbd_request_handle));
-
-usbd_status uhci_root_ctrl_transfer __P((usbd_request_handle));
-usbd_status uhci_root_ctrl_start __P((usbd_request_handle));
-void uhci_root_ctrl_abort __P((usbd_request_handle));
-void uhci_root_ctrl_close __P((usbd_pipe_handle));
-
-usbd_status uhci_root_intr_transfer __P((usbd_request_handle));
-usbd_status uhci_root_intr_start __P((usbd_request_handle));
-void uhci_root_intr_abort __P((usbd_request_handle));
-void uhci_root_intr_close __P((usbd_pipe_handle));
-void uhci_root_intr_done __P((usbd_request_handle));
-
-usbd_status uhci_open __P((usbd_pipe_handle));
-void uhci_poll __P((struct usbd_bus *));
-
-usbd_status uhci_device_request __P((usbd_request_handle reqh));
-
-void uhci_add_intr __P((uhci_softc_t *, int, uhci_soft_qh_t *));
-void uhci_remove_intr __P((uhci_softc_t *, int, uhci_soft_qh_t *));
-usbd_status uhci_device_setintr __P((uhci_softc_t *sc,
- struct uhci_pipe *pipe, int ival));
-
-void uhci_device_clear_toggle __P((usbd_pipe_handle pipe));
-void uhci_noop __P((usbd_pipe_handle pipe));
+static usbd_status uhci_alloc_std_chain __P((struct uhci_pipe *,
+ uhci_softc_t *, int, int, int, usb_dma_t *,
+ uhci_soft_td_t **, uhci_soft_td_t **));
+static void uhci_timo __P((void *));
+static void uhci_waitintr __P((uhci_softc_t *,
+ usbd_xfer_handle));
+static void uhci_check_intr __P((uhci_softc_t *,
+ uhci_intr_info_t *));
+static void uhci_idone __P((uhci_intr_info_t *));
+static void uhci_abort_req __P((usbd_xfer_handle,
+ usbd_status status));
+static void uhci_abort_req_end __P((void *v));
+static void uhci_timeout __P((void *));
+static void uhci_lock_frames __P((uhci_softc_t *));
+static void uhci_unlock_frames __P((uhci_softc_t *));
+static void uhci_add_ctrl __P((uhci_softc_t *, uhci_soft_qh_t *));
+static void uhci_add_bulk __P((uhci_softc_t *, uhci_soft_qh_t *));
+static void uhci_remove_ctrl __P((uhci_softc_t *,uhci_soft_qh_t *));
+static void uhci_remove_bulk __P((uhci_softc_t *,uhci_soft_qh_t *));
+static int uhci_str __P((usb_string_descriptor_t *, int, char *));
+static usbd_status uhci_setup_isoc __P((usbd_pipe_handle pipe));
+static void uhci_device_isoc_enter __P((usbd_xfer_handle));
+
+static usbd_status uhci_allocm __P((struct usbd_bus *, usb_dma_t *,
+ u_int32_t));
+static void uhci_freem __P((struct usbd_bus *, usb_dma_t *));
+
+static usbd_status uhci_device_ctrl_transfer __P((usbd_xfer_handle));
+static usbd_status uhci_device_ctrl_start __P((usbd_xfer_handle));
+static void uhci_device_ctrl_abort __P((usbd_xfer_handle));
+static void uhci_device_ctrl_close __P((usbd_pipe_handle));
+static void uhci_device_ctrl_done __P((usbd_xfer_handle));
+
+static usbd_status uhci_device_intr_transfer __P((usbd_xfer_handle));
+static usbd_status uhci_device_intr_start __P((usbd_xfer_handle));
+static void uhci_device_intr_abort __P((usbd_xfer_handle));
+static void uhci_device_intr_close __P((usbd_pipe_handle));
+static void uhci_device_intr_done __P((usbd_xfer_handle));
+
+static usbd_status uhci_device_bulk_transfer __P((usbd_xfer_handle));
+static usbd_status uhci_device_bulk_start __P((usbd_xfer_handle));
+static void uhci_device_bulk_abort __P((usbd_xfer_handle));
+static void uhci_device_bulk_close __P((usbd_pipe_handle));
+static void uhci_device_bulk_done __P((usbd_xfer_handle));
+
+static usbd_status uhci_device_isoc_transfer __P((usbd_xfer_handle));
+static usbd_status uhci_device_isoc_start __P((usbd_xfer_handle));
+static void uhci_device_isoc_abort __P((usbd_xfer_handle));
+static void uhci_device_isoc_close __P((usbd_pipe_handle));
+static void uhci_device_isoc_done __P((usbd_xfer_handle));
+
+static usbd_status uhci_root_ctrl_transfer __P((usbd_xfer_handle));
+static usbd_status uhci_root_ctrl_start __P((usbd_xfer_handle));
+static void uhci_root_ctrl_abort __P((usbd_xfer_handle));
+static void uhci_root_ctrl_close __P((usbd_pipe_handle));
+
+static usbd_status uhci_root_intr_transfer __P((usbd_xfer_handle));
+static usbd_status uhci_root_intr_start __P((usbd_xfer_handle));
+static void uhci_root_intr_abort __P((usbd_xfer_handle));
+static void uhci_root_intr_close __P((usbd_pipe_handle));
+static void uhci_root_intr_done __P((usbd_xfer_handle));
+
+static usbd_status uhci_open __P((usbd_pipe_handle));
+static void uhci_poll __P((struct usbd_bus *));
+
+static usbd_status uhci_device_request __P((usbd_xfer_handle xfer));
+
+static void uhci_add_intr __P((uhci_softc_t *, int,
+ uhci_soft_qh_t *));
+static void uhci_remove_intr __P((uhci_softc_t *, int,
+ uhci_soft_qh_t *));
+static usbd_status uhci_device_setintr __P((uhci_softc_t *sc,
+ struct uhci_pipe *pipe, int ival));
+
+static void uhci_device_clear_toggle __P((usbd_pipe_handle pipe));
+static void uhci_noop __P((usbd_pipe_handle pipe));
#ifdef UHCI_DEBUG
-static void uhci_dumpregs __P((uhci_softc_t *));
-void uhci_dump_tds __P((uhci_soft_td_t *));
-void uhci_dump_qh __P((uhci_soft_qh_t *));
-void uhci_dump __P((void));
-void uhci_dump_td __P((uhci_soft_td_t *));
+static void uhci_dumpregs __P((uhci_softc_t *));
+static void uhci_dump_tds __P((uhci_soft_td_t *));
+static void uhci_dump_qh __P((uhci_soft_qh_t *));
+static void uhci_dump_td __P((uhci_soft_td_t *));
#endif
#define UWRITE2(sc, r, x) bus_space_write_2((sc)->iot, (sc)->ioh, (r), (x))
@@ -336,7 +337,7 @@ usbd_status
uhci_init(sc)
uhci_softc_t *sc;
{
- usbd_status r;
+ usbd_status err;
int i, j;
uhci_soft_qh_t *csqh, *bsqh, *sqh;
uhci_soft_td_t *std;
@@ -354,18 +355,18 @@ uhci_init(sc)
uhci_busreset(sc);
/* Allocate and initialize real frame array. */
- r = usb_allocmem(&sc->sc_bus,
- UHCI_FRAMELIST_COUNT * sizeof(uhci_physaddr_t),
- UHCI_FRAMELIST_ALIGN, &sc->sc_dma);
- if (r != USBD_NORMAL_COMPLETION)
- return (r);
+ err = usb_allocmem(&sc->sc_bus,
+ UHCI_FRAMELIST_COUNT * sizeof(uhci_physaddr_t),
+ UHCI_FRAMELIST_ALIGN, &sc->sc_dma);
+ if (err)
+ return (err);
sc->sc_pframes = KERNADDR(&sc->sc_dma);
UWRITE2(sc, UHCI_FRNUM, 0); /* set frame number to 0 */
UWRITE4(sc, UHCI_FLBASEADDR, DMAADDR(&sc->sc_dma)); /* set frame list*/
/* Allocate the dummy QH where bulk traffic will be queued. */
bsqh = uhci_alloc_sqh(sc);
- if (!bsqh)
+ if (bsqh == NULL)
return (USBD_NOMEM);
bsqh->qh.qh_hlink = LE(UHCI_PTR_T); /* end of QH chain */
bsqh->qh.qh_elink = LE(UHCI_PTR_T);
@@ -373,7 +374,7 @@ uhci_init(sc)
/* Allocate the dummy QH where control traffic will be queued. */
csqh = uhci_alloc_sqh(sc);
- if (!csqh)
+ if (csqh == NULL)
return (USBD_NOMEM);
csqh->hlink = bsqh;
csqh->qh.qh_hlink = LE(bsqh->physaddr | UHCI_PTR_Q);
@@ -471,11 +472,8 @@ uhci_allocm(bus, dma, size)
usb_dma_t *dma;
u_int32_t size;
{
-#if defined(__NetBSD__) || defined(__OpenBSD__)
- struct uhci_softc *sc = (struct uhci_softc *)bus;
-#endif
-
- return (usb_allocmem(&sc->sc_bus, size, 0, dma));
+ return (usb_allocmem(&((struct uhci_softc *)bus)->sc_bus, size, 0,
+ dma));
}
void
@@ -483,11 +481,7 @@ uhci_freem(bus, dma)
struct usbd_bus *bus;
usb_dma_t *dma;
{
-#if defined(__NetBSD__) || defined(__OpenBSD__)
- struct uhci_softc *sc = (struct uhci_softc *)bus;
-#endif
-
- usb_freemem(&sc->sc_bus, dma);
+ usb_freemem(&((struct uhci_softc *)bus)->sc_bus, dma);
}
#if defined(__NetBSD__)
@@ -635,7 +629,7 @@ uhci_dump_tds(std)
{
uhci_soft_td_t *p;
- for(p = std; p; p = p->link.std)
+ for(p = std; p != NULL; p = p->link.std)
uhci_dump_td(p);
}
#endif
@@ -648,17 +642,17 @@ void
uhci_timo(addr)
void *addr;
{
- usbd_request_handle reqh = addr;
- usbd_pipe_handle pipe = reqh->pipe;
+ usbd_xfer_handle xfer = addr;
+ usbd_pipe_handle pipe = xfer->pipe;
uhci_softc_t *sc = (uhci_softc_t *)pipe->device->bus;
int s;
u_char *p;
DPRINTFN(15, ("uhci_timo\n"));
- usb_timeout(uhci_timo, reqh, sc->sc_ival, reqh->timo_handle);
+ usb_timeout(uhci_timo, xfer, sc->sc_ival, xfer->timo_handle);
- p = KERNADDR(&reqh->dmabuf);
+ p = KERNADDR(&xfer->dmabuf);
p[0] = 0;
if (UREAD2(sc, UHCI_PORTSC1) & (UHCI_PORTSC_CSC|UHCI_PORTSC_OCIC))
p[0] |= 1<<1;
@@ -668,19 +662,19 @@ uhci_timo(addr)
/* No change, try again in a while */
return;
- reqh->actlen = 1;
- reqh->status = USBD_NORMAL_COMPLETION;
+ xfer->actlen = 1;
+ xfer->status = USBD_NORMAL_COMPLETION;
s = splusb();
- reqh->hcpriv = 0;
- reqh->device->bus->intr_context++;
- usb_transfer_complete(reqh);
- reqh->device->bus->intr_context--;
+ xfer->hcpriv = 0;
+ xfer->device->bus->intr_context++;
+ usb_transfer_complete(xfer);
+ xfer->device->bus->intr_context--;
splx(s);
}
void
-uhci_root_intr_done(reqh)
- usbd_request_handle reqh;
+uhci_root_intr_done(xfer)
+ usbd_xfer_handle xfer;
{
}
@@ -690,6 +684,7 @@ uhci_lock_frames(sc)
uhci_softc_t *sc;
{
int s = splusb();
+
while (sc->sc_vflock) {
sc->sc_vflock |= UHCI_WANT_LOCK;
tsleep(&sc->sc_vflock, PRIBIO, "uhcqhl", 0);
@@ -703,6 +698,7 @@ uhci_unlock_frames(sc)
uhci_softc_t *sc;
{
int s = splusb();
+
sc->sc_vflock &= ~UHCI_HAS_LOCK;
if (sc->sc_vflock & UHCI_WANT_LOCK)
wakeup(&sc->sc_vflock);
@@ -919,16 +915,16 @@ uhci_check_intr(sc, ii)
DPRINTFN(15, ("uhci_check_intr: ii=%p\n", ii));
#ifdef DIAGNOSTIC
- if (!ii) {
+ if (ii == NULL) {
printf("uhci_check_intr: no ii? %p\n", ii);
return;
}
#endif
- if (!ii->stdstart)
+ if (ii->stdstart == NULL)
return;
lstd = ii->stdend;
#ifdef DIAGNOSTIC
- if (!lstd) {
+ if (lstd == NULL) {
printf("uhci_check_intr: std==0\n");
return;
}
@@ -961,8 +957,8 @@ void
uhci_idone(ii)
uhci_intr_info_t *ii;
{
- usbd_request_handle reqh = ii->reqh;
- struct uhci_pipe *upipe = (struct uhci_pipe *)reqh->pipe;
+ usbd_xfer_handle xfer = ii->xfer;
+ struct uhci_pipe *upipe = (struct uhci_pipe *)xfer->pipe;
uhci_soft_td_t *std;
u_int32_t status;
int actlen;
@@ -980,22 +976,22 @@ uhci_idone(ii)
}
#endif
- if (reqh->status == USBD_CANCELLED ||
- reqh->status == USBD_TIMEOUT) {
- DPRINTF(("uhci_idone: aborted reqh=%p\n", reqh));
+ if (xfer->status == USBD_CANCELLED ||
+ xfer->status == USBD_TIMEOUT) {
+ DPRINTF(("uhci_idone: aborted xfer=%p\n", xfer));
return;
}
- if (reqh->nframes) {
+ if (xfer->nframes != 0) {
/* Isoc transfer, do things differently. */
uhci_soft_td_t **stds = upipe->u.iso.stds;
int i, n, nframes;
DPRINTFN(5,("uhci_idone: ii=%p isoc ready\n", ii));
- nframes = reqh->nframes;
+ nframes = xfer->nframes;
actlen = 0;
- n = reqh->hcprivint;
+ n = xfer->hcprivint;
for (i = 0; i < nframes; i++) {
std = stds[n];
#ifdef UHCI_DEBUG
@@ -1010,10 +1006,10 @@ uhci_idone(ii)
actlen += UHCI_TD_GET_ACTLEN(status);
}
upipe->u.iso.inuse -= nframes;
- reqh->actlen = actlen;
- reqh->status = USBD_NORMAL_COMPLETION;
- reqh->hcpriv = ii;
- usb_transfer_complete(reqh);
+ xfer->actlen = actlen;
+ xfer->status = USBD_NORMAL_COMPLETION;
+ xfer->hcpriv = ii;
+ usb_transfer_complete(xfer);
return;
}
@@ -1024,9 +1020,8 @@ uhci_idone(ii)
#endif
/* The transfer is done, compute actual length and status. */
- /* XXX Is this correct for control xfers? */
actlen = 0;
- for (std = ii->stdstart; std; std = std->link.std) {
+ for (std = ii->stdstart; std != NULL; std = std->link.std) {
status = LE(std->td.td_status);
if (status & UHCI_TD_ACTIVE)
break;
@@ -1035,31 +1030,31 @@ uhci_idone(ii)
actlen += UHCI_TD_GET_ACTLEN(status);
}
/* If there are left over TDs we need to update the toggle. */
- if (std)
+ if (std != NULL)
upipe->nexttoggle = UHCI_TD_GET_DT(LE(std->td.td_token));
status &= UHCI_TD_ERROR;
DPRINTFN(10, ("uhci_check_intr: actlen=%d, status=0x%x\n",
actlen, status));
- reqh->actlen = actlen;
+ xfer->actlen = actlen;
if (status != 0) {
DPRINTFN(-1+((status&UHCI_TD_STALLED)!=0),
("uhci_idone: error, addr=%d, endpt=0x%02x, "
"status 0x%b\n",
- reqh->pipe->device->address,
- reqh->pipe->endpoint->edesc->bEndpointAddress,
+ xfer->pipe->device->address,
+ xfer->pipe->endpoint->edesc->bEndpointAddress,
(int)status,
"\20\22BITSTUFF\23CRCTO\24NAK\25BABBLE\26DBUFFER\27"
"STALLED\30ACTIVE"));
if (status == UHCI_TD_STALLED)
- reqh->status = USBD_STALLED;
+ xfer->status = USBD_STALLED;
else
- reqh->status = USBD_IOERROR; /* more info XXX */
+ xfer->status = USBD_IOERROR; /* more info XXX */
} else {
- reqh->status = USBD_NORMAL_COMPLETION;
+ xfer->status = USBD_NORMAL_COMPLETION;
}
- reqh->hcpriv = ii;
- usb_transfer_complete(reqh);
+ xfer->hcpriv = ii;
+ usb_transfer_complete(xfer);
}
/*
@@ -1073,9 +1068,9 @@ uhci_timeout(addr)
DPRINTF(("uhci_timeout: ii=%p\n", ii));
- ii->reqh->device->bus->intr_context++;
- uhci_abort_req(ii->reqh, USBD_TIMEOUT);
- ii->reqh->device->bus->intr_context--;
+ ii->xfer->device->bus->intr_context++;
+ uhci_abort_req(ii->xfer, USBD_TIMEOUT);
+ ii->xfer->device->bus->intr_context--;
}
/*
@@ -1085,22 +1080,22 @@ uhci_timeout(addr)
* Only used during boot when interrupts are not enabled yet.
*/
void
-uhci_waitintr(sc, reqh)
+uhci_waitintr(sc, xfer)
uhci_softc_t *sc;
- usbd_request_handle reqh;
+ usbd_xfer_handle xfer;
{
- int timo = reqh->timeout;
+ int timo = xfer->timeout;
uhci_intr_info_t *ii;
DPRINTFN(10,("uhci_waitintr: timeout = %dms\n", timo));
- reqh->status = USBD_IN_PROGRESS;
+ xfer->status = USBD_IN_PROGRESS;
for (; timo >= 0; timo--) {
usb_delay_ms(&sc->sc_bus, 1);
DPRINTFN(20,("uhci_waitintr: 0x%04x\n", UREAD2(sc, UHCI_STS)));
if (UREAD2(sc, UHCI_STS) & UHCI_STS_USBINT) {
uhci_intr(sc);
- if (reqh->status != USBD_IN_PROGRESS)
+ if (xfer->status != USBD_IN_PROGRESS)
return;
}
}
@@ -1108,11 +1103,11 @@ uhci_waitintr(sc, reqh)
/* Timeout */
DPRINTF(("uhci_waitintr: timeout\n"));
for (ii = LIST_FIRST(&sc->sc_intrhead);
- ii && ii->reqh != reqh;
+ ii != NULL && ii->xfer != xfer;
ii = LIST_NEXT(ii, list))
;
#ifdef DIAGNOSTIC
- if (!ii)
+ if (ii == NULL)
panic("uhci_waitintr: lost intr_info\n");
#endif
uhci_idone(ii);
@@ -1190,15 +1185,15 @@ uhci_alloc_std(sc)
uhci_softc_t *sc;
{
uhci_soft_td_t *std;
- usbd_status r;
+ usbd_status err;
int i, offs;
usb_dma_t dma;
- if (!sc->sc_freetds) {
+ if (sc->sc_freetds == NULL) {
DPRINTFN(2,("uhci_alloc_std: allocating chunk\n"));
- r = usb_allocmem(&sc->sc_bus, UHCI_STD_SIZE * UHCI_STD_CHUNK,
- UHCI_TD_ALIGN, &dma);
- if (r != USBD_NORMAL_COMPLETION)
+ err = usb_allocmem(&sc->sc_bus, UHCI_STD_SIZE * UHCI_STD_CHUNK,
+ UHCI_TD_ALIGN, &dma);
+ if (err)
return (0);
for(i = 0; i < UHCI_STD_CHUNK; i++) {
offs = i * UHCI_STD_SIZE;
@@ -1236,16 +1231,16 @@ uhci_alloc_sqh(sc)
uhci_softc_t *sc;
{
uhci_soft_qh_t *sqh;
- usbd_status r;
+ usbd_status err;
int i, offs;
usb_dma_t dma;
- if (!sc->sc_freeqhs) {
+ if (sc->sc_freeqhs == NULL) {
DPRINTFN(2, ("uhci_alloc_sqh: allocating chunk\n"));
- r = usb_allocmem(&sc->sc_bus, UHCI_SQH_SIZE * UHCI_SQH_CHUNK,
- UHCI_QH_ALIGN, &dma);
- if (r != USBD_NORMAL_COMPLETION)
- return 0;
+ err = usb_allocmem(&sc->sc_bus, UHCI_SQH_SIZE * UHCI_SQH_CHUNK,
+ UHCI_QH_ALIGN, &dma);
+ if (err)
+ return (0);
for(i = 0; i < UHCI_SQH_CHUNK; i++) {
offs = i * UHCI_SQH_SIZE;
sqh = (uhci_soft_qh_t *)((char *)KERNADDR(&dma) +offs);
@@ -1343,7 +1338,7 @@ uhci_alloc_std_chain(upipe, sc, len, rd, shortok, dma, sp, ep)
status |= UHCI_TD_SPD;
for (i = ntd; i >= 0; i--) {
p = uhci_alloc_std(sc);
- if (!p) {
+ if (p == NULL) {
uhci_free_std_chain(sc, lastp, 0);
return (USBD_NOMEM);
}
@@ -1386,55 +1381,55 @@ uhci_noop(pipe)
}
usbd_status
-uhci_device_bulk_transfer(reqh)
- usbd_request_handle reqh;
+uhci_device_bulk_transfer(xfer)
+ usbd_xfer_handle xfer;
{
- usbd_status r;
+ usbd_status err;
/* Insert last in queue. */
- r = usb_insert_transfer(reqh);
- if (r != USBD_NORMAL_COMPLETION)
- return (r);
+ err = usb_insert_transfer(xfer);
+ if (err)
+ return (err);
/* Pipe isn't running, start first */
- return (uhci_device_bulk_start(SIMPLEQ_FIRST(&reqh->pipe->queue)));
+ return (uhci_device_bulk_start(SIMPLEQ_FIRST(&xfer->pipe->queue)));
}
usbd_status
-uhci_device_bulk_start(reqh)
- usbd_request_handle reqh;
+uhci_device_bulk_start(xfer)
+ usbd_xfer_handle xfer;
{
- struct uhci_pipe *upipe = (struct uhci_pipe *)reqh->pipe;
+ struct uhci_pipe *upipe = (struct uhci_pipe *)xfer->pipe;
usbd_device_handle dev = upipe->pipe.device;
uhci_softc_t *sc = (uhci_softc_t *)dev->bus;
uhci_intr_info_t *ii = upipe->iinfo;
uhci_soft_td_t *data, *dataend;
uhci_soft_qh_t *sqh;
- usbd_status r;
+ usbd_status err;
int len, isread, endpt;
int s;
- DPRINTFN(3, ("uhci_device_bulk_transfer: reqh=%p len=%d flags=%d\n",
- reqh, reqh->length, reqh->flags));
+ DPRINTFN(3, ("uhci_device_bulk_transfer: xfer=%p len=%d flags=%d\n",
+ xfer, xfer->length, xfer->flags));
#ifdef DIAGNOSTIC
- if (reqh->rqflags & URQ_REQUEST)
+ if (xfer->rqflags & URQ_REQUEST)
panic("uhci_device_bulk_transfer: a request\n");
#endif
- len = reqh->length;
- endpt = reqh->pipe->endpoint->edesc->bEndpointAddress;
+ len = xfer->length;
+ endpt = xfer->pipe->endpoint->edesc->bEndpointAddress;
isread = UE_GET_DIR(endpt) == UE_DIR_IN;
sqh = upipe->u.bulk.sqh;
upipe->u.bulk.isread = isread;
upipe->u.bulk.length = len;
- r = uhci_alloc_std_chain(upipe, sc, len, isread,
- reqh->flags & USBD_SHORT_XFER_OK,
- &reqh->dmabuf, &data, &dataend);
- if (r != USBD_NORMAL_COMPLETION)
- return (r);
+ err = uhci_alloc_std_chain(upipe, sc, len, isread,
+ xfer->flags & USBD_SHORT_XFER_OK,
+ &xfer->dmabuf, &data, &dataend);
+ if (err)
+ return (err);
dataend->td.td_status |= LE(UHCI_TD_IOC);
#ifdef UHCI_DEBUG
@@ -1445,7 +1440,7 @@ uhci_device_bulk_start(reqh)
#endif
/* Set up interrupt info. */
- ii->reqh = reqh;
+ ii->xfer = xfer;
ii->stdstart = data;
ii->stdend = dataend;
#if defined(__FreeBSD__)
@@ -1463,8 +1458,8 @@ uhci_device_bulk_start(reqh)
uhci_add_bulk(sc, sqh);
LIST_INSERT_HEAD(&sc->sc_intrhead, ii, list);
- if (reqh->timeout && !sc->sc_bus.use_polling) {
- usb_timeout(uhci_timeout, ii, MS_TO_TICKS(reqh->timeout),
+ if (xfer->timeout && !sc->sc_bus.use_polling) {
+ usb_timeout(uhci_timeout, ii, MS_TO_TICKS(xfer->timeout),
ii->timeout_handle);
}
splx(s);
@@ -1477,31 +1472,31 @@ uhci_device_bulk_start(reqh)
#endif
if (sc->sc_bus.use_polling)
- uhci_waitintr(sc, reqh);
+ uhci_waitintr(sc, xfer);
return (USBD_IN_PROGRESS);
}
/* Abort a device bulk request. */
void
-uhci_device_bulk_abort(reqh)
- usbd_request_handle reqh;
+uhci_device_bulk_abort(xfer)
+ usbd_xfer_handle xfer;
{
DPRINTF(("uhci_device_bulk_abort:\n"));
- uhci_abort_req(reqh, USBD_CANCELLED);
+ uhci_abort_req(xfer, USBD_CANCELLED);
}
void
-uhci_abort_req(reqh, status)
- usbd_request_handle reqh;
+uhci_abort_req(xfer, status)
+ usbd_xfer_handle xfer;
usbd_status status;
{
- struct uhci_pipe *upipe = (struct uhci_pipe *)reqh->pipe;
+ struct uhci_pipe *upipe = (struct uhci_pipe *)xfer->pipe;
uhci_intr_info_t *ii = upipe->iinfo;
uhci_soft_td_t *std;
/* Make interrupt routine ignore it, */
- reqh->status = status;
+ xfer->status = status;
/* don't timeout, */
usb_untimeout(uhci_timeout, ii, ii->timeout_handle);
@@ -1510,16 +1505,16 @@ uhci_abort_req(reqh, status)
for (std = ii->stdstart; std != 0; std = std->link.std)
std->td.td_status &= LE(~(UHCI_TD_ACTIVE | UHCI_TD_IOC));
- reqh->hcpriv = ii;
+ xfer->hcpriv = ii;
/* make sure hardware has completed, */
- if (reqh->device->bus->intr_context) {
+ if (xfer->device->bus->intr_context) {
/* We have no process context, so we can't use tsleep(). */
- timeout(uhci_abort_req_end, reqh, hz / USB_FRAMES_PER_SECOND);
+ timeout(uhci_abort_req_end, xfer, hz / USB_FRAMES_PER_SECOND);
} else {
- usb_delay_ms(reqh->pipe->device->bus, 1);
+ usb_delay_ms(xfer->pipe->device->bus, 1);
/* and call final part of interrupt handler. */
- uhci_abort_req_end(reqh);
+ uhci_abort_req_end(xfer);
}
}
@@ -1527,11 +1522,11 @@ void
uhci_abort_req_end(v)
void *v;
{
- usbd_request_handle reqh = v;
+ usbd_xfer_handle xfer = v;
int s;
s = splusb();
- usb_transfer_complete(reqh);
+ usb_transfer_complete(xfer);
splx(s);
}
@@ -1550,82 +1545,82 @@ uhci_device_bulk_close(pipe)
}
usbd_status
-uhci_device_ctrl_transfer(reqh)
- usbd_request_handle reqh;
+uhci_device_ctrl_transfer(xfer)
+ usbd_xfer_handle xfer;
{
- usbd_status r;
+ usbd_status err;
/* Insert last in queue. */
- r = usb_insert_transfer(reqh);
- if (r != USBD_NORMAL_COMPLETION)
- return (r);
+ err = usb_insert_transfer(xfer);
+ if (err)
+ return (err);
/* Pipe isn't running, start first */
- return (uhci_device_ctrl_start(SIMPLEQ_FIRST(&reqh->pipe->queue)));
+ return (uhci_device_ctrl_start(SIMPLEQ_FIRST(&xfer->pipe->queue)));
}
usbd_status
-uhci_device_ctrl_start(reqh)
- usbd_request_handle reqh;
+uhci_device_ctrl_start(xfer)
+ usbd_xfer_handle xfer;
{
- uhci_softc_t *sc = (uhci_softc_t *)reqh->pipe->device->bus;
- usbd_status r;
+ uhci_softc_t *sc = (uhci_softc_t *)xfer->pipe->device->bus;
+ usbd_status err;
#ifdef DIAGNOSTIC
- if (!(reqh->rqflags & URQ_REQUEST))
+ if (!(xfer->rqflags & URQ_REQUEST))
panic("uhci_device_ctrl_transfer: not a request\n");
#endif
- r = uhci_device_request(reqh);
- if (r != USBD_NORMAL_COMPLETION)
- return (r);
+ err = uhci_device_request(xfer);
+ if (err)
+ return (err);
if (sc->sc_bus.use_polling)
- uhci_waitintr(sc, reqh);
+ uhci_waitintr(sc, xfer);
return (USBD_IN_PROGRESS);
}
usbd_status
-uhci_device_intr_transfer(reqh)
- usbd_request_handle reqh;
+uhci_device_intr_transfer(xfer)
+ usbd_xfer_handle xfer;
{
- usbd_status r;
+ usbd_status err;
/* Insert last in queue. */
- r = usb_insert_transfer(reqh);
- if (r != USBD_NORMAL_COMPLETION)
- return (r);
+ err = usb_insert_transfer(xfer);
+ if (err)
+ return (err);
/* Pipe isn't running, start first */
- return (uhci_device_intr_start(SIMPLEQ_FIRST(&reqh->pipe->queue)));
+ return (uhci_device_intr_start(SIMPLEQ_FIRST(&xfer->pipe->queue)));
}
usbd_status
-uhci_device_intr_start(reqh)
- usbd_request_handle reqh;
+uhci_device_intr_start(xfer)
+ usbd_xfer_handle xfer;
{
- struct uhci_pipe *upipe = (struct uhci_pipe *)reqh->pipe;
+ struct uhci_pipe *upipe = (struct uhci_pipe *)xfer->pipe;
usbd_device_handle dev = upipe->pipe.device;
uhci_softc_t *sc = (uhci_softc_t *)dev->bus;
uhci_intr_info_t *ii = upipe->iinfo;
uhci_soft_td_t *data, *dataend;
uhci_soft_qh_t *sqh;
- usbd_status r;
+ usbd_status err;
int i, s;
- DPRINTFN(3,("uhci_device_intr_transfer: reqh=%p len=%d flags=%d\n",
- reqh, reqh->length, reqh->flags));
+ DPRINTFN(3,("uhci_device_intr_transfer: xfer=%p len=%d flags=%d\n",
+ xfer, xfer->length, xfer->flags));
#ifdef DIAGNOSTIC
- if (reqh->rqflags & URQ_REQUEST)
+ if (xfer->rqflags & URQ_REQUEST)
panic("uhci_device_intr_transfer: a request\n");
#endif
- r = uhci_alloc_std_chain(upipe, sc, reqh->length, 1,
- reqh->flags & USBD_SHORT_XFER_OK,
- &reqh->dmabuf, &data, &dataend);
- if (r != USBD_NORMAL_COMPLETION)
- return (r);
+ err = uhci_alloc_std_chain(upipe, sc, xfer->length, 1,
+ xfer->flags & USBD_SHORT_XFER_OK,
+ &xfer->dmabuf, &data, &dataend);
+ if (err)
+ return (err);
dataend->td.td_status |= LE(UHCI_TD_IOC);
#ifdef UHCI_DEBUG
@@ -1638,7 +1633,7 @@ uhci_device_intr_start(reqh)
s = splusb();
/* Set up interrupt info. */
- ii->reqh = reqh;
+ ii->xfer = xfer;
ii->stdstart = data;
ii->stdend = dataend;
#if defined(__FreeBSD__)
@@ -1670,11 +1665,11 @@ uhci_device_intr_start(reqh)
/* Abort a device control request. */
void
-uhci_device_ctrl_abort(reqh)
- usbd_request_handle reqh;
+uhci_device_ctrl_abort(xfer)
+ usbd_xfer_handle xfer;
{
DPRINTF(("uhci_device_ctrl_abort:\n"));
- uhci_abort_req(reqh, USBD_CANCELLED);
+ uhci_abort_req(xfer, USBD_CANCELLED);
}
/* Close a device control pipe. */
@@ -1685,20 +1680,20 @@ uhci_device_ctrl_close(pipe)
struct uhci_pipe *upipe = (struct uhci_pipe *)pipe;
uhci_free_intr_info(upipe->iinfo);
- /* XXX free other resources */
+ /* XXX free other resources? */
}
/* Abort a device interrupt request. */
void
-uhci_device_intr_abort(reqh)
- usbd_request_handle reqh;
+uhci_device_intr_abort(xfer)
+ usbd_xfer_handle xfer;
{
- DPRINTFN(1,("uhci_device_intr_abort: reqh=%p\n", reqh));
- if (reqh->pipe->intrreqh == reqh) {
+ DPRINTFN(1,("uhci_device_intr_abort: xfer=%p\n", xfer));
+ if (xfer->pipe->intrxfer == xfer) {
DPRINTFN(1,("uhci_device_intr_abort: remove\n"));
- reqh->pipe->intrreqh = 0;
+ xfer->pipe->intrxfer = 0;
}
- uhci_abort_req(reqh, USBD_CANCELLED);
+ uhci_abort_req(xfer, USBD_CANCELLED);
}
/* Close a device interrupt pipe. */
@@ -1739,11 +1734,11 @@ uhci_device_intr_close(pipe)
}
usbd_status
-uhci_device_request(reqh)
- usbd_request_handle reqh;
+uhci_device_request(xfer)
+ usbd_xfer_handle xfer;
{
- struct uhci_pipe *upipe = (struct uhci_pipe *)reqh->pipe;
- usb_device_request_t *req = &reqh->request;
+ struct uhci_pipe *upipe = (struct uhci_pipe *)xfer->pipe;
+ usb_device_request_t *req = &xfer->request;
usbd_device_handle dev = upipe->pipe.device;
uhci_softc_t *sc = (uhci_softc_t *)dev->bus;
int addr = dev->address;
@@ -1753,7 +1748,7 @@ uhci_device_request(reqh)
uhci_soft_qh_t *sqh;
int len;
u_int32_t ls;
- usbd_status r;
+ usbd_status err;
int isread;
int s;
@@ -1774,11 +1769,11 @@ uhci_device_request(reqh)
/* Set up data transaction */
if (len != 0) {
upipe->nexttoggle = 1;
- r = uhci_alloc_std_chain(upipe, sc, len, isread,
- reqh->flags & USBD_SHORT_XFER_OK,
- &reqh->dmabuf, &data, &dataend);
- if (r != USBD_NORMAL_COMPLETION)
- return (r);
+ err = uhci_alloc_std_chain(upipe, sc, len, isread,
+ xfer->flags & USBD_SHORT_XFER_OK,
+ &xfer->dmabuf, &data, &dataend);
+ if (err)
+ return (err);
next = data;
dataend->link.std = stat;
dataend->td.td_link = LE(stat->physaddr);
@@ -1812,7 +1807,7 @@ uhci_device_request(reqh)
#endif
/* Set up interrupt info. */
- ii->reqh = reqh;
+ ii->xfer = xfer;
ii->stdstart = setup;
ii->stdend = stat;
#if defined(__FreeBSD__)
@@ -1844,7 +1839,7 @@ uhci_device_request(reqh)
uhci_dump_td(std);
}
for (sxqh = xqh = (uhci_soft_qh_t *)std;
- xqh;
+ xqh != NULL;
xqh = (maxqh++ == 5 || xqh->hlink==sxqh ||
xqh->hlink==xqh ? NULL : xqh->hlink)) {
uhci_dump_qh(xqh);
@@ -1855,9 +1850,9 @@ uhci_device_request(reqh)
uhci_dump_tds(sqh->elink);
}
#endif
- if (reqh->timeout && !sc->sc_bus.use_polling) {
+ if (xfer->timeout && !sc->sc_bus.use_polling) {
usb_timeout(uhci_timeout, ii,
- MS_TO_TICKS(reqh->timeout), ii->timeout_handle);
+ MS_TO_TICKS(xfer->timeout), ii->timeout_handle);
}
splx(s);
@@ -1865,37 +1860,37 @@ uhci_device_request(reqh)
}
usbd_status
-uhci_device_isoc_transfer(reqh)
- usbd_request_handle reqh;
+uhci_device_isoc_transfer(xfer)
+ usbd_xfer_handle xfer;
{
- usbd_status r;
+ usbd_status err;
- DPRINTFN(5,("uhci_device_isoc_transfer: reqh=%p\n", reqh));
+ DPRINTFN(5,("uhci_device_isoc_transfer: xfer=%p\n", xfer));
/* Put it on our queue, */
- r = usb_insert_transfer(reqh);
+ err = usb_insert_transfer(xfer);
/* bail out on error, */
- if (r != USBD_NORMAL_COMPLETION && r != USBD_IN_PROGRESS)
- return (r);
+ if (err && err != USBD_IN_PROGRESS)
+ return (err);
/* XXX should check inuse here */
/* insert into schedule, */
- uhci_device_isoc_enter(reqh);
+ uhci_device_isoc_enter(xfer);
/* and put on interrupt list if the pipe wasn't running */
- if (r == USBD_NORMAL_COMPLETION)
- uhci_device_isoc_start(SIMPLEQ_FIRST(&reqh->pipe->queue));
+ if (err == USBD_NORMAL_COMPLETION)
+ uhci_device_isoc_start(SIMPLEQ_FIRST(&xfer->pipe->queue));
- return (r);
+ return (err);
}
void
-uhci_device_isoc_enter(reqh)
- usbd_request_handle reqh;
+uhci_device_isoc_enter(xfer)
+ usbd_xfer_handle xfer;
{
- struct uhci_pipe *upipe = (struct uhci_pipe *)reqh->pipe;
+ struct uhci_pipe *upipe = (struct uhci_pipe *)xfer->pipe;
usbd_device_handle dev = upipe->pipe.device;
uhci_softc_t *sc = (uhci_softc_t *)dev->bus;
struct iso *iso = &upipe->u.iso;
@@ -1903,11 +1898,11 @@ uhci_device_isoc_enter(reqh)
u_int32_t buf, len, status;
int s, i, next, nframes;
- DPRINTFN(5,("uhci_device_isoc_enter: used=%d next=%d reqh=%p "
+ DPRINTFN(5,("uhci_device_isoc_enter: used=%d next=%d xfer=%p "
"nframes=%d\n",
- iso->inuse, iso->next, reqh, reqh->nframes));
+ iso->inuse, iso->next, xfer, xfer->nframes));
- if (reqh->status == USBD_IN_PROGRESS) {
+ if (xfer->status == USBD_IN_PROGRESS) {
/* This request has already been entered into the frame list */
}
@@ -1923,20 +1918,20 @@ uhci_device_isoc_enter(reqh)
DPRINTFN(2,("uhci_device_isoc_enter: start next=%d\n", next));
}
- reqh->status = USBD_IN_PROGRESS;
- reqh->hcprivint = next;
+ xfer->status = USBD_IN_PROGRESS;
+ xfer->hcprivint = next;
- buf = DMAADDR(&reqh->dmabuf);
+ buf = DMAADDR(&xfer->dmabuf);
status = LE(UHCI_TD_ZERO_ACTLEN(UHCI_TD_SET_ERRCNT(0) |
UHCI_TD_ACTIVE |
UHCI_TD_IOS));
- nframes = reqh->nframes;
+ nframes = xfer->nframes;
s = splusb();
for (i = 0; i < nframes; i++) {
std = iso->stds[next];
if (++next >= UHCI_VFRAMELIST_COUNT)
next = 0;
- len = reqh->frlengths[i];
+ len = xfer->frlengths[i];
std->td.td_buffer = LE(buf);
if (i == nframes - 1)
status |= LE(UHCI_TD_IOC);
@@ -1952,28 +1947,28 @@ uhci_device_isoc_enter(reqh)
buf += len;
}
iso->next = next;
- iso->inuse += reqh->nframes;
+ iso->inuse += xfer->nframes;
splx(s);
}
usbd_status
-uhci_device_isoc_start(reqh)
- usbd_request_handle reqh;
+uhci_device_isoc_start(xfer)
+ usbd_xfer_handle xfer;
{
- struct uhci_pipe *upipe = (struct uhci_pipe *)reqh->pipe;
+ struct uhci_pipe *upipe = (struct uhci_pipe *)xfer->pipe;
uhci_softc_t *sc = (uhci_softc_t *)upipe->pipe.device->bus;
uhci_intr_info_t *ii = upipe->iinfo;
uhci_soft_td_t *end;
int s, i;
#ifdef DIAGNOSTIC
- if (reqh->status != USBD_IN_PROGRESS)
- printf("uhci_device_isoc_start: not in progress %p\n", reqh);
+ if (xfer->status != USBD_IN_PROGRESS)
+ printf("uhci_device_isoc_start: not in progress %p\n", xfer);
#endif
/* Find the last TD */
- i = reqh->hcprivint + reqh->nframes;
+ i = xfer->hcprivint + xfer->nframes;
if (i >= UHCI_VFRAMELIST_COUNT)
i -= UHCI_VFRAMELIST_COUNT;
end = upipe->u.iso.stds[i];
@@ -1981,7 +1976,7 @@ uhci_device_isoc_start(reqh)
s = splusb();
/* Set up interrupt info. */
- ii->reqh = reqh;
+ ii->xfer = xfer;
ii->stdstart = end;
ii->stdend = end;
#if defined(__FreeBSD__)
@@ -1998,21 +1993,21 @@ uhci_device_isoc_start(reqh)
}
void
-uhci_device_isoc_abort(reqh)
- usbd_request_handle reqh;
+uhci_device_isoc_abort(xfer)
+ usbd_xfer_handle xfer;
{
- struct uhci_pipe *upipe = (struct uhci_pipe *)reqh->pipe;
+ struct uhci_pipe *upipe = (struct uhci_pipe *)xfer->pipe;
uhci_intr_info_t *ii = upipe->iinfo;
uhci_soft_td_t **stds = upipe->u.iso.stds;
uhci_soft_td_t *std;
int i, n, nframes;
/* Make interrupt routine ignore it, */
- reqh->status = USBD_CANCELLED;
+ xfer->status = USBD_CANCELLED;
/* make hardware ignore it, */
- nframes = reqh->nframes;
- n = reqh->hcprivint;
+ nframes = xfer->nframes;
+ n = xfer->hcprivint;
for (i = 0; i < nframes; i++) {
std = stds[n];
std->td.td_status &= LE(~(UHCI_TD_ACTIVE | UHCI_TD_IOC));
@@ -2020,16 +2015,16 @@ uhci_device_isoc_abort(reqh)
n = 0;
}
- reqh->hcpriv = ii;
+ xfer->hcpriv = ii;
/* make sure hardware has completed, */
- if (reqh->device->bus->intr_context) {
+ if (xfer->device->bus->intr_context) {
/* We have no process context, so we can't use tsleep(). */
- timeout(uhci_abort_req_end, reqh, hz / USB_FRAMES_PER_SECOND);
+ timeout(uhci_abort_req_end, xfer, hz / USB_FRAMES_PER_SECOND);
} else {
- usb_delay_ms(reqh->pipe->device->bus, 1);
+ usb_delay_ms(xfer->pipe->device->bus, 1);
/* and call final part of interrupt handler. */
- uhci_abort_req_end(reqh);
+ uhci_abort_req_end(xfer);
}
}
@@ -2135,12 +2130,12 @@ uhci_setup_isoc(pipe)
}
void
-uhci_device_isoc_done(reqh)
- usbd_request_handle reqh;
+uhci_device_isoc_done(xfer)
+ usbd_xfer_handle xfer;
{
- uhci_intr_info_t *ii = reqh->hcpriv;
+ uhci_intr_info_t *ii = xfer->hcpriv;
- DPRINTFN(4, ("uhci_isoc_done: length=%d\n", reqh->actlen));
+ DPRINTFN(4, ("uhci_isoc_done: length=%d\n", xfer->actlen));
/* Turn off the interrupt since it is active even if the TD is not. */
ii->stdend->td.td_status &= LE(~UHCI_TD_IOC);
@@ -2149,16 +2144,16 @@ uhci_device_isoc_done(reqh)
}
void
-uhci_device_intr_done(reqh)
- usbd_request_handle reqh;
+uhci_device_intr_done(xfer)
+ usbd_xfer_handle xfer;
{
- uhci_intr_info_t *ii = reqh->hcpriv;
+ uhci_intr_info_t *ii = xfer->hcpriv;
uhci_softc_t *sc = ii->sc;
- struct uhci_pipe *upipe = (struct uhci_pipe *)reqh->pipe;
+ struct uhci_pipe *upipe = (struct uhci_pipe *)xfer->pipe;
uhci_soft_qh_t *sqh;
int i, npoll;
- DPRINTFN(5, ("uhci_intr_done: length=%d\n", reqh->actlen));
+ DPRINTFN(5, ("uhci_intr_done: length=%d\n", xfer->actlen));
npoll = upipe->u.intr.npoll;
for(i = 0; i < npoll; i++) {
@@ -2169,13 +2164,13 @@ uhci_device_intr_done(reqh)
uhci_free_std_chain(sc, ii->stdstart, 0);
/* XXX Wasteful. */
- if (reqh->pipe->repeat) {
+ if (xfer->pipe->repeat) {
uhci_soft_td_t *data, *dataend;
/* This alloc cannot fail since we freed the chain above. */
- uhci_alloc_std_chain(upipe, sc, reqh->length, 1,
- reqh->flags & USBD_SHORT_XFER_OK,
- &reqh->dmabuf, &data, &dataend);
+ uhci_alloc_std_chain(upipe, sc, xfer->length, 1,
+ xfer->flags & USBD_SHORT_XFER_OK,
+ &xfer->dmabuf, &data, &dataend);
dataend->td.td_status |= LE(UHCI_TD_IOC);
#ifdef UHCI_DEBUG
@@ -2206,15 +2201,15 @@ uhci_device_intr_done(reqh)
/* Deallocate request data structures */
void
-uhci_device_ctrl_done(reqh)
- usbd_request_handle reqh;
+uhci_device_ctrl_done(xfer)
+ usbd_xfer_handle xfer;
{
- uhci_intr_info_t *ii = reqh->hcpriv;
+ uhci_intr_info_t *ii = xfer->hcpriv;
uhci_softc_t *sc = ii->sc;
- struct uhci_pipe *upipe = (struct uhci_pipe *)reqh->pipe;
+ struct uhci_pipe *upipe = (struct uhci_pipe *)xfer->pipe;
#ifdef DIAGNOSTIC
- if (!(reqh->rqflags & URQ_REQUEST))
+ if (!(xfer->rqflags & URQ_REQUEST))
panic("uhci_ctrl_done: not a request\n");
#endif
@@ -2225,17 +2220,17 @@ uhci_device_ctrl_done(reqh)
if (upipe->u.ctl.length != 0)
uhci_free_std_chain(sc, ii->stdstart->link.std, ii->stdend);
- DPRINTFN(5, ("uhci_ctrl_done: length=%d\n", reqh->actlen));
+ DPRINTFN(5, ("uhci_ctrl_done: length=%d\n", xfer->actlen));
}
/* Deallocate request data structures */
void
-uhci_device_bulk_done(reqh)
- usbd_request_handle reqh;
+uhci_device_bulk_done(xfer)
+ usbd_xfer_handle xfer;
{
- uhci_intr_info_t *ii = reqh->hcpriv;
+ uhci_intr_info_t *ii = xfer->hcpriv;
uhci_softc_t *sc = ii->sc;
- struct uhci_pipe *upipe = (struct uhci_pipe *)reqh->pipe;
+ struct uhci_pipe *upipe = (struct uhci_pipe *)xfer->pipe;
LIST_REMOVE(ii, list); /* remove from active list */
@@ -2243,7 +2238,7 @@ uhci_device_bulk_done(reqh)
uhci_free_std_chain(sc, ii->stdstart, 0);
- DPRINTFN(5, ("uhci_bulk_done: length=%d\n", reqh->actlen));
+ DPRINTFN(5, ("uhci_bulk_done: length=%d\n", xfer->actlen));
}
/* Add interrupt QH, called with vflock. */
@@ -2367,7 +2362,7 @@ uhci_open(pipe)
uhci_softc_t *sc = (uhci_softc_t *)pipe->device->bus;
struct uhci_pipe *upipe = (struct uhci_pipe *)pipe;
usb_endpoint_descriptor_t *ed = pipe->endpoint->edesc;
- usbd_status r;
+ usbd_status err;
DPRINTFN(1, ("uhci_open: pipe=%p, addr=%d, endpt=%d (%d)\n",
pipe, pipe->device->address,
@@ -2391,23 +2386,23 @@ uhci_open(pipe)
case UE_CONTROL:
pipe->methods = &uhci_device_ctrl_methods;
upipe->u.ctl.sqh = uhci_alloc_sqh(sc);
- if (upipe->u.ctl.sqh == 0)
+ if (upipe->u.ctl.sqh == NULL)
goto bad;
upipe->u.ctl.setup = uhci_alloc_std(sc);
- if (upipe->u.ctl.setup == 0) {
+ if (upipe->u.ctl.setup == NULL) {
uhci_free_sqh(sc, upipe->u.ctl.sqh);
goto bad;
}
upipe->u.ctl.stat = uhci_alloc_std(sc);
- if (upipe->u.ctl.stat == 0) {
+ if (upipe->u.ctl.stat == NULL) {
uhci_free_sqh(sc, upipe->u.ctl.sqh);
uhci_free_std(sc, upipe->u.ctl.setup);
goto bad;
}
- r = usb_allocmem(&sc->sc_bus,
- sizeof(usb_device_request_t),
- 0, &upipe->u.ctl.reqdma);
- if (r != USBD_NORMAL_COMPLETION) {
+ err = usb_allocmem(&sc->sc_bus,
+ sizeof(usb_device_request_t),
+ 0, &upipe->u.ctl.reqdma);
+ if (err) {
uhci_free_sqh(sc, upipe->u.ctl.sqh);
uhci_free_std(sc, upipe->u.ctl.setup);
uhci_free_std(sc, upipe->u.ctl.stat);
@@ -2423,7 +2418,7 @@ uhci_open(pipe)
case UE_BULK:
pipe->methods = &uhci_device_bulk_methods;
upipe->u.bulk.sqh = uhci_alloc_sqh(sc);
- if (upipe->u.bulk.sqh == 0)
+ if (upipe->u.bulk.sqh == NULL)
goto bad;
break;
}
@@ -2519,37 +2514,37 @@ uhci_str(p, l, s)
* Simulate a hardware hub by handling all the necessary requests.
*/
usbd_status
-uhci_root_ctrl_transfer(reqh)
- usbd_request_handle reqh;
+uhci_root_ctrl_transfer(xfer)
+ usbd_xfer_handle xfer;
{
- usbd_status r;
+ usbd_status err;
/* Insert last in queue. */
- r = usb_insert_transfer(reqh);
- if (r != USBD_NORMAL_COMPLETION)
- return (r);
+ err = usb_insert_transfer(xfer);
+ if (err)
+ return (err);
/* Pipe isn't running, start first */
- return (uhci_root_ctrl_start(SIMPLEQ_FIRST(&reqh->pipe->queue)));
+ return (uhci_root_ctrl_start(SIMPLEQ_FIRST(&xfer->pipe->queue)));
}
usbd_status
-uhci_root_ctrl_start(reqh)
- usbd_request_handle reqh;
+uhci_root_ctrl_start(xfer)
+ usbd_xfer_handle xfer;
{
- uhci_softc_t *sc = (uhci_softc_t *)reqh->pipe->device->bus;
+ uhci_softc_t *sc = (uhci_softc_t *)xfer->pipe->device->bus;
usb_device_request_t *req;
void *buf = NULL;
int port, x;
int s, len, value, index, status, change, l, totlen = 0;
usb_port_status_t ps;
- usbd_status r;
+ usbd_status err;
#ifdef DIAGNOSTIC
- if (!(reqh->rqflags & URQ_REQUEST))
+ if (!(xfer->rqflags & URQ_REQUEST))
panic("uhci_root_ctrl_transfer: not a request\n");
#endif
- req = &reqh->request;
+ req = &xfer->request;
DPRINTFN(2,("uhci_root_ctrl_control type=0x%02x request=%02x\n",
req->bmRequestType, req->bRequest));
@@ -2559,7 +2554,7 @@ uhci_root_ctrl_start(reqh)
index = UGETW(req->wIndex);
if (len != 0)
- buf = KERNADDR(&reqh->dmabuf);
+ buf = KERNADDR(&xfer->dmabuf);
#define C(x,y) ((x) | ((y) << 8))
switch(C(req->bRequest, req->bmRequestType)) {
@@ -2582,7 +2577,7 @@ uhci_root_ctrl_start(reqh)
switch(value >> 8) {
case UDESC_DEVICE:
if ((value & 0xff) != 0) {
- r = USBD_IOERROR;
+ err = USBD_IOERROR;
goto ret;
}
totlen = l = min(len, USB_DEVICE_DESCRIPTOR_SIZE);
@@ -2591,7 +2586,7 @@ uhci_root_ctrl_start(reqh)
break;
case UDESC_CONFIG:
if ((value & 0xff) != 0) {
- r = USBD_IOERROR;
+ err = USBD_IOERROR;
goto ret;
}
totlen = l = min(len, USB_CONFIG_DESCRIPTOR_SIZE);
@@ -2622,7 +2617,7 @@ uhci_root_ctrl_start(reqh)
}
break;
default:
- r = USBD_IOERROR;
+ err = USBD_IOERROR;
goto ret;
}
break;
@@ -2647,14 +2642,14 @@ uhci_root_ctrl_start(reqh)
break;
case C(UR_SET_ADDRESS, UT_WRITE_DEVICE):
if (value >= USB_MAX_DEVICES) {
- r = USBD_IOERROR;
+ err = USBD_IOERROR;
goto ret;
}
sc->sc_addr = value;
break;
case C(UR_SET_CONFIG, UT_WRITE_DEVICE):
if (value != 0 && value != 1) {
- r = USBD_IOERROR;
+ err = USBD_IOERROR;
goto ret;
}
sc->sc_conf = value;
@@ -2664,7 +2659,7 @@ uhci_root_ctrl_start(reqh)
case C(UR_SET_FEATURE, UT_WRITE_DEVICE):
case C(UR_SET_FEATURE, UT_WRITE_INTERFACE):
case C(UR_SET_FEATURE, UT_WRITE_ENDPOINT):
- r = USBD_IOERROR;
+ err = USBD_IOERROR;
goto ret;
case C(UR_SET_INTERFACE, UT_WRITE_INTERFACE):
break;
@@ -2682,7 +2677,7 @@ uhci_root_ctrl_start(reqh)
else if (index == 2)
port = UHCI_PORTSC2;
else {
- r = USBD_IOERROR;
+ err = USBD_IOERROR;
goto ret;
}
switch(value) {
@@ -2712,7 +2707,7 @@ uhci_root_ctrl_start(reqh)
break;
case UHF_C_PORT_RESET:
sc->sc_isreset = 0;
- r = USBD_NORMAL_COMPLETION;
+ err = USBD_NORMAL_COMPLETION;
goto ret;
case UHF_PORT_CONNECTION:
case UHF_PORT_OVER_CURRENT:
@@ -2720,7 +2715,7 @@ uhci_root_ctrl_start(reqh)
case UHF_PORT_LOW_SPEED:
case UHF_C_PORT_SUSPEND:
default:
- r = USBD_IOERROR;
+ err = USBD_IOERROR;
goto ret;
}
break;
@@ -2730,7 +2725,7 @@ uhci_root_ctrl_start(reqh)
else if (index == 2)
port = UHCI_PORTSC2;
else {
- r = USBD_IOERROR;
+ err = USBD_IOERROR;
goto ret;
}
if (len > 0) {
@@ -2742,7 +2737,7 @@ uhci_root_ctrl_start(reqh)
break;
case C(UR_GET_DESCRIPTOR, UT_READ_CLASS_DEVICE):
if (value != 0) {
- r = USBD_IOERROR;
+ err = USBD_IOERROR;
goto ret;
}
l = min(len, USB_HUB_DESCRIPTOR_SIZE);
@@ -2751,7 +2746,7 @@ uhci_root_ctrl_start(reqh)
break;
case C(UR_GET_STATUS, UT_READ_CLASS_DEVICE):
if (len != 4) {
- r = USBD_IOERROR;
+ err = USBD_IOERROR;
goto ret;
}
memset(buf, 0, len);
@@ -2763,11 +2758,11 @@ uhci_root_ctrl_start(reqh)
else if (index == 2)
port = UHCI_PORTSC2;
else {
- r = USBD_IOERROR;
+ err = USBD_IOERROR;
goto ret;
}
if (len != 4) {
- r = USBD_IOERROR;
+ err = USBD_IOERROR;
goto ret;
}
x = UREAD2(sc, port);
@@ -2798,7 +2793,7 @@ uhci_root_ctrl_start(reqh)
totlen = l;
break;
case C(UR_SET_DESCRIPTOR, UT_WRITE_CLASS_DEVICE):
- r = USBD_IOERROR;
+ err = USBD_IOERROR;
goto ret;
case C(UR_SET_FEATURE, UT_WRITE_CLASS_DEVICE):
break;
@@ -2808,7 +2803,7 @@ uhci_root_ctrl_start(reqh)
else if (index == 2)
port = UHCI_PORTSC2;
else {
- r = USBD_IOERROR;
+ err = USBD_IOERROR;
goto ret;
}
switch(value) {
@@ -2843,29 +2838,29 @@ uhci_root_ctrl_start(reqh)
case UHF_C_PORT_SUSPEND:
case UHF_C_PORT_RESET:
default:
- r = USBD_IOERROR;
+ err = USBD_IOERROR;
goto ret;
}
break;
default:
- r = USBD_IOERROR;
+ err = USBD_IOERROR;
goto ret;
}
- reqh->actlen = totlen;
- r = USBD_NORMAL_COMPLETION;
+ xfer->actlen = totlen;
+ err = USBD_NORMAL_COMPLETION;
ret:
- reqh->status = r;
- reqh->hcpriv = 0;
+ xfer->status = err;
+ xfer->hcpriv = 0;
s = splusb();
- usb_transfer_complete(reqh);
+ usb_transfer_complete(xfer);
splx(s);
return (USBD_IN_PROGRESS);
}
/* Abort a root control request. */
void
-uhci_root_ctrl_abort(reqh)
- usbd_request_handle reqh;
+uhci_root_ctrl_abort(xfer)
+ usbd_xfer_handle xfer;
{
/* Nothing to do, all transfers are syncronous. */
}
@@ -2883,51 +2878,51 @@ uhci_root_ctrl_close(pipe)
/* Abort a root interrupt request. */
void
-uhci_root_intr_abort(reqh)
- usbd_request_handle reqh;
+uhci_root_intr_abort(xfer)
+ usbd_xfer_handle xfer;
{
- uhci_softc_t *sc = (uhci_softc_t *)reqh->pipe->device->bus;
+ uhci_softc_t *sc = (uhci_softc_t *)xfer->pipe->device->bus;
- usb_untimeout(uhci_timo, reqh, reqh->timo_handle);
+ usb_untimeout(uhci_timo, xfer, xfer->timo_handle);
sc->sc_has_timo = 0;
- if (reqh->pipe->intrreqh == reqh) {
+ if (xfer->pipe->intrxfer == xfer) {
DPRINTF(("uhci_root_intr_abort: remove\n"));
- reqh->pipe->intrreqh = 0;
+ xfer->pipe->intrxfer = 0;
}
- reqh->status = USBD_CANCELLED;
- usb_transfer_complete(reqh);
+ xfer->status = USBD_CANCELLED;
+ usb_transfer_complete(xfer);
}
usbd_status
-uhci_root_intr_transfer(reqh)
- usbd_request_handle reqh;
+uhci_root_intr_transfer(xfer)
+ usbd_xfer_handle xfer;
{
- usbd_status r;
+ usbd_status err;
/* Insert last in queue. */
- r = usb_insert_transfer(reqh);
- if (r != USBD_NORMAL_COMPLETION)
- return (r);
+ err = usb_insert_transfer(xfer);
+ if (err)
+ return (err);
/* Pipe isn't running, start first */
- return (uhci_root_intr_start(SIMPLEQ_FIRST(&reqh->pipe->queue)));
+ return (uhci_root_intr_start(SIMPLEQ_FIRST(&xfer->pipe->queue)));
}
/* Start a transfer on the root interrupt pipe */
usbd_status
-uhci_root_intr_start(reqh)
- usbd_request_handle reqh;
+uhci_root_intr_start(xfer)
+ usbd_xfer_handle xfer;
{
- usbd_pipe_handle pipe = reqh->pipe;
+ usbd_pipe_handle pipe = xfer->pipe;
uhci_softc_t *sc = (uhci_softc_t *)pipe->device->bus;
- DPRINTFN(3, ("uhci_root_intr_transfer: reqh=%p len=%d flags=%d\n",
- reqh, reqh->length, reqh->flags));
+ DPRINTFN(3, ("uhci_root_intr_transfer: xfer=%p len=%d flags=%d\n",
+ xfer, xfer->length, xfer->flags));
- sc->sc_ival = MS_TO_TICKS(reqh->pipe->endpoint->edesc->bInterval);
- usb_timeout(uhci_timo, reqh, sc->sc_ival, reqh->timo_handle);
- sc->sc_has_timo = reqh;
+ sc->sc_ival = MS_TO_TICKS(xfer->pipe->endpoint->edesc->bInterval);
+ usb_timeout(uhci_timo, xfer, sc->sc_ival, xfer->timo_handle);
+ sc->sc_has_timo = xfer;
return (USBD_IN_PROGRESS);
}
@@ -2938,8 +2933,7 @@ uhci_root_intr_close(pipe)
{
uhci_softc_t *sc = (uhci_softc_t *)pipe->device->bus;
- usb_untimeout(uhci_timo, pipe->intrreqh, pipe->intrreqh->timo_handle);
+ usb_untimeout(uhci_timo, pipe->intrxfer, pipe->intrxfer->timo_handle);
sc->sc_has_timo = 0;
DPRINTF(("uhci_root_intr_close\n"));
}
-
diff --git a/sys/dev/usb/uhcivar.h b/sys/dev/usb/uhcivar.h
index a93e41d61bc..db4337b532c 100644
--- a/sys/dev/usb/uhcivar.h
+++ b/sys/dev/usb/uhcivar.h
@@ -1,4 +1,4 @@
-/* $NetBSD: uhcivar.h,v 1.16 1999/10/13 08:10:56 augustss Exp $ */
+/* $NetBSD: uhcivar.h,v 1.17 1999/11/12 00:34:57 augustss Exp $ */
/*
* Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -69,7 +69,7 @@ typedef union {
*/
typedef struct uhci_intr_info {
struct uhci_softc *sc;
- usbd_request_handle reqh;
+ usbd_xfer_handle xfer;
uhci_soft_td_t *stdstart;
uhci_soft_td_t *stdend;
LIST_ENTRY(uhci_intr_info) list;
@@ -148,7 +148,7 @@ typedef struct uhci_softc {
char sc_isreset;
char sc_suspend;
- usbd_request_handle sc_has_timo;
+ usbd_xfer_handle sc_has_timo;
LIST_HEAD(, uhci_intr_info) sc_intrhead;
diff --git a/sys/dev/usb/uhid.c b/sys/dev/usb/uhid.c
index abb3791e3ea..753d43a3161 100644
--- a/sys/dev/usb/uhid.c
+++ b/sys/dev/usb/uhid.c
@@ -1,4 +1,4 @@
-/* $NetBSD: uhid.c,v 1.26 1999/10/13 08:10:56 augustss Exp $ */
+/* $NetBSD: uhid.c,v 1.27 1999/11/12 00:34:57 augustss Exp $ */
/*
* Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -145,11 +145,13 @@ static struct cdevsw uhid_cdevsw = {
};
#endif
-void uhid_intr __P((usbd_request_handle, usbd_private_handle, usbd_status));
+static void uhid_intr __P((usbd_xfer_handle, usbd_private_handle,
+ usbd_status));
-int uhid_do_read __P((struct uhid_softc *, struct uio *uio, int));
-int uhid_do_write __P((struct uhid_softc *, struct uio *uio, int));
-int uhid_do_ioctl __P((struct uhid_softc *, u_long, caddr_t, int, struct proc *));
+static int uhid_do_read __P((struct uhid_softc *, struct uio *uio, int));
+static int uhid_do_write __P((struct uhid_softc *, struct uio *uio, int));
+static int uhid_do_ioctl __P((struct uhid_softc *, u_long, caddr_t, int,
+ struct proc *));
USB_DECLARE_DRIVER(uhid);
@@ -174,7 +176,7 @@ USB_ATTACH(uhid)
usb_endpoint_descriptor_t *ed;
int size;
void *desc;
- usbd_status r;
+ usbd_status err;
char devinfo[1024];
sc->sc_iface = iface;
@@ -185,7 +187,7 @@ USB_ATTACH(uhid)
devinfo, id->bInterfaceClass, id->bInterfaceSubClass);
ed = usbd_interface2endpoint_descriptor(iface, 0);
- if (!ed) {
+ if (ed == NULL) {
printf("%s: could not read endpoint descriptor\n",
USBDEVNAME(sc->sc_dev));
sc->sc_dying = 1;
@@ -211,11 +213,11 @@ USB_ATTACH(uhid)
sc->sc_ep_addr = ed->bEndpointAddress;
desc = 0;
- r = usbd_alloc_report_desc(uaa->iface, &desc, &size, M_USBDEV);
- if (r != USBD_NORMAL_COMPLETION) {
+ err = usbd_alloc_report_desc(uaa->iface, &desc, &size, M_USBDEV);
+ if (err) {
printf("%s: no report descriptor\n", USBDEVNAME(sc->sc_dev));
sc->sc_dying = 1;
- if (desc)
+ if (desc != NULL)
free(desc, M_USBDEV);
USB_ATTACH_ERROR_RETURN;
}
@@ -266,7 +268,7 @@ USB_DETACH(uhid)
#endif
sc->sc_dying = 1;
- if (sc->sc_intrpipe)
+ if (sc->sc_intrpipe != NULL)
usbd_abort_pipe(sc->sc_intrpipe);
if (sc->sc_state & UHID_OPEN) {
@@ -299,8 +301,8 @@ USB_DETACH(uhid)
}
void
-uhid_intr(reqh, addr, status)
- usbd_request_handle reqh;
+uhid_intr(xfer, addr, status)
+ usbd_xfer_handle xfer;
usbd_private_handle addr;
usbd_status status;
{
@@ -337,7 +339,7 @@ uhidopen(dev, flag, mode, p)
struct proc *p;
{
struct uhid_softc *sc;
- usbd_status r;
+ usbd_status err;
USB_GET_SC_OPEN(uhid, UHIDUNIT(dev), sc);
@@ -359,13 +361,12 @@ uhidopen(dev, flag, mode, p)
sc->sc_obuf = malloc(sc->sc_osize, M_USBDEV, M_WAITOK);
/* Set up interrupt pipe. */
- r = usbd_open_pipe_intr(sc->sc_iface, sc->sc_ep_addr,
- USBD_SHORT_XFER_OK,
- &sc->sc_intrpipe, sc, sc->sc_ibuf,
- sc->sc_isize, uhid_intr);
- if (r != USBD_NORMAL_COMPLETION) {
+ err = usbd_open_pipe_intr(sc->sc_iface, sc->sc_ep_addr,
+ USBD_SHORT_XFER_OK, &sc->sc_intrpipe, sc, sc->sc_ibuf,
+ sc->sc_isize, uhid_intr);
+ if (err) {
DPRINTF(("uhidopen: usbd_open_pipe_intr failed, "
- "error=%d\n",r));
+ "error=%d\n",err));
free(sc->sc_ibuf, M_USBDEV);
free(sc->sc_obuf, M_USBDEV);
sc->sc_state &= ~UHID_OPEN;
@@ -415,15 +416,15 @@ uhid_do_read(sc, uio, flag)
int error = 0;
size_t length;
u_char buffer[UHID_CHUNK];
- usbd_status r;
+ usbd_status err;
DPRINTFN(1, ("uhidread\n"));
if (sc->sc_state & UHID_IMMED) {
DPRINTFN(1, ("uhidread immed\n"));
- r = usbd_get_report(sc->sc_iface, UHID_INPUT_REPORT,
+ err = usbd_get_report(sc->sc_iface, UHID_INPUT_REPORT,
sc->sc_iid, buffer, sc->sc_isize);
- if (r != USBD_NORMAL_COMPLETION)
+ if (err)
return (EIO);
return (uiomove(buffer, sc->sc_isize, uio));
}
@@ -496,7 +497,7 @@ uhid_do_write(sc, uio, flag)
{
int error;
int size;
- usbd_status r;
+ usbd_status err;
DPRINTFN(1, ("uhidwrite\n"));
@@ -510,15 +511,13 @@ uhid_do_write(sc, uio, flag)
error = uiomove(sc->sc_obuf, size, uio);
if (!error) {
if (sc->sc_oid)
- r = usbd_set_report(sc->sc_iface, UHID_OUTPUT_REPORT,
- sc->sc_obuf[0],
- sc->sc_obuf+1, size-1);
+ err = usbd_set_report(sc->sc_iface, UHID_OUTPUT_REPORT,
+ sc->sc_obuf[0], sc->sc_obuf+1, size-1);
else
- r = usbd_set_report(sc->sc_iface, UHID_OUTPUT_REPORT,
- 0, sc->sc_obuf, size);
- if (r != USBD_NORMAL_COMPLETION) {
+ err = usbd_set_report(sc->sc_iface, UHID_OUTPUT_REPORT,
+ 0, sc->sc_obuf, size);
+ if (err)
error = EIO;
- }
}
return (error);
@@ -553,7 +552,7 @@ uhid_do_ioctl(sc, cmd, addr, flag, p)
struct usb_ctl_report_desc *rd;
struct usb_ctl_report *re;
int size, id;
- usbd_status r;
+ usbd_status err;
DPRINTFN(2, ("uhidioctl: cmd=%lx\n", cmd));
@@ -574,11 +573,10 @@ uhid_do_ioctl(sc, cmd, addr, flag, p)
case USB_SET_IMMED:
if (*(int *)addr) {
- /* XXX should read into ibuf, but does it matter */
- r = usbd_get_report(sc->sc_iface, UHID_INPUT_REPORT,
- sc->sc_iid, sc->sc_ibuf,
- sc->sc_isize);
- if (r != USBD_NORMAL_COMPLETION)
+ /* XXX should read into ibuf, but does it matter? */
+ err = usbd_get_report(sc->sc_iface, UHID_INPUT_REPORT,
+ sc->sc_iid, sc->sc_ibuf, sc->sc_isize);
+ if (err)
return (EOPNOTSUPP);
sc->sc_state |= UHID_IMMED;
@@ -604,9 +602,9 @@ uhid_do_ioctl(sc, cmd, addr, flag, p)
default:
return (EINVAL);
}
- r = usbd_get_report(sc->sc_iface, re->report, id,
- re->data, size);
- if (r != USBD_NORMAL_COMPLETION)
+ err = usbd_get_report(sc->sc_iface, re->report, id, re->data,
+ size);
+ if (err)
return (EIO);
break;
diff --git a/sys/dev/usb/uhub.c b/sys/dev/usb/uhub.c
index 1fddbcd2c1f..dee988ca9bd 100644
--- a/sys/dev/usb/uhub.c
+++ b/sys/dev/usb/uhub.c
@@ -1,4 +1,4 @@
-/* $NetBSD: uhub.c,v 1.32 1999/10/13 08:10:56 augustss Exp $ */
+/* $NetBSD: uhub.c,v 1.33 1999/11/12 00:34:57 augustss Exp $ */
/*
* Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -78,9 +78,10 @@ struct uhub_softc {
u_char sc_running;
};
-usbd_status uhub_init_port __P((struct usbd_port *));
-usbd_status uhub_explore __P((usbd_device_handle hub));
-void uhub_intr __P((usbd_request_handle, usbd_private_handle, usbd_status));
+static usbd_status uhub_init_port __P((struct usbd_port *));
+static usbd_status uhub_explore __P((usbd_device_handle hub));
+static void uhub_intr __P((usbd_xfer_handle, usbd_private_handle,
+ usbd_status));
#if defined(__FreeBSD__)
static bus_child_detached_t uhub_child_detached;
@@ -130,7 +131,7 @@ USB_MATCH(uhub)
* The subclass for hubs seems to be 0 for some and 1 for others,
* so we just ignore the subclass.
*/
- if (uaa->iface == 0 && dd->bDeviceClass == UCLASS_HUB)
+ if (uaa->iface == NULL && dd->bDeviceClass == UCLASS_HUB)
return (UMATCH_DEVCLASS_DEVSUBCLASS);
return (UMATCH_NONE);
}
@@ -140,7 +141,7 @@ USB_ATTACH(uhub)
USB_ATTACH_START(uhub, sc, uaa);
usbd_device_handle dev = uaa->device;
char devinfo[1024];
- usbd_status r;
+ usbd_status err;
struct usbd_hub *hub;
usb_device_request_t req;
usb_hub_descriptor_t hubdesc;
@@ -154,10 +155,10 @@ USB_ATTACH(uhub)
USB_ATTACH_SETUP;
printf("%s: %s\n", USBDEVNAME(sc->sc_dev), devinfo);
- r = usbd_set_config_index(dev, 0, 1);
- if (r != USBD_NORMAL_COMPLETION) {
+ err = usbd_set_config_index(dev, 0, 1);
+ if (err) {
DPRINTF(("%s: configuration failed, error=%s\n",
- USBDEVNAME(sc->sc_dev), usbd_errstr(r)));
+ USBDEVNAME(sc->sc_dev), usbd_errstr(err)));
USB_ATTACH_ERROR_RETURN;
}
@@ -174,15 +175,15 @@ USB_ATTACH(uhub)
USETW(req.wIndex, 0);
USETW(req.wLength, USB_HUB_DESCRIPTOR_SIZE);
DPRINTFN(1,("usb_init_hub: getting hub descriptor\n"));
- r = usbd_do_request(dev, &req, &hubdesc);
+ err = usbd_do_request(dev, &req, &hubdesc);
nports = hubdesc.bNbrPorts;
- if (r == USBD_NORMAL_COMPLETION && nports > 7) {
+ if (!err && nports > 7) {
USETW(req.wLength, USB_HUB_DESCRIPTOR_SIZE + (nports+1) / 8);
- r = usbd_do_request(dev, &req, &hubdesc);
+ err = usbd_do_request(dev, &req, &hubdesc);
}
- if (r != USBD_NORMAL_COMPLETION) {
+ if (err) {
DPRINTF(("%s: getting hub descriptor failed, error=%s\n",
- USBDEVNAME(sc->sc_dev), usbd_errstr(r)));
+ USBDEVNAME(sc->sc_dev), usbd_errstr(err)));
USB_ATTACH_ERROR_RETURN;
}
@@ -195,7 +196,7 @@ USB_ATTACH(uhub)
hub = malloc(sizeof(*hub) + (nports-1) * sizeof(struct usbd_port),
M_USBDEV, M_NOWAIT);
- if (hub == 0)
+ if (hub == NULL)
USB_ATTACH_ERROR_RETURN;
dev->hub = hub;
dev->hub->hubsoftc = sc;
@@ -208,7 +209,7 @@ USB_ATTACH(uhub)
dev->powersrc->parent ?
dev->powersrc->parent->self_powered : 0));
- if (!dev->self_powered && dev->powersrc->parent &&
+ if (!dev->self_powered && dev->powersrc->parent != NULL &&
!dev->powersrc->parent->self_powered) {
printf("%s: bus powered hub connected to bus powered hub, "
"ignored\n", USBDEVNAME(sc->sc_dev));
@@ -216,13 +217,13 @@ USB_ATTACH(uhub)
}
/* Set up interrupt pipe. */
- r = usbd_device2interface_handle(dev, 0, &iface);
- if (r != USBD_NORMAL_COMPLETION) {
+ err = usbd_device2interface_handle(dev, 0, &iface);
+ if (err) {
printf("%s: no interface handle\n", USBDEVNAME(sc->sc_dev));
goto bad;
}
ed = usbd_interface2endpoint_descriptor(iface, 0);
- if (ed == 0) {
+ if (ed == NULL) {
printf("%s: no endpoint descriptor\n", USBDEVNAME(sc->sc_dev));
goto bad;
}
@@ -231,11 +232,10 @@ USB_ATTACH(uhub)
goto bad;
}
- r = usbd_open_pipe_intr(iface, ed->bEndpointAddress,USBD_SHORT_XFER_OK,
- &sc->sc_ipipe, sc, sc->sc_status,
- sizeof(sc->sc_status),
- uhub_intr);
- if (r != USBD_NORMAL_COMPLETION) {
+ err = usbd_open_pipe_intr(iface, ed->bEndpointAddress,
+ USBD_SHORT_XFER_OK, &sc->sc_ipipe, sc, sc->sc_status,
+ sizeof(sc->sc_status), uhub_intr);
+ if (err) {
printf("%s: cannot open interrupt pipe\n",
USBDEVNAME(sc->sc_dev));
goto bad;
@@ -249,10 +249,10 @@ USB_ATTACH(uhub)
up->device = 0;
up->parent = dev;
up->portno = p+1;
- r = uhub_init_port(up);
- if (r != USBD_NORMAL_COMPLETION)
+ err = uhub_init_port(up);
+ if (err)
printf("%s: init of port %d failed\n",
- USBDEVNAME(sc->sc_dev), up->portno);
+ USBDEVNAME(sc->sc_dev), up->portno);
}
sc->sc_running = 1;
@@ -270,12 +270,12 @@ uhub_init_port(up)
{
int port = up->portno;
usbd_device_handle dev = up->parent;
- usbd_status r;
+ usbd_status err;
u_int16_t pstatus;
- r = usbd_get_port_status(dev, port, &up->status);
- if (r != USBD_NORMAL_COMPLETION)
- return (r);
+ err = usbd_get_port_status(dev, port, &up->status);
+ if (err)
+ return (err);
pstatus = UGETW(up->status.wPortStatus);
DPRINTF(("usbd_init_port: adding hub port=%d status=0x%04x "
"change=0x%04x\n",
@@ -292,9 +292,9 @@ usbd_clear_port_feature(dev, port, UHF_C_PORT_OVER_CURRENT);
#endif
/* then turn the power on. */
- r = usbd_set_port_feature(dev, port, UHF_PORT_POWER);
- if (r != USBD_NORMAL_COMPLETION)
- return (r);
+ err = usbd_set_port_feature(dev, port, UHF_PORT_POWER);
+ if (err)
+ return (err);
DPRINTF(("usb_init_port: turn on port %d power status=0x%04x "
"change=0x%04x\n",
port, UGETW(up->status.wPortStatus),
@@ -303,9 +303,9 @@ usbd_clear_port_feature(dev, port, UHF_C_PORT_OVER_CURRENT);
usbd_delay_ms(dev, dev->hub->hubdesc.bPwrOn2PwrGood *
UHD_PWRON_FACTOR);
/* Get the port status again. */
- r = usbd_get_port_status(dev, port, &up->status);
- if (r != USBD_NORMAL_COMPLETION)
- return (r);
+ err = usbd_get_port_status(dev, port, &up->status);
+ if (err)
+ return (err);
DPRINTF(("usb_init_port: after power on status=0x%04x "
"change=0x%04x\n",
UGETW(up->status.wPortStatus),
@@ -338,7 +338,7 @@ uhub_explore(dev)
usb_hub_descriptor_t *hd = &dev->hub->hubdesc;
struct uhub_softc *sc = dev->hub->hubsoftc;
struct usbd_port *up;
- usbd_status r;
+ usbd_status err;
int port;
int change, status;
@@ -353,11 +353,10 @@ uhub_explore(dev)
for(port = 1; port <= hd->bNbrPorts; port++) {
up = &dev->hub->ports[port-1];
- r = usbd_get_port_status(dev, port, &up->status);
- if (r != USBD_NORMAL_COMPLETION) {
+ err = usbd_get_port_status(dev, port, &up->status);
+ if (err) {
DPRINTF(("uhub_explore: get port status failed, "
- "error=%s\n",
- usbd_errstr(r)));
+ "error=%s\n", usbd_errstr(err)));
continue;
}
status = UGETW(up->status.wPortStatus);
@@ -401,7 +400,7 @@ uhub_explore(dev)
* the disconnect.
*/
disco:
- if (up->device) {
+ if (up->device != NULL) {
/* Disconnected */
DPRINTF(("uhub_explore: device %d disappeared "
"on port %d\n", up->device->address, port));
@@ -424,13 +423,13 @@ uhub_explore(dev)
continue;
/* Get device info and set its address. */
- r = usbd_new_device(USBDEV(sc->sc_dev), dev->bus,
- dev->depth + 1, status & UPS_LOW_SPEED,
- port, up);
+ err = usbd_new_device(USBDEV(sc->sc_dev), dev->bus,
+ dev->depth + 1, status & UPS_LOW_SPEED,
+ port, up);
/* XXX retry a few times? */
- if (r != USBD_NORMAL_COMPLETION) {
+ if (err) {
DPRINTFN(-1,("uhub_explore: usb_new_device failed, "
- "error=%s\n", usbd_errstr(r)));
+ "error=%s\n", usbd_errstr(err)));
/* Avoid addressing problems by disabling. */
/* usbd_reset_port(dev, port, &up->status); */
@@ -445,7 +444,7 @@ uhub_explore(dev)
/* Make sure we don't try to restart it infinitely. */
up->restartcnt = USBD_RESTART_MAX;
} else {
- if (up->device->hub)
+ if (up->device->hub != NULL)
up->device->hub->explore(up->device);
}
}
@@ -471,7 +470,7 @@ uhub_activate(self, act)
nports = devhub->hub->hubdesc.bNbrPorts;
for(p = 0; p < nports; p++) {
usbd_device_handle dev = devhub->hub->ports[p].device;
- if (dev) {
+ if (dev != NULL) {
for (i = 0; dev->subdevs[i]; i++)
config_deactivate(dev->subdevs[i]);
}
@@ -499,7 +498,7 @@ USB_DETACH(uhub)
DPRINTF(("uhub_detach: sc=%port\n", sc));
#endif
- if (!dev->hub) /* Must be partially working */
+ if (dev->hub == NULL) /* Must be partially working */
return (0);
usbd_abort_pipe(sc->sc_ipipe);
@@ -513,7 +512,7 @@ USB_DETACH(uhub)
}
free(dev->hub, M_USBDEV);
- dev->hub = 0;
+ dev->hub = NULL;
return (0);
}
@@ -525,8 +524,8 @@ USB_DETACH(uhub)
* to be explored again.
*/
void
-uhub_intr(reqh, addr, status)
- usbd_request_handle reqh;
+uhub_intr(xfer, addr, status)
+ usbd_xfer_handle xfer;
usbd_private_handle addr;
usbd_status status;
{
diff --git a/sys/dev/usb/ukbd.c b/sys/dev/usb/ukbd.c
index 2c7c1234e58..15c5917f88a 100644
--- a/sys/dev/usb/ukbd.c
+++ b/sys/dev/usb/ukbd.c
@@ -1,4 +1,4 @@
-/* $NetBSD: ukbd.c,v 1.46 1999/10/13 08:10:57 augustss Exp $ */
+/* $NetBSD: ukbd.c,v 1.47 1999/11/12 00:34:57 augustss Exp $ */
/*
* Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -202,10 +202,10 @@ struct ukbd_softc {
#define UKBD_CHUNK 128 /* chunk size for read */
#define UKBD_BSIZE 1020 /* buffer size */
-int ukbd_is_console;
+static int ukbd_is_console;
-void ukbd_cngetc __P((void *, u_int *, int *));
-void ukbd_cnpollc __P((void *, int));
+static void ukbd_cngetc __P((void *, u_int *, int *));
+static void ukbd_cnpollc __P((void *, int));
#if defined(__NetBSD__)
const struct wskbd_consops ukbd_consops = {
@@ -214,14 +214,15 @@ const struct wskbd_consops ukbd_consops = {
};
#endif
-void ukbd_intr __P((usbd_request_handle, usbd_private_handle, usbd_status));
+static void ukbd_intr __P((usbd_xfer_handle, usbd_private_handle,
+ usbd_status));
-int ukbd_enable __P((void *, int));
-void ukbd_set_leds __P((void *, int));
+static int ukbd_enable __P((void *, int));
+static void ukbd_set_leds __P((void *, int));
#if defined(__NetBSD__)
-int ukbd_ioctl __P((void *, u_long, caddr_t, int, struct proc *));
-void ukbd_rawrepeat __P((void *v));
+static int ukbd_ioctl __P((void *, u_long, caddr_t, int, struct proc *));
+static void ukbd_rawrepeat __P((void *v));
const struct wskbd_accessops ukbd_accessops = {
ukbd_enable,
@@ -245,10 +246,10 @@ USB_MATCH(ukbd)
usb_interface_descriptor_t *id;
/* Check that this is a keyboard that speaks the boot protocol. */
- if (!uaa->iface)
+ if (uaa->iface == NULL)
return (UMATCH_NONE);
id = usbd_get_interface_descriptor(uaa->iface);
- if (!id ||
+ if (id == NULL ||
id->bInterfaceClass != UCLASS_HID ||
id->bInterfaceSubClass != USUBCLASS_BOOT ||
id->bInterfaceProtocol != UPROTO_BOOT_KEYBOARD)
@@ -262,7 +263,7 @@ USB_ATTACH(ukbd)
usbd_interface_handle iface = uaa->iface;
usb_interface_descriptor_t *id;
usb_endpoint_descriptor_t *ed;
- usbd_status r;
+ usbd_status err;
char devinfo[1024];
#if defined(__NetBSD__)
struct wskbddev_attach_args a;
@@ -278,7 +279,7 @@ USB_ATTACH(ukbd)
devinfo, id->bInterfaceClass, id->bInterfaceSubClass);
ed = usbd_interface2endpoint_descriptor(iface, 0);
- if (!ed) {
+ if (ed == NULL) {
printf("%s: could not read endpoint descriptor\n",
USBDEVNAME(sc->sc_dev));
USB_ATTACH_ERROR_RETURN;
@@ -301,11 +302,11 @@ USB_ATTACH(ukbd)
}
if ((usbd_get_quirks(uaa->device)->uq_flags & UQ_NO_SET_PROTO) == 0) {
- r = usbd_set_protocol(iface, 0);
+ err = usbd_set_protocol(iface, 0);
DPRINTFN(5, ("ukbd_attach: protocol set\n"));
- if (r != USBD_NORMAL_COMPLETION) {
+ if (err) {
printf("%s: set protocol failed\n",
- USBDEVNAME(sc->sc_dev));
+ USBDEVNAME(sc->sc_dev));
USB_ATTACH_ERROR_RETURN;
}
}
@@ -355,7 +356,7 @@ ukbd_enable(v, on)
int on;
{
struct ukbd_softc *sc = v;
- usbd_status r;
+ usbd_status err;
if (on && sc->sc_dying)
return (EIO);
@@ -372,11 +373,10 @@ ukbd_enable(v, on)
DPRINTF(("ukbd_enable: sc=%p on=%d\n", sc, on));
if (on) {
/* Set up interrupt pipe. */
- r = usbd_open_pipe_intr(sc->sc_iface, sc->sc_ep_addr,
- USBD_SHORT_XFER_OK,
- &sc->sc_intrpipe, sc, &sc->sc_ndata,
- sizeof(sc->sc_ndata), ukbd_intr);
- if (r != USBD_NORMAL_COMPLETION)
+ err = usbd_open_pipe_intr(sc->sc_iface, sc->sc_ep_addr,
+ USBD_SHORT_XFER_OK, &sc->sc_intrpipe, sc,
+ &sc->sc_ndata, sizeof(sc->sc_ndata), ukbd_intr);
+ if (err)
return (EIO);
} else {
/* Disable interrupts. */
@@ -402,7 +402,7 @@ ukbd_activate(self, act)
break;
case DVACT_DEACTIVATE:
- if (sc->sc_wskbddev)
+ if (sc->sc_wskbddev != NULL)
rv = config_deactivate(sc->sc_wskbddev);
sc->sc_dying = 1;
break;
@@ -429,14 +429,14 @@ USB_DETACH(ukbd)
panic("ukbd_detach: console keyboard");
}
/* No need to do reference counting of ukbd, wskbd has all the goo. */
- if (sc->sc_wskbddev)
+ if (sc->sc_wskbddev != NULL)
rv = config_detach(sc->sc_wskbddev, flags);
return (rv);
}
void
-ukbd_intr(reqh, addr, status)
- usbd_request_handle reqh;
+ukbd_intr(xfer, addr, status)
+ usbd_xfer_handle xfer;
usbd_private_handle addr;
usbd_status status;
{
diff --git a/sys/dev/usb/ulpt.c b/sys/dev/usb/ulpt.c
index fba59ae5200..6104b1845ca 100644
--- a/sys/dev/usb/ulpt.c
+++ b/sys/dev/usb/ulpt.c
@@ -1,4 +1,4 @@
-/* $NetBSD: ulpt.c,v 1.27 1999/10/13 08:10:57 augustss Exp $ */
+/* $NetBSD: ulpt.c,v 1.28 1999/11/12 00:34:57 augustss Exp $ */
/*
* Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -117,10 +117,7 @@ struct ulpt_softc {
};
#if defined(__NetBSD__) || defined(__OpenBSD__)
-int ulptopen __P((dev_t, int, int, struct proc *));
-int ulptclose __P((dev_t, int, int, struct proc *p));
-int ulptwrite __P((dev_t, struct uio *uio, int));
-int ulptioctl __P((dev_t, u_long, caddr_t, int, struct proc *));
+cdev_decl(ulpt);
#elif defined(__FreeBSD__)
static d_open_t ulptopen;
static d_close_t ulptclose;
@@ -168,10 +165,10 @@ USB_MATCH(ulpt)
usb_interface_descriptor_t *id;
DPRINTFN(10,("ulpt_match\n"));
- if (!uaa->iface)
+ if (uaa->iface == NULL)
return (UMATCH_NONE);
id = usbd_get_interface_descriptor(uaa->iface);
- if (id &&
+ if (id != NULL &&
id->bInterfaceClass == UCLASS_PRINTER &&
id->bInterfaceSubClass == USUBCLASS_PRINTER &&
(id->bInterfaceProtocol == UPROTO_PRINTER_UNI ||
@@ -188,7 +185,7 @@ USB_ATTACH(ulpt)
usb_interface_descriptor_t *id = usbd_get_interface_descriptor(iface);
char devinfo[1024];
usb_endpoint_descriptor_t *ed;
- usbd_status r;
+ usbd_status err;
DPRINTFN(10,("ulpt_attach: sc=%p\n", sc));
usbd_devinfo(dev, 0, devinfo);
@@ -198,13 +195,13 @@ USB_ATTACH(ulpt)
/* Figure out which endpoint is the bulk out endpoint. */
ed = usbd_interface2endpoint_descriptor(iface, 0);
- if (!ed)
+ if (ed == NULL)
goto nobulk;
if (UE_GET_DIR(ed->bEndpointAddress) != UE_DIR_OUT ||
(ed->bmAttributes & UE_XFERTYPE) != UE_BULK) {
/* In case we are using a bidir protocol... */
ed = usbd_interface2endpoint_descriptor(iface, 1);
- if (!ed)
+ if (ed == NULL)
goto nobulk;
if (UE_GET_DIR(ed->bEndpointAddress) != UE_DIR_OUT ||
(ed->bmAttributes & UE_XFERTYPE) != UE_BULK)
@@ -214,8 +211,8 @@ USB_ATTACH(ulpt)
DPRINTFN(10, ("ulpt_attach: bulk=%d\n", sc->sc_bulk));
sc->sc_iface = iface;
- r = usbd_interface2device_handle(iface, &sc->sc_udev);
- if (r != USBD_NORMAL_COMPLETION) {
+ err = usbd_interface2device_handle(iface, &sc->sc_udev);
+ if (err) {
sc->sc_dying = 1;
USB_ATTACH_ERROR_RETURN;
}
@@ -237,8 +234,9 @@ USB_ATTACH(ulpt)
USETW(req.wValue, cd->bConfigurationValue);
USETW2(req.wIndex, id->bInterfaceNumber, id->bAlternateSetting);
USETW(req.wLength, sizeof devinfo - 1);
- r = usbd_do_request_flags(dev, &req, devinfo,USBD_SHORT_XFER_OK,&alen);
- if (r != USBD_NORMAL_COMPLETION) {
+ err = usbd_do_request_flags(dev, &req, devinfo,USBD_SHORT_XFER_OK,
+ &alen);
+ if (err) {
printf("%s: cannot get device id\n", USBDEVNAME(sc->sc_dev));
} else if (alen <= 2) {
printf("%s: empty device id, no printer connected?\n",
@@ -306,7 +304,7 @@ USB_DETACH(ulpt)
#endif
sc->sc_dying = 1;
- if (sc->sc_bulkpipe)
+ if (sc->sc_bulkpipe != NULL)
usbd_abort_pipe(sc->sc_bulkpipe);
s = splusb();
@@ -341,7 +339,7 @@ ulpt_status(sc)
struct ulpt_softc *sc;
{
usb_device_request_t req;
- usbd_status r;
+ usbd_status err;
u_char status;
req.bmRequestType = UT_READ_CLASS_INTERFACE;
@@ -349,9 +347,9 @@ ulpt_status(sc)
USETW(req.wValue, 0);
USETW(req.wIndex, sc->sc_ifaceno);
USETW(req.wLength, 1);
- r = usbd_do_request(sc->sc_udev, &req, &status);
- DPRINTFN(1, ("ulpt_status: status=0x%02x r=%d\n", status, r));
- if (r == USBD_NORMAL_COMPLETION)
+ err = usbd_do_request(sc->sc_udev, &req, &status);
+ DPRINTFN(1, ("ulpt_status: status=0x%02x r=%d\n", status, err));
+ if (!err)
return (status);
else
return (0);
@@ -384,12 +382,12 @@ ulptopen(dev, flag, mode, p)
{
u_char flags = ULPTFLAGS(dev);
struct ulpt_softc *sc;
- usbd_status r;
+ usbd_status err;
int spin, error;
USB_GET_SC_OPEN(ulpt, ULPTUNIT(dev), sc);
- if (!sc->sc_iface || sc->sc_dying)
+ if (sc->sc_iface == NULL || sc->sc_dying)
return (ENXIO);
if (sc->sc_state)
@@ -424,8 +422,8 @@ ulptopen(dev, flag, mode, p)
}
}
- r = usbd_open_pipe(sc->sc_iface, sc->sc_bulk, 0, &sc->sc_bulkpipe);
- if (r != USBD_NORMAL_COMPLETION) {
+ err = usbd_open_pipe(sc->sc_iface, sc->sc_bulk, 0, &sc->sc_bulkpipe);
+ if (err) {
sc->sc_state = 0;
return (EIO);
}
@@ -490,16 +488,16 @@ ulpt_do_write(sc, uio, flags)
u_int32_t n;
int error = 0;
void *bufp;
- usbd_request_handle reqh;
- usbd_status r;
+ usbd_xfer_handle xfer;
+ usbd_status err;
DPRINTF(("ulptwrite\n"));
- reqh = usbd_alloc_request(sc->sc_udev);
- if (reqh == 0)
+ xfer = usbd_alloc_request(sc->sc_udev);
+ if (xfer == NULL)
return (ENOMEM);
- bufp = usbd_alloc_buffer(reqh, ULPT_BSIZE);
- if (bufp == 0) {
- usbd_free_request(reqh);
+ bufp = usbd_alloc_buffer(xfer, ULPT_BSIZE);
+ if (bufp == NULL) {
+ usbd_free_request(xfer);
return (ENOMEM);
}
while ((n = min(ULPT_BSIZE, uio->uio_resid)) != 0) {
@@ -508,15 +506,15 @@ ulpt_do_write(sc, uio, flags)
if (error)
break;
DPRINTFN(1, ("ulptwrite: transfer %d bytes\n", n));
- r = usbd_bulk_transfer(reqh, sc->sc_bulkpipe, USBD_NO_COPY,
- USBD_NO_TIMEOUT, bufp, &n, "ulptwr");
- if (r != USBD_NORMAL_COMPLETION) {
- DPRINTF(("ulptwrite: error=%d\n", r));
+ err = usbd_bulk_transfer(xfer, sc->sc_bulkpipe, USBD_NO_COPY,
+ USBD_NO_TIMEOUT, bufp, &n, "ulptwr");
+ if (err) {
+ DPRINTF(("ulptwrite: error=%d\n", err));
error = EIO;
break;
}
}
- usbd_free_request(reqh);
+ usbd_free_request(xfer);
return (error);
}
@@ -555,6 +553,7 @@ ulptioctl(dev, cmd, data, flag, p)
switch (cmd) {
default:
error = ENODEV;
+ break;
}
return (error);
diff --git a/sys/dev/usb/umass.c b/sys/dev/usb/umass.c
index 0a41eb2c0ad..f6cdb1b8fd4 100644
--- a/sys/dev/usb/umass.c
+++ b/sys/dev/usb/umass.c
@@ -1,4 +1,4 @@
-/* $NetBSD: umass.c,v 1.21 1999/10/13 08:10:57 augustss Exp $ */
+/* $NetBSD: umass.c,v 1.22 1999/11/12 00:34:58 augustss Exp $ */
/*-
* Copyright (c) 1999 The NetBSD Foundation, Inc.
@@ -227,11 +227,11 @@ USB_MATCH(umass)
USB_MATCH_START(umass, uaa);
usb_interface_descriptor_t *id;
- if (!uaa->iface)
+ if (uaa->iface == NULL)
return(UMATCH_NONE);
id = usbd_get_interface_descriptor(uaa->iface);
- if (id
+ if (id != NULL
&& id->bInterfaceClass == UCLASS_MASS
&& id->bInterfaceSubClass == USUBCLASS_SCSI
&& id->bInterfaceProtocol == UPROTO_MASS_BULK_P)
@@ -304,7 +304,7 @@ USB_ATTACH(umass)
*/
for (i = 0 ; i < id->bNumEndpoints ; i++) {
ed = usbd_interface2endpoint_descriptor(sc->sc_iface, i);
- if (!ed) {
+ if (ed == NULL) {
printf("%s: could not read endpoint descriptor\n",
USBDEVNAME(sc->sc_dev));
USB_ATTACH_ERROR_RETURN;
@@ -322,7 +322,7 @@ USB_ATTACH(umass)
* Get the maximum LUN supported by the device.
*/
err = umass_bulk_get_max_lun(sc, &maxlun);
- if (err != USBD_NORMAL_COMPLETION) {
+ if (err) {
printf("%s: unable to get Max Lun: %s\n",
USBDEVNAME(sc->sc_dev), usbd_errstr(err));
USB_ATTACH_ERROR_RETURN;
@@ -330,14 +330,14 @@ USB_ATTACH(umass)
/* Open the bulk-in and -out pipe */
err = usbd_open_pipe(sc->sc_iface, sc->sc_bulkout,
- USBD_EXCLUSIVE_USE, &sc->sc_bulkout_pipe);
+ USBD_EXCLUSIVE_USE, &sc->sc_bulkout_pipe);
if (err) {
DPRINTF(UDMASS_USB,("cannot open bulk out pipe (address %d)\n",
sc->sc_bulkout));
USB_ATTACH_ERROR_RETURN;
}
err = usbd_open_pipe(sc->sc_iface, sc->sc_bulkin,
- USBD_EXCLUSIVE_USE, &sc->sc_bulkin_pipe);
+ USBD_EXCLUSIVE_USE, &sc->sc_bulkin_pipe);
if (err) {
DPRINTF(UDMASS_USB,("cannot open bulk in pipe (address %d)\n",
sc->sc_bulkin));
@@ -453,7 +453,7 @@ usbd_status
umass_usb_transfer(umass_softc_t *sc, usbd_pipe_handle pipe,
void *buf, int buflen, int flags, int *xfer_size)
{
- usbd_request_handle reqh;
+ usbd_xfer_handle xfer;
usbd_private_handle priv;
void *buffer;
int size;
@@ -463,28 +463,28 @@ umass_usb_transfer(umass_softc_t *sc, usbd_pipe_handle pipe,
* transfer and then wait for it to complete
*/
- reqh = usbd_alloc_request(usbd_pipe2device_handle(pipe));
- if (!reqh) {
+ xfer = usbd_alloc_request(usbd_pipe2device_handle(pipe));
+ if (xfer == NULL) {
DPRINTF(UDMASS_USB, ("%s: not enough memory\n",
USBDEVNAME(sc->sc_dev)));
return USBD_NOMEM;
}
- usbd_setup_request(reqh, pipe, 0, buf, buflen,flags, 3000/*ms*/, NULL);
- err = usbd_sync_transfer(reqh);
+ usbd_setup_request(xfer, pipe, 0, buf, buflen,flags, 3000/*ms*/, NULL);
+ err = usbd_sync_transfer(xfer);
if (err) {
DPRINTF(UDMASS_USB, ("%s: transfer failed: %s\n",
USBDEVNAME(sc->sc_dev), usbd_errstr(err)));
- usbd_free_request(reqh);
+ usbd_free_request(xfer);
return(err);
}
- usbd_get_request_status(reqh, &priv, &buffer, &size, &err);
+ usbd_get_request_status(xfer, &priv, &buffer, &size, &err);
- if (xfer_size)
+ if (xfer_size != NULL)
*xfer_size = size;
- usbd_free_request(reqh);
+ usbd_free_request(xfer);
return(USBD_NORMAL_COMPLETION);
}
@@ -632,7 +632,7 @@ umass_bulk_transfer(umass_softc_t *sc, int lun, void *cmd, int cmdlen,
u_int8_t *c = cmd;
/* check the given arguments */
- if (!data && datalen > 0) { /* no buffer for transfer */
+ if (data == NULL && datalen > 0) { /* no buffer for transfer */
DPRINTF(UDMASS_BULK, ("%s: no buffer, but datalen > 0 !\n",
USBDEVNAME(sc->sc_dev)));
return USBD_IOERROR;
@@ -744,8 +744,7 @@ umass_bulk_transfer(umass_softc_t *sc, int lun, void *cmd, int cmdlen,
err = usbd_clear_endpoint_stall(sc->sc_bulkin_pipe);
if (!err) {
err = umass_usb_transfer(sc, sc->sc_bulkin_pipe,
- &csw, USB_BULK_CSW_SIZE, 0,
- NULL);
+ &csw, USB_BULK_CSW_SIZE, 0, NULL);
}
}
if (err && err != USBD_STALLED)
diff --git a/sys/dev/usb/umodem.c b/sys/dev/usb/umodem.c
index 954f7c5c642..f9ebb606fa2 100644
--- a/sys/dev/usb/umodem.c
+++ b/sys/dev/usb/umodem.c
@@ -1,4 +1,4 @@
-/* $NetBSD: umodem.c,v 1.15 1999/09/11 08:19:27 augustss Exp $ */
+/* $NetBSD: umodem.c,v 1.16 1999/11/12 00:34:58 augustss Exp $ */
/*
* Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -108,12 +108,12 @@ struct umodem_softc {
int sc_bulkin_no; /* bulk in endpoint address */
usbd_pipe_handle sc_bulkin_pipe; /* bulk in pipe */
- usbd_request_handle sc_ireqh; /* read request */
+ usbd_xfer_handle sc_ixfer; /* read request */
u_char *sc_ibuf; /* read buffer */
int sc_bulkout_no; /* bulk out endpoint address */
usbd_pipe_handle sc_bulkout_pipe;/* bulk out pipe */
- usbd_request_handle sc_oreqh; /* read request */
+ usbd_xfer_handle sc_oxfer; /* read request */
int sc_cm_cap; /* CM capabilities */
int sc_acm_cap; /* ACM capabilities */
@@ -146,9 +146,9 @@ void umodem_shutdown __P((struct umodem_softc *));
void umodem_modem __P((struct umodem_softc *, int));
void umodem_break __P((struct umodem_softc *, int));
usbd_status umodemstartread __P((struct umodem_softc *));
-void umodemreadcb __P((usbd_request_handle, usbd_private_handle,
+void umodemreadcb __P((usbd_xfer_handle, usbd_private_handle,
usbd_status status));
-void umodemwritecb __P((usbd_request_handle, usbd_private_handle,
+void umodemwritecb __P((usbd_xfer_handle, usbd_private_handle,
usbd_status status));
USB_DECLARE_DRIVER(umodem);
@@ -358,18 +358,18 @@ umodemstart(tp)
DPRINTFN(4,("umodemstart: %d chars\n", cnt));
/* XXX what can we do on error? */
- usbd_setup_request(sc->sc_oreqh, sc->sc_bulkout_pipe,
+ usbd_setup_request(sc->sc_oxfer, sc->sc_bulkout_pipe,
(usbd_private_handle)sc, data, cnt,
0, USBD_NO_TIMEOUT, umodemwritecb);
- (void)usbd_transfer(sc->sc_oreqh);
+ (void)usbd_transfer(sc->sc_oxfer);
out:
splx(s);
}
void
-umodemwritecb(reqh, p, status)
- usbd_request_handle reqh;
+umodemwritecb(xfer, p, status)
+ usbd_xfer_handle xfer;
usbd_private_handle p;
usbd_status status;
{
@@ -390,7 +390,7 @@ umodemwritecb(reqh, p, status)
return;
}
- usbd_get_request_status(reqh, 0, 0, &cc, 0);
+ usbd_get_request_status(xfer, 0, 0, &cc, 0);
DPRINTFN(5,("umodemwritecb: cc=%d\n", cc));
s = spltty();
@@ -565,17 +565,17 @@ umodemopen(dev, flag, mode, p)
}
/* Allocate a request and an input buffer and start reading. */
- sc->sc_ireqh = usbd_alloc_request(sc->sc_udev);
- if (sc->sc_ireqh == 0) {
+ sc->sc_ixfer = usbd_alloc_request(sc->sc_udev);
+ if (sc->sc_ixfer == 0) {
usbd_close_pipe(sc->sc_bulkin_pipe);
usbd_close_pipe(sc->sc_bulkout_pipe);
return (ENOMEM);
}
- sc->sc_oreqh = usbd_alloc_request(sc->sc_udev);
- if (sc->sc_oreqh == 0) {
+ sc->sc_oxfer = usbd_alloc_request(sc->sc_udev);
+ if (sc->sc_oxfer == 0) {
usbd_close_pipe(sc->sc_bulkin_pipe);
usbd_close_pipe(sc->sc_bulkout_pipe);
- usbd_free_request(sc->sc_ireqh);
+ usbd_free_request(sc->sc_ixfer);
return (ENOMEM);
}
sc->sc_ibuf = malloc(UMODEMIBUFSIZE, M_USBDEV, M_WAITOK);
@@ -614,19 +614,19 @@ umodemstartread(sc)
usbd_status r;
DPRINTFN(5,("umodemstartread: start\n"));
- usbd_setup_request(sc->sc_ireqh, sc->sc_bulkin_pipe,
+ usbd_setup_request(sc->sc_ixfer, sc->sc_bulkin_pipe,
(usbd_private_handle)sc,
sc->sc_ibuf, UMODEMIBUFSIZE, USBD_SHORT_XFER_OK,
USBD_NO_TIMEOUT, umodemreadcb);
- r = usbd_transfer(sc->sc_ireqh);
+ r = usbd_transfer(sc->sc_ixfer);
if (r != USBD_IN_PROGRESS)
return (r);
return (USBD_NORMAL_COMPLETION);
}
void
-umodemreadcb(reqh, p, status)
- usbd_request_handle reqh;
+umodemreadcb(xfer, p, status)
+ usbd_xfer_handle xfer;
usbd_private_handle p;
usbd_status status;
{
@@ -648,7 +648,7 @@ umodemreadcb(reqh, p, status)
return;
}
- usbd_get_request_status(reqh, 0, (void **)&cp, &cc, 0);
+ usbd_get_request_status(xfer, 0, (void **)&cp, &cc, 0);
DPRINTFN(5,("umodemreadcb: got %d chars, tp=%p\n", cc, tp));
s = spltty();
/* Give characters to tty layer. */
@@ -709,8 +709,8 @@ umodem_cleanup(sc)
usbd_close_pipe(sc->sc_bulkin_pipe);
usbd_abort_pipe(sc->sc_bulkout_pipe);
usbd_close_pipe(sc->sc_bulkout_pipe);
- usbd_free_request(sc->sc_ireqh);
- usbd_free_request(sc->sc_oreqh);
+ usbd_free_request(sc->sc_ixfer);
+ usbd_free_request(sc->sc_oxfer);
free(sc->sc_ibuf, M_USBDEV);
}
diff --git a/sys/dev/usb/ums.c b/sys/dev/usb/ums.c
index 3629c900fcc..9e0b05d75e0 100644
--- a/sys/dev/usb/ums.c
+++ b/sys/dev/usb/ums.c
@@ -1,4 +1,4 @@
-/* $NetBSD: ums.c,v 1.33 1999/10/13 08:10:57 augustss Exp $ */
+/* $NetBSD: ums.c,v 1.34 1999/11/12 00:34:58 augustss Exp $ */
/*
* Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -114,7 +114,8 @@ struct ums_softc {
#define MOUSE_FLAGS_MASK (HIO_CONST|HIO_RELATIVE)
#define MOUSE_FLAGS (HIO_RELATIVE)
-void ums_intr __P((usbd_request_handle, usbd_private_handle, usbd_status));
+static void ums_intr __P((usbd_xfer_handle, usbd_private_handle,
+ usbd_status));
static int ums_enable __P((void *));
static void ums_disable __P((void *));
@@ -134,16 +135,16 @@ USB_MATCH(ums)
usb_interface_descriptor_t *id;
int size, ret;
void *desc;
- usbd_status r;
+ usbd_status err;
- if (!uaa->iface)
+ if (uaa->iface == NULL)
return (UMATCH_NONE);
id = usbd_get_interface_descriptor(uaa->iface);
- if (!id || id->bInterfaceClass != UCLASS_HID)
+ if (id == NULL || id->bInterfaceClass != UCLASS_HID)
return (UMATCH_NONE);
- r = usbd_alloc_report_desc(uaa->iface, &desc, &size, M_TEMP);
- if (r != USBD_NORMAL_COMPLETION)
+ err = usbd_alloc_report_desc(uaa->iface, &desc, &size, M_TEMP);
+ if (err)
return (UMATCH_NONE);
if (hid_is_collection(desc, size,
@@ -165,7 +166,7 @@ USB_ATTACH(ums)
struct wsmousedev_attach_args a;
int size;
void *desc;
- usbd_status r;
+ usbd_status err;
char devinfo[1024];
u_int32_t flags;
int i;
@@ -178,7 +179,7 @@ USB_ATTACH(ums)
printf("%s: %s, iclass %d/%d\n", USBDEVNAME(sc->sc_dev),
devinfo, id->bInterfaceClass, id->bInterfaceSubClass);
ed = usbd_interface2endpoint_descriptor(iface, 0);
- if (!ed) {
+ if (ed == NULL) {
printf("%s: could not read endpoint descriptor\n",
USBDEVNAME(sc->sc_dev));
USB_ATTACH_ERROR_RETURN;
@@ -202,8 +203,8 @@ USB_ATTACH(ums)
sc->revz = (usbd_get_quirks(uaa->device)->uq_flags & UQ_MS_REVZ) != 0;
- r = usbd_alloc_report_desc(uaa->iface, &desc, &size, M_TEMP);
- if (r != USBD_NORMAL_COMPLETION)
+ err = usbd_alloc_report_desc(uaa->iface, &desc, &size, M_TEMP);
+ if (err)
USB_ATTACH_ERROR_RETURN;
if (!hid_locate(desc, size, HID_USAGE2(HUP_GENERIC_DESKTOP, HUG_X),
@@ -262,7 +263,7 @@ USB_ATTACH(ums)
sc->sc_isize = hid_report_size(desc, size, hid_input, &sc->sc_iid);
sc->sc_ibuf = malloc(sc->sc_isize, M_USBDEV, M_NOWAIT);
- if (!sc->sc_ibuf) {
+ if (sc->sc_ibuf == NULL) {
printf("%s: no memory\n", USBDEVNAME(sc->sc_dev));
free(sc->sc_loc_btn, M_USBDEV);
USB_ATTACH_ERROR_RETURN;
@@ -309,7 +310,7 @@ ums_activate(self, act)
break;
case DVACT_DEACTIVATE:
- if (sc->sc_wsmousedev)
+ if (sc->sc_wsmousedev != NULL)
rv = config_deactivate(sc->sc_wsmousedev);
sc->sc_dying = 1;
break;
@@ -325,7 +326,7 @@ USB_DETACH(ums)
DPRINTF(("ums_detach: sc=%p flags=%d\n", sc, flags));
/* No need to do reference counting of ums, wsmouse has all the goo. */
- if (sc->sc_wsmousedev)
+ if (sc->sc_wsmousedev != NULL)
rv = config_detach(sc->sc_wsmousedev, flags);
if (rv == 0) {
free(sc->sc_loc_btn, M_USBDEV);
@@ -335,8 +336,8 @@ USB_DETACH(ums)
}
void
-ums_intr(reqh, addr, status)
- usbd_request_handle reqh;
+ums_intr(xfer, addr, status)
+ usbd_xfer_handle xfer;
usbd_private_handle addr;
usbd_status status;
{
@@ -361,7 +362,7 @@ ums_intr(reqh, addr, status)
}
ibuf = sc->sc_ibuf;
- if (sc->sc_iid) {
+ if (sc->sc_iid != 0) {
if (*ibuf++ != sc->sc_iid)
return;
}
@@ -392,7 +393,7 @@ ums_enable(v)
{
struct ums_softc *sc = v;
- usbd_status r;
+ usbd_status err;
DPRINTFN(1,("ums_enable: sc=%p\n", sc));
@@ -406,12 +407,12 @@ ums_enable(v)
sc->sc_buttons = 0;
/* Set up interrupt pipe. */
- r = usbd_open_pipe_intr(sc->sc_iface, sc->sc_ep_addr,
- USBD_SHORT_XFER_OK, &sc->sc_intrpipe, sc,
- sc->sc_ibuf, sc->sc_isize, ums_intr);
- if (r != USBD_NORMAL_COMPLETION) {
+ err = usbd_open_pipe_intr(sc->sc_iface, sc->sc_ep_addr,
+ USBD_SHORT_XFER_OK, &sc->sc_intrpipe, sc,
+ sc->sc_ibuf, sc->sc_isize, ums_intr);
+ if (err) {
DPRINTF(("ums_enable: usbd_open_pipe_intr failed, error=%d\n",
- r));
+ err));
sc->sc_enabled = 0;
return (EIO);
}
@@ -456,4 +457,3 @@ ums_ioctl(v, cmd, data, flag, p)
return (-1);
}
-
diff --git a/sys/dev/usb/usb.c b/sys/dev/usb/usb.c
index e553ada15a8..e075f73518a 100644
--- a/sys/dev/usb/usb.c
+++ b/sys/dev/usb/usb.c
@@ -1,4 +1,4 @@
-/* $NetBSD: usb.c,v 1.28 1999/10/13 08:10:57 augustss Exp $ */
+/* $NetBSD: usb.c,v 1.29 1999/11/12 00:34:58 augustss Exp $ */
/*
* Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -131,22 +131,23 @@ struct cdevsw usb_cdevsw = {
};
#endif
-usbd_status usb_discover __P((struct usb_softc *));
-void usb_create_event_thread __P((void *));
-void usb_event_thread __P((void *));
+static usbd_status usb_discover __P((struct usb_softc *));
+static void usb_create_event_thread __P((void *));
+static void usb_event_thread __P((void *));
#define USB_MAX_EVENTS 50
struct usb_event_q {
struct usb_event ue;
SIMPLEQ_ENTRY(usb_event_q) next;
};
-SIMPLEQ_HEAD(, usb_event_q) usb_events = SIMPLEQ_HEAD_INITIALIZER(usb_events);
-int usb_nevents = 0;
-struct selinfo usb_selevent;
-struct proc *usb_async_proc; /* process who wants USB SIGIO */
-int usb_dev_open = 0;
+static SIMPLEQ_HEAD(, usb_event_q) usb_events =
+ SIMPLEQ_HEAD_INITIALIZER(usb_events);
+static int usb_nevents = 0;
+static struct selinfo usb_selevent;
+static struct proc *usb_async_proc; /* process who wants USB SIGIO */
+static int usb_dev_open = 0;
-int usb_get_next_event __P((struct usb_event *));
+static int usb_get_next_event __P((struct usb_event *));
/* Flag to see if we are in the cold boot process. */
extern int cold;
@@ -168,7 +169,7 @@ USB_ATTACH(usb)
void *aux = device_get_ivars(self);
#endif
usbd_device_handle dev;
- usbd_status r;
+ usbd_status err;
#if defined(__NetBSD__) || defined(__OpenBSD__)
printf("\n");
@@ -181,12 +182,12 @@ USB_ATTACH(usb)
sc->sc_bus = aux;
sc->sc_bus->usbctl = sc;
sc->sc_port.power = USB_MAX_POWER;
- r = usbd_new_device(USBDEV(sc->sc_dev), sc->sc_bus, 0, 0, 0,
- &sc->sc_port);
+ err = usbd_new_device(USBDEV(sc->sc_dev), sc->sc_bus, 0, 0, 0,
+ &sc->sc_port);
- if (r == USBD_NORMAL_COMPLETION) {
+ if (!err) {
dev = sc->sc_port.device;
- if (!dev->hub) {
+ if (dev->hub == NULL) {
sc->sc_dying = 1;
printf("%s: root device is not a hub\n",
USBDEVNAME(sc->sc_dev));
@@ -207,7 +208,7 @@ USB_ATTACH(usb)
#endif
} else {
printf("%s: root hub problem, error=%d\n",
- USBDEVNAME(sc->sc_dev), r);
+ USBDEVNAME(sc->sc_dev), err);
sc->sc_dying = 1;
}
@@ -407,7 +408,7 @@ usbioctl(devt, cmd, data, flag, p)
struct uio uio;
void *ptr = 0;
int addr = ur->addr;
- usbd_status r;
+ usbd_status err;
int error = 0;
DPRINTF(("usbioctl: USB_REQUEST addr=%d len=%d\n", addr, len));
@@ -435,10 +436,9 @@ usbioctl(devt, cmd, data, flag, p)
goto ret;
}
}
- r = usbd_do_request_flags(sc->sc_bus->devices[addr],
- &ur->request, ptr,
- ur->flags, &ur->actlen);
- if (r != USBD_NORMAL_COMPLETION) {
+ err = usbd_do_request_flags(sc->sc_bus->devices[addr],
+ &ur->request, ptr, ur->flags, &ur->actlen);
+ if (err) {
error = EIO;
goto ret;
}
@@ -569,7 +569,7 @@ usbd_add_event(type, devh)
}
/* Don't want to wait here inside splusb() */
ueq = malloc(sizeof *ueq, M_USBDEV, M_NOWAIT);
- if (ueq == 0) {
+ if (ueq == NULL) {
printf("usb: no memory, event dropped\n");
splx(s);
return;
@@ -582,7 +582,7 @@ usbd_add_event(type, devh)
SIMPLEQ_INSERT_TAIL(&usb_events, ueq, next);
wakeup(&usb_events);
selwakeup(&usb_selevent);
- if (usb_async_proc)
+ if (usb_async_proc != NULL)
psignal(usb_async_proc, SIGIO);
splx(s);
}
diff --git a/sys/dev/usb/usb_mem.c b/sys/dev/usb/usb_mem.c
index d5a74f2c2a6..f53c4034d8e 100644
--- a/sys/dev/usb/usb_mem.c
+++ b/sys/dev/usb/usb_mem.c
@@ -1,4 +1,4 @@
-/* $NetBSD: usb_mem.c,v 1.15 1999/10/12 11:24:22 augustss Exp $ */
+/* $NetBSD: usb_mem.c,v 1.16 1999/11/12 00:34:58 augustss Exp $ */
/*
* Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -85,10 +85,10 @@ static usbd_status usb_block_allocmem __P((bus_dma_tag_t, size_t, size_t,
usb_dma_block_t **));
static void usb_block_freemem __P((usb_dma_block_t *));
-LIST_HEAD(, usb_dma_block) usb_blk_freelist =
+static LIST_HEAD(, usb_dma_block) usb_blk_freelist =
LIST_HEAD_INITIALIZER(usb_blk_freelist);
/* XXX should have different free list for different tags (for speed) */
-LIST_HEAD(, usb_frag_dma) usb_frag_freelist =
+static LIST_HEAD(, usb_frag_dma) usb_frag_freelist =
LIST_HEAD_INITIALIZER(usb_frag_freelist);
static usbd_status
@@ -134,7 +134,7 @@ usb_block_allocmem(tag, size, align, dmap)
DPRINTFN(6, ("usb_block_allocmem: no free\n"));
p = malloc(sizeof *p, M_USB, M_NOWAIT);
- if (p == 0)
+ if (p == NULL)
return (USBD_NOMEM);
*dmap = p;
@@ -161,7 +161,7 @@ usb_block_allocmem(tag, size, align, dmap)
BUS_DMA_NOWAIT);
if (error)
goto destroy;
- return 0;
+ return (USBD_NORMAL_COMPLETION);
destroy:
bus_dmamap_destroy(tag, p->map);
@@ -216,7 +216,7 @@ usb_allocmem(bus, size, align, p)
usb_dma_t *p;
{
bus_dma_tag_t tag = bus->dmatag;
- usbd_status r;
+ usbd_status err;
struct usb_frag_dma *f;
usb_dma_block_t *b;
int i;
@@ -226,12 +226,12 @@ usb_allocmem(bus, size, align, p)
if (size > USB_MEM_SMALL || align > USB_MEM_SMALL) {
DPRINTFN(1, ("usb_allocmem: large alloc %d\n", (int)size));
size = (size + USB_MEM_BLOCK - 1) & ~(USB_MEM_BLOCK - 1);
- r = usb_block_allocmem(tag, size, align, &p->block);
- if (r == USBD_NORMAL_COMPLETION) {
+ err = usb_block_allocmem(tag, size, align, &p->block);
+ if (!err) {
p->block->fullblock = 1;
p->offs = 0;
}
- return (r);
+ return (err);
}
s = splusb();
@@ -239,12 +239,12 @@ usb_allocmem(bus, size, align, p)
for (f = LIST_FIRST(&usb_frag_freelist); f; f = LIST_NEXT(f, next))
if (f->block->tag == tag)
break;
- if (!f) {
+ if (f == NULL) {
DPRINTFN(1, ("usb_allocmem: adding fragments\n"));
- r = usb_block_allocmem(tag, USB_MEM_BLOCK, USB_MEM_SMALL, &b);
- if (r != USBD_NORMAL_COMPLETION) {
+ err = usb_block_allocmem(tag, USB_MEM_BLOCK, USB_MEM_SMALL,&b);
+ if (err) {
splx(s);
- return (r);
+ return (err);
}
b->fullblock = 0;
for (i = 0; i < USB_MEM_BLOCK; i += USB_MEM_SMALL) {
diff --git a/sys/dev/usb/usb_quirks.c b/sys/dev/usb/usb_quirks.c
index ae3679483a7..dfe036e3a7a 100644
--- a/sys/dev/usb/usb_quirks.c
+++ b/sys/dev/usb/usb_quirks.c
@@ -1,4 +1,4 @@
-/* $NetBSD: usb_quirks.c,v 1.14 1999/09/15 13:57:09 augustss Exp $ */
+/* $NetBSD: usb_quirks.c,v 1.15 1999/11/12 00:34:58 augustss Exp $ */
/*
* Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -52,12 +52,12 @@
extern int usbdebug;
#endif
-struct usbd_quirk_entry {
+static struct usbd_quirk_entry {
u_int16_t idVendor;
u_int16_t idProduct;
u_int16_t bcdDevice;
struct usbd_quirks quirks;
-} quirks[] = {
+} usb_quirks[] = {
{ USB_VENDOR_KYE, USB_PRODUCT_KYE_NICHE, 0x100, { UQ_NO_SET_PROTO}},
{ USB_VENDOR_INSIDEOUT,USB_PRODUCT_INSIDEOUT_EDGEPORT4,
0x094, { UQ_SWAP_UNICODE}},
@@ -77,7 +77,7 @@ usbd_find_quirk(d)
{
struct usbd_quirk_entry *t;
- for (t = quirks; t->idVendor != 0; t++) {
+ for (t = usb_quirks; t->idVendor != 0; t++) {
if (t->idVendor == UGETW(d->idVendor) &&
t->idProduct == UGETW(d->idProduct) &&
t->bcdDevice == UGETW(d->bcdDevice))
diff --git a/sys/dev/usb/usb_subr.c b/sys/dev/usb/usb_subr.c
index bd4184e2f5a..06f84003419 100644
--- a/sys/dev/usb/usb_subr.c
+++ b/sys/dev/usb/usb_subr.c
@@ -1,4 +1,4 @@
-/* $NetBSD: usb_subr.c,v 1.52 1999/10/13 08:10:58 augustss Exp $ */
+/* $NetBSD: usb_subr.c,v 1.53 1999/11/12 00:34:58 augustss Exp $ */
/*
* Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -75,17 +75,17 @@ extern int usbdebug;
#endif
static usbd_status usbd_set_config __P((usbd_device_handle, int));
-char *usbd_get_string __P((usbd_device_handle, int, char *));
-int usbd_getnewaddr __P((usbd_bus_handle bus));
-int usbd_print __P((void *aux, const char *pnp));
+static char *usbd_get_string __P((usbd_device_handle, int, char *));
+static int usbd_getnewaddr __P((usbd_bus_handle bus));
+static int usbd_print __P((void *aux, const char *pnp));
#if defined(__NetBSD__)
-int usbd_submatch __P((device_ptr_t, struct cfdata *cf, void *));
+static int usbd_submatch __P((device_ptr_t, struct cfdata *cf, void *));
#elif defined(__OpenBSD__)
-int usbd_submatch __P((device_ptr_t, void *, void *));
+static int usbd_submatch __P((device_ptr_t, void *, void *));
#endif
-void usbd_free_iface_data __P((usbd_device_handle dev, int ifcno));
-void usbd_kill_pipe __P((usbd_pipe_handle));
-usbd_status usbd_probe_and_attach
+static void usbd_free_iface_data __P((usbd_device_handle dev, int ifcno));
+static void usbd_kill_pipe __P((usbd_pipe_handle));
+static usbd_status usbd_probe_and_attach
__P((device_ptr_t parent, usbd_device_handle dev, int port, int addr));
static u_int32_t usb_cookie_no = 0;
@@ -108,7 +108,7 @@ struct usb_knowndev {
#include <dev/usb/usbdevs_data.h>
#endif /* USBVERBOSE */
-const char *usbd_error_strs[] = {
+static const char *usbd_error_strs[] = {
"NORMAL_COMPLETION",
"IN_PROGRESS",
"PENDING_REQUESTS",
@@ -153,16 +153,16 @@ usbd_get_string_desc(dev, sindex, langid, sdesc)
usb_string_descriptor_t *sdesc;
{
usb_device_request_t req;
- usbd_status r;
+ usbd_status err;
req.bmRequestType = UT_READ_DEVICE;
req.bRequest = UR_GET_DESCRIPTOR;
USETW2(req.wValue, UDESC_STRING, sindex);
USETW(req.wIndex, langid);
USETW(req.wLength, 1); /* only size byte first */
- r = usbd_do_request(dev, &req, sdesc);
- if (r != USBD_NORMAL_COMPLETION)
- return (r);
+ err = usbd_do_request(dev, &req, sdesc);
+ if (err)
+ return (err);
USETW(req.wLength, sdesc->bLength); /* the whole string */
return (usbd_do_request(dev, &req, sdesc));
}
@@ -178,7 +178,7 @@ usbd_get_string(dev, si, buf)
char *s;
int i, n;
u_int16_t c;
- usbd_status r;
+ usbd_status err;
if (si == 0)
return (0);
@@ -186,16 +186,16 @@ usbd_get_string(dev, si, buf)
return (0);
if (dev->langid == USBD_NOLANG) {
/* Set up default language */
- r = usbd_get_string_desc(dev, USB_LANGUAGE_TABLE, 0, &us);
- if (r != USBD_NORMAL_COMPLETION || us.bLength < 4) {
+ err = usbd_get_string_desc(dev, USB_LANGUAGE_TABLE, 0, &us);
+ if (err || us.bLength < 4) {
dev->langid = 0; /* Well, just pick English then */
} else {
/* Pick the first language as the default. */
dev->langid = UGETW(us.bString[0]);
}
}
- r = usbd_get_string_desc(dev, si, dev->langid, &us);
- if (r != USBD_NORMAL_COMPLETION)
+ err = usbd_get_string_desc(dev, si, dev->langid, &us);
+ if (err)
return (0);
s = buf;
n = us.bLength / 2 - 1;
@@ -210,7 +210,7 @@ usbd_get_string(dev, si, buf)
*s++ = '?';
}
*s++ = 0;
- return buf;
+ return (buf);
}
void
@@ -224,7 +224,7 @@ usbd_devinfo_vp(dev, v, p)
struct usb_knowndev *kdp;
#endif
- if (!dev) {
+ if (dev == NULL) {
v[0] = p[0] = '\0';
return;
}
@@ -232,7 +232,7 @@ usbd_devinfo_vp(dev, v, p)
vendor = usbd_get_string(dev, udd->iManufacturer, v);
product = usbd_get_string(dev, udd->iProduct, p);
#ifdef USBVERBOSE
- if (!vendor) {
+ if (vendor == NULL) {
for(kdp = usb_knowndevs;
kdp->vendorname != NULL;
kdp++) {
@@ -250,11 +250,11 @@ usbd_devinfo_vp(dev, v, p)
}
}
#endif
- if (vendor)
+ if (vendor != NULL)
strcpy(v, vendor);
else
sprintf(v, "vendor 0x%04x", UGETW(udd->idVendor));
- if (product)
+ if (product != NULL)
strcpy(p, product);
else
sprintf(p, "product 0x%04x", UGETW(udd->idProduct));
@@ -323,7 +323,7 @@ usbd_reset_port(dev, port, ps)
usb_port_status_t *ps;
{
usb_device_request_t req;
- usbd_status r;
+ usbd_status err;
int n;
req.bmRequestType = UT_WRITE_CLASS_OTHER;
@@ -331,34 +331,36 @@ usbd_reset_port(dev, port, ps)
USETW(req.wValue, UHF_PORT_RESET);
USETW(req.wIndex, port);
USETW(req.wLength, 0);
- r = usbd_do_request(dev, &req, 0);
+ err = usbd_do_request(dev, &req, 0);
DPRINTFN(1,("usbd_reset_port: port %d reset done, error=%s\n",
- port, usbd_errstr(r)));
- if (r != USBD_NORMAL_COMPLETION)
- return (r);
+ port, usbd_errstr(err)));
+ if (err)
+ return (err);
n = 10;
do {
/* Wait for device to recover from reset. */
usbd_delay_ms(dev, USB_PORT_RESET_DELAY);
- r = usbd_get_port_status(dev, port, ps);
- if (r != USBD_NORMAL_COMPLETION) {
- DPRINTF(("usbd_reset_port: get status failed %d\n",r));
- return (r);
+ err = usbd_get_port_status(dev, port, ps);
+ if (err) {
+ DPRINTF(("usbd_reset_port: get status failed %d\n",
+ err));
+ return (err);
}
} while ((UGETW(ps->wPortChange) & UPS_C_PORT_RESET) == 0 && --n > 0);
if (n == 0) {
printf("usbd_reset_port: timeout\n");
return (USBD_IOERROR);
}
- r = usbd_clear_port_feature(dev, port, UHF_C_PORT_RESET);
+ err = usbd_clear_port_feature(dev, port, UHF_C_PORT_RESET);
#ifdef USB_DEBUG
- if (r != USBD_NORMAL_COMPLETION)
- DPRINTF(("usbd_reset_port: clear port feature failed %d\n",r));
+ if (err)
+ DPRINTF(("usbd_reset_port: clear port feature failed %d\n",
+ err));
#endif
/* Wait for the device to recover from reset. */
usbd_delay_ms(dev, USB_PORT_RESET_RECOVERY);
- return (r);
+ return (err);
}
usb_interface_descriptor_t *
@@ -409,7 +411,7 @@ usbd_find_edesc(cd, ifaceidx, altidx, endptidx)
int curidx;
d = usbd_find_idesc(cd, ifaceidx, altidx);
- if (!d)
+ if (d == NULL)
return (0);
if (endptidx >= d->bNumEndpoints) /* quick exit */
return (0);
@@ -525,14 +527,14 @@ usbd_set_config_no(dev, no, msg)
{
int index;
usb_config_descriptor_t cd;
- usbd_status r;
+ usbd_status err;
DPRINTFN(5,("usbd_set_config_no: %d\n", no));
/* Figure out what config index to use. */
for (index = 0; index < dev->ddesc.bNumConfigurations; index++) {
- r = usbd_get_config_desc(dev, index, &cd);
- if (r != USBD_NORMAL_COMPLETION)
- return (r);
+ err = usbd_get_config_desc(dev, index, &cd);
+ if (err)
+ return (err);
if (cd.bConfigurationValue == no)
return (usbd_set_config_index(dev, index, msg));
}
@@ -547,7 +549,7 @@ usbd_set_config_index(dev, index, msg)
{
usb_status_t ds;
usb_config_descriptor_t cd, *cdp;
- usbd_status r;
+ usbd_status err;
int ifcidx, nifc, len, selfpowered, power;
DPRINTFN(5,("usbd_set_config_index: dev=%p index=%d\n", dev, index));
@@ -567,20 +569,20 @@ usbd_set_config_index(dev, index, msg)
}
/* Figure out what config number to use. */
- r = usbd_get_config_desc(dev, index, &cd);
- if (r != USBD_NORMAL_COMPLETION)
- return (r);
+ err = usbd_get_config_desc(dev, index, &cd);
+ if (err)
+ return (err);
len = UGETW(cd.wTotalLength);
cdp = malloc(len, M_USB, M_NOWAIT);
- if (cdp == 0)
+ if (cdp == NULL)
return (USBD_NOMEM);
- r = usbd_get_desc(dev, UDESC_CONFIG, index, len, cdp);
- if (r != USBD_NORMAL_COMPLETION)
+ err = usbd_get_desc(dev, UDESC_CONFIG, index, len, cdp);
+ if (err)
goto bad;
if (cdp->bDescriptorType != UDESC_CONFIG) {
DPRINTFN(-1,("usbd_set_config_index: bad desc %d\n",
cdp->bDescriptorType));
- r = USBD_INVAL;
+ err = USBD_INVAL;
goto bad;
}
selfpowered = 0;
@@ -589,13 +591,12 @@ usbd_set_config_index(dev, index, msg)
/* May be self powered. */
if (cdp->bmAttributes & UC_BUS_POWERED) {
/* Must ask device. */
- r = usbd_get_device_status(dev, &ds);
- if (r == USBD_NORMAL_COMPLETION &&
- (UGETW(ds.wStatus) & UDS_SELF_POWERED))
+ err = usbd_get_device_status(dev, &ds);
+ if (!err && (UGETW(ds.wStatus) & UDS_SELF_POWERED))
selfpowered = 1;
DPRINTF(("usbd_set_config_index: status=0x%04x, "
"error=%s\n",
- UGETW(ds.wStatus), usbd_errstr(r)));
+ UGETW(ds.wStatus), usbd_errstr(err)));
} else
selfpowered = 1;
}
@@ -604,7 +605,7 @@ usbd_set_config_index(dev, index, msg)
dev->address, cdp->bmAttributes,
selfpowered, cdp->bMaxPower * 2));
#ifdef USB_DEBUG
- if (!dev->powersrc) {
+ if (dev->powersrc == NULL) {
DPRINTF(("usbd_set_config_index: No power source?\n"));
return (USBD_IOERROR);
}
@@ -618,7 +619,7 @@ usbd_set_config_index(dev, index, msg)
USBDEVNAME(dev->bus->bdev), dev->address,
cdp->bConfigurationValue,
power, dev->powersrc->power);
- r = USBD_NO_POWER;
+ err = USBD_NO_POWER;
goto bad;
}
dev->power = power;
@@ -626,11 +627,11 @@ usbd_set_config_index(dev, index, msg)
DPRINTF(("usbd_set_config_index: set config %d\n",
cdp->bConfigurationValue));
- r = usbd_set_config(dev, cdp->bConfigurationValue);
- if (r != USBD_NORMAL_COMPLETION) {
+ err = usbd_set_config(dev, cdp->bConfigurationValue);
+ if (err) {
DPRINTF(("usbd_set_config_index: setting config=%d failed, "
"error=%s\n",
- cdp->bConfigurationValue, usbd_errstr(r)));
+ cdp->bConfigurationValue, usbd_errstr(err)));
goto bad;
}
DPRINTF(("usbd_set_config_index: setting new config %d\n",
@@ -639,15 +640,15 @@ usbd_set_config_index(dev, index, msg)
dev->ifaces = malloc(nifc * sizeof(struct usbd_interface),
M_USB, M_NOWAIT);
if (dev->ifaces == 0) {
- r = USBD_NOMEM;
+ err = USBD_NOMEM;
goto bad;
}
DPRINTFN(5,("usbd_set_config_index: dev=%p cdesc=%p\n", dev, cdp));
dev->cdesc = cdp;
dev->config = cdp->bConfigurationValue;
for (ifcidx = 0; ifcidx < nifc; ifcidx++) {
- r = usbd_fill_iface_data(dev, ifcidx, 0);
- if (r != USBD_NORMAL_COMPLETION) {
+ err = usbd_fill_iface_data(dev, ifcidx, 0);
+ if (err) {
while (--ifcidx >= 0)
usbd_free_iface_data(dev, ifcidx);
goto bad;
@@ -658,7 +659,7 @@ usbd_set_config_index(dev, index, msg)
bad:
free(cdp, M_USB);
- return (r);
+ return (err);
}
/* XXX add function for alternate settings */
@@ -671,29 +672,29 @@ usbd_setup_pipe(dev, iface, ep, pipe)
usbd_pipe_handle *pipe;
{
usbd_pipe_handle p;
- usbd_status r;
+ usbd_status err;
DPRINTFN(1,("usbd_setup_pipe: dev=%p iface=%p ep=%p pipe=%p\n",
dev, iface, ep, pipe));
p = malloc(dev->bus->pipe_size, M_USB, M_NOWAIT);
- if (p == 0)
+ if (p == NULL)
return (USBD_NOMEM);
p->device = dev;
p->iface = iface;
p->endpoint = ep;
ep->refcnt++;
p->refcnt = 1;
- p->intrreqh = 0;
+ p->intrxfer = 0;
p->running = 0;
p->repeat = 0;
SIMPLEQ_INIT(&p->queue);
- r = dev->bus->methods->open_pipe(p);
- if (r != USBD_NORMAL_COMPLETION) {
+ err = dev->bus->methods->open_pipe(p);
+ if (err) {
DPRINTFN(-1,("usbd_setup_pipe: endpoint=0x%x failed, error="
"%s\n",
- ep->edesc->bEndpointAddress, usbd_errstr(r)));
+ ep->edesc->bEndpointAddress, usbd_errstr(err)));
free(p, M_USB);
- return (r);
+ return (err);
}
/* Clear any stall and make sure DATA0 toggle will be used next. */
if (UE_GET_ADDR(ep->edesc->bEndpointAddress) != USB_CONTROL_ENDPOINT)
@@ -734,7 +735,8 @@ usbd_probe_and_attach(parent, dev, port, addr)
{
struct usb_attach_arg uaa;
usb_device_descriptor_t *dd = &dev->ddesc;
- int r, found, i, confi, nifaces;
+ int found, i, confi, nifaces;
+ usbd_status err;
device_ptr_t dv;
usbd_interface_handle ifaces[256]; /* 256 is the absolute max */
@@ -781,12 +783,12 @@ usbd_probe_and_attach(parent, dev, port, addr)
for (confi = 0; confi < dd->bNumConfigurations; confi++) {
DPRINTFN(1,("usbd_probe_and_attach: trying config idx=%d\n",
confi));
- r = usbd_set_config_index(dev, confi, 1);
- if (r != USBD_NORMAL_COMPLETION) {
+ err = usbd_set_config_index(dev, confi, 1);
+ if (err) {
#ifdef USB_DEBUG
DPRINTF(("%s: port %d, set config at addr %d failed, "
"error=%s\n", USBDEVPTRNAME(parent), port,
- addr, usbd_errstr(r)));
+ addr, usbd_errstr(err)));
#else
printf("%s: port %d, set config at addr %d failed\n",
USBDEVPTRNAME(parent), port, addr);
@@ -795,7 +797,7 @@ usbd_probe_and_attach(parent, dev, port, addr)
device_delete_child(parent, bdev);
#endif
- return (r);
+ return (err);
}
nifaces = dev->cdesc->bNumInterface;
uaa.configno = dev->cdesc->bConfigurationValue;
@@ -813,13 +815,13 @@ usbd_probe_and_attach(parent, dev, port, addr)
found = 0;
for (i = 0; i < nifaces; i++) {
- if (!ifaces[i])
+ if (ifaces[i] == NULL)
continue; /* interface already claimed */
uaa.iface = ifaces[i];
uaa.ifaceno = ifaces[i]->idesc->bInterfaceNumber;
dv = USB_DO_ATTACH(dev, bdev, parent, &uaa, usbd_print,
usbd_submatch);
- if (dv) {
+ if (dv != NULL) {
dev->subdevs[found++] = dv;
dev->subdevs[found] = 0;
ifaces[i] = 0; /* consumed */
@@ -862,7 +864,7 @@ usbd_probe_and_attach(parent, dev, port, addr)
uaa.product = UHUB_UNK_PRODUCT;
uaa.release = UHUB_UNK_RELEASE;
dv = USB_DO_ATTACH(dev, bdev, parent, &uaa, usbd_print, usbd_submatch);
- if (dv) {
+ if (dv != NULL) {
dev->subdevs = malloc(2 * sizeof dv, M_USB, M_NOWAIT);
if (dev->subdevs == 0)
return (USBD_NOMEM);
@@ -901,7 +903,7 @@ usbd_new_device(parent, bus, depth, lowspeed, port, up)
{
usbd_device_handle dev;
usb_device_descriptor_t *dd;
- usbd_status r;
+ usbd_status err;
int addr;
int i;
@@ -915,7 +917,7 @@ usbd_new_device(parent, bus, depth, lowspeed, port, up)
}
dev = malloc(sizeof *dev, M_USB, M_NOWAIT);
- if (dev == 0)
+ if (dev == NULL)
return (USBD_NOMEM);
memset(dev, 0, sizeof(*dev));
@@ -942,10 +944,10 @@ usbd_new_device(parent, bus, depth, lowspeed, port, up)
dev->cookie.cookie = ++usb_cookie_no;
/* Establish the the default pipe. */
- r = usbd_setup_pipe(dev, 0, &dev->def_ep, &dev->default_pipe);
- if (r != USBD_NORMAL_COMPLETION) {
+ err = usbd_setup_pipe(dev, 0, &dev->def_ep, &dev->default_pipe);
+ if (err) {
usbd_remove_device(dev, up);
- return (r);
+ return (err);
}
up->device = dev;
@@ -953,17 +955,16 @@ usbd_new_device(parent, bus, depth, lowspeed, port, up)
/* Try a few times in case the device is slow (i.e. outside specs.) */
for (i = 0; i < 5; i++) {
/* Get the first 8 bytes of the device descriptor. */
- r = usbd_get_desc(dev, UDESC_DEVICE, 0, USB_MAX_IPACKET, dd);
- if (r == USBD_NORMAL_COMPLETION)
+ err = usbd_get_desc(dev, UDESC_DEVICE, 0, USB_MAX_IPACKET, dd);
+ if (!err)
break;
usbd_delay_ms(dev, 200);
}
- if (r != USBD_NORMAL_COMPLETION) {
+ if (err) {
DPRINTFN(-1, ("usbd_new_device: addr=%d, getting first desc "
- "failed\n",
- addr));
+ "failed\n", addr));
usbd_remove_device(dev, up);
- return (r);
+ return (err);
}
DPRINTF(("usbd_new_device: adding unit addr=%d, rev=%02x, class=%d, "
@@ -989,24 +990,24 @@ usbd_new_device(parent, bus, depth, lowspeed, port, up)
USETW(dev->def_ep_desc.wMaxPacketSize, dd->bMaxPacketSize);
/* Get the full device descriptor. */
- r = usbd_get_device_desc(dev, dd);
- if (r != USBD_NORMAL_COMPLETION) {
+ err = usbd_get_device_desc(dev, dd);
+ if (err) {
DPRINTFN(-1, ("usbd_new_device: addr=%d, getting full desc "
"failed\n", addr));
usbd_remove_device(dev, up);
- return (r);
+ return (err);
}
/* Figure out what's wrong with this device. */
dev->quirks = usbd_find_quirk(dd);
/* Set the address */
- r = usbd_set_address(dev, addr);
- if (r != USBD_NORMAL_COMPLETION) {
+ err = usbd_set_address(dev, addr);
+ if (err) {
DPRINTFN(-1,("usb_new_device: set address %d failed\n",addr));
- r = USBD_SET_ADDR_FAILED;
+ err = USBD_SET_ADDR_FAILED;
usbd_remove_device(dev, up);
- return (r);
+ return (err);
}
/* Allow device time to set new address */
usbd_delay_ms(dev, USB_SET_ADDRESS_SETTLE);
@@ -1021,10 +1022,10 @@ usbd_new_device(parent, bus, depth, lowspeed, port, up)
DPRINTF(("usbd_new_device: new dev (addr %d), dev=%p, parent=%p\n",
addr, dev, parent));
- r = usbd_probe_and_attach(parent, dev, port, addr);
- if (r != USBD_NORMAL_COMPLETION) {
+ err = usbd_probe_and_attach(parent, dev, port, addr);
+ if (err) {
usbd_remove_device(dev, up);
- return (r);
+ return (err);
}
usbd_add_event(USB_EVENT_ATTACH, dev);
@@ -1038,7 +1039,7 @@ usbd_remove_device(dev, up)
{
DPRINTF(("usbd_remove_device: %p\n", dev));
- if (dev->default_pipe)
+ if (dev->default_pipe != NULL)
usbd_kill_pipe(dev->default_pipe);
up->device = 0;
dev->bus->devices[dev->address] = 0;
@@ -1176,17 +1177,17 @@ usb_free_device(dev)
{
int ifcidx, nifc;
- if (dev->default_pipe)
+ if (dev->default_pipe != NULL)
usbd_kill_pipe(dev->default_pipe);
- if (dev->ifaces) {
+ if (dev->ifaces != NULL) {
nifc = dev->cdesc->bNumInterface;
for (ifcidx = 0; ifcidx < nifc; ifcidx++)
usbd_free_iface_data(dev, ifcidx);
free(dev->ifaces, M_USB);
}
- if (dev->cdesc)
+ if (dev->cdesc != NULL)
free(dev->cdesc, M_USB);
- if (dev->subdevs)
+ if (dev->subdevs != NULL)
free(dev->subdevs, M_USB);
free(dev, M_USB);
}
@@ -1221,20 +1222,20 @@ usb_disconnect_port(up, parent)
up, dev, up->portno));
#ifdef DIAGNOSTIC
- if (!dev) {
+ if (dev == NULL) {
printf("usb_disconnect_port: no device\n");
return;
}
#endif
- if (!dev->cdesc) {
+ if (dev->cdesc == NULL) {
/* Partially attached device, just drop it. */
dev->bus->devices[dev->address] = 0;
up->device = 0;
return;
}
- if (dev->subdevs) {
+ if (dev->subdevs == NULL) {
for (i = 0; dev->subdevs[i]; i++) {
if (!dev->subdevs[i]) /* skip empty elements */
continue;
diff --git a/sys/dev/usb/usbdi.c b/sys/dev/usb/usbdi.c
index 5eac70105da..979e9f9b6c1 100644
--- a/sys/dev/usb/usbdi.c
+++ b/sys/dev/usb/usbdi.c
@@ -1,4 +1,4 @@
-/* $NetBSD: usbdi.c,v 1.47 1999/10/13 23:46:10 augustss Exp $ */
+/* $NetBSD: usbdi.c,v 1.48 1999/11/12 00:34:58 augustss Exp $ */
/*
* Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -69,11 +69,11 @@ extern int usbdebug;
#endif
static usbd_status usbd_ar_pipe __P((usbd_pipe_handle pipe));
-void usbd_do_request_async_cb
- __P((usbd_request_handle, usbd_private_handle, usbd_status));
-void usbd_start_next __P((usbd_pipe_handle pipe));
+static void usbd_do_request_async_cb
+ __P((usbd_xfer_handle, usbd_private_handle, usbd_status));
+static void usbd_start_next __P((usbd_pipe_handle pipe));
-static SIMPLEQ_HEAD(, usbd_request) usbd_free_requests =
+static SIMPLEQ_HEAD(, usbd_xfer) usbd_free_requests =
SIMPLEQ_HEAD_INITIALIZER(usbd_free_requests);
static int usbd_nbuses = 0;
@@ -87,29 +87,29 @@ usbd_init()
void
usbd_finish()
{
- usbd_request_handle reqh;
+ usbd_xfer_handle xfer;
if (--usbd_nbuses == 0) {
/* Last controller is gone, free all requests. */
for (;;) {
- reqh = SIMPLEQ_FIRST(&usbd_free_requests);
- if (reqh == NULL)
+ xfer = SIMPLEQ_FIRST(&usbd_free_requests);
+ if (xfer == NULL)
break;
- SIMPLEQ_REMOVE_HEAD(&usbd_free_requests, reqh, next);
- free(reqh, M_USB);
+ SIMPLEQ_REMOVE_HEAD(&usbd_free_requests, xfer, next);
+ free(xfer, M_USB);
}
}
}
-static __inline int usbd_reqh_isread __P((usbd_request_handle reqh));
+static __inline int usbd_xfer_isread __P((usbd_xfer_handle xfer));
static __inline int
-usbd_reqh_isread(reqh)
- usbd_request_handle reqh;
+usbd_xfer_isread(xfer)
+ usbd_xfer_handle xfer;
{
- if (reqh->rqflags & URQ_REQUEST)
- return (reqh->request.bmRequestType & UT_READ);
+ if (xfer->rqflags & URQ_REQUEST)
+ return (xfer->request.bmRequestType & UT_READ);
else
- return (reqh->pipe->endpoint->edesc->bEndpointAddress &
+ return (xfer->pipe->endpoint->edesc->bEndpointAddress &
UE_DIR_IN);
}
@@ -120,13 +120,13 @@ void
usbd_dump_queue(pipe)
usbd_pipe_handle pipe;
{
- usbd_request_handle reqh;
+ usbd_xfer_handle xfer;
printf("usbd_dump_queue: pipe=%p\n", pipe);
- for (reqh = SIMPLEQ_FIRST(&pipe->queue);
- reqh;
- reqh = SIMPLEQ_NEXT(reqh, next)) {
- printf(" reqh=%p\n", reqh);
+ for (xfer = SIMPLEQ_FIRST(&pipe->queue);
+ xfer;
+ xfer = SIMPLEQ_NEXT(xfer, next)) {
+ printf(" xfer=%p\n", xfer);
}
}
#endif
@@ -140,7 +140,7 @@ usbd_open_pipe(iface, address, flags, pipe)
{
usbd_pipe_handle p;
struct usbd_endpoint *ep;
- usbd_status r;
+ usbd_status err;
int i;
for (i = 0; i < iface->idesc->bNumEndpoints; i++) {
@@ -153,9 +153,9 @@ usbd_open_pipe(iface, address, flags, pipe)
if ((flags & USBD_EXCLUSIVE_USE) &&
ep->refcnt != 0)
return (USBD_IN_USE);
- r = usbd_setup_pipe(iface->device, iface, ep, &p);
- if (r != USBD_NORMAL_COMPLETION)
- return (r);
+ err = usbd_setup_pipe(iface->device, iface, ep, &p);
+ if (err)
+ return (err);
LIST_INSERT_HEAD(&iface->pipes, p, next);
*pipe = p;
return (USBD_NORMAL_COMPLETION);
@@ -172,35 +172,35 @@ usbd_open_pipe_intr(iface, address, flags, pipe, priv, buffer, length, cb)
u_int32_t length;
usbd_callback cb;
{
- usbd_status r;
- usbd_request_handle reqh;
+ usbd_status err;
+ usbd_xfer_handle xfer;
usbd_pipe_handle ipipe;
- r = usbd_open_pipe(iface, address, USBD_EXCLUSIVE_USE, &ipipe);
- if (r != USBD_NORMAL_COMPLETION)
- return (r);
- reqh = usbd_alloc_request(iface->device);
- if (reqh == 0) {
- r = USBD_NOMEM;
+ err = usbd_open_pipe(iface, address, USBD_EXCLUSIVE_USE, &ipipe);
+ if (err)
+ return (err);
+ xfer = usbd_alloc_request(iface->device);
+ if (xfer == NULL) {
+ err = USBD_NOMEM;
goto bad1;
}
- usbd_setup_request(reqh, ipipe, priv, buffer, length, flags,
+ usbd_setup_request(xfer, ipipe, priv, buffer, length, flags,
USBD_NO_TIMEOUT, cb);
- ipipe->intrreqh = reqh;
+ ipipe->intrxfer = xfer;
ipipe->repeat = 1;
- r = usbd_transfer(reqh);
+ err = usbd_transfer(xfer);
*pipe = ipipe;
- if (r != USBD_IN_PROGRESS)
+ if (err != USBD_IN_PROGRESS)
goto bad2;
return (USBD_NORMAL_COMPLETION);
bad2:
- ipipe->intrreqh = 0;
+ ipipe->intrxfer = NULL;
ipipe->repeat = 0;
- usbd_free_request(reqh);
+ usbd_free_request(xfer);
bad1:
usbd_close_pipe(ipipe);
- return r;
+ return (err);
}
usbd_status
@@ -208,7 +208,7 @@ usbd_close_pipe(pipe)
usbd_pipe_handle pipe;
{
#ifdef DIAGNOSTIC
- if (pipe == 0) {
+ if (pipe == NULL) {
printf("usbd_close_pipe: pipe==NULL\n");
return (USBD_NORMAL_COMPLETION);
}
@@ -221,185 +221,185 @@ usbd_close_pipe(pipe)
LIST_REMOVE(pipe, next);
pipe->endpoint->refcnt--;
pipe->methods->close(pipe);
- if (pipe->intrreqh)
- usbd_free_request(pipe->intrreqh);
+ if (pipe->intrxfer != NULL)
+ usbd_free_request(pipe->intrxfer);
free(pipe, M_USB);
return (USBD_NORMAL_COMPLETION);
}
usbd_status
-usbd_transfer(reqh)
- usbd_request_handle reqh;
+usbd_transfer(xfer)
+ usbd_xfer_handle xfer;
{
- usbd_pipe_handle pipe = reqh->pipe;
- usb_dma_t *dmap = &reqh->dmabuf;
- usbd_status r;
+ usbd_pipe_handle pipe = xfer->pipe;
+ usb_dma_t *dmap = &xfer->dmabuf;
+ usbd_status err;
u_int size;
int s;
- DPRINTFN(5,("usbd_transfer: reqh=%p, flags=%d, pipe=%p, running=%d\n",
- reqh, reqh->flags, pipe, pipe->running));
+ DPRINTFN(5,("usbd_transfer: xfer=%p, flags=%d, pipe=%p, running=%d\n",
+ xfer, xfer->flags, pipe, pipe->running));
#ifdef USB_DEBUG
if (usbdebug > 5)
usbd_dump_queue(pipe);
#endif
- reqh->done = 0;
+ xfer->done = 0;
- size = reqh->length;
+ size = xfer->length;
/* If there is no buffer, allocate one. */
- if (!(reqh->rqflags & URQ_DEV_DMABUF) && size != 0) {
+ if (!(xfer->rqflags & URQ_DEV_DMABUF) && size != 0) {
struct usbd_bus *bus = pipe->device->bus;
#ifdef DIAGNOSTIC
- if (reqh->rqflags & URQ_AUTO_DMABUF)
+ if (xfer->rqflags & URQ_AUTO_DMABUF)
printf("usbd_transfer: has old buffer!\n");
#endif
- r = bus->methods->allocm(bus, dmap, size);
- if (r != USBD_NORMAL_COMPLETION)
- return (r);
- reqh->rqflags |= URQ_AUTO_DMABUF;
+ err = bus->methods->allocm(bus, dmap, size);
+ if (err)
+ return (err);
+ xfer->rqflags |= URQ_AUTO_DMABUF;
}
/* Copy data if going out. */
- if (!(reqh->flags & USBD_NO_COPY) && size != 0 &&
- !usbd_reqh_isread(reqh))
- memcpy(KERNADDR(dmap), reqh->buffer, size);
+ if (!(xfer->flags & USBD_NO_COPY) && size != 0 &&
+ !usbd_xfer_isread(xfer))
+ memcpy(KERNADDR(dmap), xfer->buffer, size);
- r = pipe->methods->transfer(reqh);
+ err = pipe->methods->transfer(xfer);
- if (r != USBD_IN_PROGRESS && r != USBD_NORMAL_COMPLETION) {
+ if (err != USBD_IN_PROGRESS && err != USBD_NORMAL_COMPLETION) {
/* The transfer has not been queued, so free buffer. */
- if (reqh->rqflags & URQ_AUTO_DMABUF) {
+ if (xfer->rqflags & URQ_AUTO_DMABUF) {
struct usbd_bus *bus = pipe->device->bus;
- bus->methods->freem(bus, &reqh->dmabuf);
- reqh->rqflags &= ~URQ_AUTO_DMABUF;
+ bus->methods->freem(bus, &xfer->dmabuf);
+ xfer->rqflags &= ~URQ_AUTO_DMABUF;
}
}
- if (!(reqh->flags & USBD_SYNCHRONOUS))
- return (r);
+ if (!(xfer->flags & USBD_SYNCHRONOUS))
+ return (err);
/* Sync transfer, wait for completion. */
- if (r != USBD_IN_PROGRESS)
- return (r);
+ if (err != USBD_IN_PROGRESS)
+ return (err);
s = splusb();
- if (!reqh->done) {
+ if (!xfer->done) {
if (pipe->device->bus->use_polling)
panic("usbd_transfer: not done\n");
- tsleep(reqh, PRIBIO, "usbsyn", 0);
+ tsleep(xfer, PRIBIO, "usbsyn", 0);
}
splx(s);
- return (reqh->status);
+ return (xfer->status);
}
/* Like usbd_transfer(), but waits for completion. */
usbd_status
-usbd_sync_transfer(reqh)
- usbd_request_handle reqh;
+usbd_sync_transfer(xfer)
+ usbd_xfer_handle xfer;
{
- reqh->flags |= USBD_SYNCHRONOUS;
- return (usbd_transfer(reqh));
+ xfer->flags |= USBD_SYNCHRONOUS;
+ return (usbd_transfer(xfer));
}
void *
-usbd_alloc_buffer(reqh, size)
- usbd_request_handle reqh;
+usbd_alloc_buffer(xfer, size)
+ usbd_xfer_handle xfer;
u_int32_t size;
{
- struct usbd_bus *bus = reqh->device->bus;
- usbd_status r;
+ struct usbd_bus *bus = xfer->device->bus;
+ usbd_status err;
- r = bus->methods->allocm(bus, &reqh->dmabuf, size);
- if (r != USBD_NORMAL_COMPLETION)
+ err = bus->methods->allocm(bus, &xfer->dmabuf, size);
+ if (err)
return (0);
- reqh->rqflags |= URQ_DEV_DMABUF;
- return (KERNADDR(&reqh->dmabuf));
+ xfer->rqflags |= URQ_DEV_DMABUF;
+ return (KERNADDR(&xfer->dmabuf));
}
void
-usbd_free_buffer(reqh)
- usbd_request_handle reqh;
+usbd_free_buffer(xfer)
+ usbd_xfer_handle xfer;
{
#ifdef DIAGNOSTIC
- if (!(reqh->rqflags & (URQ_DEV_DMABUF | URQ_AUTO_DMABUF))) {
+ if (!(xfer->rqflags & (URQ_DEV_DMABUF | URQ_AUTO_DMABUF))) {
printf("usbd_free_buffer: no buffer\n");
return;
}
#endif
- reqh->rqflags &= ~(URQ_DEV_DMABUF | URQ_AUTO_DMABUF);
- reqh->device->bus->methods->freem(reqh->device->bus, &reqh->dmabuf);
+ xfer->rqflags &= ~(URQ_DEV_DMABUF | URQ_AUTO_DMABUF);
+ xfer->device->bus->methods->freem(xfer->device->bus, &xfer->dmabuf);
}
void *
-usbd_get_buffer(reqh)
- usbd_request_handle reqh;
+usbd_get_buffer(xfer)
+ usbd_xfer_handle xfer;
{
- if (!(reqh->rqflags & URQ_DEV_DMABUF))
+ if (!(xfer->rqflags & URQ_DEV_DMABUF))
return (0);
- return (KERNADDR(&reqh->dmabuf));
+ return (KERNADDR(&xfer->dmabuf));
}
-usbd_request_handle
+usbd_xfer_handle
usbd_alloc_request(dev)
usbd_device_handle dev;
{
- usbd_request_handle reqh;
+ usbd_xfer_handle xfer;
- reqh = SIMPLEQ_FIRST(&usbd_free_requests);
- if (reqh)
- SIMPLEQ_REMOVE_HEAD(&usbd_free_requests, reqh, next);
+ xfer = SIMPLEQ_FIRST(&usbd_free_requests);
+ if (xfer != NULL)
+ SIMPLEQ_REMOVE_HEAD(&usbd_free_requests, xfer, next);
else
- reqh = malloc(sizeof(*reqh), M_USB, M_NOWAIT);
- if (!reqh)
+ xfer = malloc(sizeof(*xfer), M_USB, M_NOWAIT);
+ if (xfer == NULL)
return (0);
- memset(reqh, 0, sizeof *reqh);
- reqh->device = dev;
- DPRINTFN(5,("usbd_alloc_request() = %p\n", reqh));
- return (reqh);
+ memset(xfer, 0, sizeof *xfer);
+ xfer->device = dev;
+ DPRINTFN(5,("usbd_alloc_request() = %p\n", xfer));
+ return (xfer);
}
usbd_status
-usbd_free_request(reqh)
- usbd_request_handle reqh;
+usbd_free_request(xfer)
+ usbd_xfer_handle xfer;
{
- DPRINTFN(5,("usbd_free_request: %p\n", reqh));
- if (reqh->rqflags & (URQ_DEV_DMABUF | URQ_AUTO_DMABUF))
- usbd_free_buffer(reqh);
- SIMPLEQ_INSERT_HEAD(&usbd_free_requests, reqh, next);
+ DPRINTFN(5,("usbd_free_request: %p\n", xfer));
+ if (xfer->rqflags & (URQ_DEV_DMABUF | URQ_AUTO_DMABUF))
+ usbd_free_buffer(xfer);
+ SIMPLEQ_INSERT_HEAD(&usbd_free_requests, xfer, next);
return (USBD_NORMAL_COMPLETION);
}
void
-usbd_setup_request(reqh, pipe, priv, buffer, length, flags, timeout, callback)
- usbd_request_handle reqh;
+usbd_setup_request(xfer, pipe, priv, buffer, length, flags, timeout, callback)
+ usbd_xfer_handle xfer;
usbd_pipe_handle pipe;
usbd_private_handle priv;
void *buffer;
u_int32_t length;
u_int16_t flags;
u_int32_t timeout;
- void (*callback) __P((usbd_request_handle,
+ void (*callback) __P((usbd_xfer_handle,
usbd_private_handle,
usbd_status));
{
- reqh->pipe = pipe;
- reqh->priv = priv;
- reqh->buffer = buffer;
- reqh->length = length;
- reqh->actlen = 0;
- reqh->flags = flags;
- reqh->timeout = timeout;
- reqh->status = USBD_NOT_STARTED;
- reqh->callback = callback;
- reqh->rqflags &= ~URQ_REQUEST;
- reqh->nframes = 0;
+ xfer->pipe = pipe;
+ xfer->priv = priv;
+ xfer->buffer = buffer;
+ xfer->length = length;
+ xfer->actlen = 0;
+ xfer->flags = flags;
+ xfer->timeout = timeout;
+ xfer->status = USBD_NOT_STARTED;
+ xfer->callback = callback;
+ xfer->rqflags &= ~URQ_REQUEST;
+ xfer->nframes = 0;
}
void
-usbd_setup_default_request(reqh, dev, priv, timeout, req, buffer,
+usbd_setup_default_request(xfer, dev, priv, timeout, req, buffer,
length, flags, callback)
- usbd_request_handle reqh;
+ usbd_xfer_handle xfer;
usbd_device_handle dev;
usbd_private_handle priv;
u_int32_t timeout;
@@ -407,27 +407,27 @@ usbd_setup_default_request(reqh, dev, priv, timeout, req, buffer,
void *buffer;
u_int32_t length;
u_int16_t flags;
- void (*callback) __P((usbd_request_handle,
+ void (*callback) __P((usbd_xfer_handle,
usbd_private_handle,
usbd_status));
{
- reqh->pipe = dev->default_pipe;
- reqh->priv = priv;
- reqh->buffer = buffer;
- reqh->length = length;
- reqh->actlen = 0;
- reqh->flags = flags;
- reqh->timeout = timeout;
- reqh->status = USBD_NOT_STARTED;
- reqh->callback = callback;
- reqh->request = *req;
- reqh->rqflags |= URQ_REQUEST;
- reqh->nframes = 0;
+ xfer->pipe = dev->default_pipe;
+ xfer->priv = priv;
+ xfer->buffer = buffer;
+ xfer->length = length;
+ xfer->actlen = 0;
+ xfer->flags = flags;
+ xfer->timeout = timeout;
+ xfer->status = USBD_NOT_STARTED;
+ xfer->callback = callback;
+ xfer->request = *req;
+ xfer->rqflags |= URQ_REQUEST;
+ xfer->nframes = 0;
}
void
-usbd_setup_isoc_request(reqh, pipe, priv, frlengths, nframes, flags, callback)
- usbd_request_handle reqh;
+usbd_setup_isoc_request(xfer, pipe, priv, frlengths, nframes, flags, callback)
+ usbd_xfer_handle xfer;
usbd_pipe_handle pipe;
usbd_private_handle priv;
u_int16_t *frlengths;
@@ -435,36 +435,36 @@ usbd_setup_isoc_request(reqh, pipe, priv, frlengths, nframes, flags, callback)
u_int16_t flags;
usbd_callback callback;
{
- reqh->pipe = pipe;
- reqh->priv = priv;
- reqh->buffer = 0;
- reqh->length = 0;
- reqh->actlen = 0;
- reqh->flags = flags;
- reqh->timeout = USBD_NO_TIMEOUT;
- reqh->status = USBD_NOT_STARTED;
- reqh->callback = callback;
- reqh->rqflags &= ~URQ_REQUEST;
- reqh->frlengths = frlengths;
- reqh->nframes = nframes;
+ xfer->pipe = pipe;
+ xfer->priv = priv;
+ xfer->buffer = 0;
+ xfer->length = 0;
+ xfer->actlen = 0;
+ xfer->flags = flags;
+ xfer->timeout = USBD_NO_TIMEOUT;
+ xfer->status = USBD_NOT_STARTED;
+ xfer->callback = callback;
+ xfer->rqflags &= ~URQ_REQUEST;
+ xfer->frlengths = frlengths;
+ xfer->nframes = nframes;
}
void
-usbd_get_request_status(reqh, priv, buffer, count, status)
- usbd_request_handle reqh;
+usbd_get_request_status(xfer, priv, buffer, count, status)
+ usbd_xfer_handle xfer;
usbd_private_handle *priv;
void **buffer;
u_int32_t *count;
usbd_status *status;
{
- if (priv)
- *priv = reqh->priv;
- if (buffer)
- *buffer = reqh->buffer;
- if (count)
- *count = reqh->actlen;
- if (status)
- *status = reqh->status;
+ if (priv != NULL)
+ *priv = xfer->priv;
+ if (buffer != NULL)
+ *buffer = xfer->buffer;
+ if (count != NULL)
+ *count = xfer->actlen;
+ if (status != NULL)
+ *status = xfer->status;
}
usb_config_descriptor_t *
@@ -502,19 +502,19 @@ usbd_status
usbd_abort_pipe(pipe)
usbd_pipe_handle pipe;
{
- usbd_status r;
+ usbd_status err;
int s;
#ifdef DIAGNOSTIC
- if (pipe == 0) {
+ if (pipe == NULL) {
printf("usbd_close_pipe: pipe==NULL\n");
return (USBD_NORMAL_COMPLETION);
}
#endif
s = splusb();
- r = usbd_ar_pipe(pipe);
+ err = usbd_ar_pipe(pipe);
splx(s);
- return (r);
+ return (err);
}
usbd_status
@@ -523,7 +523,7 @@ usbd_clear_endpoint_stall(pipe)
{
usbd_device_handle dev = pipe->device;
usb_device_request_t req;
- usbd_status r;
+ usbd_status err;
DPRINTFN(8, ("usbd_clear_endpoint_stall\n"));
@@ -538,15 +538,15 @@ usbd_clear_endpoint_stall(pipe)
USETW(req.wValue, UF_ENDPOINT_HALT);
USETW(req.wIndex, pipe->endpoint->edesc->bEndpointAddress);
USETW(req.wLength, 0);
- r = usbd_do_request(dev, &req, 0);
+ err = usbd_do_request(dev, &req, 0);
#if 0
XXX should we do this?
- if (r == USBD_NORMAL_COMPLETION) {
+ if (err == USBD_NORMAL_COMPLETION) {
pipe->state = USBD_PIPE_ACTIVE;
/* XXX activate pipe */
}
#endif
- return (r);
+ return (err);
}
usbd_status
@@ -555,7 +555,7 @@ usbd_clear_endpoint_stall_async(pipe)
{
usbd_device_handle dev = pipe->device;
usb_device_request_t req;
- usbd_status r;
+ usbd_status err;
pipe->methods->cleartoggle(pipe);
@@ -564,8 +564,8 @@ usbd_clear_endpoint_stall_async(pipe)
USETW(req.wValue, UF_ENDPOINT_HALT);
USETW(req.wIndex, pipe->endpoint->edesc->bEndpointAddress);
USETW(req.wLength, 0);
- r = usbd_do_request_async(dev, &req, 0);
- return (r);
+ err = usbd_do_request_async(dev, &req, 0);
+ return (err);
}
usbd_status
@@ -582,7 +582,7 @@ usbd_interface_count(dev, count)
usbd_device_handle dev;
u_int8_t *count;
{
- if (!dev->cdesc)
+ if (dev->cdesc == NULL)
return (USBD_NOT_CONFIGURED);
*count = dev->cdesc->bNumInterface;
return (USBD_NORMAL_COMPLETION);
@@ -603,7 +603,7 @@ usbd_device2interface_handle(dev, ifaceno, iface)
u_int8_t ifaceno;
usbd_interface_handle *iface;
{
- if (!dev->cdesc)
+ if (dev->cdesc == NULL)
return (USBD_NOT_CONFIGURED);
if (ifaceno >= dev->cdesc->bNumInterface)
return (USBD_INVAL);
@@ -625,7 +625,7 @@ usbd_set_interface(iface, altidx)
int altidx;
{
usb_device_request_t req;
- usbd_status r;
+ usbd_status err;
if (LIST_FIRST(&iface->pipes) != 0)
return (USBD_IN_USE);
@@ -635,16 +635,16 @@ usbd_set_interface(iface, altidx)
iface->endpoints = 0;
iface->idesc = 0;
- r = usbd_fill_iface_data(iface->device, iface->index, altidx);
- if (r != USBD_NORMAL_COMPLETION)
- return (r);
+ err = usbd_fill_iface_data(iface->device, iface->index, altidx);
+ if (err)
+ return (err);
req.bmRequestType = UT_WRITE_INTERFACE;
req.bRequest = UR_SET_INTERFACE;
USETW(req.wValue, iface->idesc->bAlternateSetting);
USETW(req.wIndex, iface->idesc->bInterfaceNumber);
USETW(req.wLength, 0);
- return usbd_do_request(iface->device, &req, 0);
+ return (usbd_do_request(iface->device, &req, 0));
}
int
@@ -686,7 +686,7 @@ usbd_get_interface(iface, aiface)
USETW(req.wValue, 0);
USETW(req.wIndex, iface->idesc->bInterfaceNumber);
USETW(req.wLength, 1);
- return usbd_do_request(iface->device, &req, aiface);
+ return (usbd_do_request(iface->device, &req, aiface));
}
/*** Internal routines ***/
@@ -696,7 +696,7 @@ static usbd_status
usbd_ar_pipe(pipe)
usbd_pipe_handle pipe;
{
- usbd_request_handle reqh;
+ usbd_xfer_handle xfer;
SPLUSBCHECK;
@@ -706,11 +706,11 @@ usbd_ar_pipe(pipe)
usbd_dump_queue(pipe);
#endif
pipe->repeat = 0;
- while ((reqh = SIMPLEQ_FIRST(&pipe->queue))) {
- DPRINTFN(2,("usbd_ar_pipe: pipe=%p reqh=%p (methods=%p)\n",
- pipe, reqh, pipe->methods));
+ while ((xfer = SIMPLEQ_FIRST(&pipe->queue)) != NULL) {
+ DPRINTFN(2,("usbd_ar_pipe: pipe=%p xfer=%p (methods=%p)\n",
+ pipe, xfer, pipe->methods));
/* Make the HC abort it (and invoke the callback). */
- pipe->methods->abort(reqh);
+ pipe->methods->abort(xfer);
/* XXX only for non-0 usbd_clear_endpoint_stall(pipe); */
}
return (USBD_NORMAL_COMPLETION);
@@ -718,22 +718,22 @@ usbd_ar_pipe(pipe)
/* Called at splusb() */
void
-usb_transfer_complete(reqh)
- usbd_request_handle reqh;
+usb_transfer_complete(xfer)
+ usbd_xfer_handle xfer;
{
- usbd_pipe_handle pipe = reqh->pipe;
- usb_dma_t *dmap = &reqh->dmabuf;
+ usbd_pipe_handle pipe = xfer->pipe;
+ usb_dma_t *dmap = &xfer->dmabuf;
int repeat = pipe->repeat;
int polling;
SPLUSBCHECK;
- DPRINTFN(5, ("usb_transfer_complete: pipe=%p reqh=%p status=%d actlen=%d\n",
- pipe, reqh, reqh->status, reqh->actlen));
+ DPRINTFN(5, ("usb_transfer_complete: pipe=%p xfer=%p status=%d "
+ "actlen=%d\n", pipe, xfer, xfer->status, xfer->actlen));
#ifdef DIAGNOSTIC
- if (!pipe) {
- printf("usbd_transfer_cb: pipe==0, reqh=%p\n", reqh);
+ if (pipe == NULL) {
+ printf("usbd_transfer_cb: pipe==0, xfer=%p\n", xfer);
return;
}
#endif
@@ -742,63 +742,63 @@ usb_transfer_complete(reqh)
if (polling)
pipe->running = 0;
- if (!(reqh->flags & USBD_NO_COPY) && reqh->actlen != 0 &&
- usbd_reqh_isread(reqh)) {
+ if (!(xfer->flags & USBD_NO_COPY) && xfer->actlen != 0 &&
+ usbd_xfer_isread(xfer)) {
#ifdef DIAGNOSTIC
- if (reqh->actlen > reqh->length) {
+ if (xfer->actlen > xfer->length) {
printf("usb_transfer_complete: actlen > len %d > %d\n",
- reqh->actlen, reqh->length);
- reqh->actlen = reqh->length;
+ xfer->actlen, xfer->length);
+ xfer->actlen = xfer->length;
}
#endif
- memcpy(reqh->buffer, KERNADDR(dmap), reqh->actlen);
+ memcpy(xfer->buffer, KERNADDR(dmap), xfer->actlen);
}
/* if we allocated the buffer in usbd_transfer() we free it here. */
- if (reqh->rqflags & URQ_AUTO_DMABUF) {
+ if (xfer->rqflags & URQ_AUTO_DMABUF) {
if (!repeat) {
struct usbd_bus *bus = pipe->device->bus;
bus->methods->freem(bus, dmap);
- reqh->rqflags &= ~URQ_AUTO_DMABUF;
+ xfer->rqflags &= ~URQ_AUTO_DMABUF;
}
}
- if (pipe->methods->done)
- pipe->methods->done(reqh);
+ if (pipe->methods->done != NULL)
+ pipe->methods->done(xfer);
if (!repeat) {
/* Remove request from queue. */
#ifdef DIAGNOSTIC
- if (reqh != SIMPLEQ_FIRST(&pipe->queue))
+ if (xfer != SIMPLEQ_FIRST(&pipe->queue))
printf("usb_transfer_complete: bad dequeue %p != %p\n",
- reqh, SIMPLEQ_FIRST(&pipe->queue));
+ xfer, SIMPLEQ_FIRST(&pipe->queue));
#endif
- SIMPLEQ_REMOVE_HEAD(&pipe->queue, reqh, next);
+ SIMPLEQ_REMOVE_HEAD(&pipe->queue, xfer, next);
}
/* Count completed transfers. */
++pipe->device->bus->stats.requests
[pipe->endpoint->edesc->bmAttributes & UE_XFERTYPE];
- reqh->done = 1;
- if (reqh->status == USBD_NORMAL_COMPLETION &&
- reqh->actlen < reqh->length &&
- !(reqh->flags & USBD_SHORT_XFER_OK)) {
- DPRINTFN(-1, ("usbd_transfer_cb: short xfer %d<%d (bytes)\n",
- reqh->actlen, reqh->length));
- reqh->status = USBD_SHORT_XFER;
+ xfer->done = 1;
+ if (xfer->status == USBD_NORMAL_COMPLETION &&
+ xfer->actlen < xfer->length &&
+ !(xfer->flags & USBD_SHORT_XFER_OK)) {
+ DPRINTFN(-1,("usbd_transfer_cb: short transfer %d<%d\n",
+ xfer->actlen, xfer->length));
+ xfer->status = USBD_SHORT_XFER;
}
- if (reqh->callback)
- reqh->callback(reqh, reqh->priv, reqh->status);
+ if (xfer->callback)
+ xfer->callback(xfer, xfer->priv, xfer->status);
- if ((reqh->flags & USBD_SYNCHRONOUS) && !polling)
- wakeup(reqh);
+ if ((xfer->flags & USBD_SYNCHRONOUS) && !polling)
+ wakeup(xfer);
if (!repeat) {
/* XXX should we stop the queue on all errors? */
- if (reqh->status == USBD_CANCELLED ||
- reqh->status == USBD_TIMEOUT)
+ if (xfer->status == USBD_CANCELLED ||
+ xfer->status == USBD_TIMEOUT)
pipe->running = 0;
else
usbd_start_next(pipe);
@@ -806,25 +806,25 @@ usb_transfer_complete(reqh)
}
usbd_status
-usb_insert_transfer(reqh)
- usbd_request_handle reqh;
+usb_insert_transfer(xfer)
+ usbd_xfer_handle xfer;
{
- usbd_pipe_handle pipe = reqh->pipe;
- usbd_status r;
+ usbd_pipe_handle pipe = xfer->pipe;
+ usbd_status err;
int s;
DPRINTFN(5,("usb_insert_transfer: pipe=%p running=%d timeout=%d\n",
- pipe, pipe->running, reqh->timeout));
+ pipe, pipe->running, xfer->timeout));
s = splusb();
- SIMPLEQ_INSERT_TAIL(&pipe->queue, reqh, next);
+ SIMPLEQ_INSERT_TAIL(&pipe->queue, xfer, next);
if (pipe->running)
- r = USBD_IN_PROGRESS;
+ err = USBD_IN_PROGRESS;
else {
pipe->running = 1;
- r = USBD_NORMAL_COMPLETION;
+ err = USBD_NORMAL_COMPLETION;
}
splx(s);
- return (r);
+ return (err);
}
/* Called at splusb() */
@@ -832,33 +832,33 @@ void
usbd_start_next(pipe)
usbd_pipe_handle pipe;
{
- usbd_request_handle reqh;
- usbd_status r;
+ usbd_xfer_handle xfer;
+ usbd_status err;
SPLUSBCHECK;
DPRINTFN(10, ("usbd_start_next: pipe=%p\n", pipe));
#ifdef DIAGNOSTIC
- if (!pipe) {
+ if (pipe == NULL) {
printf("usbd_start_next: pipe == 0\n");
return;
}
- if (!pipe->methods || !pipe->methods->start) {
+ if (pipe->methods == NULL || pipe->methods->start == NULL) {
printf("usbd_start_next: no start method\n");
return;
}
#endif
/* Get next request in queue. */
- reqh = SIMPLEQ_FIRST(&pipe->queue);
- DPRINTFN(5, ("usbd_start_next: pipe=%p start reqh=%p\n", pipe, reqh));
- if (!reqh)
+ xfer = SIMPLEQ_FIRST(&pipe->queue);
+ DPRINTFN(5, ("usbd_start_next: pipe=%p start xfer=%p\n", pipe, xfer));
+ if (xfer == NULL)
pipe->running = 0;
else {
- r = pipe->methods->start(reqh);
- if (r != USBD_IN_PROGRESS) {
- printf("usbd_start_next: error=%d\n", r);
+ err = pipe->methods->start(xfer);
+ if (err != USBD_IN_PROGRESS) {
+ printf("usbd_start_next: error=%d\n", err);
pipe->running = 0;
/* XXX do what? */
}
@@ -882,8 +882,8 @@ usbd_do_request_flags(dev, req, data, flags, actlen)
u_int16_t flags;
int *actlen;
{
- usbd_request_handle reqh;
- usbd_status r;
+ usbd_xfer_handle xfer;
+ usbd_status err;
#ifdef DIAGNOSTIC
if (dev->bus->intr_context) {
@@ -892,25 +892,25 @@ usbd_do_request_flags(dev, req, data, flags, actlen)
}
#endif
- reqh = usbd_alloc_request(dev);
- if (reqh == 0)
+ xfer = usbd_alloc_request(dev);
+ if (xfer == NULL)
return (USBD_NOMEM);
- usbd_setup_default_request(reqh, dev, 0, USBD_DEFAULT_TIMEOUT, req,
+ usbd_setup_default_request(xfer, dev, 0, USBD_DEFAULT_TIMEOUT, req,
data, UGETW(req->wLength), flags, 0);
- r = usbd_sync_transfer(reqh);
+ err = usbd_sync_transfer(xfer);
#if defined(USB_DEBUG) || defined(DIAGNOSTIC)
- if (reqh->actlen > reqh->length)
+ if (xfer->actlen > xfer->length)
DPRINTF(("usbd_do_request: overrun addr=%d type=0x%02x req=0x"
"%02x val=%d index=%d rlen=%d length=%d actlen=%d\n",
- dev->address, reqh->request.bmRequestType,
- reqh->request.bRequest, UGETW(reqh->request.wValue),
- UGETW(reqh->request.wIndex),
- UGETW(reqh->request.wLength),
- reqh->length, reqh->actlen));
+ dev->address, xfer->request.bmRequestType,
+ xfer->request.bRequest, UGETW(xfer->request.wValue),
+ UGETW(xfer->request.wIndex),
+ UGETW(xfer->request.wLength),
+ xfer->length, xfer->actlen));
#endif
- if (actlen)
- *actlen = reqh->actlen;
- if (r == USBD_STALLED) {
+ if (actlen != NULL)
+ *actlen = xfer->actlen;
+ if (err == USBD_STALLED) {
/*
* The control endpoint has stalled. Control endpoints
* should not halt, but some may do so anyway so clear
@@ -919,18 +919,18 @@ usbd_do_request_flags(dev, req, data, flags, actlen)
usb_device_request_t treq;
usb_status_t status;
u_int16_t s;
- usbd_status nr;
+ usbd_status nerr;
treq.bmRequestType = UT_READ_ENDPOINT;
treq.bRequest = UR_GET_STATUS;
USETW(treq.wValue, 0);
USETW(treq.wIndex, 0);
USETW(treq.wLength, sizeof(usb_status_t));
- usbd_setup_default_request(reqh, dev, 0, USBD_DEFAULT_TIMEOUT,
+ usbd_setup_default_request(xfer, dev, 0, USBD_DEFAULT_TIMEOUT,
&treq, &status,sizeof(usb_status_t),
0, 0);
- nr = usbd_sync_transfer(reqh);
- if (nr != USBD_NORMAL_COMPLETION)
+ nerr = usbd_sync_transfer(xfer);
+ if (nerr)
goto bad;
s = UGETW(status.wStatus);
DPRINTF(("usbd_do_request: status = 0x%04x\n", s));
@@ -941,36 +941,36 @@ usbd_do_request_flags(dev, req, data, flags, actlen)
USETW(treq.wValue, UF_ENDPOINT_HALT);
USETW(treq.wIndex, 0);
USETW(treq.wLength, 0);
- usbd_setup_default_request(reqh, dev, 0, USBD_DEFAULT_TIMEOUT,
+ usbd_setup_default_request(xfer, dev, 0, USBD_DEFAULT_TIMEOUT,
&treq, &status, 0, 0, 0);
- nr = usbd_sync_transfer(reqh);
- if (nr != USBD_NORMAL_COMPLETION)
+ nerr = usbd_sync_transfer(xfer);
+ if (nerr)
goto bad;
}
bad:
- usbd_free_request(reqh);
- return (r);
+ usbd_free_request(xfer);
+ return (err);
}
void
-usbd_do_request_async_cb(reqh, priv, status)
- usbd_request_handle reqh;
+usbd_do_request_async_cb(xfer, priv, status)
+ usbd_xfer_handle xfer;
usbd_private_handle priv;
usbd_status status;
{
#if defined(USB_DEBUG) || defined(DIAGNOSTIC)
- if (reqh->actlen > reqh->length)
+ if (xfer->actlen > xfer->length)
DPRINTF(("usbd_do_request: overrun addr=%d type=0x%02x req=0x"
"%02x val=%d index=%d rlen=%d length=%d actlen=%d\n",
- reqh->pipe->device->address,
- reqh->request.bmRequestType,
- reqh->request.bRequest, UGETW(reqh->request.wValue),
- UGETW(reqh->request.wIndex),
- UGETW(reqh->request.wLength),
- reqh->length, reqh->actlen));
+ xfer->pipe->device->address,
+ xfer->request.bmRequestType,
+ xfer->request.bRequest, UGETW(xfer->request.wValue),
+ UGETW(xfer->request.wIndex),
+ UGETW(xfer->request.wLength),
+ xfer->length, xfer->actlen));
#endif
- usbd_free_request(reqh);
+ usbd_free_request(xfer);
}
/*
@@ -983,19 +983,18 @@ usbd_do_request_async(dev, req, data)
usb_device_request_t *req;
void *data;
{
- usbd_request_handle reqh;
- usbd_status r;
+ usbd_xfer_handle xfer;
+ usbd_status err;
- reqh = usbd_alloc_request(dev);
- if (reqh == 0)
+ xfer = usbd_alloc_request(dev);
+ if (xfer == 0)
return (USBD_NOMEM);
- usbd_setup_default_request(reqh, dev, 0, USBD_DEFAULT_TIMEOUT, req, data,
- UGETW(req->wLength), 0,
- usbd_do_request_async_cb);
- r = usbd_transfer(reqh);
- if (r != USBD_IN_PROGRESS) {
- usbd_free_request(reqh);
- return (r);
+ usbd_setup_default_request(xfer, dev, 0, USBD_DEFAULT_TIMEOUT, req,
+ data, UGETW(req->wLength), 0, usbd_do_request_async_cb);
+ err = usbd_transfer(xfer);
+ if (err != USBD_IN_PROGRESS) {
+ usbd_free_request(xfer);
+ return (err);
}
return (USBD_NORMAL_COMPLETION);
}
@@ -1053,7 +1052,7 @@ usbd_driver_load(module_t mod, int what, void *arg)
{
/* XXX should implement something like a function that removes all generic devices */
- return 0;
+ return (0);
}
#endif
diff --git a/sys/dev/usb/usbdi.h b/sys/dev/usb/usbdi.h
index ea61ac8ffc8..1838aa5da6c 100644
--- a/sys/dev/usb/usbdi.h
+++ b/sys/dev/usb/usbdi.h
@@ -1,4 +1,4 @@
-/* $NetBSD: usbdi.h,v 1.31 1999/10/13 08:10:58 augustss Exp $ */
+/* $NetBSD: usbdi.h,v 1.32 1999/11/12 00:34:58 augustss Exp $ */
/*
* Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -41,7 +41,7 @@ typedef struct usbd_bus *usbd_bus_handle;
typedef struct usbd_device *usbd_device_handle;
typedef struct usbd_interface *usbd_interface_handle;
typedef struct usbd_pipe *usbd_pipe_handle;
-typedef struct usbd_request *usbd_request_handle;
+typedef struct usbd_xfer *usbd_xfer_handle;
typedef void *usbd_private_handle;
typedef enum { /* keep in sync with usbd_status_msgs */
@@ -71,7 +71,7 @@ typedef enum { /* keep in sync with usbd_status_msgs */
typedef int usbd_lock_token;
-typedef void (*usbd_callback) __P((usbd_request_handle, usbd_private_handle,
+typedef void (*usbd_callback) __P((usbd_xfer_handle, usbd_private_handle,
usbd_status));
/* Open flags */
@@ -93,25 +93,25 @@ usbd_status usbd_open_pipe
__P((usbd_interface_handle iface, u_int8_t address,
u_int8_t flags, usbd_pipe_handle *pipe));
usbd_status usbd_close_pipe __P((usbd_pipe_handle pipe));
-usbd_status usbd_transfer __P((usbd_request_handle req));
-usbd_request_handle usbd_alloc_request __P((usbd_device_handle));
-usbd_status usbd_free_request __P((usbd_request_handle reqh));
+usbd_status usbd_transfer __P((usbd_xfer_handle req));
+usbd_xfer_handle usbd_alloc_request __P((usbd_device_handle));
+usbd_status usbd_free_request __P((usbd_xfer_handle xfer));
void usbd_setup_request
- __P((usbd_request_handle reqh, usbd_pipe_handle pipe,
+ __P((usbd_xfer_handle xfer, usbd_pipe_handle pipe,
usbd_private_handle priv, void *buffer,
u_int32_t length, u_int16_t flags, u_int32_t timeout,
usbd_callback));
void usbd_setup_default_request
- __P((usbd_request_handle reqh, usbd_device_handle dev,
+ __P((usbd_xfer_handle xfer, usbd_device_handle dev,
usbd_private_handle priv, u_int32_t timeout,
usb_device_request_t *req, void *buffer,
u_int32_t length, u_int16_t flags, usbd_callback));
void usbd_setup_isoc_request
- __P((usbd_request_handle reqh, usbd_pipe_handle pipe,
+ __P((usbd_xfer_handle xfer, usbd_pipe_handle pipe,
usbd_private_handle priv, u_int16_t *frlengths,
u_int32_t nframes, u_int16_t flags, usbd_callback));
void usbd_get_request_status
- __P((usbd_request_handle reqh, usbd_private_handle *priv,
+ __P((usbd_xfer_handle xfer, usbd_private_handle *priv,
void **buffer, u_int32_t *count, usbd_status *status));
usb_endpoint_descriptor_t *usbd_interface2endpoint_descriptor
__P((usbd_interface_handle iface, u_int8_t address));
@@ -128,10 +128,10 @@ usbd_status usbd_device2interface_handle
__P((usbd_device_handle dev, u_int8_t ifaceno, usbd_interface_handle *iface));
usbd_device_handle usbd_pipe2device_handle __P((usbd_pipe_handle));
-void *usbd_alloc_buffer __P((usbd_request_handle req, u_int32_t size));
-void usbd_free_buffer __P((usbd_request_handle req));
-void *usbd_get_buffer __P((usbd_request_handle reqh));
-usbd_status usbd_sync_transfer __P((usbd_request_handle req));
+void *usbd_alloc_buffer __P((usbd_xfer_handle req, u_int32_t size));
+void usbd_free_buffer __P((usbd_xfer_handle req));
+void *usbd_get_buffer __P((usbd_xfer_handle xfer));
+usbd_status usbd_sync_transfer __P((usbd_xfer_handle req));
usbd_status usbd_open_pipe_intr
__P((usbd_interface_handle iface, u_int8_t address,
u_int8_t flags, usbd_pipe_handle *pipe,
diff --git a/sys/dev/usb/usbdi_util.c b/sys/dev/usb/usbdi_util.c
index c83a14746c0..b1ee3f03504 100644
--- a/sys/dev/usb/usbdi_util.c
+++ b/sys/dev/usb/usbdi_util.c
@@ -1,4 +1,4 @@
-/* $NetBSD: usbdi_util.c,v 1.22 1999/10/13 08:10:59 augustss Exp $ */
+/* $NetBSD: usbdi_util.c,v 1.23 1999/11/12 00:34:58 augustss Exp $ */
/*
* Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -87,13 +87,13 @@ usbd_get_config_desc(dev, conf, d)
int conf;
usb_config_descriptor_t *d;
{
- usbd_status r;
+ usbd_status err;
DPRINTFN(3,("usbd_get_config_desc: conf=%d\n", conf));
- r = usbd_get_desc(dev, UDESC_CONFIG, conf,
+ err = usbd_get_desc(dev, UDESC_CONFIG, conf,
USB_CONFIG_DESCRIPTOR_SIZE, d);
- if (r != USBD_NORMAL_COMPLETION)
- return (r);
+ if (err)
+ return (err);
if (d->bDescriptorType != UDESC_CONFIG) {
DPRINTFN(-1,("usbd_get_config_desc: conf %d, bad desc %d\n",
conf, d->bDescriptorType));
@@ -253,17 +253,15 @@ usbd_set_protocol(iface, report)
usb_interface_descriptor_t *id = usbd_get_interface_descriptor(iface);
usbd_device_handle dev;
usb_device_request_t req;
- usbd_status r;
+ usbd_status err;
DPRINTFN(4, ("usbd_set_protocol: iface=%p, report=%d, endpt=%d\n",
iface, report, id->bInterfaceNumber));
- if (!id)
+ if (id == NULL)
return (USBD_IOERROR);
- r = usbd_interface2device_handle(iface, &dev);
- if (r != USBD_NORMAL_COMPLETION)
- return (r);
- if (!id)
- return (USBD_INVAL);
+ err = usbd_interface2device_handle(iface, &dev);
+ if (err)
+ return (err);
req.bmRequestType = UT_WRITE_CLASS_INTERFACE;
req.bRequest = UR_SET_PROTOCOL;
USETW(req.wValue, report);
@@ -283,16 +281,14 @@ usbd_set_report(iface, type, id, data, len)
usb_interface_descriptor_t *ifd = usbd_get_interface_descriptor(iface);
usbd_device_handle dev;
usb_device_request_t req;
- usbd_status r;
+ usbd_status err;
DPRINTFN(4, ("usbd_set_report: len=%d\n", len));
- if (!ifd)
+ if (ifd == NULL)
return (USBD_IOERROR);
- r = usbd_interface2device_handle(iface, &dev);
- if (r != USBD_NORMAL_COMPLETION)
- return (r);
- if (!ifd)
- return (USBD_INVAL);
+ err = usbd_interface2device_handle(iface, &dev);
+ if (err)
+ return (err);
req.bmRequestType = UT_WRITE_CLASS_INTERFACE;
req.bRequest = UR_SET_REPORT;
USETW2(req.wValue, type, id);
@@ -312,16 +308,14 @@ usbd_set_report_async(iface, type, id, data, len)
usb_interface_descriptor_t *ifd = usbd_get_interface_descriptor(iface);
usbd_device_handle dev;
usb_device_request_t req;
- usbd_status r;
+ usbd_status err;
DPRINTFN(4, ("usbd_set_report_async: len=%d\n", len));
- if (!ifd)
+ if (ifd == NULL)
return (USBD_IOERROR);
- r = usbd_interface2device_handle(iface, &dev);
- if (r != USBD_NORMAL_COMPLETION)
- return (r);
- if (!ifd)
- return (USBD_INVAL);
+ err = usbd_interface2device_handle(iface, &dev);
+ if (err)
+ return (err);
req.bmRequestType = UT_WRITE_CLASS_INTERFACE;
req.bRequest = UR_SET_REPORT;
USETW2(req.wValue, type, id);
@@ -341,16 +335,14 @@ usbd_get_report(iface, type, id, data, len)
usb_interface_descriptor_t *ifd = usbd_get_interface_descriptor(iface);
usbd_device_handle dev;
usb_device_request_t req;
- usbd_status r;
+ usbd_status err;
DPRINTFN(4, ("usbd_set_report: len=%d\n", len));
- if (!id)
+ if (id == NULL)
return (USBD_IOERROR);
- r = usbd_interface2device_handle(iface, &dev);
- if (r != USBD_NORMAL_COMPLETION)
- return (r);
- if (!ifd)
- return (USBD_INVAL);
+ err = usbd_interface2device_handle(iface, &dev);
+ if (err)
+ return (err);
req.bmRequestType = UT_READ_CLASS_INTERFACE;
req.bRequest = UR_GET_REPORT;
USETW2(req.wValue, type, id);
@@ -368,16 +360,14 @@ usbd_set_idle(iface, duration, id)
usb_interface_descriptor_t *ifd = usbd_get_interface_descriptor(iface);
usbd_device_handle dev;
usb_device_request_t req;
- usbd_status r;
+ usbd_status err;
DPRINTFN(4, ("usbd_set_idle: %d %d\n", duration, id));
- if (!ifd)
+ if (ifd == NULL)
return (USBD_IOERROR);
- r = usbd_interface2device_handle(iface, &dev);
- if (r != USBD_NORMAL_COMPLETION)
- return (r);
- if (!ifd)
- return (USBD_INVAL);
+ err = usbd_interface2device_handle(iface, &dev);
+ if (err)
+ return (err);
req.bmRequestType = UT_WRITE_CLASS_INTERFACE;
req.bRequest = UR_SET_IDLE;
USETW2(req.wValue, duration, id);
@@ -413,12 +403,12 @@ usbd_get_hid_descriptor(ifc)
usb_config_descriptor_t *cdesc;
usb_hid_descriptor_t *hd;
char *p, *end;
- usbd_status r;
+ usbd_status err;
- if (!idesc)
+ if (idesc == NULL)
return (0);
- r = usbd_interface2device_handle(ifc, &dev);
- if (r != USBD_NORMAL_COMPLETION)
+ err = usbd_interface2device_handle(ifc, &dev);
+ if (err)
return (0);
cdesc = usbd_get_config_descriptor(dev);
@@ -450,27 +440,27 @@ usbd_alloc_report_desc(ifc, descp, sizep, mem)
usb_interface_descriptor_t *id;
usb_hid_descriptor_t *hid;
usbd_device_handle dev;
- usbd_status r;
+ usbd_status err;
- r = usbd_interface2device_handle(ifc, &dev);
- if (r != USBD_NORMAL_COMPLETION)
- return (r);
+ err = usbd_interface2device_handle(ifc, &dev);
+ if (err)
+ return (err);
id = usbd_get_interface_descriptor(ifc);
- if (!id)
+ if (id == NULL)
return (USBD_INVAL);
hid = usbd_get_hid_descriptor(ifc);
if (!hid)
return (USBD_IOERROR);
*sizep = UGETW(hid->descrs[0].wDescriptorLength);
*descp = malloc(*sizep, mem, M_NOWAIT);
- if (!*descp)
+ if (*descp == NULL)
return (USBD_NOMEM);
/* XXX should not use 0 Report ID */
- r = usbd_get_report_descriptor(dev, id->bInterfaceNumber, 0,
+ err = usbd_get_report_descriptor(dev, id->bInterfaceNumber, 0,
*sizep, *descp);
- if (r != USBD_NORMAL_COMPLETION) {
+ if (err) {
free(*descp, mem);
- return (r);
+ return (err);
}
return (USBD_NORMAL_COMPLETION);
}
@@ -490,20 +480,20 @@ usbd_get_config(dev, conf)
return (usbd_do_request(dev, &req, conf));
}
-static void usbd_bulk_transfer_cb __P((usbd_request_handle reqh,
+static void usbd_bulk_transfer_cb __P((usbd_xfer_handle xfer,
usbd_private_handle priv, usbd_status status));
static void
-usbd_bulk_transfer_cb(reqh, priv, status)
- usbd_request_handle reqh;
+usbd_bulk_transfer_cb(xfer, priv, status)
+ usbd_xfer_handle xfer;
usbd_private_handle priv;
usbd_status status;
{
- wakeup(reqh);
+ wakeup(xfer);
}
usbd_status
-usbd_bulk_transfer(reqh, pipe, flags, timeout, buf, size, lbl)
- usbd_request_handle reqh;
+usbd_bulk_transfer(xfer, pipe, flags, timeout, buf, size, lbl)
+ usbd_xfer_handle xfer;
usbd_pipe_handle pipe;
u_int16_t flags;
u_int32_t timeout;
@@ -511,32 +501,32 @@ usbd_bulk_transfer(reqh, pipe, flags, timeout, buf, size, lbl)
u_int32_t *size;
char *lbl;
{
- usbd_status r;
+ usbd_status err;
int s, error;
- usbd_setup_request(reqh, pipe, 0, buf, *size,
+ usbd_setup_request(xfer, pipe, 0, buf, *size,
flags, timeout, usbd_bulk_transfer_cb);
DPRINTFN(1, ("usbd_bulk_transfer: start transfer %d bytes\n", *size));
s = splusb(); /* don't want callback until tsleep() */
- r = usbd_transfer(reqh);
- if (r != USBD_IN_PROGRESS) {
+ err = usbd_transfer(xfer);
+ if (err != USBD_IN_PROGRESS) {
splx(s);
- return (r);
+ return (err);
}
- error = tsleep((caddr_t)reqh, PZERO | PCATCH, lbl, 0);
+ error = tsleep((caddr_t)xfer, PZERO | PCATCH, lbl, 0);
splx(s);
if (error) {
DPRINTF(("usbd_bulk_transfer: tsleep=%d\n", error));
usbd_abort_pipe(pipe);
return (USBD_INTERRUPTED);
}
- usbd_get_request_status(reqh, 0, 0, size, &r);
+ usbd_get_request_status(xfer, 0, 0, size, &err);
DPRINTFN(1,("usbd_bulk_transfer: transferred %d\n", *size));
- if (r != USBD_NORMAL_COMPLETION) {
- DPRINTF(("usbd_bulk_transfer: error=%d\n", r));
+ if (err) {
+ DPRINTF(("usbd_bulk_transfer: error=%d\n", err));
usbd_clear_endpoint_stall(pipe);
}
- return (r);
+ return (err);
}
void
diff --git a/sys/dev/usb/usbdi_util.h b/sys/dev/usb/usbdi_util.h
index 7e92df1edfd..5deacf6279d 100644
--- a/sys/dev/usb/usbdi_util.h
+++ b/sys/dev/usb/usbdi_util.h
@@ -1,4 +1,4 @@
-/* $NetBSD: usbdi_util.h,v 1.17 1999/09/05 19:32:19 augustss Exp $ */
+/* $NetBSD: usbdi_util.h,v 1.18 1999/11/12 00:34:58 augustss Exp $ */
/*
* Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -89,7 +89,7 @@ usbd_status usbd_set_config_index
__P((usbd_device_handle dev, int index, int msg));
usbd_status usbd_bulk_transfer
- __P((usbd_request_handle reqh, usbd_pipe_handle pipe, u_int16_t flags,
+ __P((usbd_xfer_handle xfer, usbd_pipe_handle pipe, u_int16_t flags,
u_int32_t timeout, void *buf, u_int32_t *size, char *lbl));
void usb_detach_wait __P((device_ptr_t));
diff --git a/sys/dev/usb/usbdivar.h b/sys/dev/usb/usbdivar.h
index bf9de9fb5b0..0cb0f1b7058 100644
--- a/sys/dev/usb/usbdivar.h
+++ b/sys/dev/usb/usbdivar.h
@@ -1,4 +1,4 @@
-/* $NetBSD: usbdivar.h,v 1.39 1999/11/10 04:19:59 mycroft Exp $ */
+/* $NetBSD: usbdivar.h,v 1.40 1999/11/12 00:34:58 augustss Exp $ */
/*
* Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -40,7 +40,7 @@
/* From usb_mem.h */
DECLARE_USB_DMA_T;
-struct usbd_request;
+struct usbd_xfer;
struct usbd_pipe;
struct usbd_endpoint {
@@ -57,12 +57,12 @@ struct usbd_bus_methods {
};
struct usbd_pipe_methods {
- usbd_status (*transfer)__P((usbd_request_handle reqh));
- usbd_status (*start)__P((usbd_request_handle reqh));
- void (*abort)__P((usbd_request_handle reqh));
+ usbd_status (*transfer)__P((usbd_xfer_handle xfer));
+ usbd_status (*start)__P((usbd_xfer_handle xfer));
+ void (*abort)__P((usbd_xfer_handle xfer));
void (*close)__P((usbd_pipe_handle pipe));
void (*cleartoggle)__P((usbd_pipe_handle pipe));
- void (*done)__P((usbd_request_handle reqh));
+ void (*done)__P((usbd_xfer_handle xfer));
};
struct usbd_port {
@@ -144,17 +144,17 @@ struct usbd_pipe {
struct usbd_endpoint *endpoint;
int refcnt;
char running;
- SIMPLEQ_HEAD(, usbd_request) queue;
+ SIMPLEQ_HEAD(, usbd_xfer) queue;
LIST_ENTRY(usbd_pipe) next;
- usbd_request_handle intrreqh; /* used for repeating requests */
+ usbd_xfer_handle intrxfer; /* used for repeating requests */
char repeat;
/* Filled by HC driver. */
struct usbd_pipe_methods *methods;
};
-struct usbd_request {
+struct usbd_xfer {
struct usbd_pipe *pipe;
void *priv;
void *buffer;
@@ -182,7 +182,7 @@ struct usbd_request {
#define URQ_AUTO_DMABUF 0x10
#define URQ_DEV_DMABUF 0x20
- SIMPLEQ_ENTRY(usbd_request) next;
+ SIMPLEQ_ENTRY(usbd_xfer) next;
void *hcpriv; /* private use by the HC driver */
int hcprivint; /* ditto */
@@ -216,8 +216,8 @@ usbd_status usbd_fill_iface_data __P((usbd_device_handle dev,
int i, int a));
void usb_free_device __P((usbd_device_handle));
-usbd_status usb_insert_transfer __P((usbd_request_handle reqh));
-void usb_transfer_complete __P((usbd_request_handle reqh));
+usbd_status usb_insert_transfer __P((usbd_xfer_handle xfer));
+void usb_transfer_complete __P((usbd_xfer_handle xfer));
void usb_disconnect_port __P((struct usbd_port *up, device_ptr_t));
/* Routines from usb.c */