From owner-svn-src-all@FreeBSD.ORG Mon Apr 27 19:39:18 2009 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 840F01065674; Mon, 27 Apr 2009 19:39:18 +0000 (UTC) (envelope-from jkim@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 723348FC0C; Mon, 27 Apr 2009 19:39:18 +0000 (UTC) (envelope-from jkim@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n3RJdIFi024834; Mon, 27 Apr 2009 19:39:18 GMT (envelope-from jkim@svn.freebsd.org) Received: (from jkim@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n3RJdIds024833; Mon, 27 Apr 2009 19:39:18 GMT (envelope-from jkim@svn.freebsd.org) Message-Id: <200904271939.n3RJdIds024833@svn.freebsd.org> From: Jung-uk Kim Date: Mon, 27 Apr 2009 19:39:18 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r191593 - head/sys/dev/ata X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 27 Apr 2009 19:39:19 -0000 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