Commit 80c5b023 authored by Takashi Sakamoto's avatar Takashi Sakamoto
Browse files

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: default avatarTakashi Sakamoto <o-takashi@sakamocchi.jp>
parent 931383f1
Loading
Loading
Loading
Loading
+34 −40
Original line number Diff line number Diff line
@@ -458,25 +458,18 @@ void fw_core_handle_bus_reset(struct fw_card *card, int node_id, int generation,

	trace_bus_reset_handle(card->index, generation, node_id, bm_abdicate, self_ids, self_id_count);

	guard(spinlock_irqsave)(&card->lock);

	/*
	 * If the selfID buffer is not the immediate successor of the
	 * previously processed one, we cannot reliably compare the
	 * old and new topologies.
	 */
	if (!is_next_generation(generation, card->generation) &&
	    card->local_node != NULL) {
	scoped_guard(spinlock, &card->lock) {
		// If the selfID buffer is not the immediate successor of the
		// previously processed one, we cannot reliably compare the
		// old and new topologies.
		if (!is_next_generation(generation, card->generation) && card->local_node != NULL) {
			fw_destroy_nodes(card);
			card->bm_retries = 0;
		}

		card->broadcast_channel_allocated = card->broadcast_channel_auto_allocated;
		card->node_id = node_id;
	/*
	 * Update node_id before generation to prevent anybody from using
	 * a stale node_id together with a current generation.
	 */
		// Update node_id before generation to prevent anybody from using
		// a stale node_id together with a current generation.
		smp_wmb();
		card->generation = generation;
		card->reset_jiffies = get_jiffies_64();
@@ -492,7 +485,7 @@ void fw_core_handle_bus_reset(struct fw_card *card, int node_id, int generation,

		if (local_node == NULL) {
			fw_err(card, "topology build failed\n");
		/* FIXME: We need to issue a bus reset in this case. */
			// FIXME: We need to issue a bus reset in this case.
		} else if (card->local_node == NULL) {
			card->local_node = local_node;
			for_each_fw_node(card, local_node, report_found_node);
@@ -500,4 +493,5 @@ void fw_core_handle_bus_reset(struct fw_card *card, int node_id, int generation,
			update_tree(card, local_node);
		}
	}
}
EXPORT_SYMBOL(fw_core_handle_bus_reset);