From nobody Mon Feb 9 08:59:51 2026 Received: from fhigh-a1-smtp.messagingengine.com (fhigh-a1-smtp.messagingengine.com [103.168.172.152]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 63ED82BD036 for ; Sat, 1 Nov 2025 10:21:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=103.168.172.152 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1761992501; cv=none; b=SPsvfl02tSZ9XU2+LQuu78FWA3fj3yBmLhvhZpnBmpRiVGu5lB0FjV5oVPohkDZaleeNPP+F62O/LWkB7J7xkYap1Y40qdO8Jun7qv9layK+j5yODoymUlstUcg9VqtXY7hd667LefYJILC+LTJAtHbmSt2EIZ56GzCHY2/Stvk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1761992501; c=relaxed/simple; bh=LzAu6v+8s1WTD9z4jdIwRhHNsNiBTivfpsq38Uy3sWg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=pvsLY4rIhqrD1h973xCEUtVOdOJL3uKReSjcmn9f0llPUZ0pORv1U6a7/Nt3l91TKenumR0Dn/CzTcp8zVXeJBm7ix4ySlfARpkf791M/zneqNkql/W5hf3Enaz//elIp4a5RQ8vnNKHYDKTR5xWYbhWhk/9oLfUbAysbGNL98s= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=sakamocchi.jp; spf=pass smtp.mailfrom=sakamocchi.jp; dkim=pass (2048-bit key) header.d=sakamocchi.jp header.i=@sakamocchi.jp header.b=VYKbdz+C; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=UKlbrhnY; arc=none smtp.client-ip=103.168.172.152 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=sakamocchi.jp Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=sakamocchi.jp Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=sakamocchi.jp header.i=@sakamocchi.jp header.b="VYKbdz+C"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="UKlbrhnY" Received: from phl-compute-05.internal (phl-compute-05.internal [10.202.2.45]) by mailfhigh.phl.internal (Postfix) with ESMTP id 49E6414000EA; Sat, 1 Nov 2025 06:21:37 -0400 (EDT) Received: from phl-mailfrontend-02 ([10.202.2.163]) by phl-compute-05.internal (MEProxy); Sat, 01 Nov 2025 06:21:37 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sakamocchi.jp; h=cc:cc:content-transfer-encoding:content-type:date:date:from :from:in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:subject:subject:to:to; s=fm3; t=1761992497; x= 1762078897; bh=77kuYOsBRwvBh/7lbhnKnv+0cwuxlXHkbL+er1/2V50=; b=V YKbdz+C8UkDbhryRUP5JF93fo1N9oYRBi7BntzgH3EHtf0mawF7LnHEqicGRrJGC yrJ1Xy99rwRu1TAmfqTz3MHW56a5dLzGByc7jrcwK8Aq9VMicdDwMziPm8M6Is4H yLE0FW/aV0vsTtAciFjvLgsd9yzi5tiM0TQLxhPgZLIYQKzUMXr7u6gOhfzOnuGf tWeUitShQ3mGNHZMUKJMIyV9ht5V7QwcYvf8L1+5u3/FOEBMsjGT8c8XWzHjoca0 jsH9n7/yRvv1rdsA6LBtPykoU75uaZwIA/w2PNUWVHVlXx+c4eo+gg4Cpp6k6o3E XnwFx86X7qCpUxz5MxN3g== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:subject:subject:to:to:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm3; t=1761992497; x=1762078897; bh=7 7kuYOsBRwvBh/7lbhnKnv+0cwuxlXHkbL+er1/2V50=; b=UKlbrhnYG48DJ+9gq aoUHA6mc3hEdAw6jDv4ZFcwJdaYVjP1Fk34U72rucURQmRYt++bK8ef7FmCeMGX3 6vX82O+kQLG1fT/zipaFKzlP52QkpaCtNqQZ6X7/P/1mqu4NFMK9yNCuqDXLwncg GT/y8B4Ng8yTZWTdVDY2GelEMCMB7d1d+8pXv5p8ZJKDOwlbF0TRgPhEp1mUUR0n w6qSCAwWJTu+kt5zWiS+5snef/0/6q/GrYu/rbJH/JMIHNhiXgMu+6Ign1WV64TV koy/wPrZWi/cEjXS2DZpT4ZNJHWjbL07g5UoWtwyun6chKl7unHHU3XEHCTqE9pW CSdGw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeffedrtdeggddujedvuddvucetufdoteggodetrf dotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfurfetoffkrfgpnffqhgenuceu rghilhhouhhtmecufedttdenucenucfjughrpefhvfevufffkffojghfggfgsedtkeertd ertddtnecuhfhrohhmpefvrghkrghshhhiucfurghkrghmohhtohcuoehoqdhtrghkrghs hhhisehsrghkrghmohgttghhihdrjhhpqeenucggtffrrghtthgvrhhnpedvjefgjeeuvd fguddukeelveetgfdtvefhtdfffeeigfevueetffeivdffkedvtdenucevlhhushhtvghr ufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehoqdhtrghkrghshhhisehsrg hkrghmohgttghhihdrjhhppdhnsggprhgtphhtthhopedvpdhmohguvgepshhmthhpohhu thdprhgtphhtthhopehlihhnuhigudefleegqdguvghvvghlsehlihhsthhsrdhsohhurh gtvghfohhrghgvrdhnvghtpdhrtghpthhtoheplhhinhhugidqkhgvrhhnvghlsehvghgv rhdrkhgvrhhnvghlrdhorhhg X-ME-Proxy: Feedback-ID: ie8e14432:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Sat, 1 Nov 2025 06:21:36 -0400 (EDT) From: Takashi Sakamoto To: linux1394-devel@lists.sourceforge.net Cc: linux-kernel@vger.kernel.org Subject: [PATCH 1/2] firewire: core: code refactoring to remove transaction entry Date: Sat, 1 Nov 2025 19:21:30 +0900 Message-ID: <20251101102131.925071-2-o-takashi@sakamocchi.jp> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251101102131.925071-1-o-takashi@sakamocchi.jp> References: <20251101102131.925071-1-o-takashi@sakamocchi.jp> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The list operation to remove transaction entry appears several times in transaction implementation and can be replaced with a helper function. Signed-off-by: Takashi Sakamoto --- drivers/firewire/core-transaction.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/drivers/firewire/core-transaction.c b/drivers/firewire/core-tr= ansaction.c index dd3656a0c1ff..8bd79c3f97f2 100644 --- a/drivers/firewire/core-transaction.c +++ b/drivers/firewire/core-transaction.c @@ -44,6 +44,13 @@ static int try_cancel_split_timeout(struct fw_transactio= n *t) return 1; } =20 +// card->transactions.lock must be acquired in advance. +static void remove_transaction_entry(struct fw_card *card, struct fw_trans= action *entry) +{ + list_del_init(&entry->link); + card->transactions.tlabel_mask &=3D ~(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 *trans= action, struct fw_card list_for_each_entry(iter, &card->transactions.list, link) { if (iter =3D=3D transaction) { if (try_cancel_split_timeout(iter)) { - list_del_init(&iter->link); - card->transactions.tlabel_mask &=3D ~(1ULL << iter->tlabel); + remove_transaction_entry(card, iter); t =3D iter; } break; @@ -122,8 +128,7 @@ static void split_transaction_timeout_callback(struct t= imer_list *timer) scoped_guard(spinlock_irqsave, &card->transactions.lock) { if (list_empty(&t->link)) return; - list_del(&t->link); - card->transactions.tlabel_mask &=3D ~(1ULL << t->tlabel); + remove_transaction_entry(card, t); } =20 if (!t->with_tstamp) { @@ -1142,8 +1147,7 @@ void fw_core_handle_response(struct fw_card *card, st= ruct fw_packet *p) list_for_each_entry(iter, &card->transactions.list, link) { if (iter->node_id =3D=3D source && iter->tlabel =3D=3D tlabel) { if (try_cancel_split_timeout(iter)) { - list_del_init(&iter->link); - card->transactions.tlabel_mask &=3D ~(1ULL << iter->tlabel); + remove_transaction_entry(card, iter); t =3D iter; } break; --=20 2.51.0 From nobody Mon Feb 9 08:59:51 2026 Received: from fout-a6-smtp.messagingengine.com (fout-a6-smtp.messagingengine.com [103.168.172.149]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AB11D2C11DB for ; Sat, 1 Nov 2025 10:21:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=103.168.172.149 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1761992502; cv=none; b=Frl53rcf7igilTFuTTip5M7NyF/1OxtOagJzxitFi/kGsHW3b18EUpEJCQbs5qrIiiC6mtBUBemrqcZ4jsGl7ofhJEodTRMsvxqY4zpCpX0IrA76TJhKl2M1qmMAWz4S+o8zbrUcWMt6kjCfvJrZkIOCWRxoP/HHreC+ioYd+Eg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1761992502; c=relaxed/simple; bh=VXvhdCtIF94jIUy9sZM5HOnX/S1loA6RO4drU2W4ZCc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=H1V2qThtTm6UxT3vq3+HYXabDh6rImfnShFP4j6BU/OnPGkPI5TSFipXz7qenq91KnisUo//joR/gBBeCkjqXa9nhkaJdf9LpTQo2aFdXlMrObs7eykDCaIhDTXncWO0t80Q6RIrpt39WM952qDpYZXa2D7TYj3tk3uL+9EMAkg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=sakamocchi.jp; spf=pass smtp.mailfrom=sakamocchi.jp; dkim=pass (2048-bit key) header.d=sakamocchi.jp header.i=@sakamocchi.jp header.b=dpRB9xT/; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=3OGk3Fwt; arc=none smtp.client-ip=103.168.172.149 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=sakamocchi.jp Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=sakamocchi.jp Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=sakamocchi.jp header.i=@sakamocchi.jp header.b="dpRB9xT/"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="3OGk3Fwt" Received: from phl-compute-04.internal (phl-compute-04.internal [10.202.2.44]) by mailfout.phl.internal (Postfix) with ESMTP id 7CC33EC00DA; Sat, 1 Nov 2025 06:21:38 -0400 (EDT) Received: from phl-mailfrontend-02 ([10.202.2.163]) by phl-compute-04.internal (MEProxy); Sat, 01 Nov 2025 06:21:38 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sakamocchi.jp; h=cc:cc:content-transfer-encoding:content-type:date:date:from :from:in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:subject:subject:to:to; s=fm3; t=1761992498; x= 1762078898; bh=VDehe93yxTJXuOHBmVVwaEhZloz0X+dnzSOWWU6PpS0=; b=d pRB9xT/th3Z6KGq5FNgfkfDwJ3WHxkIt7OhcjRU15s7Fpchf3iyDXD+VSnJVbizU co/SeFl7eG5u7N0IskowZYp5WLBFvdwJvSr8U1ODR9GfUH/ROXluE4t+WfZYxNk8 pYppYckAb65PL5HBz/4QzBwy4j1C9i9AsGCbJ4nWJj0/otcuwL67XkeVAHkbp9mx 5OltfhCIAwhGPFNILM8hbg6A52AQss33QGv2V8LMkJxLtbcndTIVp2ZmUiAOD5mE BbtHsfQCyTt4s2lkeqMq+Fz0+dBSO0HiHwtbuiM31KRxxojjJragoWc4Jo1ekfrM 2NITtTE2xFpVfjwJAVSbQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:subject:subject:to:to:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm3; t=1761992498; x=1762078898; bh=V Dehe93yxTJXuOHBmVVwaEhZloz0X+dnzSOWWU6PpS0=; b=3OGk3FwtFXjnGr/w+ zxx4x8lHuoJR9EDRb9VOqWqscWa7yuvG60Zl4cbufXgAtatInHkV954PV0ggH0UF q6A5fb9Jqgo03AOkJYkXpmjkCn1/viNMlFngw9nYXqzc0cVKKN7jGsfiY1eppJve 9oWNkqzpkpEe9x9/NKf5J1uBTqLsP9k5lR1tBskvqAU67zCh2z6/WFmT3j/jo7e+ Yef8VnC1IpGB3G7OLvxQfyKEx4W03UFLYtX4gbHLrDw1v8OM5dtItVGnYjD4e0uE T+hamhZxhrj9Px8pEvkyVhy0ajcXDV5aklcIkFMl7N4xKrB6SgaG5VufhnuQ1rXG pvVVw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeffedrtdeggddujedvuddvucetufdoteggodetrf dotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfurfetoffkrfgpnffqhgenuceu rghilhhouhhtmecufedttdenucenucfjughrpefhvfevufffkffojghfggfgsedtkeertd ertddtnecuhfhrohhmpefvrghkrghshhhiucfurghkrghmohhtohcuoehoqdhtrghkrghs hhhisehsrghkrghmohgttghhihdrjhhpqeenucggtffrrghtthgvrhhnpedvjefgjeeuvd fguddukeelveetgfdtvefhtdfffeeigfevueetffeivdffkedvtdenucevlhhushhtvghr ufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehoqdhtrghkrghshhhisehsrg hkrghmohgttghhihdrjhhppdhnsggprhgtphhtthhopedvpdhmohguvgepshhmthhpohhu thdprhgtphhtthhopehlihhnuhigudefleegqdguvghvvghlsehlihhsthhsrdhsohhurh gtvghfohhrghgvrdhnvghtpdhrtghpthhtoheplhhinhhugidqkhgvrhhnvghlsehvghgv rhdrkhgvrhhnvghlrdhorhhg X-ME-Proxy: Feedback-ID: ie8e14432:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Sat, 1 Nov 2025 06:21:37 -0400 (EDT) From: Takashi Sakamoto To: linux1394-devel@lists.sourceforge.net Cc: linux-kernel@vger.kernel.org Subject: [PATCH 2/2] firewire: core: code refactoring to find and pop transaction entry Date: Sat, 1 Nov 2025 19:21:31 +0900 Message-ID: <20251101102131.925071-3-o-takashi@sakamocchi.jp> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251101102131.925071-1-o-takashi@sakamocchi.jp> References: <20251101102131.925071-1-o-takashi@sakamocchi.jp> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The list operation to find and pop transaction entry appears several times in transaction implementation, and can be replaced with a helper functional macro. Signed-off-by: Takashi Sakamoto --- drivers/firewire/core-transaction.c | 45 ++++++++++++++--------------- 1 file changed, 22 insertions(+), 23 deletions(-) diff --git a/drivers/firewire/core-transaction.c b/drivers/firewire/core-tr= ansaction.c index 8bd79c3f97f2..e80791d6d46b 100644 --- a/drivers/firewire/core-transaction.c +++ b/drivers/firewire/core-transaction.c @@ -51,28 +51,34 @@ static void remove_transaction_entry(struct fw_card *ca= rd, struct fw_transaction card->transactions.tlabel_mask &=3D ~(1ULL << entry->tlabel); } =20 +// card->transactions.lock must be acquired in advance. +#define find_and_pop_transaction_entry(card, condition) \ +({ \ + struct fw_transaction *iter, *t =3D NULL; \ + list_for_each_entry(iter, &card->transactions.list, link) { \ + if (condition) { \ + t =3D iter; \ + break; \ + } \ + } \ + if (t && try_cancel_split_timeout(t)) \ + remove_transaction_entry(card, t); \ + t; \ +}) + static int close_transaction(struct fw_transaction *transaction, struct fw= _card *card, int rcode, u32 response_tstamp) { - struct fw_transaction *t =3D NULL, *iter; + struct fw_transaction *t; =20 // NOTE: This can be without irqsave when we can guarantee that __fw_send= _request() for // local destination never runs in any type of IRQ context. scoped_guard(spinlock_irqsave, &card->transactions.lock) { - list_for_each_entry(iter, &card->transactions.list, link) { - if (iter =3D=3D transaction) { - if (try_cancel_split_timeout(iter)) { - remove_transaction_entry(card, iter); - t =3D iter; - } - break; - } - } + t =3D find_and_pop_transaction_entry(card, iter =3D=3D transaction); + if (!t) + return -ENOENT; } =20 - if (!t) - return -ENOENT; - if (!t->with_tstamp) { t->callback.without_tstamp(card, rcode, NULL, 0, t->callback_data); } else { @@ -1102,7 +1108,7 @@ EXPORT_SYMBOL(fw_core_handle_request); =20 void fw_core_handle_response(struct fw_card *card, struct fw_packet *p) { - struct fw_transaction *t =3D NULL, *iter; + struct fw_transaction *t =3D NULL; u32 *data; size_t data_length; int tcode, tlabel, source, rcode; @@ -1144,15 +1150,8 @@ void fw_core_handle_response(struct fw_card *card, s= truct fw_packet *p) // NOTE: This can be without irqsave when we can guarantee that __fw_send= _request() for // local destination never runs in any type of IRQ context. scoped_guard(spinlock_irqsave, &card->transactions.lock) { - list_for_each_entry(iter, &card->transactions.list, link) { - if (iter->node_id =3D=3D source && iter->tlabel =3D=3D tlabel) { - if (try_cancel_split_timeout(iter)) { - remove_transaction_entry(card, iter); - t =3D iter; - } - break; - } - } + t =3D find_and_pop_transaction_entry(card, + iter->node_id =3D=3D source && iter->tlabel =3D=3D tlabel); } =20 trace_async_response_inbound((uintptr_t)t, card->index, p->generation, p-= >speed, p->ack, --=20 2.51.0