summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsimokawa <simokawa@FreeBSD.org>2003-02-01 06:34:36 +0000
committersimokawa <simokawa@FreeBSD.org>2003-02-01 06:34:36 +0000
commit551f94c8c8ef3be88bfb0d73f48d3b5c81d78454 (patch)
tree37841213db41ce2caec6de61ea3ca474ad93d4ec
parent34fa6078b2e0f3a0c678d71e0c6a2ce5188ef4ef (diff)
downloadFreeBSD-src-551f94c8c8ef3be88bfb0d73f48d3b5c81d78454.zip
FreeBSD-src-551f94c8c8ef3be88bfb0d73f48d3b5c81d78454.tar.gz
Sort device list by eui64 in acendent order correctly.
-rw-r--r--sys/dev/firewire/firewire.c24
1 files changed, 12 insertions, 12 deletions
diff --git a/sys/dev/firewire/firewire.c b/sys/dev/firewire/firewire.c
index 5158e12..5c9652d6 100644
--- a/sys/dev/firewire/firewire.c
+++ b/sys/dev/firewire/firewire.c
@@ -1112,7 +1112,7 @@ static void
fw_bus_explore(struct firewire_comm *fc )
{
int err = 0;
- struct fw_device *fwdev, *tfwdev;
+ struct fw_device *fwdev, *pfwdev, *tfwdev;
u_int32_t addr;
struct fw_xfer *xfer;
struct fw_pkt *fp;
@@ -1176,18 +1176,18 @@ loop:
fwdev->speed = fc->speed_map->speed[fc->nodeid][fc->ongonode];
#endif
- tfwdev = TAILQ_FIRST(&fc->devices);
- while( tfwdev != NULL &&
- (tfwdev->eui.hi > fwdev->eui.hi) &&
- ((tfwdev->eui.hi == fwdev->eui.hi) &&
- tfwdev->eui.lo > fwdev->eui.lo)){
- tfwdev = TAILQ_NEXT( tfwdev, link);
- }
- if(tfwdev == NULL){
- TAILQ_INSERT_TAIL(&fc->devices, fwdev, link);
- }else{
- TAILQ_INSERT_BEFORE(tfwdev, fwdev, link);
+ pfwdev = NULL;
+ TAILQ_FOREACH(tfwdev, &fc->devices, link) {
+ if (tfwdev->eui.hi > fwdev->eui.hi ||
+ (tfwdev->eui.hi == fwdev->eui.hi &&
+ tfwdev->eui.lo > fwdev->eui.lo))
+ break;
+ pfwdev = tfwdev;
}
+ if (pfwdev == NULL)
+ TAILQ_INSERT_HEAD(&fc->devices, fwdev, link);
+ else
+ TAILQ_INSERT_AFTER(&fc->devices, pfwdev, fwdev, link);
device_printf(fc->bdev, "New %s device ID:%08x%08x\n",
linkspeed[fwdev->speed],
OpenPOWER on IntegriCloud