svn commit: r216518 - in head/sys/dev: if_ndis le malo sound/pci

Tijl Coosemans tijl at FreeBSD.org
Sat Dec 18 14:21:29 UTC 2010


Author: tijl
Date: Sat Dec 18 14:21:28 2010
New Revision: 216518
URL: http://svn.freebsd.org/changeset/base/216518

Log:
  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)

Modified:
  head/sys/dev/if_ndis/if_ndis_pci.c
  head/sys/dev/le/if_le_pci.c
  head/sys/dev/malo/if_malo_pci.c
  head/sys/dev/sound/pci/atiixp.c
  head/sys/dev/sound/pci/ich.c

Modified: head/sys/dev/if_ndis/if_ndis_pci.c
==============================================================================
--- head/sys/dev/if_ndis/if_ndis_pci.c	Sat Dec 18 11:45:54 2010	(r216517)
+++ head/sys/dev/if_ndis/if_ndis_pci.c	Sat Dec 18 14:21:28 2010	(r216518)
@@ -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,11 +307,8 @@ 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))
-					break;
-			}
+			else if (pci_get_subvendor(dev) == t->ndis_subsys)
+				break;
 		}
 		t++;
 		devidx++;

Modified: head/sys/dev/le/if_le_pci.c
==============================================================================
--- head/sys/dev/le/if_le_pci.c	Sat Dec 18 11:45:54 2010	(r216517)
+++ head/sys/dev/le/if_le_pci.c	Sat Dec 18 14:21:28 2010	(r216518)
@@ -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,

Modified: head/sys/dev/malo/if_malo_pci.c
==============================================================================
--- head/sys/dev/malo/if_malo_pci.c	Sat Dec 18 11:45:54 2010	(r216517)
+++ head/sys/dev/malo/if_malo_pci.c	Sat Dec 18 14:21:28 2010	(r216518)
@@ -150,21 +150,6 @@ malo_pci_probe(device_t dev)
 }
 
 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)
 {
 	int error = ENXIO, i, msic, reg;
@@ -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);

Modified: head/sys/dev/sound/pci/atiixp.c
==============================================================================
--- head/sys/dev/sound/pci/atiixp.c	Sat Dec 18 11:45:54 2010	(r216517)
+++ head/sys/dev/sound/pci/atiixp.c	Sat Dec 18 14:21:28 2010	(r216518)
@@ -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);

Modified: head/sys/dev/sound/pci/ich.c
==============================================================================
--- head/sys/dev/sound/pci/ich.c	Sat Dec 18 11:45:54 2010	(r216517)
+++ head/sys/dev/sound/pci/ich.c	Sat Dec 18 14:21:28 2010	(r216518)
@@ -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) {


More information about the svn-src-all mailing list