]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
firewire: core: code refactoring to remove transaction entry
authorTakashi Sakamoto <o-takashi@sakamocchi.jp>
Sat, 1 Nov 2025 10:21:30 +0000 (19:21 +0900)
committerTakashi Sakamoto <o-takashi@sakamocchi.jp>
Sat, 1 Nov 2025 10:29:35 +0000 (19:29 +0900)
The list operation to remove transaction entry appears several times in
transaction implementation and can be replaced with a helper function.

Link: https://lore.kernel.org/r/20251101102131.925071-2-o-takashi@sakamocchi.jp
Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
drivers/firewire/core-transaction.c

index dd3656a0c1ff0d90d0bb0cac2298f54831421b2c..8bd79c3f97f2459995d5bb88653307fbd209e6cd 100644 (file)
@@ -44,6 +44,13 @@ static int try_cancel_split_timeout(struct fw_transaction *t)
                return 1;
 }
 
+// card->transactions.lock must be acquired in advance.
+static void remove_transaction_entry(struct fw_card *card, struct fw_transaction *entry)
+{
+       list_del_init(&entry->link);
+       card->transactions.tlabel_mask &= ~(1ULL << entry->tlabel);
+}
+
 static int close_transaction(struct fw_transaction *transaction, struct fw_card *card, int rcode,
                             u32 response_tstamp)
 {
@@ -55,8 +62,7 @@ static int close_transaction(struct fw_transaction *transaction, struct fw_card
                list_for_each_entry(iter, &card->transactions.list, link) {
                        if (iter == transaction) {
                                if (try_cancel_split_timeout(iter)) {
-                                       list_del_init(&iter->link);
-                                       card->transactions.tlabel_mask &= ~(1ULL << iter->tlabel);
+                                       remove_transaction_entry(card, iter);
                                        t = iter;
                                }
                                break;
@@ -122,8 +128,7 @@ static void split_transaction_timeout_callback(struct timer_list *timer)
        scoped_guard(spinlock_irqsave, &card->transactions.lock) {
                if (list_empty(&t->link))
                        return;
-               list_del(&t->link);
-               card->transactions.tlabel_mask &= ~(1ULL << t->tlabel);
+               remove_transaction_entry(card, t);
        }
 
        if (!t->with_tstamp) {
@@ -1142,8 +1147,7 @@ void fw_core_handle_response(struct fw_card *card, struct fw_packet *p)
                list_for_each_entry(iter, &card->transactions.list, link) {
                        if (iter->node_id == source && iter->tlabel == tlabel) {
                                if (try_cancel_split_timeout(iter)) {
-                                       list_del_init(&iter->link);
-                                       card->transactions.tlabel_mask &= ~(1ULL << iter->tlabel);
+                                       remove_transaction_entry(card, iter);
                                        t = iter;
                                }
                                break;