Date: Fri, 10 Feb 2006 22:04:09 GMT From: Warner Losh <imp@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 91523 for review Message-ID: <200602102204.k1AM49pj050358@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=91523 Change 91523 by imp@imp_Speedy on 2006/02/10 22:03:27 fix ohci interrupt return value rewrite most of ohci_atmelarm and claim copyright now Affected files ... .. //depot/projects/arm/src/sys/arm/at91/ohci_atmelarm.c#2 edit .. //depot/projects/arm/src/sys/dev/usb/ohci.c#5 edit .. //depot/projects/arm/src/sys/dev/usb/ohci_pci.c#5 edit .. //depot/projects/arm/src/sys/dev/usb/ohcivar.h#4 edit Differences ... ==== //depot/projects/arm/src/sys/arm/at91/ohci_atmelarm.c#2 (text+ko) ==== @@ -1,10 +1,5 @@ /*- - * Copyright (c) 1998 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Lennart Augustsson (augustss@carlstedt.se) at - * Carlstedt Research & Technology. + * Copyright (c) 2006 M. Warner Losh. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -14,25 +9,17 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the NetBSD - * Foundation, Inc. and its contributors. - * 4. Neither the name of The NetBSD Foundation nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include <sys/cdefs.h> @@ -58,8 +45,8 @@ #define MEM_RID 0 -static int ohci_atmelarm_attach(device_t self); -static int ohci_atmelarm_detach(device_t self); +static int ohci_atmelarm_attach(device_t dev); +static int ohci_atmelarm_detach(device_t dev); static int ohci_atmelarm_probe(device_t self) @@ -77,42 +64,37 @@ /* XXX where does it say so in the spec? */ sc->sc_bus.usbrev = USBREV_1_0; + strlcpy(sc->sc_vendor, "Atmel", sizeof(sc->sc_vendor)); rid = MEM_RID; sc->io_res = bus_alloc_resource_any(self, SYS_RES_MEMORY, &rid, RF_ACTIVE); - if (!sc->io_res) { - device_printf(self, "Could not map memory\n"); - return ENXIO; + if (sc->io_res == NULL) { + err = ENXIO; + goto error; } sc->iot = rman_get_bustag(sc->io_res); sc->ioh = rman_get_bushandle(sc->io_res); rid = 0; sc->irq_res = bus_alloc_resource_any(self, SYS_RES_IRQ, &rid, - RF_SHAREABLE | RF_ACTIVE); + RF_ACTIVE); if (sc->irq_res == NULL) { - device_printf(self, "Could not allocate irq\n"); - ohci_atmelarm_detach(self); - return ENXIO; + err = ENXIO; + goto error; } sc->sc_bus.bdev = device_add_child(self, "usb", -1); - if (!sc->sc_bus.bdev) { - device_printf(self, "Could not add USB device\n"); - ohci_atmelarm_detach(self); - return ENOMEM; + if (sc->sc_bus.bdev == NULL) { + err = ENOMEM; + goto error; } device_set_ivars(sc->sc_bus.bdev, &sc->sc_bus); - strlcpy(sc->sc_vendor, "Atmel", sizeof(sc->sc_vendor)) - - err = bus_setup_intr(self, sc->irq_res, INTR_TYPE_BIO | INTR_MPSAFE, - (driver_intr_t *) ohci_intr, sc, &sc->ih); + err = bus_setup_intr(self, sc->irq_res, INTR_TYPE_BIO, ohci_intr, sc, + &sc->ih); if (err) { - device_printf(self, "Could not setup irq, %d\n", err); - sc->ih = NULL; - ohci_atmelarm_detach(self); - return ENXIO; + err = ENXIO; + goto error; } err = ohci_init(sc); if (!err) { @@ -120,12 +102,12 @@ err = device_probe_and_attach(sc->sc_bus.bdev); } +error:; if (err) { - device_printf(self, "USB init failed\n"); ohci_atmelarm_detach(self); - return EIO; + return (err); } - return 0; + return (err); } static int @@ -138,13 +120,8 @@ sc->sc_flags &= ~OHCI_SCFLG_DONEINIT; } - if (sc->irq_res && sc->ih) { - int err = bus_teardown_intr(self, sc->irq_res, sc->ih); - - if (err) - /* XXX or should we panic? */ - device_printf(self, "Could not tear down irq, %d\n", - err); + if (sc->ih) { + bus_teardown_intr(self, sc->irq_res, sc->ih); sc->ih = NULL; } if (sc->sc_bus.bdev) { @@ -161,7 +138,7 @@ sc->iot = 0; sc->ioh = 0; } - return 0; + return (0); } static device_method_t ohci_methods[] = { ==== //depot/projects/arm/src/sys/dev/usb/ohci.c#5 (text+ko) ==== @@ -1145,23 +1145,23 @@ Static int ohci_intr1(ohci_softc_t *); -int +void ohci_intr(void *p) { ohci_softc_t *sc = p; if (sc == NULL || sc->sc_dying) - return (0); + return; /* If we get an interrupt while polling, then just ignore it. */ if (sc->sc_bus.use_polling) { #ifdef DIAGNOSTIC printf("ohci_intr: ignored interrupt while polling\n"); #endif - return (0); + return; } - return (ohci_intr1(sc)); + ohci_intr1(sc); } Static int ==== //depot/projects/arm/src/sys/dev/usb/ohci_pci.c#5 (text+ko) ==== @@ -295,8 +295,8 @@ sprintf(sc->sc_vendor, "(0x%04x)", pci_get_vendor(self)); } - err = bus_setup_intr(self, sc->irq_res, INTR_TYPE_BIO, - (driver_intr_t *) ohci_intr, sc, &sc->ih); + err = bus_setup_intr(self, sc->irq_res, INTR_TYPE_BIO, ohci_intr, sc, + &sc->ih); if (err) { device_printf(self, "Could not setup irq, %d\n", err); sc->ih = NULL; ==== //depot/projects/arm/src/sys/dev/usb/ohcivar.h#4 (text+ko) ==== @@ -164,7 +164,7 @@ #define OXFER(xfer) ((struct ohci_xfer *)(xfer)) usbd_status ohci_init(ohci_softc_t *); -int ohci_intr(void *); +void ohci_intr(void *); int ohci_detach(ohci_softc_t *, int); #if defined(__NetBSD__) || defined(__OpenBSD__) int ohci_activate(device_ptr_t, enum devact);
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200602102204.k1AM49pj050358>