diff options
author | jkim <jkim@FreeBSD.org> | 2009-04-27 19:39:18 +0000 |
---|---|---|
committer | jkim <jkim@FreeBSD.org> | 2009-04-27 19:39:18 +0000 |
commit | 57c7fbd32383b60b96d3614adf031e3e4471c4d1 (patch) | |
tree | 99ff62bf6d5e89fd6877c0843f322508f9592894 /sys/dev | |
parent | 7a3f45569d122d8aae47334d3a8568287f86fa00 (diff) | |
download | FreeBSD-src-57c7fbd32383b60b96d3614adf031e3e4471c4d1.zip FreeBSD-src-57c7fbd32383b60b96d3614adf031e3e4471c4d1.tar.gz |
Reduce code duplication and excessive pci_get_slot() calls.
Reviewed by: mav
Diffstat (limited to 'sys/dev')
-rw-r--r-- | sys/dev/ata/ata-pci.c | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/sys/dev/ata/ata-pci.c b/sys/dev/ata/ata-pci.c index 65a7fca..dd6c3f1 100644 --- a/sys/dev/ata/ata-pci.c +++ b/sys/dev/ata/ata-pci.c @@ -775,26 +775,26 @@ ata_match_chip(device_t dev, struct ata_chip_id *index) 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 |