From owner-p4-projects@FreeBSD.ORG Fri Feb 10 22:04:10 2006 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 3ACD716A424; Fri, 10 Feb 2006 22:04:10 +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 F067016A420 for ; Fri, 10 Feb 2006 22:04:09 +0000 (GMT) (envelope-from imp@freebsd.org) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id AD80F43D45 for ; Fri, 10 Feb 2006 22:04:09 +0000 (GMT) (envelope-from imp@freebsd.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.13.1/8.13.1) with ESMTP id k1AM49F2050361 for ; Fri, 10 Feb 2006 22:04:09 GMT (envelope-from imp@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.13.1/8.13.1/Submit) id k1AM49pj050358 for perforce@freebsd.org; Fri, 10 Feb 2006 22:04:09 GMT (envelope-from imp@freebsd.org) Date: Fri, 10 Feb 2006 22:04:09 GMT Message-Id: <200602102204.k1AM49pj050358@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to imp@freebsd.org using -f From: Warner Losh To: Perforce Change Reviews Cc: Subject: PERFORCE change 91523 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: Fri, 10 Feb 2006 22:04:11 -0000 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 @@ -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);