Author: marius
Date: Fri Apr 25 22:23:26 2014
New Revision: 264955
URL: http://svnweb.freebsd.org/changeset/base/264955

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/9/sys/dev/wpi/if_wpi.c
  stable/9/sys/dev/wpi/if_wpivar.h
Directory Properties:
  stable/9/sys/   (props changed)
  stable/9/sys/dev/   (props changed)

Modified: stable/9/sys/dev/wpi/if_wpi.c
==============================================================================
--- stable/9/sys/dev/wpi/if_wpi.c       Fri Apr 25 22:19:18 2014        
(r264954)
+++ stable/9/sys/dev/wpi/if_wpi.c       Fri Apr 25 22:23:26 2014        
(r264955)
@@ -250,7 +250,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),
@@ -260,7 +259,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 = {
@@ -271,7 +270,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);
 
@@ -282,12 +281,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)
 {
@@ -297,7 +296,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;
@@ -490,7 +489,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];
@@ -522,20 +521,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");
@@ -546,8 +539,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");
@@ -714,6 +707,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;
 
@@ -743,13 +739,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);
@@ -3189,7 +3184,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/9/sys/dev/wpi/if_wpivar.h
==============================================================================
--- stable/9/sys/dev/wpi/if_wpivar.h    Fri Apr 25 22:19:18 2014        
(r264954)
+++ stable/9/sys/dev/wpi/if_wpivar.h    Fri Apr 25 22:23:26 2014        
(r264955)
@@ -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;
_______________________________________________
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to