Use convenience functions where possible instead of accessing the PCI

configuration registers directly.

Remove pci_enable_io calls where they are redundant. The PCI bus driver
will set the right bits when the corresponding bus resource is activated.

Remove redundant pci_* function calls from suspend/resume methods. The
bus driver already saves and restores the PCI configuration.

Reviewed by:	jhb
Approved by:	kib (mentor)
This commit is contained in:
Tijl Coosemans 2010-12-18 14:21:28 +00:00
parent a9b31c256e
commit 0e4e9e170c
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=216518
5 changed files with 5 additions and 45 deletions

View File

@ -116,8 +116,8 @@ ndis_devcompare(bustype, t, dev)
while(t->ndis_name != NULL) { while(t->ndis_name != NULL) {
if ((pci_get_vendor(dev) == t->ndis_vid) && if ((pci_get_vendor(dev) == t->ndis_vid) &&
(pci_get_device(dev) == t->ndis_did) && (pci_get_device(dev) == t->ndis_did) &&
((pci_read_config(dev, PCIR_SUBVEND_0, 4) == (pci_get_subvendor(dev) == t->ndis_subsys ||
t->ndis_subsys) || t->ndis_subsys == 0)) { t->ndis_subsys == 0)) {
device_set_desc(dev, t->ndis_name); device_set_desc(dev, t->ndis_name);
return(TRUE); return(TRUE);
} }
@ -201,7 +201,6 @@ ndis_attach_pci(dev)
error = ENXIO; error = ENXIO;
goto fail; goto fail;
} }
pci_enable_io(dev, SYS_RES_IOPORT);
break; break;
case SYS_RES_MEMORY: case SYS_RES_MEMORY:
if (sc->ndis_res_altmem != NULL && if (sc->ndis_res_altmem != NULL &&
@ -239,7 +238,6 @@ ndis_attach_pci(dev)
goto fail; goto fail;
} }
} }
pci_enable_io(dev, SYS_RES_MEMORY);
break; break;
case SYS_RES_IRQ: case SYS_RES_IRQ:
rid = rle->rid; rid = rle->rid;
@ -309,11 +307,8 @@ ndis_attach_pci(dev)
(pci_get_device(dev) == t->ndis_did)) { (pci_get_device(dev) == t->ndis_did)) {
if (t->ndis_subsys == 0) if (t->ndis_subsys == 0)
defidx = devidx; defidx = devidx;
else { else if (pci_get_subvendor(dev) == t->ndis_subsys)
if (t->ndis_subsys == break;
pci_read_config(dev, PCIR_SUBVEND_0, 4))
break;
}
} }
t++; t++;
devidx++; devidx++;

View File

@ -312,7 +312,6 @@ le_pci_attach(device_t dev)
LE_LOCK_INIT(sc, device_get_nameunit(dev)); LE_LOCK_INIT(sc, device_get_nameunit(dev));
pci_enable_busmaster(dev); pci_enable_busmaster(dev);
pci_enable_io(dev, SYS_RES_IOPORT);
i = PCIR_BAR(0); i = PCIR_BAR(0);
lesc->sc_rres = bus_alloc_resource_any(dev, SYS_RES_IOPORT, lesc->sc_rres = bus_alloc_resource_any(dev, SYS_RES_IOPORT,

View File

@ -149,21 +149,6 @@ malo_pci_probe(device_t dev)
#undef N #undef N
} }
static int
malo_pci_setup(device_t dev)
{
/*
* Enable memory mapping and bus mastering.
*/
if (pci_enable_busmaster(dev) != 0)
return -1;
if (pci_enable_io(dev, SYS_RES_MEMORY) != 0)
return -1;
return 0;
}
static int static int
malo_pci_attach(device_t dev) malo_pci_attach(device_t dev)
{ {
@ -173,11 +158,7 @@ malo_pci_attach(device_t dev)
sc->malo_dev = dev; sc->malo_dev = dev;
/* pci_enable_busmaster(dev);
* Enable memory mapping and bus mastering.
*/
if (malo_pci_setup(dev))
return (ENXIO);
/* /*
* Setup memory-mapping of PCI registers. * Setup memory-mapping of PCI registers.
@ -342,9 +323,6 @@ malo_pci_resume(device_t dev)
{ {
struct malo_pci_softc *psc = device_get_softc(dev); struct malo_pci_softc *psc = device_get_softc(dev);
if (!malo_pci_setup(dev))
return ENXIO;
malo_resume(&psc->malo_sc); malo_resume(&psc->malo_sc);
return (0); return (0);

View File

@ -1202,7 +1202,6 @@ atiixp_pci_attach(device_t dev)
else else
sc->polling = 0; sc->polling = 0;
pci_set_powerstate(dev, PCI_POWERSTATE_D0);
pci_enable_busmaster(dev); pci_enable_busmaster(dev);
sc->regid = PCIR_BAR(0); sc->regid = PCIR_BAR(0);
@ -1354,7 +1353,6 @@ atiixp_pci_suspend(device_t dev)
value = atiixp_rd(sc, ATI_REG_CMD); value = atiixp_rd(sc, ATI_REG_CMD);
value |= ATI_REG_CMD_POWERDOWN | ATI_REG_CMD_AC_RESET; value |= ATI_REG_CMD_POWERDOWN | ATI_REG_CMD_AC_RESET;
atiixp_wr(sc, ATI_REG_CMD, ATI_REG_CMD_POWERDOWN); atiixp_wr(sc, ATI_REG_CMD, ATI_REG_CMD_POWERDOWN);
pci_set_powerstate(dev, PCI_POWERSTATE_D3);
atiixp_unlock(sc); atiixp_unlock(sc);
return (0); return (0);
@ -1366,10 +1364,6 @@ atiixp_pci_resume(device_t dev)
struct atiixp_info *sc = pcm_getdevinfo(dev); struct atiixp_info *sc = pcm_getdevinfo(dev);
atiixp_lock(sc); atiixp_lock(sc);
/* power up pci bus */
pci_set_powerstate(dev, PCI_POWERSTATE_D0);
pci_enable_io(dev, SYS_RES_MEMORY);
pci_enable_busmaster(dev);
/* reset / power up aclink */ /* reset / power up aclink */
atiixp_reset_aclink(sc); atiixp_reset_aclink(sc);
atiixp_unlock(sc); atiixp_unlock(sc);

View File

@ -1192,12 +1192,6 @@ ich_pci_resume(device_t dev)
sc = pcm_getdevinfo(dev); sc = pcm_getdevinfo(dev);
if (sc->regtype == SYS_RES_IOPORT)
pci_enable_io(dev, SYS_RES_IOPORT);
else
pci_enable_io(dev, SYS_RES_MEMORY);
pci_enable_busmaster(dev);
ICH_LOCK(sc); ICH_LOCK(sc);
/* Reinit audio device */ /* Reinit audio device */
if (ich_init(sc) == -1) { if (ich_init(sc) == -1) {