summaryrefslogtreecommitdiffstats
path: root/sys/dev/wpi
diff options
context:
space:
mode:
authormarius <marius@FreeBSD.org>2014-04-25 22:23:38 +0000
committermarius <marius@FreeBSD.org>2014-04-25 22:23:38 +0000
commitad9e466c20bd5e2f9eef5f03cc8fc44a2b78c317 (patch)
tree97c2dc106fd724330ab620288ab7528b87fac6d8 /sys/dev/wpi
parentebc043d66bed02dcf3202ae7c02dd34fad0ba901 (diff)
downloadFreeBSD-src-ad9e466c20bd5e2f9eef5f03cc8fc44a2b78c317.zip
FreeBSD-src-ad9e466c20bd5e2f9eef5f03cc8fc44a2b78c317.tar.gz
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.
Diffstat (limited to 'sys/dev/wpi')
-rw-r--r--sys/dev/wpi/if_wpi.c40
-rw-r--r--sys/dev/wpi/if_wpivar.h2
2 files changed, 17 insertions, 25 deletions
diff --git a/sys/dev/wpi/if_wpi.c b/sys/dev/wpi/if_wpi.c
index 2fbb7a4..6b3929e 100644
--- a/sys/dev/wpi/if_wpi.c
+++ b/sys/dev/wpi/if_wpi.c
@@ -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);
diff --git a/sys/dev/wpi/if_wpivar.h b/sys/dev/wpi/if_wpivar.h
index 00579b3e..e579264 100644
--- a/sys/dev/wpi/if_wpivar.h
+++ b/sys/dev/wpi/if_wpivar.h
@@ -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;
OpenPOWER on IntegriCloud