Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 27 Jul 2007 05:43:39 GMT
From:      Christopher Davis <loafier@FreeBSD.org>
To:        Perforce Change Reviews <perforce@FreeBSD.org>
Subject:   PERFORCE change 124155 for review
Message-ID:  <200707270543.l6R5hd4T033226@repoman.freebsd.org>

next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=124155

Change 124155 by loafier@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;
 	}
 
 	/*



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200707270543.l6R5hd4T033226>