From owner-p4-projects@FreeBSD.ORG Fri Jul 12 03:17:58 2013 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 5112A10F; Fri, 12 Jul 2013 03:17:58 +0000 (UTC) Delivered-To: perforce@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id EF02C10D for ; Fri, 12 Jul 2013 03:17:57 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from skunkworks.freebsd.org (skunkworks.freebsd.org [8.8.178.74]) by mx1.freebsd.org (Postfix) with ESMTP id E0699166C for ; Fri, 12 Jul 2013 03:17:57 +0000 (UTC) Received: from skunkworks.freebsd.org ([127.0.1.74]) by skunkworks.freebsd.org (8.14.7/8.14.7) with ESMTP id r6C3Hvx5036515 for ; Fri, 12 Jul 2013 03:17:57 GMT (envelope-from jhb@freebsd.org) Received: (from perforce@localhost) by skunkworks.freebsd.org (8.14.7/8.14.6/Submit) id r6C3Hv24036512 for perforce@freebsd.org; Fri, 12 Jul 2013 03:17:57 GMT (envelope-from jhb@freebsd.org) Date: Fri, 12 Jul 2013 03:17:57 GMT Message-Id: <201307120317.r6C3Hv24036512@skunkworks.freebsd.org> X-Authentication-Warning: skunkworks.freebsd.org: perforce set sender to jhb@freebsd.org using -f From: John Baldwin Subject: PERFORCE change 231064 for review To: Perforce Change Reviews Precedence: bulk X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.14 List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 12 Jul 2013 03:17:58 -0000 http://p4web.freebsd.org/@@231064?ac=10 Change 231064 by jhb@jhb_pippin on 2013/07/12 03:17:47 Move bus number allocation support code completely into the PCI front-end. Affected files ... .. //depot/projects/pci/sys/dev/pccbb/pccbb.c#7 edit .. //depot/projects/pci/sys/dev/pccbb/pccbb_pci.c#7 edit Differences ... ==== //depot/projects/pci/sys/dev/pccbb/pccbb.c#7 (text+ko) ==== @@ -1503,11 +1503,6 @@ { struct cbb_softc *sc = device_get_softc(brdev); -#if defined(NEW_PCIB) && defined(PCI_RES_BUS) - if (type == PCI_RES_BUS) - return (pcib_alloc_subbus(&sc->bus, child, rid, start, end, - count, flags)); -#endif if (sc->flags & CBB_16BIT_CARD) return (cbb_pcic_alloc_resource(brdev, child, type, rid, start, end, count, flags)); @@ -1521,20 +1516,7 @@ struct resource *r) { struct cbb_softc *sc = device_get_softc(brdev); -#if defined(NEW_PCIB) && defined(PCI_RES_BUS) - int error; - if (type == PCI_RES_BUS) { - if (!rman_is_region_manager(r, &sc->bus.rman)) - return (EINVAL); - if (rman_get_flags(r) & RF_ACTIVE) { - error = bus_deactivate_resource(child, type, rid, r); - if (error) - return (error); - } - return (rman_release_resource(r)); - } -#endif if (sc->flags & CBB_16BIT_CARD) return (cbb_pcic_release_resource(brdev, child, type, rid, r)); ==== //depot/projects/pci/sys/dev/pccbb/pccbb_pci.c#7 (text+ko) ==== @@ -797,6 +797,20 @@ } #if defined(NEW_PCIB) && defined(PCI_RES_BUS) +static struct resource * +cbb_pci_alloc_resource(device_t bus, device_t child, int type, int *rid, + u_long start, u_long end, u_long count, u_int flags) +{ + struct cbb_softc *sc; + + sc = device_get_softc(bus); + if (type == PCI_RES_BUS) + return (pcib_alloc_subbus(&sc->bus, child, rid, start, end, + count, flags)); + return (cbb_alloc_resource(bus, child, type, rid, start, end, count, + flags)); +} + static int cbb_pci_adjust_resource(device_t bus, device_t child, int type, struct resource *r, u_long start, u_long end) @@ -811,6 +825,27 @@ } return (bus_generic_adjust_resource(bus, child, type, r, start, end)); } + +static int +cbb_pci_release_resource(device_t bus, device_t child, int type, int rid, + struct resource *r) +{ + struct cbb_softc *sc; + int error; + + sc = device_get_softc(bus); + if (type == PCI_RES_BUS) { + if (!rman_is_region_manager(r, &sc->bus.rman)) + return (EINVAL); + if (rman_get_flags(r) & RF_ACTIVE) { + error = bus_deactivate_resource(child, type, rid, r); + if (error) + return (error); + } + return (rman_release_resource(r)); + } + return (cbb_release_resource(bus, child, type, rid, r)); +} #endif /************************************************************************/ @@ -856,11 +891,14 @@ /* bus methods */ DEVMETHOD(bus_read_ivar, cbb_read_ivar), DEVMETHOD(bus_write_ivar, cbb_write_ivar), - DEVMETHOD(bus_alloc_resource, cbb_alloc_resource), #if defined(NEW_PCIB) && defined(PCI_RES_BUS) + DEVMETHOD(bus_alloc_resource, cbb_pci_alloc_resource), DEVMETHOD(bus_adjust_resource, cbb_pci_adjust_resource), + DEVMETHOD(bus_release_resource, cbb_pci_release_resource), +#else + DEVMETHOD(bus_alloc_resource, cbb_alloc_resource), + DEVMETHOD(bus_release_resource, cbb_release_resource), #endif - DEVMETHOD(bus_release_resource, cbb_release_resource), DEVMETHOD(bus_activate_resource, cbb_activate_resource), DEVMETHOD(bus_deactivate_resource, cbb_deactivate_resource), DEVMETHOD(bus_driver_added, cbb_driver_added),