From owner-p4-projects@FreeBSD.ORG Sun Sep 18 15:35:42 2005 Return-Path: X-Original-To: p4-projects@freebsd.org Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 389F816A421; Sun, 18 Sep 2005 15:35:42 +0000 (GMT) X-Original-To: perforce@freebsd.org Delivered-To: perforce@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 0AE5F16A41F for ; Sun, 18 Sep 2005 15:35:42 +0000 (GMT) (envelope-from bb+lists.freebsd.perforce@cyrus.watson.org) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id ABC9543D46 for ; Sun, 18 Sep 2005 15:35:41 +0000 (GMT) (envelope-from bb+lists.freebsd.perforce@cyrus.watson.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.13.1/8.13.1) with ESMTP id j8IFZfnd042115 for ; Sun, 18 Sep 2005 15:35:41 GMT (envelope-from bb+lists.freebsd.perforce@cyrus.watson.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.13.1/8.13.1/Submit) id j8IFZfk9042112 for perforce@freebsd.org; Sun, 18 Sep 2005 15:35:41 GMT (envelope-from bb+lists.freebsd.perforce@cyrus.watson.org) Date: Sun, 18 Sep 2005 15:35:41 GMT Message-Id: <200509181535.j8IFZfk9042112@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to bb+lists.freebsd.perforce@cyrus.watson.org using -f From: Robert Watson To: Perforce Change Reviews Cc: Subject: PERFORCE change 83844 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 18 Sep 2005 15:35:43 -0000 http://perforce.freebsd.org/chv.cgi?CH=83844 Change 83844 by rwatson@rwatson_peppercorn on 2005/09/18 15:35:29 Integrate netsmp from FreeBSD CVS: - if_gem locking fixes (etc) - usb updates from netbsd - listen_backlog regression test - loop back fifo assertion - loop back sbcompress() comment Affected files ... .. //depot/projects/netsmp/src/sys/dev/gem/if_gem.c#9 integrate .. //depot/projects/netsmp/src/sys/dev/sound/usb/uaudio.c#3 integrate .. //depot/projects/netsmp/src/sys/dev/usb/ehci_pci.c#2 integrate .. //depot/projects/netsmp/src/sys/dev/usb/ehcireg.h#2 integrate .. //depot/projects/netsmp/src/sys/dev/usb/ehcivar.h#2 integrate .. //depot/projects/netsmp/src/sys/dev/usb/usb_port.h#2 integrate .. //depot/projects/netsmp/src/sys/fs/fifofs/fifo_vnops.c#17 integrate .. //depot/projects/netsmp/src/sys/kern/uipc_socket.c#11 integrate .. //depot/projects/netsmp/src/tools/regression/sockets/listen_backlog/Makefile#1 branch .. //depot/projects/netsmp/src/tools/regression/sockets/listen_backlog/listen_backlog.c#1 branch Differences ... ==== //depot/projects/netsmp/src/sys/dev/gem/if_gem.c#9 (text+ko) ==== @@ -28,7 +28,7 @@ */ #include -__FBSDID("$FreeBSD: src/sys/dev/gem/if_gem.c,v 1.34 2005/08/28 15:07:30 marius Exp $"); +__FBSDID("$FreeBSD: src/sys/dev/gem/if_gem.c,v 1.35 2005/09/18 13:23:19 marius Exp $"); /* * Driver for Sun GEM ethernet controllers. @@ -137,15 +137,19 @@ int i, error; u_int32_t v; - GEM_LOCK_ASSERT(sc, MA_NOTOWNED); - ifp = sc->sc_ifp = if_alloc(IFT_ETHER); if (ifp == NULL) return (ENOSPC); + callout_init_mtx(&sc->sc_tick_ch, &sc->sc_mtx, 0); +#ifdef GEM_RINT_TIMEOUT + callout_init_mtx(&sc->sc_rx_ch, &sc->sc_mtx, 0); +#endif + /* Make sure the chip is stopped. */ ifp->if_softc = sc; GEM_LOCK(sc); + gem_stop(ifp, 0); gem_reset(sc); GEM_UNLOCK(sc); @@ -173,7 +177,7 @@ BUS_SPACE_MAXADDR_32BIT, BUS_SPACE_MAXADDR, NULL, NULL, sizeof(struct gem_control_data), 1, sizeof(struct gem_control_data), BUS_DMA_ALLOCNOW, - busdma_lock_mutex, &Giant, &sc->sc_cdmatag); + busdma_lock_mutex, &sc->sc_mtx, &sc->sc_cdmatag); if (error) goto fail_ttag; @@ -235,9 +239,7 @@ sc->sc_rxsoft[i].rxs_mbuf = NULL; } - GEM_LOCK(sc); gem_mifinit(sc); - GEM_UNLOCK(sc); if ((error = mii_phy_probe(sc->sc_dev, &sc->sc_miibus, gem_mediachange, gem_mediastatus)) != 0) { @@ -330,11 +332,6 @@ "hook\n"); #endif - callout_init(&sc->sc_tick_ch, CALLOUT_MPSAFE); -#ifdef GEM_RINT_TIMEOUT - callout_init(&sc->sc_rx_ch, CALLOUT_MPSAFE); -#endif - /* * Tell the upper layer(s) we support long frames. */ @@ -384,11 +381,13 @@ struct ifnet *ifp = sc->sc_ifp; int i; - GEM_LOCK_ASSERT(sc, MA_NOTOWNED); - GEM_LOCK(sc); gem_stop(ifp, 1); GEM_UNLOCK(sc); + callout_drain(&sc->sc_tick_ch); +#ifdef GEM_RINT_TIMEOUT + callout_drain(&sc->sc_rx_ch); +#endif ether_ifdetach(ifp); if_free(ifp); device_delete_child(sc->sc_dev, sc->sc_miibus); @@ -541,6 +540,7 @@ { struct gem_softc *sc = arg; + GEM_LOCK_ASSERT(sc, MA_OWNED); mii_tick(sc->sc_mii); callout_reset(&sc->sc_tick_ch, hz, gem_tick, sc); @@ -624,6 +624,9 @@ #endif callout_stop(&sc->sc_tick_ch); +#ifdef GEM_RINT_TIMEOUT + callout_stop(&sc->sc_rx_ch); +#endif /* XXX - Should we reset these instead? */ gem_disable_tx(sc); @@ -965,9 +968,7 @@ bus_space_write_4(t, h, GEM_RX_BLANKING, (6<<12)|6); /* step 11. Configure Media */ - GEM_UNLOCK(sc); mii_mediachg(sc->sc_mii); - GEM_LOCK(sc); /* step 12. RX_MAC Configuration Register */ v = bus_space_read_4(t, h, GEM_MAC_RX_CONFIG); @@ -1371,9 +1372,8 @@ { struct gem_softc *sc = (struct gem_softc *)arg; - GEM_LOCK(sc); + GEM_LOCK_ASSERT(sc, MA_OWNED); gem_rint(sc); - GEM_UNLOCK(sc); } #endif @@ -1655,8 +1655,6 @@ bus_space_tag_t t = sc->sc_bustag; bus_space_handle_t mif = sc->sc_h; - GEM_LOCK_ASSERT(sc, MA_OWNED); - /* Configure the MIF in frame mode */ sc->sc_mif_config = bus_space_read_4(t, mif, GEM_MIF_CONFIG); sc->sc_mif_config &= ~GEM_MIF_CONFIG_BB_ENA; @@ -1688,7 +1686,6 @@ int n; u_int32_t v; - GEM_LOCK(sc); #ifdef GEM_DEBUG_PHY printf("gem_mii_readreg: phy %d reg %d\n", phy, reg); #endif @@ -1712,14 +1709,11 @@ for (n = 0; n < 100; n++) { DELAY(1); v = bus_space_read_4(t, mif, GEM_MIF_FRAME); - if (v & GEM_MIF_FRAME_TA0) { - GEM_UNLOCK(sc); + if (v & GEM_MIF_FRAME_TA0) return (v & GEM_MIF_FRAME_DATA); - } } device_printf(sc->sc_dev, "mii_read timeout\n"); - GEM_UNLOCK(sc); return (0); } @@ -1734,7 +1728,6 @@ int n; u_int32_t v; - GEM_LOCK(sc); #ifdef GEM_DEBUG_PHY printf("gem_mii_writereg: phy %d reg %d val %x\n", phy, reg, val); #endif @@ -1759,14 +1752,11 @@ for (n = 0; n < 100; n++) { DELAY(1); v = bus_space_read_4(t, mif, GEM_MIF_FRAME); - if (v & GEM_MIF_FRAME_TA0) { - GEM_UNLOCK(sc); + if (v & GEM_MIF_FRAME_TA0) return (1); - } } device_printf(sc->sc_dev, "mii_write timeout\n"); - GEM_UNLOCK(sc); return (0); } @@ -1782,7 +1772,6 @@ bus_space_handle_t mac = sc->sc_h; u_int32_t v; - GEM_LOCK(sc); #ifdef GEM_DEBUG instance = IFM_INST(sc->sc_mii->mii_media.ifm_cur->ifm_media); if (sc->sc_debug) @@ -1824,7 +1813,6 @@ v |= GEM_MAC_XIF_MII_BUF_ENA; } bus_space_write_4(t, mac, GEM_MAC_XIF_CONFIG, v); - GEM_UNLOCK(sc); } int @@ -1832,10 +1820,14 @@ struct ifnet *ifp; { struct gem_softc *sc = ifp->if_softc; + int error; /* XXX Add support for serial media. */ - return (mii_mediachg(sc->sc_mii)); + GEM_LOCK(sc); + error = mii_mediachg(sc->sc_mii); + GEM_UNLOCK(sc); + return (error); } void @@ -1851,9 +1843,7 @@ return; } - GEM_UNLOCK(sc); mii_pollstat(sc->sc_mii); - GEM_LOCK(sc); ifmr->ifm_active = sc->sc_mii->mii_media_active; ifmr->ifm_status = sc->sc_mii->mii_media_status; GEM_UNLOCK(sc); @@ -1872,17 +1862,9 @@ struct ifreq *ifr = (struct ifreq *)data; int error = 0; - GEM_LOCK(sc); - switch (cmd) { - case SIOCSIFADDR: - case SIOCGIFADDR: - case SIOCSIFMTU: - GEM_UNLOCK(sc); - error = ether_ioctl(ifp, cmd, data); + case SIOCSIFFLAGS: GEM_LOCK(sc); - break; - case SIOCSIFFLAGS: if (ifp->if_flags & IFF_UP) { if ((sc->sc_ifflags ^ ifp->if_flags) == IFF_PROMISC) gem_setladrf(sc); @@ -1893,25 +1875,25 @@ gem_stop(ifp, 0); } sc->sc_ifflags = ifp->if_flags; - error = 0; + GEM_UNLOCK(sc); break; case SIOCADDMULTI: case SIOCDELMULTI: + GEM_LOCK(sc); gem_setladrf(sc); - error = 0; + GEM_UNLOCK(sc); break; case SIOCGIFMEDIA: case SIOCSIFMEDIA: - GEM_UNLOCK(sc); error = ifmedia_ioctl(ifp, ifr, &sc->sc_mii->mii_media, cmd); - GEM_LOCK(sc); break; default: - error = ENOTTY; + error = ether_ioctl(ifp, cmd, data); break; } /* Try to get things going again */ + GEM_LOCK(sc); if (ifp->if_flags & IFF_UP) gem_start_locked(ifp); GEM_UNLOCK(sc); ==== //depot/projects/netsmp/src/sys/dev/sound/usb/uaudio.c#3 (text+ko) ==== @@ -1,5 +1,5 @@ /* $NetBSD: uaudio.c,v 1.91 2004/11/05 17:46:14 kent Exp $ */ -/* $FreeBSD: src/sys/dev/sound/usb/uaudio.c,v 1.15 2005/09/11 09:15:42 netchild Exp $ */ +/* $FreeBSD: src/sys/dev/sound/usb/uaudio.c,v 1.16 2005/09/18 15:13:06 netchild Exp $ */ /*- * Copyright (c) 1999 The NetBSD Foundation, Inc. @@ -49,6 +49,14 @@ __KERNEL_RCSID(0, "$NetBSD: uaudio.c,v 1.91 2004/11/05 17:46:14 kent Exp $"); #endif +/* + * Also merged: + * $NetBSD: uaudio.c,v 1.94 2005/01/15 15:19:53 kent Exp $ + * $NetBSD: uaudio.c,v 1.95 2005/01/16 06:02:19 dsainty Exp $ + * $NetBSD: uaudio.c,v 1.96 2005/01/16 12:46:00 kent Exp $ + * $NetBSD: uaudio.c,v 1.97 2005/02/24 08:19:38 martin Exp $ + */ + #include #include #include @@ -129,10 +137,10 @@ #define MIX_MAX_CHAN 8 struct mixerctl { - u_int16_t wValue[MIX_MAX_CHAN]; /* using nchan */ - u_int16_t wIndex; - u_int8_t nchan; - u_int8_t type; + uint16_t wValue[MIX_MAX_CHAN]; /* using nchan */ + uint16_t wIndex; + uint8_t nchan; + uint8_t type; #define MIX_ON_OFF 1 #define MIX_SIGNED_16 2 #define MIX_UNSIGNED_16 3 @@ -146,9 +154,9 @@ #if defined(__FreeBSD__) /* XXXXX */ unsigned ctl; #define MAX_SELECTOR_INPUT_PIN 256 - u_int8_t slctrtype[MAX_SELECTOR_INPUT_PIN]; + uint8_t slctrtype[MAX_SELECTOR_INPUT_PIN]; #endif - u_int8_t class; + uint8_t class; #if !defined(__FreeBSD__) char ctlname[MAX_AUDIO_DEV_LEN]; char *ctlunit; @@ -157,9 +165,9 @@ #define MAKE(h,l) (((h) << 8) | (l)) struct as_info { - u_int8_t alt; - u_int8_t encoding; - u_int8_t attributes; /* Copy of bmAttributes of + uint8_t alt; + uint8_t encoding; + uint8_t attributes; /* Copy of bmAttributes of * usb_audio_streaming_endpoint_descriptor */ usbd_interface_handle ifaceh; @@ -489,7 +497,7 @@ usb_interface_descriptor_t *id; if (uaa->iface == NULL) - return (UMATCH_NONE); + return UMATCH_NONE; id = usbd_get_interface_descriptor(uaa->iface); /* Trigger on the control interface. */ @@ -497,9 +505,9 @@ id->bInterfaceClass != UICLASS_AUDIO || id->bInterfaceSubClass != UISUBCLASS_AUDIOCONTROL || (usbd_get_quirks(uaa->device)->uq_flags & UQ_BAD_AUDIO)) - return (UMATCH_NONE); + return UMATCH_NONE; - return (UMATCH_IFACECLASS_IFACESUBCLASS); + return UMATCH_IFACECLASS_IFACESUBCLASS; } USB_ATTACH(uaudio) @@ -516,9 +524,6 @@ USB_ATTACH_SETUP; #else usbd_devinfo(uaa->device, 0, devinfo, sizeof(devinfo)); -#endif - -#if !defined(__FreeBSD__) printf(": %s\n", devinfo); #endif @@ -607,13 +612,14 @@ int uaudio_activate(device_ptr_t self, enum devact act) { - struct uaudio_softc *sc = (struct uaudio_softc *)self; - int rv = 0; + struct uaudio_softc *sc; + int rv; + sc = (struct uaudio_softc *)self; + rv = 0; switch (act) { case DVACT_ACTIVATE: - return (EOPNOTSUPP); - break; + return EOPNOTSUPP; case DVACT_DEACTIVATE: if (sc->sc_audiodev != NULL) @@ -621,7 +627,7 @@ sc->sc_dying = 1; break; } - return (rv); + return rv; } #endif @@ -629,9 +635,11 @@ int uaudio_detach(device_ptr_t self, int flags) { - struct uaudio_softc *sc = (struct uaudio_softc *)self; - int rv = 0; + struct uaudio_softc *sc; + int rv; + sc = (struct uaudio_softc *)self; + rv = 0; /* Wait for outstanding requests to complete. */ usbd_delay_ms(sc->sc_udev, UAUDIO_NCHANBUFS * UAUDIO_NFRAMES); @@ -641,7 +649,7 @@ usbd_add_drv_event(USB_EVENT_DRIVER_DETACH, sc->sc_udev, USBDEV(sc->sc_dev)); - return (rv); + return rv; } #elif defined(__FreeBSD__) @@ -668,15 +676,17 @@ Static int uaudio_query_encoding(void *addr, struct audio_encoding *fp) { - struct uaudio_softc *sc = addr; - int flags = sc->sc_altflags; + struct uaudio_softc *sc; + int flags; int idx; + sc = addr; + flags = sc->sc_altflags; if (sc->sc_dying) - return (EIO); + return EIO; if (sc->sc_nalts == 0 || flags == 0) - return (ENXIO); + return ENXIO; idx = fp->index; switch (idx) { @@ -745,9 +755,9 @@ if (d->bDescriptorType == UDESC_INTERFACE && d->bInterfaceClass == UICLASS_AUDIO && d->bInterfaceSubClass == subtype) - return (d); + return d; } - return (NULL); + return NULL; } Static void @@ -839,8 +849,9 @@ uaudio_id_name(struct uaudio_softc *sc, const struct io_terminal *iot, int id) { static char buf[32]; + snprintf(buf, sizeof(buf), "i%d", id); - return (buf); + return buf; } #endif @@ -887,14 +898,14 @@ r.bNrChannels = iot[id].d.it->bNrChannels; USETW(r.wChannelConfig, UGETW(iot[id].d.it->wChannelConfig)); r.iChannelNames = iot[id].d.it->iChannelNames; - return (r); + return r; case UDESCSUB_AC_OUTPUT: id = iot[id].d.ot->bSourceId; break; case UDESCSUB_AC_MIXER: r = *(const struct usb_audio_cluster *) &iot[id].d.mu->baSourceId[iot[id].d.mu->bNrInPins]; - return (r); + return r; case UDESCSUB_AC_SELECTOR: /* XXX This is not really right */ id = iot[id].d.su->baSourceId[0]; @@ -905,11 +916,11 @@ case UDESCSUB_AC_PROCESSING: r = *(const struct usb_audio_cluster *) &iot[id].d.pu->baSourceId[iot[id].d.pu->bNrInPins]; - return (r); + return r; case UDESCSUB_AC_EXTENSION: r = *(const struct usb_audio_cluster *) &iot[id].d.eu->baSourceId[iot[id].d.eu->bNrInPins]; - return (r); + return r; default: goto bad; } @@ -917,7 +928,7 @@ bad: printf("uaudio_get_cluster: bad data\n"); memset(&r, 0, sizeof r); - return (r); + return r; } @@ -940,8 +951,9 @@ uaudio_add_output(struct uaudio_softc *sc, const struct io_terminal *iot, int id) { #ifdef USB_DEBUG - const struct usb_audio_output_terminal *d = iot[id].d.ot; + const struct usb_audio_output_terminal *d; + d = iot[id].d.ot; DPRINTFN(2,("uaudio_add_output: bTerminalId=%d wTerminalType=0x%04x " "bAssocTerminal=%d bSourceId=%d iTerminal=%d\n", d->bTerminalId, UGETW(d->wTerminalType), d->bAssocTerminal, @@ -1021,7 +1033,7 @@ Static void uaudio_add_selector(struct uaudio_softc *sc, const struct io_terminal *iot, int id) { - const struct usb_audio_selector_unit *d = iot[id].d.su; + const struct usb_audio_selector_unit *d; struct mixerctl mix; #if !defined(__FreeBSD__) int i, wp; @@ -1030,6 +1042,7 @@ struct mixerctl dummy; #endif + d = iot[id].d.su; DPRINTFN(2,("uaudio_add_selector: bUnitId=%d bNrInPins=%d\n", d->bUnitId, d->bNrInPins)); mix.wIndex = MAKE(d->bUnitId, sc->sc_ac_iface); @@ -1399,10 +1412,10 @@ Static void uaudio_add_feature(struct uaudio_softc *sc, const struct io_terminal *iot, int id) { - const struct usb_audio_feature_unit *d = iot[id].d.fu; - uByte *ctls = d->bmaControls; - int ctlsize = d->bControlSize; - int nchan = (d->bLength - 7) / ctlsize; + const struct usb_audio_feature_unit *d; + const uByte *ctls; + int ctlsize; + int nchan; u_int fumask, mmask, cmask; struct mixerctl mix; int chan, ctl, i, unit; @@ -1414,7 +1427,10 @@ #define GET(i) (ctls[(i)*ctlsize] | \ (ctlsize > 1 ? ctls[(i)*ctlsize+1] << 8 : 0)) - + d = iot[id].d.fu; + ctls = d->bmaControls; + ctlsize = d->bControlSize; + nchan = (d->bLength - 7) / ctlsize; mmask = GET(0); /* Figure out what we can control */ for (cmask = 0, chan = 1; chan < nchan; chan++) { @@ -1560,15 +1576,17 @@ uaudio_add_processing_updown(struct uaudio_softc *sc, const struct io_terminal *iot, int id) { - const struct usb_audio_processing_unit *d = iot[id].d.pu; - const struct usb_audio_processing_unit_1 *d1 = - (const struct usb_audio_processing_unit_1 *)&d->baSourceId[d->bNrInPins]; - const struct usb_audio_processing_unit_updown *ud = - (const struct usb_audio_processing_unit_updown *) - &d1->bmControls[d1->bControlSize]; + const struct usb_audio_processing_unit *d; + const struct usb_audio_processing_unit_1 *d1; + const struct usb_audio_processing_unit_updown *ud; struct mixerctl mix; int i; + d = iot[id].d.pu; + d1 = (const struct usb_audio_processing_unit_1 *) + &d->baSourceId[d->bNrInPins]; + ud = (const struct usb_audio_processing_unit_updown *) + &d1->bmControls[d1->bControlSize]; DPRINTFN(2,("uaudio_add_processing_updown: bUnitId=%d bNrModes=%d\n", d->bUnitId, ud->bNrModes)); @@ -1598,12 +1616,15 @@ Static void uaudio_add_processing(struct uaudio_softc *sc, const struct io_terminal *iot, int id) { - const struct usb_audio_processing_unit *d = iot[id].d.pu; - const struct usb_audio_processing_unit_1 *d1 = - (const struct usb_audio_processing_unit_1 *)&d->baSourceId[d->bNrInPins]; - int ptype = UGETW(d->wProcessType); + const struct usb_audio_processing_unit *d; + const struct usb_audio_processing_unit_1 *d1; + int ptype; struct mixerctl mix; + d = iot[id].d.pu; + d1 = (const struct usb_audio_processing_unit_1 *) + &d->baSourceId[d->bNrInPins]; + ptype = UGETW(d->wProcessType); DPRINTFN(2,("uaudio_add_processing: wProcessType=%d bUnitId=%d " "bNrInPins=%d\n", ptype, d->bUnitId, d->bNrInPins)); @@ -1642,11 +1663,13 @@ Static void uaudio_add_extension(struct uaudio_softc *sc, const struct io_terminal *iot, int id) { - const struct usb_audio_extension_unit *d = iot[id].d.eu; - const struct usb_audio_extension_unit_1 *d1 = - (const struct usb_audio_extension_unit_1 *)&d->baSourceId[d->bNrInPins]; + const struct usb_audio_extension_unit *d; + const struct usb_audio_extension_unit_1 *d1; struct mixerctl mix; + d = iot[id].d.eu; + d1 = (const struct usb_audio_extension_unit_1 *) + &d->baSourceId[d->bNrInPins]; DPRINTFN(2,("uaudio_add_extension: bUnitId=%d bNrInPins=%d\n", d->bUnitId, d->bNrInPins)); @@ -1861,8 +1884,8 @@ err = uaudio_identify_ac(sc, cdesc); if (err) - return (err); - return (uaudio_identify_as(sc, cdesc)); + return err; + return uaudio_identify_as(sc, cdesc); } Static void @@ -1907,30 +1930,30 @@ if (asid->bDescriptorType != UDESC_CS_INTERFACE || asid->bDescriptorSubtype != AS_GENERAL) - return (USBD_INVAL); + return USBD_INVAL; DPRINTF(("uaudio_process_as: asid: bTerminakLink=%d wFormatTag=%d\n", asid->bTerminalLink, UGETW(asid->wFormatTag))); offs += asid->bLength; if (offs > size) - return (USBD_INVAL); + return USBD_INVAL; asf1d = (const void *)(buf + offs); if (asf1d->bDescriptorType != UDESC_CS_INTERFACE || asf1d->bDescriptorSubtype != FORMAT_TYPE) - return (USBD_INVAL); + return USBD_INVAL; offs += asf1d->bLength; if (offs > size) - return (USBD_INVAL); + return USBD_INVAL; if (asf1d->bFormatType != FORMAT_TYPE_I) { printf("%s: ignored setting with type %d format\n", USBDEVNAME(sc->sc_dev), UGETW(asid->wFormatTag)); - return (USBD_NORMAL_COMPLETION); + return USBD_NORMAL_COMPLETION; } ed = (const void *)(buf + offs); if (ed->bDescriptorType != UDESC_ENDPOINT) - return (USBD_INVAL); + return USBD_INVAL; DPRINTF(("uaudio_process_as: endpoint[0] bLength=%d bDescriptorType=%d " "bEndpointAddress=%d bmAttributes=0x%x wMaxPacketSize=%d " "bInterval=%d bRefresh=%d bSynchAddress=%d\n", @@ -1939,9 +1962,9 @@ ed->bInterval, ed->bRefresh, ed->bSynchAddress)); offs += ed->bLength; if (offs > size) - return (USBD_INVAL); + return USBD_INVAL; if (UE_GET_XFERTYPE(ed->bmAttributes) != UE_ISOCHRONOUS) - return (USBD_INVAL); + return USBD_INVAL; dir = UE_GET_DIR(ed->bEndpointAddress); type = UE_GET_ISO_TYPE(ed->bmAttributes); @@ -1956,7 +1979,7 @@ #ifndef UAUDIO_MULTIPLE_ENDPOINTS printf("%s: ignored input endpoint of type adaptive\n", USBDEVNAME(sc->sc_dev)); - return (USBD_NORMAL_COMPLETION); + return USBD_NORMAL_COMPLETION; #endif } if (dir != UE_DIR_IN && type == UE_ISO_ASYNC) { @@ -1964,18 +1987,18 @@ #ifndef UAUDIO_MULTIPLE_ENDPOINTS printf("%s: ignored output endpoint of type async\n", USBDEVNAME(sc->sc_dev)); - return (USBD_NORMAL_COMPLETION); + return USBD_NORMAL_COMPLETION; #endif } sed = (const void *)(buf + offs); if (sed->bDescriptorType != UDESC_CS_ENDPOINT || sed->bDescriptorSubtype != AS_GENERAL) - return (USBD_INVAL); + return USBD_INVAL; DPRINTF((" streadming_endpoint: offset=%d bLength=%d\n", offs, sed->bLength)); offs += sed->bLength; if (offs > size) - return (USBD_INVAL); + return USBD_INVAL; if (sync && id->bNumEndpoints <= 1) { printf("%s: a sync-pipe endpoint but no other endpoint\n", @@ -2030,7 +2053,7 @@ if (prec != 8 && prec != 16 && prec != 24) { printf("%s: ignored setting with precision %d\n", USBDEVNAME(sc->sc_dev), prec); - return (USBD_NORMAL_COMPLETION); + return USBD_NORMAL_COMPLETION; } switch (format) { case UA_FMT_PCM: @@ -2063,7 +2086,7 @@ default: printf("%s: ignored setting with format %d\n", USBDEVNAME(sc->sc_dev), format); - return (USBD_NORMAL_COMPLETION); + return USBD_NORMAL_COMPLETION; } #ifdef USB_DEBUG printf("%s: %s: %dch, %d/%dbit, %s,", USBDEVNAME(sc->sc_dev), @@ -2118,7 +2141,7 @@ #endif sc->sc_mode |= (dir == UE_DIR_OUT) ? AUMODE_PLAY : AUMODE_RECORD; - return (USBD_NORMAL_COMPLETION); + return USBD_NORMAL_COMPLETION; } #undef offs @@ -2137,7 +2160,7 @@ offs = 0; id = uaudio_find_iface(buf, size, &offs, UISUBCLASS_AUDIOSTREAM); if (id == NULL) - return (USBD_INVAL); + return USBD_INVAL; #if defined(__FreeBSD__) sc->uaudio_sndstat_flag = 0; @@ -2174,16 +2197,16 @@ sbuf_finish(&(sc->uaudio_sndstat)); #endif if (offs > size) - return (USBD_INVAL); + return USBD_INVAL; DPRINTF(("uaudio_identify_as: %d alts available\n", sc->sc_nalts)); if (sc->sc_mode == 0) { printf("%s: no usable endpoint found\n", USBDEVNAME(sc->sc_dev)); - return (USBD_INVAL); + return USBD_INVAL; } - return (USBD_NORMAL_COMPLETION); + return USBD_NORMAL_COMPLETION; } Static usbd_status @@ -2205,9 +2228,9 @@ offs = 0; id = uaudio_find_iface(buf, size, &offs, UISUBCLASS_AUDIOCONTROL); if (id == NULL) - return (USBD_INVAL); + return USBD_INVAL; if (offs + sizeof *acdp > size) - return (USBD_INVAL); + return USBD_INVAL; sc->sc_ac_iface = id->bInterfaceNumber; DPRINTFN(2,("uaudio_identify_ac: AC interface is %d\n", sc->sc_ac_iface)); @@ -2216,14 +2239,14 @@ acdp = (const struct usb_audio_control_descriptor *)ibuf; if (acdp->bDescriptorType != UDESC_CS_INTERFACE || acdp->bDescriptorSubtype != UDESCSUB_AC_HEADER) - return (USBD_INVAL); + return USBD_INVAL; aclen = UGETW(acdp->wTotalLength); if (offs + aclen > size) - return (USBD_INVAL); + return USBD_INVAL; if (!(usbd_get_quirks(sc->sc_udev)->uq_flags & UQ_BAD_ADC) && UGETW(acdp->bcdADC) != UAUDIO_VERSION) - return (USBD_INVAL); + return USBD_INVAL; sc->sc_audio_rev = UGETW(acdp->bcdADC); DPRINTFN(2,("uaudio_identify_ac: found AC header, vers=%03x, len=%d\n", @@ -2245,8 +2268,10 @@ if (ibuf >= ibufend) break; dp = (const usb_descriptor_t *)ibuf; - if (ibuf + dp->bLength > ibufend) - return (USBD_INVAL); + if (ibuf + dp->bLength > ibufend) { + free(iot, M_TEMP); + return USBD_INVAL; + } if (dp->bDescriptorType != UDESC_CS_INTERFACE) { printf("uaudio_identify_ac: skip desc type=0x%02x\n", dp->bDescriptorType); @@ -2409,20 +2434,21 @@ } free(iot, M_TEMP); - return (USBD_NORMAL_COMPLETION); + return USBD_NORMAL_COMPLETION; } #if defined(__NetBSD__) || defined(__OpenBSD__) Static int uaudio_query_devinfo(void *addr, mixer_devinfo_t *mi) { - struct uaudio_softc *sc = addr; + struct uaudio_softc *sc; struct mixerctl *mc; int n, nctls, i; + sc = addr; DPRINTFN(2,("uaudio_query_devinfo: index=%d\n", mi->index)); if (sc->sc_dying) - return (EIO); + return EIO; n = mi->index; nctls = sc->sc_nctls; @@ -2433,20 +2459,20 @@ mi->mixer_class = UAC_OUTPUT; mi->next = mi->prev = AUDIO_MIXER_LAST; strlcpy(mi->label.name, AudioCoutputs, sizeof(mi->label.name)); - return (0); + return 0; case UAC_INPUT: mi->type = AUDIO_MIXER_CLASS; mi->mixer_class = UAC_INPUT; mi->next = mi->prev = AUDIO_MIXER_LAST; strlcpy(mi->label.name, AudioCinputs, sizeof(mi->label.name)); - return (0); + return 0; case UAC_EQUAL: mi->type = AUDIO_MIXER_CLASS; mi->mixer_class = UAC_EQUAL; mi->next = mi->prev = AUDIO_MIXER_LAST; strlcpy(mi->label.name, AudioCequalization, sizeof(mi->label.name)); - return (0); + return 0; case UAC_RECORD: mi->type = AUDIO_MIXER_CLASS; mi->mixer_class = UAC_RECORD; @@ -2459,7 +2485,7 @@ n -= UAC_NCLASSES; if (n < 0 || n >= nctls) - return (ENXIO); + return ENXIO; mc = &sc->sc_ctls[n]; strlcpy(mi->label.name, mc->ctlname, sizeof(mi->label.name)); @@ -2493,24 +2519,25 @@ mi->un.v.delta = mc->delta; break; } - return (0); + return 0; } Static int uaudio_open(void *addr, int flags) { - struct uaudio_softc *sc = addr; + struct uaudio_softc *sc; + sc = addr; DPRINTF(("uaudio_open: sc=%p\n", sc)); if (sc->sc_dying) - return (EIO); + return EIO; if ((flags & FWRITE) && !(sc->sc_mode & AUMODE_PLAY)) - return (EACCES); + return EACCES; if ((flags & FREAD) && !(sc->sc_mode & AUMODE_RECORD)) - return (EACCES); + return EACCES; - return (0); + return 0; } /* @@ -2524,20 +2551,22 @@ Static int uaudio_drain(void *addr) { - struct uaudio_softc *sc = addr; + struct uaudio_softc *sc; + sc = addr; usbd_delay_ms(sc->sc_udev, UAUDIO_NCHANBUFS * UAUDIO_NFRAMES); - return (0); + return 0; } Static int uaudio_halt_out_dma(void *addr) { - struct uaudio_softc *sc = addr; + struct uaudio_softc *sc; + sc = addr; if (sc->sc_dying) - return (EIO); + return EIO; DPRINTF(("uaudio_halt_out_dma: enter\n")); if (sc->sc_playchan.pipe != NULL) { @@ -2546,35 +2575,37 @@ uaudio_chan_free_buffers(sc, &sc->sc_playchan); sc->sc_playchan.intr = NULL; } - return (0); + return 0; } Static int uaudio_halt_in_dma(void *addr) { - struct uaudio_softc *sc = addr; + struct uaudio_softc *sc; DPRINTF(("uaudio_halt_in_dma: enter\n")); + sc = addr; if (sc->sc_recchan.pipe != NULL) { uaudio_chan_close(sc, &sc->sc_recchan); sc->sc_recchan.pipe = NULL; uaudio_chan_free_buffers(sc, &sc->sc_recchan); sc->sc_recchan.intr = NULL; } - return (0); + return 0; } Static int uaudio_getdev(void *addr, struct audio_device *retp) { - struct uaudio_softc *sc = addr; + struct uaudio_softc *sc; DPRINTF(("uaudio_mixer_getdev:\n")); + sc = addr; if (sc->sc_dying) - return (EIO); + return EIO; *retp = uaudio_device; - return (0); + return 0; } /* @@ -2583,27 +2614,37 @@ Static int uaudio_round_blocksize(void *addr, int blk) { - struct uaudio_softc *sc = addr; - int bpf; + struct uaudio_softc *sc; >>> TRUNCATED FOR MAIL (1000 lines) <<<