From owner-svn-src-all@FreeBSD.ORG Fri Apr 25 22:23:39 2014 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 3847ED36; Fri, 25 Apr 2014 22:23:39 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 18EEF1077; Fri, 25 Apr 2014 22:23:39 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.8/8.14.8) with ESMTP id s3PMNcCM074612; Fri, 25 Apr 2014 22:23:38 GMT (envelope-from marius@svn.freebsd.org) Received: (from marius@localhost) by svn.freebsd.org (8.14.8/8.14.8/Submit) id s3PMNcbd074610; Fri, 25 Apr 2014 22:23:38 GMT (envelope-from marius@svn.freebsd.org) Message-Id: <201404252223.s3PMNcbd074610@svn.freebsd.org> From: Marius Strobl Date: Fri, 25 Apr 2014 22:23:38 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r264956 - stable/10/sys/dev/wpi X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.17 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 25 Apr 2014 22:23:39 -0000 Author: marius Date: Fri Apr 25 22:23:38 2014 New Revision: 264956 URL: http://svnweb.freebsd.org/changeset/base/264956 Log: MFC: r260064 - Probe with BUS_PROBE_DEFAULT instead of 0. - Nuke code setting PCI_POWERSTATE_D0; pci(4) already does that for type 0 devices. - There's no need to keep track of resource IDs. - Quiesce the interrupt before actually detaching. - Use DEVMETHOD_END. - Use NULL instead of 0 for pointers. Modified: stable/10/sys/dev/wpi/if_wpi.c stable/10/sys/dev/wpi/if_wpivar.h Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/dev/wpi/if_wpi.c ============================================================================== --- stable/10/sys/dev/wpi/if_wpi.c Fri Apr 25 22:23:26 2014 (r264955) +++ stable/10/sys/dev/wpi/if_wpi.c Fri Apr 25 22:23:38 2014 (r264956) @@ -252,7 +252,6 @@ static int wpi_shutdown(device_t); static int wpi_suspend(device_t); static int wpi_resume(device_t); - static device_method_t wpi_methods[] = { /* Device interface */ DEVMETHOD(device_probe, wpi_probe), @@ -262,7 +261,7 @@ static device_method_t wpi_methods[] = { DEVMETHOD(device_suspend, wpi_suspend), DEVMETHOD(device_resume, wpi_resume), - { 0, 0 } + DEVMETHOD_END }; static driver_t wpi_driver = { @@ -273,7 +272,7 @@ static driver_t wpi_driver = { static devclass_t wpi_devclass; -DRIVER_MODULE(wpi, pci, wpi_driver, wpi_devclass, 0, 0); +DRIVER_MODULE(wpi, pci, wpi_driver, wpi_devclass, NULL, NULL); MODULE_VERSION(wpi, 1); @@ -284,12 +283,12 @@ static const uint8_t wpi_ridx_to_plcp[] /* CCK: device-dependent */ 10, 20, 55, 110 }; + static const uint8_t wpi_ridx_to_rate[] = { 12, 18, 24, 36, 48, 72, 96, 108, /* OFDM */ 2, 4, 11, 22 /*CCK */ }; - static int wpi_probe(device_t dev) { @@ -299,7 +298,7 @@ wpi_probe(device_t dev) if (pci_get_vendor(dev) == ident->vendor && pci_get_device(dev) == ident->device) { device_set_desc(dev, ident->name); - return 0; + return (BUS_PROBE_DEFAULT); } } return ENXIO; @@ -492,7 +491,7 @@ wpi_attach(device_t dev) struct wpi_softc *sc = device_get_softc(dev); struct ifnet *ifp; struct ieee80211com *ic; - int ac, error, supportsa = 1; + int ac, error, rid, supportsa = 1; uint32_t tmp; const struct wpi_ident *ident; uint8_t macaddr[IEEE80211_ADDR_LEN]; @@ -524,20 +523,14 @@ wpi_attach(device_t dev) callout_init_mtx(&sc->calib_to, &sc->sc_mtx, 0); callout_init_mtx(&sc->watchdog_to, &sc->sc_mtx, 0); - if (pci_get_powerstate(dev) != PCI_POWERSTATE_D0) { - device_printf(dev, "chip is in D%d power mode " - "-- setting to D0\n", pci_get_powerstate(dev)); - pci_set_powerstate(dev, PCI_POWERSTATE_D0); - } - /* disable the retry timeout register */ pci_write_config(dev, 0x41, 0, 1); /* enable bus-mastering */ pci_enable_busmaster(dev); - sc->mem_rid = PCIR_BAR(0); - sc->mem = bus_alloc_resource_any(dev, SYS_RES_MEMORY, &sc->mem_rid, + rid = PCIR_BAR(0); + sc->mem = bus_alloc_resource_any(dev, SYS_RES_MEMORY, &rid, RF_ACTIVE); if (sc->mem == NULL) { device_printf(dev, "could not allocate memory resource\n"); @@ -548,8 +541,8 @@ wpi_attach(device_t dev) sc->sc_st = rman_get_bustag(sc->mem); sc->sc_sh = rman_get_bushandle(sc->mem); - sc->irq_rid = 0; - sc->irq = bus_alloc_resource_any(dev, SYS_RES_IRQ, &sc->irq_rid, + rid = 0; + sc->irq = bus_alloc_resource_any(dev, SYS_RES_IRQ, &rid, RF_ACTIVE | RF_SHAREABLE); if (sc->irq == NULL) { device_printf(dev, "could not allocate interrupt resource\n"); @@ -716,6 +709,9 @@ wpi_detach(device_t dev) struct ieee80211com *ic; int ac; + if (sc->irq != NULL) + bus_teardown_intr(dev, sc->irq, sc->sc_ih); + if (ifp != NULL) { ic = ifp->if_l2com; @@ -745,13 +741,12 @@ wpi_detach(device_t dev) wpi_free_fwmem(sc); WPI_UNLOCK(sc); - if (sc->irq != NULL) { - bus_teardown_intr(dev, sc->irq, sc->sc_ih); - bus_release_resource(dev, SYS_RES_IRQ, sc->irq_rid, sc->irq); - } - + if (sc->irq != NULL) + bus_release_resource(dev, SYS_RES_IRQ, rman_get_rid(sc->irq), + sc->irq); if (sc->mem != NULL) - bus_release_resource(dev, SYS_RES_MEMORY, sc->mem_rid, sc->mem); + bus_release_resource(dev, SYS_RES_MEMORY, + rman_get_rid(sc->mem), sc->mem); if (ifp != NULL) if_free(ifp); @@ -3191,7 +3186,6 @@ wpi_stop_locked(struct wpi_softc *sc) callout_stop(&sc->watchdog_to); callout_stop(&sc->calib_to); - /* disable interrupts */ WPI_WRITE(sc, WPI_MASK, 0); WPI_WRITE(sc, WPI_INTR, WPI_INTR_MASK); Modified: stable/10/sys/dev/wpi/if_wpivar.h ============================================================================== --- stable/10/sys/dev/wpi/if_wpivar.h Fri Apr 25 22:23:26 2014 (r264955) +++ stable/10/sys/dev/wpi/if_wpivar.h Fri Apr 25 22:23:38 2014 (r264956) @@ -162,8 +162,6 @@ struct wpi_softc { bus_space_tag_t sc_st; bus_space_handle_t sc_sh; void *sc_ih; - int mem_rid; - int irq_rid; struct wpi_config config; int temp;