Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 27 Apr 2009 19:39:18 +0000 (UTC)
From:      Jung-uk Kim <jkim@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r191593 - head/sys/dev/ata
Message-ID:  <200904271939.n3RJdIds024833@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
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



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