aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/firewire/fw-topology.c
diff options
context:
space:
mode:
authorKristian Høgsberg <krh@redhat.com>2007-03-07 12:12:55 -0500
committerStefan Richter <stefanr@s5r6.in-berlin.de>2007-03-09 16:03:14 -0500
commit473d28c730e2de888c24b226cfe4183868eacde2 (patch)
tree8653544f742c8c99d6076f881eb0eb0ef4b30904 /drivers/firewire/fw-topology.c
parent7c6e647da00883ec2208171d51537f23498dd669 (diff)
firewire: Implement topology map and fix a couple of loopback bugs.
Signed-off-by: Kristian Høgsberg <krh@redhat.com> Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
Diffstat (limited to 'drivers/firewire/fw-topology.c')
-rw-r--r--drivers/firewire/fw-topology.c28
1 files changed, 21 insertions, 7 deletions
diff --git a/drivers/firewire/fw-topology.c b/drivers/firewire/fw-topology.c
index 36c9be75b025..7923463fdbf3 100644
--- a/drivers/firewire/fw-topology.c
+++ b/drivers/firewire/fw-topology.c
@@ -163,11 +163,12 @@ static void update_hop_count(struct fw_node *node)
163 * internally consistent. On succcess this funtions returns the 163 * internally consistent. On succcess this funtions returns the
164 * fw_node corresponding to the local card otherwise NULL. 164 * fw_node corresponding to the local card otherwise NULL.
165 */ 165 */
166static struct fw_node *build_tree(struct fw_card *card) 166static struct fw_node *build_tree(struct fw_card *card,
167 u32 *sid, int self_id_count)
167{ 168{
168 struct fw_node *node, *child, *local_node; 169 struct fw_node *node, *child, *local_node;
169 struct list_head stack, *h; 170 struct list_head stack, *h;
170 u32 *sid, *next_sid, *end, q; 171 u32 *next_sid, *end, q;
171 int i, port_count, child_port_count, phy_id, parent_count, stack_depth; 172 int i, port_count, child_port_count, phy_id, parent_count, stack_depth;
172 int gap_count, topology_type; 173 int gap_count, topology_type;
173 174
@@ -175,8 +176,7 @@ static struct fw_node *build_tree(struct fw_card *card)
175 node = NULL; 176 node = NULL;
176 INIT_LIST_HEAD(&stack); 177 INIT_LIST_HEAD(&stack);
177 stack_depth = 0; 178 stack_depth = 0;
178 sid = card->self_ids; 179 end = sid + self_id_count;
179 end = sid + card->self_id_count;
180 phy_id = 0; 180 phy_id = 0;
181 card->irm_node = NULL; 181 card->irm_node = NULL;
182 gap_count = self_id_gap_count(*sid); 182 gap_count = self_id_gap_count(*sid);
@@ -460,6 +460,20 @@ update_tree(struct fw_card *card, struct fw_node *root)
460 } 460 }
461} 461}
462 462
463static void
464update_topology_map(struct fw_card *card, u32 *self_ids, int self_id_count)
465{
466 int node_count;
467 u32 crc;
468
469 card->topology_map[1]++;
470 node_count = (card->root_node->node_id & 0x3f) + 1;
471 card->topology_map[2] = (node_count << 16) | self_id_count;
472 crc = crc16_itu_t(card->topology_map + 1, self_id_count + 2);
473 card->topology_map[0] = ((self_id_count + 2) << 16) | crc;
474 memcpy(&card->topology_map[3], self_ids, self_id_count * 4);
475}
476
463void 477void
464fw_core_handle_bus_reset(struct fw_card *card, 478fw_core_handle_bus_reset(struct fw_card *card,
465 int node_id, int generation, 479 int node_id, int generation,
@@ -479,13 +493,13 @@ fw_core_handle_bus_reset(struct fw_card *card,
479 card->bm_retries = 0; 493 card->bm_retries = 0;
480 494
481 card->node_id = node_id; 495 card->node_id = node_id;
482 card->self_id_count = self_id_count;
483 card->generation = generation; 496 card->generation = generation;
484 memcpy(card->self_ids, self_ids, self_id_count * 4);
485 card->reset_jiffies = jiffies; 497 card->reset_jiffies = jiffies;
486 schedule_delayed_work(&card->work, 0); 498 schedule_delayed_work(&card->work, 0);
487 499
488 local_node = build_tree(card); 500 local_node = build_tree(card, self_ids, self_id_count);
501
502 update_topology_map(card, self_ids, self_id_count);
489 503
490 card->color++; 504 card->color++;
491 505