From 4230e8de2fbc8c8eb45f7c1e1c1ce20db4867e9a Mon Sep 17 00:00:00 2001 From: Hidetoshi Shimokawa Date: Sat, 1 Feb 2003 06:34:36 +0000 Subject: [PATCH] Sort device list by eui64 in acendent order correctly. --- sys/dev/firewire/firewire.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/sys/dev/firewire/firewire.c b/sys/dev/firewire/firewire.c index 5158e120ccd..5c9652d6585 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],