Lines Matching refs:card
183 static struct fw_node *build_tree(struct fw_card *card, in build_tree() argument
207 fw_err(card, "inconsistent extended self IDs\n"); in build_tree()
213 fw_err(card, "PHY ID mismatch in self ID: %d != %d\n", in build_tree()
219 fw_err(card, "topology stack underflow\n"); in build_tree()
235 node = fw_node_create(q, port_count, card->color); in build_tree()
237 fw_err(card, "out of memory while building topology\n"); in build_tree()
241 if (phy_id == (card->node_id & 0x3f)) in build_tree()
273 child->color = card->color; in build_tree()
286 fw_err(card, "parent port inconsistency for node %d: " in build_tree()
313 card->root_node = node; in build_tree()
314 card->irm_node = irm_node; in build_tree()
315 card->gap_count = gap_count; in build_tree()
316 card->beta_repeaters_present = beta_repeaters_present; in build_tree()
321 typedef void (*fw_node_callback_t)(struct fw_card * card,
325 static void for_each_fw_node(struct fw_card *card, struct fw_node *root, in for_each_fw_node() argument
338 node->color = card->color; in for_each_fw_node()
344 if (child->color == card->color) in for_each_fw_node()
352 callback(card, node, parent); in for_each_fw_node()
359 static void report_lost_node(struct fw_card *card, in report_lost_node() argument
362 fw_node_event(card, node, FW_NODE_DESTROYED); in report_lost_node()
366 card->bm_retries = 0; in report_lost_node()
369 static void report_found_node(struct fw_card *card, in report_found_node() argument
384 fw_node_event(card, node, FW_NODE_CREATED); in report_found_node()
387 card->bm_retries = 0; in report_found_node()
390 void fw_destroy_nodes(struct fw_card *card) in fw_destroy_nodes() argument
394 spin_lock_irqsave(&card->lock, flags); in fw_destroy_nodes()
395 card->color++; in fw_destroy_nodes()
396 if (card->local_node != NULL) in fw_destroy_nodes()
397 for_each_fw_node(card, card->local_node, report_lost_node); in fw_destroy_nodes()
398 card->local_node = NULL; in fw_destroy_nodes()
399 spin_unlock_irqrestore(&card->lock, flags); in fw_destroy_nodes()
422 static void update_tree(struct fw_card *card, struct fw_node *root) in update_tree() argument
429 list_add_tail(&card->local_node->link, &list0); in update_tree()
449 node0->color = card->color; in update_tree()
453 node1->color = card->color; in update_tree()
454 fw_node_event(card, node0, event); in update_tree()
456 if (card->root_node == node1) in update_tree()
457 card->root_node = node0; in update_tree()
458 if (card->irm_node == node1) in update_tree()
459 card->irm_node = node0; in update_tree()
468 if (node0->ports[i]->color == card->color) in update_tree()
480 for_each_fw_node(card, node0->ports[i], in update_tree()
491 for_each_fw_node(card, node0->ports[i], in update_tree()
503 static void update_topology_map(struct fw_card *card, in update_topology_map() argument
506 int node_count = (card->root_node->node_id & 0x3f) + 1; in update_topology_map()
507 __be32 *map = card->topology_map; in update_topology_map()
510 *map++ = cpu_to_be32(be32_to_cpu(card->topology_map[1]) + 1); in update_topology_map()
516 fw_compute_block_crc(card->topology_map); in update_topology_map()
519 void fw_core_handle_bus_reset(struct fw_card *card, int node_id, int generation, in fw_core_handle_bus_reset() argument
530 if (!is_next_generation(generation, card->generation) && in fw_core_handle_bus_reset()
531 card->local_node != NULL) { in fw_core_handle_bus_reset()
532 fw_destroy_nodes(card); in fw_core_handle_bus_reset()
533 card->bm_retries = 0; in fw_core_handle_bus_reset()
536 spin_lock_irqsave(&card->lock, flags); in fw_core_handle_bus_reset()
538 card->broadcast_channel_allocated = card->broadcast_channel_auto_allocated; in fw_core_handle_bus_reset()
539 card->node_id = node_id; in fw_core_handle_bus_reset()
545 card->generation = generation; in fw_core_handle_bus_reset()
546 card->reset_jiffies = get_jiffies_64(); in fw_core_handle_bus_reset()
547 card->bm_node_id = 0xffff; in fw_core_handle_bus_reset()
548 card->bm_abdicate = bm_abdicate; in fw_core_handle_bus_reset()
549 fw_schedule_bm_work(card, 0); in fw_core_handle_bus_reset()
551 local_node = build_tree(card, self_ids, self_id_count); in fw_core_handle_bus_reset()
553 update_topology_map(card, self_ids, self_id_count); in fw_core_handle_bus_reset()
555 card->color++; in fw_core_handle_bus_reset()
558 fw_err(card, "topology build failed\n"); in fw_core_handle_bus_reset()
560 } else if (card->local_node == NULL) { in fw_core_handle_bus_reset()
561 card->local_node = local_node; in fw_core_handle_bus_reset()
562 for_each_fw_node(card, local_node, report_found_node); in fw_core_handle_bus_reset()
564 update_tree(card, local_node); in fw_core_handle_bus_reset()
567 spin_unlock_irqrestore(&card->lock, flags); in fw_core_handle_bus_reset()