PERFORCE change 124155 for review
Christopher Davis
loafier at FreeBSD.org
Fri Jul 27 05:43:40 UTC 2007
http://perforce.freebsd.org/chv.cgi?CH=124155
Change 124155 by loafier at chrisdsoc on 2007/07/27 05:43:02
Use return value from pci_enable_io() to help determine whether to
allocate memory or io ports.
Affected files ...
.. //depot/projects/soc2007/loafier_busalloc/src/share/examples/drivers/template.c#2 edit
Differences ...
==== //depot/projects/soc2007/loafier_busalloc/src/share/examples/drivers/template.c#2 (text+ko) ====
@@ -534,6 +534,7 @@
static int
XX_pci_attach(device_t dev)
{
+ int mapped = 0;
struct sc_info *sc;
struct ac97_info *codec;
uint32_t data;
@@ -551,16 +552,20 @@
/* power up */
pci_set_powerstate(dev, PCI_POWERSTATE_D0);
pci_enable_busmaster(dev);
- pci_enable_io(dev, SYS_RES_MEMORY);
- pci_enable_io(dev, SYS_RES_IOPORT);
- sc->spec = XX_res_spec_mem;
- if (bus_alloc_resources(dev, sc->spec, sc->res) != 0) {
+ if (mapped == 0 && pci_enable_io(dev, SYS_RES_MEMORY) == 0) {
+ sc->spec = XX_res_spec_mem;
+ if (bus_alloc_resources(dev, sc->spec, sc->res) != 0)
+ mapped = 1;
+ }
+ if (mapped == 0 && pci_enable_io(dev, SYS_RES_IOPORT) == 0) {
sc->spec = XX_res_spec_io;
- if (bus_alloc_resources(dev, sc->spec, sc->res) != 0) {
- device_printf(dev, "unable to allocate resources\n");
- goto bad;
- }
+ if (bus_alloc_resources(dev, sc->spec, sc->res) != 0)
+ mapped = 1;
+ }
+ if (mapped == 0) {
+ device_printf(dev, "unable to allocate resources\n");
+ goto bad;
}
/*
More information about the p4-projects
mailing list