Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

firewire: core: use scoped_guard() to manage critical section to update topology

At present, guard() macro is used for the critical section to update
topology. It is inconvenient to add the other critical sections into
the function.

This commit uses scoped_guard() macro instead.

Link: https://lore.kernel.org/r/20250915234747.915922-2-o-takashi@sakamocchi.jp
Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>

+30 -36
+30 -36
drivers/firewire/core-topology.c
··· 458 458 459 459 trace_bus_reset_handle(card->index, generation, node_id, bm_abdicate, self_ids, self_id_count); 460 460 461 - guard(spinlock_irqsave)(&card->lock); 461 + scoped_guard(spinlock, &card->lock) { 462 + // If the selfID buffer is not the immediate successor of the 463 + // previously processed one, we cannot reliably compare the 464 + // old and new topologies. 465 + if (!is_next_generation(generation, card->generation) && card->local_node != NULL) { 466 + fw_destroy_nodes(card); 467 + card->bm_retries = 0; 468 + } 469 + card->broadcast_channel_allocated = card->broadcast_channel_auto_allocated; 470 + card->node_id = node_id; 471 + // Update node_id before generation to prevent anybody from using 472 + // a stale node_id together with a current generation. 473 + smp_wmb(); 474 + card->generation = generation; 475 + card->reset_jiffies = get_jiffies_64(); 476 + card->bm_node_id = 0xffff; 477 + card->bm_abdicate = bm_abdicate; 478 + fw_schedule_bm_work(card, 0); 462 479 463 - /* 464 - * If the selfID buffer is not the immediate successor of the 465 - * previously processed one, we cannot reliably compare the 466 - * old and new topologies. 467 - */ 468 - if (!is_next_generation(generation, card->generation) && 469 - card->local_node != NULL) { 470 - fw_destroy_nodes(card); 471 - card->bm_retries = 0; 472 - } 480 + local_node = build_tree(card, self_ids, self_id_count, generation); 473 481 474 - card->broadcast_channel_allocated = card->broadcast_channel_auto_allocated; 475 - card->node_id = node_id; 476 - /* 477 - * Update node_id before generation to prevent anybody from using 478 - * a stale node_id together with a current generation. 479 - */ 480 - smp_wmb(); 481 - card->generation = generation; 482 - card->reset_jiffies = get_jiffies_64(); 483 - card->bm_node_id = 0xffff; 484 - card->bm_abdicate = bm_abdicate; 485 - fw_schedule_bm_work(card, 0); 482 + update_topology_map(card, self_ids, self_id_count); 486 483 487 - local_node = build_tree(card, self_ids, self_id_count, generation); 484 + card->color++; 488 485 489 - update_topology_map(card, self_ids, self_id_count); 490 - 491 - card->color++; 492 - 493 - if (local_node == NULL) { 494 - fw_err(card, "topology build failed\n"); 495 - /* FIXME: We need to issue a bus reset in this case. */ 496 - } else if (card->local_node == NULL) { 497 - card->local_node = local_node; 498 - for_each_fw_node(card, local_node, report_found_node); 499 - } else { 500 - update_tree(card, local_node); 486 + if (local_node == NULL) { 487 + fw_err(card, "topology build failed\n"); 488 + // FIXME: We need to issue a bus reset in this case. 489 + } else if (card->local_node == NULL) { 490 + card->local_node = local_node; 491 + for_each_fw_node(card, local_node, report_found_node); 492 + } else { 493 + update_tree(card, local_node); 494 + } 501 495 } 502 496 } 503 497 EXPORT_SYMBOL(fw_core_handle_bus_reset);