diff options
Diffstat (limited to 'drivers/firewire/fw-topology.c')
-rw-r--r-- | drivers/firewire/fw-topology.c | 65 |
1 files changed, 42 insertions, 23 deletions
diff --git a/drivers/firewire/fw-topology.c b/drivers/firewire/fw-topology.c index 018c6b8afba6..c26d5d5e8d53 100644 --- a/drivers/firewire/fw-topology.c +++ b/drivers/firewire/fw-topology.c | |||
@@ -1,6 +1,5 @@ | |||
1 | /* -*- c-basic-offset: 8 -*- | 1 | /* |
2 | * | 2 | * Incremental bus scan, based on bus topology |
3 | * fw-topology.c - Incremental bus scan, based on bus topology | ||
4 | * | 3 | * |
5 | * Copyright (C) 2004-2006 Kristian Hoegsberg <krh@bitplanet.net> | 4 | * Copyright (C) 2004-2006 Kristian Hoegsberg <krh@bitplanet.net> |
6 | * | 5 | * |
@@ -69,10 +68,12 @@ static u32 *count_ports(u32 *sid, int *total_port_count, int *child_port_count) | |||
69 | sid++; | 68 | sid++; |
70 | q = *sid; | 69 | q = *sid; |
71 | 70 | ||
72 | /* Check that the extra packets actually are | 71 | /* |
72 | * Check that the extra packets actually are | ||
73 | * extended self ID packets and that the | 73 | * extended self ID packets and that the |
74 | * sequence numbers in the extended self ID | 74 | * sequence numbers in the extended self ID |
75 | * packets increase as expected. */ | 75 | * packets increase as expected. |
76 | */ | ||
76 | 77 | ||
77 | if (!self_id_extended(q) || | 78 | if (!self_id_extended(q) || |
78 | seq != self_id_ext_sequence(q)) | 79 | seq != self_id_ext_sequence(q)) |
@@ -113,7 +114,8 @@ static struct fw_node *fw_node_create(u32 sid, int port_count, int color) | |||
113 | return node; | 114 | return node; |
114 | } | 115 | } |
115 | 116 | ||
116 | /* Compute the maximum hop count for this node and it's children. The | 117 | /* |
118 | * Compute the maximum hop count for this node and it's children. The | ||
117 | * maximum hop count is the maximum number of connections between any | 119 | * maximum hop count is the maximum number of connections between any |
118 | * two nodes in the subtree rooted at this node. We need this for | 120 | * two nodes in the subtree rooted at this node. We need this for |
119 | * setting the gap count. As we build the tree bottom up in | 121 | * setting the gap count. As we build the tree bottom up in |
@@ -202,8 +204,10 @@ static struct fw_node *build_tree(struct fw_card *card, | |||
202 | return NULL; | 204 | return NULL; |
203 | } | 205 | } |
204 | 206 | ||
205 | /* Seek back from the top of our stack to find the | 207 | /* |
206 | * start of the child nodes for this node. */ | 208 | * Seek back from the top of our stack to find the |
209 | * start of the child nodes for this node. | ||
210 | */ | ||
207 | for (i = 0, h = &stack; i < child_port_count; i++) | 211 | for (i = 0, h = &stack; i < child_port_count; i++) |
208 | h = h->prev; | 212 | h = h->prev; |
209 | child = fw_node(h); | 213 | child = fw_node(h); |
@@ -230,7 +234,8 @@ static struct fw_node *build_tree(struct fw_card *card, | |||
230 | for (i = 0; i < port_count; i++) { | 234 | for (i = 0; i < port_count; i++) { |
231 | switch (get_port_type(sid, i)) { | 235 | switch (get_port_type(sid, i)) { |
232 | case SELFID_PORT_PARENT: | 236 | case SELFID_PORT_PARENT: |
233 | /* Who's your daddy? We dont know the | 237 | /* |
238 | * Who's your daddy? We dont know the | ||
234 | * parent node at this time, so we | 239 | * parent node at this time, so we |
235 | * temporarily abuse node->color for | 240 | * temporarily abuse node->color for |
236 | * remembering the entry in the | 241 | * remembering the entry in the |
@@ -245,8 +250,10 @@ static struct fw_node *build_tree(struct fw_card *card, | |||
245 | 250 | ||
246 | case SELFID_PORT_CHILD: | 251 | case SELFID_PORT_CHILD: |
247 | node->ports[i].node = child; | 252 | node->ports[i].node = child; |
248 | /* Fix up parent reference for this | 253 | /* |
249 | * child node. */ | 254 | * Fix up parent reference for this |
255 | * child node. | ||
256 | */ | ||
250 | child->ports[child->color].node = node; | 257 | child->ports[child->color].node = node; |
251 | child->color = card->color; | 258 | child->color = card->color; |
252 | child = fw_node(child->link.next); | 259 | child = fw_node(child->link.next); |
@@ -254,9 +261,11 @@ static struct fw_node *build_tree(struct fw_card *card, | |||
254 | } | 261 | } |
255 | } | 262 | } |
256 | 263 | ||
257 | /* Check that the node reports exactly one parent | 264 | /* |
265 | * Check that the node reports exactly one parent | ||
258 | * port, except for the root, which of course should | 266 | * port, except for the root, which of course should |
259 | * have no parents. */ | 267 | * have no parents. |
268 | */ | ||
260 | if ((next_sid == end && parent_count != 0) || | 269 | if ((next_sid == end && parent_count != 0) || |
261 | (next_sid < end && parent_count != 1)) { | 270 | (next_sid < end && parent_count != 1)) { |
262 | fw_error("Parent port inconsistency for node %d: " | 271 | fw_error("Parent port inconsistency for node %d: " |
@@ -269,9 +278,11 @@ static struct fw_node *build_tree(struct fw_card *card, | |||
269 | list_add_tail(&node->link, &stack); | 278 | list_add_tail(&node->link, &stack); |
270 | stack_depth += 1 - child_port_count; | 279 | stack_depth += 1 - child_port_count; |
271 | 280 | ||
272 | /* If all PHYs does not report the same gap count | 281 | /* |
282 | * If all PHYs does not report the same gap count | ||
273 | * setting, we fall back to 63 which will force a gap | 283 | * setting, we fall back to 63 which will force a gap |
274 | * count reconfiguration and a reset. */ | 284 | * count reconfiguration and a reset. |
285 | */ | ||
275 | if (self_id_gap_count(q) != gap_count) | 286 | if (self_id_gap_count(q) != gap_count) |
276 | gap_count = 63; | 287 | gap_count = 63; |
277 | 288 | ||
@@ -427,9 +438,11 @@ update_tree(struct fw_card *card, struct fw_node *root) | |||
427 | 438 | ||
428 | for (i = 0; i < node0->port_count; i++) { | 439 | for (i = 0; i < node0->port_count; i++) { |
429 | if (node0->ports[i].node && node1->ports[i].node) { | 440 | if (node0->ports[i].node && node1->ports[i].node) { |
430 | /* This port didn't change, queue the | 441 | /* |
442 | * This port didn't change, queue the | ||
431 | * connected node for further | 443 | * connected node for further |
432 | * investigation. */ | 444 | * investigation. |
445 | */ | ||
433 | if (node0->ports[i].node->color == card->color) | 446 | if (node0->ports[i].node->color == card->color) |
434 | continue; | 447 | continue; |
435 | list_add_tail(&node0->ports[i].node->link, | 448 | list_add_tail(&node0->ports[i].node->link, |
@@ -437,19 +450,23 @@ update_tree(struct fw_card *card, struct fw_node *root) | |||
437 | list_add_tail(&node1->ports[i].node->link, | 450 | list_add_tail(&node1->ports[i].node->link, |
438 | &list1); | 451 | &list1); |
439 | } else if (node0->ports[i].node) { | 452 | } else if (node0->ports[i].node) { |
440 | /* The nodes connected here were | 453 | /* |
454 | * The nodes connected here were | ||
441 | * unplugged; unref the lost nodes and | 455 | * unplugged; unref the lost nodes and |
442 | * queue FW_NODE_LOST callbacks for | 456 | * queue FW_NODE_LOST callbacks for |
443 | * them. */ | 457 | * them. |
458 | */ | ||
444 | 459 | ||
445 | for_each_fw_node(card, node0->ports[i].node, | 460 | for_each_fw_node(card, node0->ports[i].node, |
446 | report_lost_node); | 461 | report_lost_node); |
447 | node0->ports[i].node = NULL; | 462 | node0->ports[i].node = NULL; |
448 | } else if (node1->ports[i].node) { | 463 | } else if (node1->ports[i].node) { |
449 | /* One or more node were connected to | 464 | /* |
465 | * One or more node were connected to | ||
450 | * this port. Move the new nodes into | 466 | * this port. Move the new nodes into |
451 | * the tree and queue FW_NODE_CREATED | 467 | * the tree and queue FW_NODE_CREATED |
452 | * callbacks for them. */ | 468 | * callbacks for them. |
469 | */ | ||
453 | move_tree(node0, node1, i); | 470 | move_tree(node0, node1, i); |
454 | for_each_fw_node(card, node0->ports[i].node, | 471 | for_each_fw_node(card, node0->ports[i].node, |
455 | report_found_node); | 472 | report_found_node); |
@@ -486,9 +503,11 @@ fw_core_handle_bus_reset(struct fw_card *card, | |||
486 | 503 | ||
487 | spin_lock_irqsave(&card->lock, flags); | 504 | spin_lock_irqsave(&card->lock, flags); |
488 | 505 | ||
489 | /* If the new topology has a different self_id_count the topology | 506 | /* |
507 | * If the new topology has a different self_id_count the topology | ||
490 | * changed, either nodes were added or removed. In that case we | 508 | * changed, either nodes were added or removed. In that case we |
491 | * reset the IRM reset counter. */ | 509 | * reset the IRM reset counter. |
510 | */ | ||
492 | if (card->self_id_count != self_id_count) | 511 | if (card->self_id_count != self_id_count) |
493 | card->bm_retries = 0; | 512 | card->bm_retries = 0; |
494 | 513 | ||