From nobody Fri Dec 19 20:58:39 2025 Received: from fout7-smtp.messagingengine.com (fout7-smtp.messagingengine.com [103.168.172.150]) (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 D530014F9D7 for ; Mon, 5 Aug 2024 08:54:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=103.168.172.150 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722848070; cv=none; b=GMTx2AwnRkzfXQXFzSu/L0FfYGYm9Z0kPBPu5oIRPLt3tHnphriIwIVZ2bIc+kUHMimPshWUhMgh4YAugA9+7RDzZxlRXYQwTi6c0xqXzTZ2nY/61sGSeTulCJnozapNv8mZJkHNUei09I47obUDiiUU8MMI7e36l6VROH+sdZk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722848070; c=relaxed/simple; bh=byjeyaU0KCacHc1trU6Nd+xN8T9yKFSqZfE68WM9laI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=iEzEOECrVFriNy/abph6ufNdYB2psoYNzGwFWPjB56ttN1XWxHcpo2PWdWBfuPc0j1P87C1drhE+ltsugjLtWPCSVmFjTgHj7wXTYfrHzo2cum48lBv2uqMxoTzVQWXSj11bf1zclUIZz3SbiYXb1xx0aQg8Kh3x56rxNASLHg8= 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=E6LNQtp5; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=p6wXme3m; arc=none smtp.client-ip=103.168.172.150 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="E6LNQtp5"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="p6wXme3m" Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailfout.nyi.internal (Postfix) with ESMTP id 14303138FDDD; Mon, 5 Aug 2024 04:54:28 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute5.internal (MEProxy); Mon, 05 Aug 2024 04:54:28 -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=1722848068; x= 1722934468; bh=p2/8Uhv2yJT1ffx5iSM4w272zr0fR0S1Kk6bKcSHexE=; b=E 6LNQtp5AStedNJslYJ4QMrYROoXOrV+Flv4uwvtC2l3JkgAAkNL8zaGxbO8hxayf TAz5JOVl6STAWdeRWk1UZCBolgvOaDKTuUx/lGuqrP+kB286mrAavMHW/CTEVVRp NgcCa3P7dofnCI4JNwmFPkAvxBxm+I8T3j/1n44Vu509utHXOsPpC8x9+MWYgl9v xnvtv51akvF8xBl6XSE5yF6xNh7fARtgBLXIUkts3LpfJXqoUyE3m3OLKfm8LhB9 IFl/eJ6nAr6COqAFwhMNnRtfCWbjK4dc8FpBKS6c2+SiLIMAN6KSCo/CrvTGlxZk WUxFAsH4aG8i5JAqqwY2w== 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-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm3; t=1722848068; x= 1722934468; bh=p2/8Uhv2yJT1ffx5iSM4w272zr0fR0S1Kk6bKcSHexE=; b=p 6wXme3mvRSKs/ieLIGIZpKQ4z9pJ3xRXwkRDazw2Qsl9lQ4MzHAZ8HgDNrJo4aJR bY8QM3iqnyq5zyru6cMDgdLx2YMYfF9SyjWmbOj2qmAecNGguXMErZtgXX+0Jn5/ lI79F0ir99irRKb41UnFxhNmR4oCBmVdLBf/SfBcVrqzN1EDKcNnjVG6SQDTUKKR fcbBjrShhwVAzkfq6wkwS7zOq09ksmc6dh1Wb4DrMKWu0mwUy/gQYj5I1/wgEo7O Qu75g0BLE8eqMtJXiNoDHjUIj5xYi63FumXvCtqIkoRGqPWQBSxclw9DiBQyeQK5 BzZ1oeqMHkcDo9ObVdI+w== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeftddrkeeigddutdcutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecunecujfgurhephffvvefufffkofgjfhgggfestdekre dtredttdenucfhrhhomhepvfgrkhgrshhhihcuufgrkhgrmhhothhouceoohdqthgrkhgr shhhihesshgrkhgrmhhotggthhhirdhjpheqnecuggftrfgrthhtvghrnhepvdejgfejue dvgfduudekleevtefgtdevhfdtffefiefgveeuteffiedvffekvddtnecuvehluhhsthgv rhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepohdqthgrkhgrshhhihessh grkhgrmhhotggthhhirdhjphdpnhgspghrtghpthhtoheptd X-ME-Proxy: Feedback-ID: ie8e14432:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 5 Aug 2024 04:54:26 -0400 (EDT) From: Takashi Sakamoto To: linux1394-devel@lists.sourceforge.net Cc: linux-kernel@vger.kernel.org Subject: [PATCH v2 12/17] firewire: core: use guard macro to maintain list of receivers for phy configuration packets Date: Mon, 5 Aug 2024 17:54:03 +0900 Message-ID: <20240805085408.251763-13-o-takashi@sakamocchi.jp> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240805085408.251763-1-o-takashi@sakamocchi.jp> References: <20240805085408.251763-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 core function maintains clients to receive phy configuration packets by list in the instance of fw_card. The concurrent access to the list is protected by spinlock in the instance. This commit uses guard macro to maintain the list. Signed-off-by: Takashi Sakamoto --- drivers/firewire/core-cdev.c | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/drivers/firewire/core-cdev.c b/drivers/firewire/core-cdev.c index ac6f9ad9e88e..f32f8667ef2c 100644 --- a/drivers/firewire/core-cdev.c +++ b/drivers/firewire/core-cdev.c @@ -1659,26 +1659,22 @@ static int ioctl_receive_phy_packets(struct client = *client, union ioctl_arg *arg if (!client->device->is_local) return -ENOSYS; =20 - spin_lock_irq(&card->lock); + guard(spinlock_irq)(&card->lock); =20 list_move_tail(&client->phy_receiver_link, &card->phy_receiver_list); client->phy_receiver_closure =3D a->closure; =20 - spin_unlock_irq(&card->lock); - return 0; } =20 void fw_cdev_handle_phy_packet(struct fw_card *card, struct fw_packet *p) { struct client *client; - struct inbound_phy_packet_event *e; - unsigned long flags; =20 - spin_lock_irqsave(&card->lock, flags); + guard(spinlock_irqsave)(&card->lock); =20 list_for_each_entry(client, &card->phy_receiver_list, phy_receiver_link) { - e =3D kmalloc(sizeof(*e) + 8, GFP_ATOMIC); + struct inbound_phy_packet_event *e =3D kmalloc(sizeof(*e) + 8, GFP_ATOMI= C); if (e =3D=3D NULL) break; =20 @@ -1706,8 +1702,6 @@ void fw_cdev_handle_phy_packet(struct fw_card *card, = struct fw_packet *p) queue_event(client, &e->event, &e->phy_packet, sizeof(*pp) + 8, NULL, 0= ); } } - - spin_unlock_irqrestore(&card->lock, flags); } =20 static int (* const ioctl_handlers[])(struct client *, union ioctl_arg *) = =3D { @@ -1855,9 +1849,8 @@ static int fw_device_op_release(struct inode *inode, = struct file *file) struct client *client =3D file->private_data; struct event *event, *next_event; =20 - spin_lock_irq(&client->device->card->lock); - list_del(&client->phy_receiver_link); - spin_unlock_irq(&client->device->card->lock); + scoped_guard(spinlock_irq, &client->device->card->lock) + list_del(&client->phy_receiver_link); =20 scoped_guard(mutex, &client->device->client_list_mutex) list_del(&client->link); --=20 2.43.0