- 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. - Nuke dupe $FreeBSD$. MFC after: 1 week
This commit is contained in:
parent
97db2528ed
commit
66168a0428
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=260062
@ -1,5 +1,3 @@
|
||||
/* $FreeBSD$ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2004-2006
|
||||
* Damien Bergamini <damien.bergamini@free.fr>. All rights reserved.
|
||||
@ -187,7 +185,7 @@ static device_method_t ipw_methods[] = {
|
||||
DEVMETHOD(device_suspend, ipw_suspend),
|
||||
DEVMETHOD(device_resume, ipw_resume),
|
||||
|
||||
{ 0, 0 }
|
||||
DEVMETHOD_END
|
||||
};
|
||||
|
||||
static driver_t ipw_driver = {
|
||||
@ -198,7 +196,7 @@ static driver_t ipw_driver = {
|
||||
|
||||
static devclass_t ipw_devclass;
|
||||
|
||||
DRIVER_MODULE(ipw, pci, ipw_driver, ipw_devclass, 0, 0);
|
||||
DRIVER_MODULE(ipw, pci, ipw_driver, ipw_devclass, NULL, NULL);
|
||||
|
||||
MODULE_VERSION(ipw, 1);
|
||||
|
||||
@ -211,15 +209,13 @@ ipw_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 IPW_PCI_BAR0 0x10
|
||||
|
||||
static int
|
||||
ipw_attach(device_t dev)
|
||||
{
|
||||
@ -239,20 +235,13 @@ ipw_attach(device_t dev)
|
||||
TASK_INIT(&sc->sc_init_task, 0, ipw_init_task, sc);
|
||||
callout_init_mtx(&sc->sc_wdtimer, &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 = IPW_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;
|
||||
@ -261,8 +250,8 @@ ipw_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");
|
||||
@ -387,9 +376,10 @@ ipw_attach(device_t dev)
|
||||
fail3:
|
||||
ipw_release(sc);
|
||||
fail2:
|
||||
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);
|
||||
fail1:
|
||||
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);
|
||||
fail:
|
||||
mtx_destroy(&sc->sc_mtx);
|
||||
return ENXIO;
|
||||
@ -402,6 +392,8 @@ ipw_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);
|
||||
|
||||
ieee80211_draintask(ic, &sc->sc_init_task);
|
||||
ipw_stop(sc);
|
||||
|
||||
@ -411,10 +403,10 @@ ipw_detach(device_t dev)
|
||||
|
||||
ipw_release(sc);
|
||||
|
||||
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);
|
||||
|
||||
if_free(ifp);
|
||||
|
||||
|
@ -105,8 +105,6 @@ struct ipw_softc {
|
||||
#define IPW_FLAG_ASSOCIATING 0x0080
|
||||
#define IPW_FLAG_ASSOCIATED 0x0100
|
||||
|
||||
int irq_rid;
|
||||
int mem_rid;
|
||||
struct resource *irq;
|
||||
struct resource *mem;
|
||||
bus_space_tag_t sc_st;
|
||||
|
Loading…
Reference in New Issue
Block a user