mirror of
https://git.FreeBSD.org/src.git
synced 2024-12-17 10:26:15 +00:00
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:
parent
a9b31c256e
commit
0e4e9e170c
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=216518
@ -116,8 +116,8 @@ ndis_devcompare(bustype, t, dev)
|
||||
while(t->ndis_name != NULL) {
|
||||
if ((pci_get_vendor(dev) == t->ndis_vid) &&
|
||||
(pci_get_device(dev) == t->ndis_did) &&
|
||||
((pci_read_config(dev, PCIR_SUBVEND_0, 4) ==
|
||||
t->ndis_subsys) || t->ndis_subsys == 0)) {
|
||||
(pci_get_subvendor(dev) == t->ndis_subsys ||
|
||||
t->ndis_subsys == 0)) {
|
||||
device_set_desc(dev, t->ndis_name);
|
||||
return(TRUE);
|
||||
}
|
||||
@ -201,7 +201,6 @@ ndis_attach_pci(dev)
|
||||
error = ENXIO;
|
||||
goto fail;
|
||||
}
|
||||
pci_enable_io(dev, SYS_RES_IOPORT);
|
||||
break;
|
||||
case SYS_RES_MEMORY:
|
||||
if (sc->ndis_res_altmem != NULL &&
|
||||
@ -239,7 +238,6 @@ ndis_attach_pci(dev)
|
||||
goto fail;
|
||||
}
|
||||
}
|
||||
pci_enable_io(dev, SYS_RES_MEMORY);
|
||||
break;
|
||||
case SYS_RES_IRQ:
|
||||
rid = rle->rid;
|
||||
@ -309,12 +307,9 @@ ndis_attach_pci(dev)
|
||||
(pci_get_device(dev) == t->ndis_did)) {
|
||||
if (t->ndis_subsys == 0)
|
||||
defidx = devidx;
|
||||
else {
|
||||
if (t->ndis_subsys ==
|
||||
pci_read_config(dev, PCIR_SUBVEND_0, 4))
|
||||
else if (pci_get_subvendor(dev) == t->ndis_subsys)
|
||||
break;
|
||||
}
|
||||
}
|
||||
t++;
|
||||
devidx++;
|
||||
}
|
||||
|
@ -312,7 +312,6 @@ le_pci_attach(device_t dev)
|
||||
LE_LOCK_INIT(sc, device_get_nameunit(dev));
|
||||
|
||||
pci_enable_busmaster(dev);
|
||||
pci_enable_io(dev, SYS_RES_IOPORT);
|
||||
|
||||
i = PCIR_BAR(0);
|
||||
lesc->sc_rres = bus_alloc_resource_any(dev, SYS_RES_IOPORT,
|
||||
|
@ -149,21 +149,6 @@ malo_pci_probe(device_t dev)
|
||||
#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
|
||||
malo_pci_attach(device_t dev)
|
||||
{
|
||||
@ -173,11 +158,7 @@ malo_pci_attach(device_t dev)
|
||||
|
||||
sc->malo_dev = dev;
|
||||
|
||||
/*
|
||||
* Enable memory mapping and bus mastering.
|
||||
*/
|
||||
if (malo_pci_setup(dev))
|
||||
return (ENXIO);
|
||||
pci_enable_busmaster(dev);
|
||||
|
||||
/*
|
||||
* 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);
|
||||
|
||||
if (!malo_pci_setup(dev))
|
||||
return ENXIO;
|
||||
|
||||
malo_resume(&psc->malo_sc);
|
||||
|
||||
return (0);
|
||||
|
@ -1202,7 +1202,6 @@ atiixp_pci_attach(device_t dev)
|
||||
else
|
||||
sc->polling = 0;
|
||||
|
||||
pci_set_powerstate(dev, PCI_POWERSTATE_D0);
|
||||
pci_enable_busmaster(dev);
|
||||
|
||||
sc->regid = PCIR_BAR(0);
|
||||
@ -1354,7 +1353,6 @@ atiixp_pci_suspend(device_t dev)
|
||||
value = atiixp_rd(sc, ATI_REG_CMD);
|
||||
value |= ATI_REG_CMD_POWERDOWN | ATI_REG_CMD_AC_RESET;
|
||||
atiixp_wr(sc, ATI_REG_CMD, ATI_REG_CMD_POWERDOWN);
|
||||
pci_set_powerstate(dev, PCI_POWERSTATE_D3);
|
||||
atiixp_unlock(sc);
|
||||
|
||||
return (0);
|
||||
@ -1366,10 +1364,6 @@ atiixp_pci_resume(device_t dev)
|
||||
struct atiixp_info *sc = pcm_getdevinfo(dev);
|
||||
|
||||
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 */
|
||||
atiixp_reset_aclink(sc);
|
||||
atiixp_unlock(sc);
|
||||
|
@ -1192,12 +1192,6 @@ ich_pci_resume(device_t 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);
|
||||
/* Reinit audio device */
|
||||
if (ich_init(sc) == -1) {
|
||||
|
Loading…
Reference in New Issue
Block a user