svn commit: r191593 - head/sys/dev/ata

Jung-uk Kim jkim at FreeBSD.org
Mon Apr 27 19:39:19 UTC 2009


Author: jkim
Date: Mon Apr 27 19:39:18 2009
New Revision: 191593
URL: http://svn.freebsd.org/changeset/base/191593

Log:
  Reduce code duplication and excessive pci_get_slot() calls.
  
  Reviewed by:	mav

Modified:
  head/sys/dev/ata/ata-pci.c

Modified: head/sys/dev/ata/ata-pci.c
==============================================================================
--- head/sys/dev/ata/ata-pci.c	Mon Apr 27 19:30:09 2009	(r191592)
+++ head/sys/dev/ata/ata-pci.c	Mon Apr 27 19:39:18 2009	(r191593)
@@ -775,26 +775,26 @@ ata_match_chip(device_t dev, struct ata_
 struct ata_chip_id *
 ata_find_chip(device_t dev, struct ata_chip_id *index, int slot)
 {
+    struct ata_chip_id *idx;
     device_t *children;
     int nchildren, i;
+    uint8_t s;
 
     if (device_get_children(device_get_parent(dev), &children, &nchildren))
-	return 0;
+	return (NULL);
 
-    while (index->chipid != 0) {
-	for (i = 0; i < nchildren; i++) {
-	    if (((slot >= 0 && pci_get_slot(children[i]) == slot) || 
-		 (slot < 0 && pci_get_slot(children[i]) <= -slot)) &&
-		pci_get_devid(children[i]) == index->chipid &&
-		pci_get_revid(children[i]) >= index->chiprev) {
+    for (i = 0; i < nchildren; i++) {
+	s = pci_get_slot(children[i]);
+	if ((slot >= 0 && s == slot) || (slot < 0 && s <= -slot)) {
+	    idx = ata_match_chip(children[i], index);
+	    if (idx != NULL) {
 		free(children, M_TEMP);
-		return index;
+		return (idx);
 	    }
 	}
-	index++;
     }
     free(children, M_TEMP);
-    return NULL;
+    return (NULL);
 }
 
 void


More information about the svn-src-all mailing list