svn commit: r264953 - stable/9/sys/dev/iwi
Marius Strobl
marius at FreeBSD.org
Fri Apr 25 22:19:07 UTC 2014
Author: marius
Date: Fri Apr 25 22:19:06 2014
New Revision: 264953
URL: http://svnweb.freebsd.org/changeset/base/264953
Log:
MFC: r260063
- Probe with BUS_PROBE_DEFAULT instead of 0.
- Nuke code setting PCI_POWERSTATE_D0; pci(4) already does that for type 0
devices.
- Use PCIR_BAR instead of a homegrown macro.
- 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/iwi/if_iwi.c
stable/9/sys/dev/iwi/if_iwivar.h
Directory Properties:
stable/9/sys/ (props changed)
stable/9/sys/dev/ (props changed)
Modified: stable/9/sys/dev/iwi/if_iwi.c
==============================================================================
--- stable/9/sys/dev/iwi/if_iwi.c Fri Apr 25 22:04:40 2014 (r264952)
+++ stable/9/sys/dev/iwi/if_iwi.c Fri Apr 25 22:19:06 2014 (r264953)
@@ -219,7 +219,7 @@ static device_method_t iwi_methods[] = {
DEVMETHOD(device_suspend, iwi_suspend),
DEVMETHOD(device_resume, iwi_resume),
- { 0, 0 }
+ DEVMETHOD_END
};
static driver_t iwi_driver = {
@@ -230,7 +230,7 @@ static driver_t iwi_driver = {
static devclass_t iwi_devclass;
-DRIVER_MODULE(iwi, pci, iwi_driver, iwi_devclass, 0, 0);
+DRIVER_MODULE(iwi, pci, iwi_driver, iwi_devclass, NULL, NULL);
MODULE_VERSION(iwi, 1);
@@ -257,15 +257,12 @@ iwi_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;
}
-/* Base Address Register */
-#define IWI_PCI_BAR0 0x10
-
static int
iwi_attach(device_t dev)
{
@@ -300,20 +297,13 @@ iwi_attach(device_t dev)
callout_init_mtx(&sc->sc_wdtimer, &sc->sc_mtx, 0);
callout_init_mtx(&sc->sc_rftimer, &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);
- }
-
pci_write_config(dev, 0x41, 0, 1);
/* enable bus-mastering */
pci_enable_busmaster(dev);
- sc->mem_rid = IWI_PCI_BAR0;
- sc->mem = bus_alloc_resource_any(dev, SYS_RES_MEMORY, &sc->mem_rid,
- RF_ACTIVE);
+ i = PCIR_BAR(0);
+ sc->mem = bus_alloc_resource_any(dev, SYS_RES_MEMORY, &i, RF_ACTIVE);
if (sc->mem == NULL) {
device_printf(dev, "could not allocate memory resource\n");
goto fail;
@@ -322,8 +312,8 @@ iwi_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,
+ i = 0;
+ sc->irq = bus_alloc_resource_any(dev, SYS_RES_IRQ, &i,
RF_ACTIVE | RF_SHAREABLE);
if (sc->irq == NULL) {
device_printf(dev, "could not allocate interrupt resource\n");
@@ -459,6 +449,8 @@ iwi_detach(device_t dev)
struct ifnet *ifp = sc->sc_ifp;
struct ieee80211com *ic = ifp->if_l2com;
+ bus_teardown_intr(dev, sc->irq, sc->sc_ih);
+
/* NB: do early to drain any pending tasks */
ieee80211_draintask(ic, &sc->sc_radiontask);
ieee80211_draintask(ic, &sc->sc_radiofftask);
@@ -480,10 +472,10 @@ iwi_detach(device_t dev)
iwi_free_tx_ring(sc, &sc->txq[3]);
iwi_free_rx_ring(sc, &sc->rxq);
- bus_teardown_intr(dev, sc->irq, sc->sc_ih);
- bus_release_resource(dev, SYS_RES_IRQ, sc->irq_rid, sc->irq);
+ bus_release_resource(dev, SYS_RES_IRQ, rman_get_rid(sc->irq), sc->irq);
- 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);
delete_unrhdr(sc->sc_unr);
Modified: stable/9/sys/dev/iwi/if_iwivar.h
==============================================================================
--- stable/9/sys/dev/iwi/if_iwivar.h Fri Apr 25 22:04:40 2014 (r264952)
+++ stable/9/sys/dev/iwi/if_iwivar.h Fri Apr 25 22:19:06 2014 (r264953)
@@ -153,8 +153,6 @@ struct iwi_softc {
bus_space_tag_t sc_st;
bus_space_handle_t sc_sh;
void *sc_ih;
- int mem_rid;
- int irq_rid;
/*
* The card needs external firmware images to work, which is made of a
More information about the svn-src-stable-9
mailing list