Skip to content

Commit ddc021b

Browse files
committed
firewire: core: code refactoring to remove transaction entry
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>
1 parent b330f98 commit ddc021b

1 file changed

Lines changed: 10 additions & 6 deletions

File tree

drivers/firewire/core-transaction.c

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,13 @@ static int try_cancel_split_timeout(struct fw_transaction *t)
4444
return 1;
4545
}
4646

47+
// card->transactions.lock must be acquired in advance.
48+
static void remove_transaction_entry(struct fw_card *card, struct fw_transaction *entry)
49+
{
50+
list_del_init(&entry->link);
51+
card->transactions.tlabel_mask &= ~(1ULL << entry->tlabel);
52+
}
53+
4754
static int close_transaction(struct fw_transaction *transaction, struct fw_card *card, int rcode,
4855
u32 response_tstamp)
4956
{
@@ -55,8 +62,7 @@ static int close_transaction(struct fw_transaction *transaction, struct fw_card
5562
list_for_each_entry(iter, &card->transactions.list, link) {
5663
if (iter == transaction) {
5764
if (try_cancel_split_timeout(iter)) {
58-
list_del_init(&iter->link);
59-
card->transactions.tlabel_mask &= ~(1ULL << iter->tlabel);
65+
remove_transaction_entry(card, iter);
6066
t = iter;
6167
}
6268
break;
@@ -122,8 +128,7 @@ static void split_transaction_timeout_callback(struct timer_list *timer)
122128
scoped_guard(spinlock_irqsave, &card->transactions.lock) {
123129
if (list_empty(&t->link))
124130
return;
125-
list_del(&t->link);
126-
card->transactions.tlabel_mask &= ~(1ULL << t->tlabel);
131+
remove_transaction_entry(card, t);
127132
}
128133

129134
if (!t->with_tstamp) {
@@ -1142,8 +1147,7 @@ void fw_core_handle_response(struct fw_card *card, struct fw_packet *p)
11421147
list_for_each_entry(iter, &card->transactions.list, link) {
11431148
if (iter->node_id == source && iter->tlabel == tlabel) {
11441149
if (try_cancel_split_timeout(iter)) {
1145-
list_del_init(&iter->link);
1146-
card->transactions.tlabel_mask &= ~(1ULL << iter->tlabel);
1150+
remove_transaction_entry(card, iter);
11471151
t = iter;
11481152
}
11491153
break;

0 commit comments

Comments
 (0)