From fc45c8c81571191d5d104d0d66c159ec3b8cad83 Mon Sep 17 00:00:00 2001 From: dfr Date: Sun, 16 May 2004 11:26:39 +0000 Subject: [PATCH] Don't use the node id as an index into the topology map. This breaks if a node on the bus has more than three ports (like my cheapo six port hub). --- sys/dev/firewire/firewire.c | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/sys/dev/firewire/firewire.c b/sys/dev/firewire/firewire.c index 29c65b56c89d..a72e3843dd0d 100644 --- a/sys/dev/firewire/firewire.c +++ b/sys/dev/firewire/firewire.c @@ -1292,6 +1292,25 @@ fw_bus_probe(struct firewire_comm *fc) splx(s); } +/* + * Find the self_id packet for a node, ignoring sequels. + */ +static union fw_self_id * +fw_find_self_id(struct firewire_comm *fc, int node) +{ + uint32_t i; + union fw_self_id *s; + + for (i = 0; i < fc->topology_map->self_id_count; i++) { + s = &fc->topology_map->self_id[i]; + if (s->p0.sequel) + continue; + if (s->p0.phy_id == node) + return s; + } + return 0; +} + /* * To collect device informations on the IEEE1394 bus. */ @@ -1315,7 +1334,7 @@ fw_bus_explore(struct firewire_comm *fc ) /* check link */ /* XXX we need to check phy_id first */ - if (!fc->topology_map->self_id[fc->ongonode].p0.link_active) { + if (!fw_find_self_id(fc, fc->ongonode)->p0.link_active) { if (firewire_debug) printf("node%d: link down\n", fc->ongonode); fc->ongonode++; @@ -2185,7 +2204,7 @@ fw_bmr(struct firewire_comm *fc) u_int32_t quad; /* Check to see if the current root node is cycle master capable */ - self_id = &fc->topology_map->self_id[fc->max_node]; + self_id = fw_find_self_id(fc, fc->max_node); if (fc->max_node > 0) { /* XXX check cmc bit of businfo block rather than contender */ if (self_id->p0.link_active && self_id->p0.contender)