From nobody Fri Oct 3 02:17:19 2025 Received: from fhigh-a2-smtp.messagingengine.com (fhigh-a2-smtp.messagingengine.com [103.168.172.153]) (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 35EFC15E97 for ; Mon, 8 Sep 2025 01:21:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=103.168.172.153 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757294479; cv=none; b=lTVT/04snMtz/gAiD4Jg6WLJXsY5B60RaYwbiTIi/wlb0ygj83MIl/0nfRUasH9kuvIKH9TcVlZYjsAOfhbnzYOomDdTviR2XR+fGzPtTn0XXnM3uqH+eo3grvVDewfLdEPobmEY/BFCBdTttesDTD+kcfhqTS710KA8QNMeqzA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757294479; c=relaxed/simple; bh=BwIw5chTj+JYj7x6Gcc0ICDdS/qolqQ0C2AKuuTEPAY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=YF3bnj9Ee438A48aqknDHktx+ApTDENH5oRk1QanQiMA8Qs3zzjvzOKUBPU9mhMogN6vQ/pYz9B3pzFkHuYMy3vw/RWLiKhJkflR4BajV/HTWGddJpkSpaclz8joPCBznfwUNd7sa3h6yLeEDoCSVn14InqhVonRFGNjHu53g0c= 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=ID95PfqI; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=WYbXacV9; arc=none smtp.client-ip=103.168.172.153 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="ID95PfqI"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="WYbXacV9" Received: from phl-compute-04.internal (phl-compute-04.internal [10.202.2.44]) by mailfhigh.phl.internal (Postfix) with ESMTP id 32A3C140002E; Sun, 7 Sep 2025 21:21:15 -0400 (EDT) Received: from phl-mailfrontend-01 ([10.202.2.162]) by phl-compute-04.internal (MEProxy); Sun, 07 Sep 2025 21:21:15 -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=fm1; t=1757294475; x= 1757380875; bh=IU8eRzIzzoCn+klvIX+UYvGJSjMoL3fwFs3HuV6Tx0Y=; b=I D95PfqI9f2K5md/n+nf0Mak+y3mA5wjL2mTxlRKuE1Jzgqj9KvdaY0lA5VM6Btg7 nq0fWJFI+gHm0OZEKO9cstNkPa2k0STVRnaxKCVifdNVboGZpeJlnr5oyW6FUIvA b+fuQFSRIUJSzNahIBREogdAMGaQ22YbtqqstwPT66ce3RKDKCoueKKkgiqquLGA Rt5iFrSuZGZwoOhpj7LmaoThzmmF8FNc8zsVKN2H2WQ36bStaCxr7P+XXVOGDn8G 9jVgQMUBcT6Xje10t87jG08AJZfxHzZ2bXiNbXL5f2c9sfvcLO+kyx1kmsmhznuR xwfk6RFqBveVZK5Vgg5mA== 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=fm1; t=1757294475; x=1757380875; bh=I U8eRzIzzoCn+klvIX+UYvGJSjMoL3fwFs3HuV6Tx0Y=; b=WYbXacV9FMlwlTKdy DXue8RWTHoZJgFPnr8/Pe65z2OvtYNMNd1RbsPGatA1KxJsEvV32ElYfMIt8166U jmmf22d4jMlEa836CJfjomrSun24lbQT//iF2uYqZSMDP3EQUaFRyBuOEl5R+W40 22wszK+ZuEJPlkk8lGFUf0hQnThgJVoh9IwC02UCqJQmk6yKdBvSoccI4qWnhVep Np4XbZU3t0EFtx4wdPqmPDnrDHWgkrM9RBMF7DlisVm5OfsfHYEZ+xrVokQ7W1ia sjuAQwttaYrqUNEzXD19OQIBft18otPntG2SgXnR84rG1Lqfg+MnsYfi8ozMeoHk HlGgA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeffedrtdeggdduiedulecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpuffrtefokffrpgfnqfghnecuuegr ihhlohhuthemuceftddtnecunecujfgurhephffvvefufffkofgjfhgggfestdekredtre dttdenucfhrhhomhepvfgrkhgrshhhihcuufgrkhgrmhhothhouceoohdqthgrkhgrshhh ihesshgrkhgrmhhotggthhhirdhjpheqnecuggftrfgrthhtvghrnhepvdejgfejuedvgf duudekleevtefgtdevhfdtffefiefgveeuteffiedvffekvddtnecuvehluhhsthgvrhfu ihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepohdqthgrkhgrshhhihesshgrkh grmhhotggthhhirdhjphdpnhgspghrtghpthhtohepvddpmhhouggvpehsmhhtphhouhht pdhrtghpthhtoheplhhinhhugidufeelgedquggvvhgvlheslhhishhtshdrshhouhhrtg gvfhhorhhgvgdrnhgvthdprhgtphhtthhopehlihhnuhigqdhkvghrnhgvlhesvhhgvghr rdhkvghrnhgvlhdrohhrgh X-ME-Proxy: Feedback-ID: ie8e14432:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Sun, 7 Sep 2025 21:21:14 -0400 (EDT) From: Takashi Sakamoto To: linux1394-devel@lists.sourceforge.net Cc: linux-kernel@vger.kernel.org Subject: [PATCH 01/11] firewire: ohci: use kcalloc() variant for array allocation Date: Mon, 8 Sep 2025 10:20:58 +0900 Message-ID: <20250908012108.514698-2-o-takashi@sakamocchi.jp> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250908012108.514698-1-o-takashi@sakamocchi.jp> References: <20250908012108.514698-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" When allocating the list of isochronous context structure, a kzalloc() variant of managed device API is used. In this case, a kcalloc() variant is available. This commit replaces these lines with devm_kcalloc(). Signed-off-by: Takashi Sakamoto --- drivers/firewire/ohci.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/drivers/firewire/ohci.c b/drivers/firewire/ohci.c index 40851b120615..030aed5453a1 100644 --- a/drivers/firewire/ohci.c +++ b/drivers/firewire/ohci.c @@ -3482,7 +3482,6 @@ static int pci_probe(struct pci_dev *dev, u32 bus_options, max_receive, link_speed, version; u64 guid; int i, flags, irq, err; - size_t size; =20 if (dev->vendor =3D=3D PCI_VENDOR_ID_PINNACLE_SYSTEMS) { dev_err(&dev->dev, "Pinnacle MovieBoard is not yet supported\n"); @@ -3576,8 +3575,7 @@ static int pci_probe(struct pci_dev *dev, reg_write(ohci, OHCI1394_IsoRecvIntMaskClear, ~0); ohci->ir_context_mask =3D ohci->ir_context_support; ohci->n_ir =3D hweight32(ohci->ir_context_mask); - size =3D sizeof(struct iso_context) * ohci->n_ir; - ohci->ir_context_list =3D devm_kzalloc(&dev->dev, size, GFP_KERNEL); + ohci->ir_context_list =3D devm_kcalloc(&dev->dev, ohci->n_ir, sizeof(stru= ct iso_context), GFP_KERNEL); if (!ohci->ir_context_list) return -ENOMEM; =20 @@ -3591,8 +3589,7 @@ static int pci_probe(struct pci_dev *dev, reg_write(ohci, OHCI1394_IsoXmitIntMaskClear, ~0); ohci->it_context_mask =3D ohci->it_context_support; ohci->n_it =3D hweight32(ohci->it_context_mask); - size =3D sizeof(struct iso_context) * ohci->n_it; - ohci->it_context_list =3D devm_kzalloc(&dev->dev, size, GFP_KERNEL); + ohci->it_context_list =3D devm_kcalloc(&dev->dev, ohci->n_it, sizeof(stru= ct iso_context), GFP_KERNEL); if (!ohci->it_context_list) return -ENOMEM; =20 --=20 2.48.1 From nobody Fri Oct 3 02:17:19 2025 Received: from fhigh-a2-smtp.messagingengine.com (fhigh-a2-smtp.messagingengine.com [103.168.172.153]) (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 BA4B219F13F for ; Mon, 8 Sep 2025 01:21:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=103.168.172.153 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757294479; cv=none; b=QaeWiPA1VKsYsy/JhmbEU/neKclw8sgkZYqCtib1sKwUPut7fFIXa2gp2ctI4irG06ocr+Mm3B7uk/X9CaSeNgTXnJUkyHUvV8NR+k7lpwAEevVIatOZZV1CBUOSFdt1QwTxvJEs5WwGYS9NQ/EkY1Wo3SDZ6IZFbA2fSZPqhHY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757294479; c=relaxed/simple; bh=WAQYN5+cHgOSWk2CN7pDhjYQd0Ix42e4/wJ2L5ZVpyc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=er9x9Nxfxm8KhbL3gCIqcnjBf34hDtDFzqy87RzaoXkH1R+Ul+kea0/6RD/NqY3T20GW+uZGkM6KxJJZdJhT0FEMisnfRxbrJw7Saoz1VQejbgX5G5D+uarKW2EZJbTSj2dvvm768kMNuWTG3ZqeUP/pEdr/86Jqj0yS1SrAO2w= 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=sjs+Rkr8; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=dga+qsR3; arc=none smtp.client-ip=103.168.172.153 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="sjs+Rkr8"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="dga+qsR3" Received: from phl-compute-11.internal (phl-compute-11.internal [10.202.2.51]) by mailfhigh.phl.internal (Postfix) with ESMTP id A8C761400013; Sun, 7 Sep 2025 21:21:16 -0400 (EDT) Received: from phl-mailfrontend-01 ([10.202.2.162]) by phl-compute-11.internal (MEProxy); Sun, 07 Sep 2025 21:21:16 -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=fm1; t=1757294476; x= 1757380876; bh=ORliYewnYZlo6BK2CHJ6vPurP1L4VVoWaqONrnniiRY=; b=s js+Rkr8KpUnKs2CXhaBwSbjFNt8Bkl/WIl2TxNMgQIsyPBWvNIDXRmlPvG7ZEKMH CCSLAt3dTaCpXOyXySo8SFAI82bmgOoKQmY1RbCNqyh+7GA9xu8NNTMUUQe8i8Ru ylNfJKrHFWQ6wczhlT8iE2IK0KAlwNS+z/3t+FwzRQUwV+4gi0ZKkjw4rQaXujz1 7eDwTvwDMDu7+7vAC8C1evvRk1h/14e/9kAcSVnScHP2cR8cp8QbzwW39/D4AUEM ToGqXPch4WQq6dg5KjsylYDtHCLGYlGvogh1Qa/JS4AtcvA/QMax8U9jZtKh3GQh ryuSMUcimFXR5rBxYNfCg== 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=fm1; t=1757294476; x=1757380876; bh=O RliYewnYZlo6BK2CHJ6vPurP1L4VVoWaqONrnniiRY=; b=dga+qsR3Op+h47ujO JY77MDX269onrIQo3h7HDSnuaErlhWZwjWTmqZ5v00ypGWClNtPmPN4MKc3EvvmJ 94xWjMFKAE3zsI1zwDZlMwFo+djgOKNS0oJg/E/ttmqFDBGvr5+CPOBHvjt0u0kb C5VAAMLhJgDJzk8oDkvfFKdKyBsV/LWl90mwkjMOqwXjO8aStorU8zgFlvrEkFkQ 0LhYNiR531Jgsy21wvCvm3o7iNeJzfxdgeEFcl4L2Ngz7fn4jYCKNr7wlxlIQXFJ y1GMfaT1bnaasWhslnhiFR2B7JzgBCCB5h8f+xNIp7OgxPZo+mx2g6vKTWdspnwh Qi9dQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeffedrtdeggdduiedulecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpuffrtefokffrpgfnqfghnecuuegr ihhlohhuthemuceftddtnecunecujfgurhephffvvefufffkofgjfhgggfestdekredtre dttdenucfhrhhomhepvfgrkhgrshhhihcuufgrkhgrmhhothhouceoohdqthgrkhgrshhh ihesshgrkhgrmhhotggthhhirdhjpheqnecuggftrfgrthhtvghrnhepvdejgfejuedvgf duudekleevtefgtdevhfdtffefiefgveeuteffiedvffekvddtnecuvehluhhsthgvrhfu ihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepohdqthgrkhgrshhhihesshgrkh grmhhotggthhhirdhjphdpnhgspghrtghpthhtohepvddpmhhouggvpehsmhhtphhouhht pdhrtghpthhtoheplhhinhhugidufeelgedquggvvhgvlheslhhishhtshdrshhouhhrtg gvfhhorhhgvgdrnhgvthdprhgtphhtthhopehlihhnuhigqdhkvghrnhgvlhesvhhgvghr rdhkvghrnhgvlhdrohhrgh X-ME-Proxy: Feedback-ID: ie8e14432:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Sun, 7 Sep 2025 21:21:15 -0400 (EDT) From: Takashi Sakamoto To: linux1394-devel@lists.sourceforge.net Cc: linux-kernel@vger.kernel.org Subject: [PATCH 02/11] firewire: core: utilize cleanup function to release workqueue in error path Date: Mon, 8 Sep 2025 10:20:59 +0900 Message-ID: <20250908012108.514698-3-o-takashi@sakamocchi.jp> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250908012108.514698-1-o-takashi@sakamocchi.jp> References: <20250908012108.514698-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 helper macro, retain_and_null_ptr(), introduced by a commit 092d00ead733 ("cleanup: Provide retain_and_null_ptr()") in v6.16 kernel, is useful in the error path to release the part of structure member. This commit uses the relatively new function. Signed-off-by: Takashi Sakamoto --- drivers/firewire/core-card.c | 40 ++++++++++++++++++++---------------- 1 file changed, 22 insertions(+), 18 deletions(-) diff --git a/drivers/firewire/core-card.c b/drivers/firewire/core-card.c index aae774e7a5c3..d128c7a8bf5f 100644 --- a/drivers/firewire/core-card.c +++ b/drivers/firewire/core-card.c @@ -570,9 +570,13 @@ void fw_card_initialize(struct fw_card *card, } EXPORT_SYMBOL(fw_card_initialize); =20 +DEFINE_FREE(workqueue_destroy, struct workqueue_struct *, if (_T) destroy_= workqueue(_T)) + int fw_card_add(struct fw_card *card, u32 max_receive, u32 link_speed, u64= guid, unsigned int supported_isoc_contexts) { + struct workqueue_struct *isoc_wq __free(workqueue_destroy) =3D NULL; + struct workqueue_struct *async_wq __free(workqueue_destroy) =3D NULL; int ret; =20 // This workqueue should be: @@ -587,10 +591,10 @@ int fw_card_add(struct fw_card *card, u32 max_receive= , u32 link_speed, u64 guid, // * =3D=3D WQ_SYSFS Parameters are available via sysfs. // * max_active =3D=3D n_it + n_ir A hardIRQ could notify events for mul= tiple isochronous // contexts if they are scheduled to the same cycle. - card->isoc_wq =3D alloc_workqueue("firewire-isoc-card%u", - WQ_UNBOUND | WQ_FREEZABLE | WQ_HIGHPRI | WQ_SYSFS, - supported_isoc_contexts, card->index); - if (!card->isoc_wq) + isoc_wq =3D alloc_workqueue("firewire-isoc-card%u", + WQ_UNBOUND | WQ_FREEZABLE | WQ_HIGHPRI | WQ_SYSFS, + supported_isoc_contexts, card->index); + if (!isoc_wq) return -ENOMEM; =20 // This workqueue should be: @@ -602,14 +606,14 @@ int fw_card_add(struct fw_card *card, u32 max_receive= , u32 link_speed, u64 guid, // * =3D=3D WQ_SYSFS Parameters are available via sysfs. // * max_active =3D=3D 4 A hardIRQ could notify events for a pair of re= quests and // response AR/AT contexts. - card->async_wq =3D alloc_workqueue("firewire-async-card%u", - WQ_UNBOUND | WQ_MEM_RECLAIM | WQ_FREEZABLE | WQ_HIGHPRI | WQ_SYSFS, - 4, card->index); - if (!card->async_wq) { - ret =3D -ENOMEM; - goto err_isoc; - } + async_wq =3D alloc_workqueue("firewire-async-card%u", + WQ_UNBOUND | WQ_MEM_RECLAIM | WQ_FREEZABLE | WQ_HIGHPRI | WQ_SYSFS, + 4, card->index); + if (!async_wq) + return -ENOMEM; =20 + card->isoc_wq =3D isoc_wq; + card->async_wq =3D async_wq; card->max_receive =3D max_receive; card->link_speed =3D link_speed; card->guid =3D guid; @@ -617,18 +621,18 @@ int fw_card_add(struct fw_card *card, u32 max_receive= , u32 link_speed, u64 guid, scoped_guard(mutex, &card_mutex) { generate_config_rom(card, tmp_config_rom); ret =3D card->driver->enable(card, tmp_config_rom, config_rom_length); - if (ret < 0) - goto err_async; + if (ret < 0) { + card->isoc_wq =3D NULL; + card->async_wq =3D NULL; + return ret; + } + retain_and_null_ptr(isoc_wq); + retain_and_null_ptr(async_wq); =20 list_add_tail(&card->link, &card_list); } =20 return 0; -err_async: - destroy_workqueue(card->async_wq); -err_isoc: - destroy_workqueue(card->isoc_wq); - return ret; } EXPORT_SYMBOL(fw_card_add); =20 --=20 2.48.1 From nobody Fri Oct 3 02:17:19 2025 Received: from fout-a3-smtp.messagingengine.com (fout-a3-smtp.messagingengine.com [103.168.172.146]) (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 0EFBA1A5B8B for ; Mon, 8 Sep 2025 01:21:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=103.168.172.146 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757294480; cv=none; b=SCw3FGd1Q+bXv6g5kX6RiQU+ZZHKGO2QkDp0xyAiy5hZeDvHXguLgncxQHUyvcjj3DpYUCMmDZpPGzDDnbJv4EH/QLMnKN0zLmaKRafhaF2N6qx73GbRz4PhfDyzICS0PfBZ6bOgMic1D0QNvMchlqmv2nQla1r3RUVgHdbl22Q= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757294480; c=relaxed/simple; bh=5ULHdccKNb4AQvYbXXvPgsynluSrbowxO6ZXAto5onI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Z1z77NJsZrSJxbdYJO5P7W7FZr0Zy36VjIc7Tj2uhqxRR3zf0WTtW9eZoOCM6nDs9YiaRj2sNLEIGImiXq/DNrGcTTuFBOfW+j6RdUR9CAUQHAAJMxCm3hO70cCkaI3tAXbL3SD4MquouH4QpfbqS6O1QPNAWmZSFCN2lgRys/s= 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=HL6eCRId; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=neymfP6i; arc=none smtp.client-ip=103.168.172.146 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="HL6eCRId"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="neymfP6i" Received: from phl-compute-11.internal (phl-compute-11.internal [10.202.2.51]) by mailfout.phl.internal (Postfix) with ESMTP id 0EDA1EC005A; Sun, 7 Sep 2025 21:21:18 -0400 (EDT) Received: from phl-mailfrontend-01 ([10.202.2.162]) by phl-compute-11.internal (MEProxy); Sun, 07 Sep 2025 21:21:18 -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=fm1; t=1757294478; x= 1757380878; bh=uchyU61E1WIGg/6ydRyc3JrxwAu4U5r2JO2FznzjLnk=; b=H L6eCRIdp4ivv+I2DZSCdwkbr1hiRCnAowS3Wx78c7PMtnnBFazulA/pkQ0rQXuns 5+Xt6F4eg3b0hidzycnMU5J/5dt7pDbhvQgd3IVFkYR5TsCAZWUUHaSoaaZmxNbQ 0gwpmcXWkShsLXB0+AEkyFE47KNNB20Kcic51184GkHI9gGpMtvFVznrgHxL6DBK yajFmocniauz/CdiRasxS173Aq0bXMhQpk6DPVLGeYSLtmBZjrIFlSxPMhwSuRdn vqeyhuWPFvsKMzOS9ynko0mKmSL5jJCaTD8JYYIPgLb5iWSN3r17n9rvgNvcMOvT 5upRWu9L/1DK/6JoIMSCw== 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=fm1; t=1757294478; x=1757380878; bh=u chyU61E1WIGg/6ydRyc3JrxwAu4U5r2JO2FznzjLnk=; b=neymfP6iC68HIfFfw SpGTYrE7pgR7uLD0RKGp2zRfw5kUyqcm1VXAl1+Klr1ROtEQUC5fv+5CbrNfee4/ o9QbSOYFrwDsQhGWmQC1IGYLq5yxtWuM2CPCCFFipYBPEJxVAJL1TmoHs4qiciR8 0RtGQ8T3maVE3XidVGY1dAMEJLNoW6NCLBNFQZA4nNFnPsF+mx6Hu4tpmllRbvoU nSdLDrtz0myfoSxqLyprmQIxuYKnDNtFwhu/yzN4SwpvA+mAZvX9f8yZTcFSY+Tf CNHVbmsUsD6SxjQ9QX+65vdQYL9pKoo9N2EmO0Dc/feOH/4Zw5W//fkHhvVtPOun 6KErg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeffedrtdeggdduiedulecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpuffrtefokffrpgfnqfghnecuuegr ihhlohhuthemuceftddtnecunecujfgurhephffvvefufffkofgjfhgggfestdekredtre dttdenucfhrhhomhepvfgrkhgrshhhihcuufgrkhgrmhhothhouceoohdqthgrkhgrshhh ihesshgrkhgrmhhotggthhhirdhjpheqnecuggftrfgrthhtvghrnhepvdejgfejuedvgf duudekleevtefgtdevhfdtffefiefgveeuteffiedvffekvddtnecuvehluhhsthgvrhfu ihiivgepudenucfrrghrrghmpehmrghilhhfrhhomhepohdqthgrkhgrshhhihesshgrkh grmhhotggthhhirdhjphdpnhgspghrtghpthhtohepvddpmhhouggvpehsmhhtphhouhht pdhrtghpthhtoheplhhinhhugidufeelgedquggvvhgvlheslhhishhtshdrshhouhhrtg gvfhhorhhgvgdrnhgvthdprhgtphhtthhopehlihhnuhigqdhkvghrnhgvlhesvhhgvghr rdhkvghrnhgvlhdrohhrgh X-ME-Proxy: Feedback-ID: ie8e14432:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Sun, 7 Sep 2025 21:21:16 -0400 (EDT) From: Takashi Sakamoto To: linux1394-devel@lists.sourceforge.net Cc: linux-kernel@vger.kernel.org Subject: [PATCH 03/11] firewire: ohci: use return value from fw_node_get() Date: Mon, 8 Sep 2025 10:21:00 +0900 Message-ID: <20250908012108.514698-4-o-takashi@sakamocchi.jp> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250908012108.514698-1-o-takashi@sakamocchi.jp> References: <20250908012108.514698-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 programming pattern, referring after increasing reference count, is supported by fw_node_get(). This commit simplify the programming pattern. Signed-off-by: Takashi Sakamoto --- drivers/firewire/core-card.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/firewire/core-card.c b/drivers/firewire/core-card.c index d128c7a8bf5f..41902dcc10a0 100644 --- a/drivers/firewire/core-card.c +++ b/drivers/firewire/core-card.c @@ -306,8 +306,7 @@ static void bm_work(struct work_struct *work) =20 generation =3D card->generation; =20 - root_node =3D card->root_node; - fw_node_get(root_node); + root_node =3D fw_node_get(card->root_node); root_device =3D root_node->data; root_device_is_running =3D root_device && atomic_read(&root_device->state) =3D=3D FW_DEVICE_RUNNING; --=20 2.48.1 From nobody Fri Oct 3 02:17:19 2025 Received: from fout-a3-smtp.messagingengine.com (fout-a3-smtp.messagingengine.com [103.168.172.146]) (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 5DD601C3C11 for ; Mon, 8 Sep 2025 01:21:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=103.168.172.146 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757294482; cv=none; b=YbEBpJwi2QcAtzmXTTx5wYXydVtaTJi315M0SIuY3PA+zoDNhZjJ6EVM3PtNvX95j0rx4MCFtBg2F60QWGaBE4C7dmclmvSqOjM6lGLhaKxwvY9cI32jVbFhXcjntii8szJPYYgqyc1WgLSJJdViSrnZ9Y1ulu3vFSIylaxf45Y= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757294482; c=relaxed/simple; bh=c4HtsegVi3uw9RorKzEf9C5EDnAVZTi4VD9ITXs7jYk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=c2bv0sgVo+T3mB68Z8Jev+b+TXwR5gKUSaRclprant8Y0jpKMA5lIf52Ua5ZuZjSCEUoRYFdp5su6SNvfRwJatbbR8/U7t/8poo4r3k7FCCbC4vS2dtfD3nNF3CFiJuNUusGE2z9H5udgdBDee5L9HxvX2QojRNBazLKRXd5M00= 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=LUbNN6nY; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=NrAEHOZG; arc=none smtp.client-ip=103.168.172.146 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="LUbNN6nY"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="NrAEHOZG" Received: from phl-compute-11.internal (phl-compute-11.internal [10.202.2.51]) by mailfout.phl.internal (Postfix) with ESMTP id 7A0E1EC007B; Sun, 7 Sep 2025 21:21:19 -0400 (EDT) Received: from phl-mailfrontend-01 ([10.202.2.162]) by phl-compute-11.internal (MEProxy); Sun, 07 Sep 2025 21:21:19 -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=fm1; t=1757294479; x= 1757380879; bh=VnQqzEe4MIZzE9rsM4hqaAJTPrsvj4NXRFbWU+fyj6g=; b=L UbNN6nYXHbf8e8gxRWAsbkmQJhBC1+f/l21su8w4hWVoTfF88WMwgKFxHMiN+ns0 LXcTq1/oOgR3YEBpZZ8Hquu/+XfL+l26EWV9rKSkOdM3ZZlMcUQvcG90z7B/ES2m AxEuFK+pZaVAIE1pL7+U2qGuDnSTQswUe01KbZcj1dWtqpJBVapxA5xh0IZCc5kM GNiANm/4ezkVLX7DXlAuqs5ZIlwXYbCd3z3RyISDJTjtmGi39TDoKGSeJQRDeSsn suyUgyzBmS6SR9DpWk7RMDvk4S9oQZKW2rzgZ/2gk4yIHdv5vkqR9iphghKkpalM p3P4QDb1ECrcrJKNW4mXA== 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=fm1; t=1757294479; x=1757380879; bh=V nQqzEe4MIZzE9rsM4hqaAJTPrsvj4NXRFbWU+fyj6g=; b=NrAEHOZGBrACcP2ji i/S/QWBzQrlw+Tbb5tlHvGeV4qTmovOSINBFqbo/4h+ubcDhoq/Pw4O9h9KocsGZ RqRor/VxLh6No6QOvmI47RO+QioxGeXGvnq9bHpJ6ZDrOI5NXonAi7jvL78S2VPD UHMUN65M4TAcBhsdTImCFpzoBuiTRzMDTRvAYczd6mGnGpdegxTr5xw0gzaOjbtd H9C81GrzLrCEnV45I3pDgRpMREQpBi+5xidt8cTAfIOHTtr32Y63FtdBHgPBSatx RCRzdv2nzLKQBpLO729JmWQZsAPXiK0ZuW2q2vdDOAD+W3OAdma9BX/KHgS4uwLU HsIWg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeffedrtdeggdduiedulecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpuffrtefokffrpgfnqfghnecuuegr ihhlohhuthemuceftddtnecunecujfgurhephffvvefufffkofgjfhgggfestdekredtre dttdenucfhrhhomhepvfgrkhgrshhhihcuufgrkhgrmhhothhouceoohdqthgrkhgrshhh ihesshgrkhgrmhhotggthhhirdhjpheqnecuggftrfgrthhtvghrnhepvdejgfejuedvgf duudekleevtefgtdevhfdtffefiefgveeuteffiedvffekvddtnecuvehluhhsthgvrhfu ihiivgepudenucfrrghrrghmpehmrghilhhfrhhomhepohdqthgrkhgrshhhihesshgrkh grmhhotggthhhirdhjphdpnhgspghrtghpthhtohepvddpmhhouggvpehsmhhtphhouhht pdhrtghpthhtoheplhhinhhugidufeelgedquggvvhgvlheslhhishhtshdrshhouhhrtg gvfhhorhhgvgdrnhgvthdprhgtphhtthhopehlihhnuhigqdhkvghrnhgvlhesvhhgvghr rdhkvghrnhgvlhdrohhrgh X-ME-Proxy: Feedback-ID: ie8e14432:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Sun, 7 Sep 2025 21:21:18 -0400 (EDT) From: Takashi Sakamoto To: linux1394-devel@lists.sourceforge.net Cc: linux-kernel@vger.kernel.org Subject: [PATCH 04/11] firewire: core: add helper functions to access to fw_device data in fw_node structure Date: Mon, 8 Sep 2025 10:21:01 +0900 Message-ID: <20250908012108.514698-5-o-takashi@sakamocchi.jp> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250908012108.514698-1-o-takashi@sakamocchi.jp> References: <20250908012108.514698-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 data mbmer in fw_node structure is an opaque pointer, while nowadays it is just used to refer to fw_device associated with the fw_node. This commit redefines the opaque pointer to a pointer to fw_device structure, and adds some helper functions to set/get it. Signed-off-by: Takashi Sakamoto --- drivers/firewire/core-card.c | 4 ++-- drivers/firewire/core-device.c | 18 +++++++++--------- drivers/firewire/core.h | 14 ++++++++++++-- 3 files changed, 23 insertions(+), 13 deletions(-) diff --git a/drivers/firewire/core-card.c b/drivers/firewire/core-card.c index 41902dcc10a0..4a4210cda571 100644 --- a/drivers/firewire/core-card.c +++ b/drivers/firewire/core-card.c @@ -307,12 +307,12 @@ static void bm_work(struct work_struct *work) generation =3D card->generation; =20 root_node =3D fw_node_get(card->root_node); - root_device =3D root_node->data; + root_device =3D fw_node_get_device(root_node); root_device_is_running =3D root_device && atomic_read(&root_device->state) =3D=3D FW_DEVICE_RUNNING; root_device_is_cmc =3D root_device && root_device->cmc; =20 - irm_device =3D card->irm_node->data; + irm_device =3D fw_node_get_device(card->irm_node); irm_is_1394_1995_only =3D irm_device && irm_device->config_rom && (irm_device->config_rom[2] & 0x000000f0) =3D=3D 0; =20 diff --git a/drivers/firewire/core-device.c b/drivers/firewire/core-device.c index aeacd4cfd694..6a04a0014694 100644 --- a/drivers/firewire/core-device.c +++ b/drivers/firewire/core-device.c @@ -887,7 +887,7 @@ static void fw_device_release(struct device *dev) * bus manager work looks at this node. */ scoped_guard(spinlock_irqsave, &card->lock) - device->node->data =3D NULL; + fw_node_set_device(device->node, NULL); =20 fw_node_put(device->node); kfree(device->config_rom); @@ -1007,7 +1007,7 @@ static void fw_device_init(struct work_struct *work) int ret; =20 /* - * All failure paths here set node->data to NULL, so that we + * All failure paths here call fw_node_set_device(node, NULL), so that we * don't try to do device_for_each_child() on a kfree()'d * device. */ @@ -1051,9 +1051,9 @@ static void fw_device_init(struct work_struct *work) struct fw_node *obsolete_node =3D reused->node; =20 device->node =3D obsolete_node; - device->node->data =3D device; + fw_node_set_device(device->node, device); reused->node =3D current_node; - reused->node->data =3D reused; + fw_node_set_device(reused->node, reused); =20 reused->max_speed =3D device->max_speed; reused->node_id =3D current_node->node_id; @@ -1292,7 +1292,7 @@ void fw_node_event(struct fw_card *card, struct fw_no= de *node, int event) * FW_NODE_UPDATED callbacks can update the node_id * and generation for the device. */ - node->data =3D device; + fw_node_set_device(node, device); =20 /* * Many devices are slow to respond after bus resets, @@ -1307,7 +1307,7 @@ void fw_node_event(struct fw_card *card, struct fw_no= de *node, int event) =20 case FW_NODE_INITIATED_RESET: case FW_NODE_LINK_ON: - device =3D node->data; + device =3D fw_node_get_device(node); if (device =3D=3D NULL) goto create; =20 @@ -1324,7 +1324,7 @@ void fw_node_event(struct fw_card *card, struct fw_no= de *node, int event) break; =20 case FW_NODE_UPDATED: - device =3D node->data; + device =3D fw_node_get_device(node); if (device =3D=3D NULL) break; =20 @@ -1339,7 +1339,7 @@ void fw_node_event(struct fw_card *card, struct fw_no= de *node, int event) =20 case FW_NODE_DESTROYED: case FW_NODE_LINK_OFF: - if (!node->data) + if (!fw_node_get_device(node)) break; =20 /* @@ -1354,7 +1354,7 @@ void fw_node_event(struct fw_card *card, struct fw_no= de *node, int event) * the device in shutdown state to have that code fail * to create the device. */ - device =3D node->data; + device =3D fw_node_get_device(node); if (atomic_xchg(&device->state, FW_DEVICE_GONE) =3D=3D FW_DEVICE_RUNNING) { device->workfn =3D fw_device_shutdown; diff --git a/drivers/firewire/core.h b/drivers/firewire/core.h index 9b298af1cac0..083e39034c37 100644 --- a/drivers/firewire/core.h +++ b/drivers/firewire/core.h @@ -194,8 +194,8 @@ struct fw_node { /* For serializing node topology into a list. */ struct list_head link; =20 - /* Upper layer specific data. */ - void *data; + // The device when already associated, else NULL. + struct fw_device *device; =20 struct fw_node *ports[] __counted_by(port_count); }; @@ -219,6 +219,16 @@ static inline void fw_node_put(struct fw_node *node) kref_put(&node->kref, release_node); } =20 +static inline struct fw_device *fw_node_get_device(struct fw_node *node) +{ + return node->device; +} + +static inline void fw_node_set_device(struct fw_node *node, struct fw_devi= ce *device) +{ + node->device =3D device; +} + void fw_core_handle_bus_reset(struct fw_card *card, int node_id, int generation, int self_id_count, u32 *self_ids, bool bm_abdicate); void fw_destroy_nodes(struct fw_card *card); --=20 2.48.1 From nobody Fri Oct 3 02:17:19 2025 Received: from fhigh-a2-smtp.messagingengine.com (fhigh-a2-smtp.messagingengine.com [103.168.172.153]) (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 BE6D51DF246 for ; Mon, 8 Sep 2025 01:21:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=103.168.172.153 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757294483; cv=none; b=LGxv4+KYq3RfnYthMZT12+/EgHnFkX7GXmeDp8+yCrUU0vCHcjZBz5Qxcg7uBPGMmAMDUHwIrahXubWzMVM5KSa6OVzG+ISX8h0/dO01Hn2+p1nXTLlG4+P5DmkfLECPOEuESifs5MSuXiFdSNg+VbiHcm3KqEAOycz3MNtkdFo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757294483; c=relaxed/simple; bh=3QvAJWGv1gPQ3eJSGXr06KRvz10xtfAcuAZOZKEKQMw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=JFQ7uRTzQetstc7AkYSc11zjgzI4BqNFpBI9Lo0KRDWcw1OxrfJajYA/jfawGLhkJgVtQm524+UqnkR86x2XBi1GttPQurDqULkC6leMLjILePhWmGimW9iTaXoo7a63ou3MsXApBXjs7t270Lt0Z6eloARCEAk7lM5uxpb1+xA= 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=gZJHO4D0; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=Iscf8s9u; arc=none smtp.client-ip=103.168.172.153 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="gZJHO4D0"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="Iscf8s9u" Received: from phl-compute-09.internal (phl-compute-09.internal [10.202.2.49]) by mailfhigh.phl.internal (Postfix) with ESMTP id EA0301400031; Sun, 7 Sep 2025 21:21:20 -0400 (EDT) Received: from phl-mailfrontend-01 ([10.202.2.162]) by phl-compute-09.internal (MEProxy); Sun, 07 Sep 2025 21:21:20 -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=fm1; t=1757294480; x= 1757380880; bh=H7DOpTJkIKamZnnlkDD1SFk3tG3wPCtz+PxOLCk1rJA=; b=g ZJHO4D0taD6mqOFuMbyNxqUv3ayiE4OGADR1Zl79iNhuahUTtiFSn2pgX5O5+C10 WVubXjw02/hbyh3kZihjTnqH9Jz800bpAOHyoseoM30U1ylIAI26LNnADfSCYGkh ece6k/pZRXkOktfexQZWXuMFDr3Etm+KXS5Tk7IBWZXSnkv/H//AjdPkzECfQ1Hf 5mJDkHJObzA4KM32JrbA/DN9eR2g12+LM2F170MhSjwmY3e3zsiWavJi/8XaW/T0 yOAfElZx4Vp6BFE3bCJUDpbOi910sgzBqLSfoMmKO/9aAULeV43QrORa4tCE66xf qu6UsjTN6qWX8XCJc752A== 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=fm1; t=1757294480; x=1757380880; bh=H 7DOpTJkIKamZnnlkDD1SFk3tG3wPCtz+PxOLCk1rJA=; b=Iscf8s9ugpTeE2bIo Mr+nk6pxOKJF+PshEI92Til+A5+QvU7R2t8eOQQnNp5z3GNTjXJizfpUPI+BNOBc vZnLdzQrXu47toE4X3b+hiLsKCYDBAfgAttZeIM7ut7RCQGBKV9OzE+5Wt5DKZMZ sVWPFMOoJzwAm641M4C7doggo2FiwaZbXkQyRx1Suqgd7hbBcjRkt4ywN3y9+uDQ 0ulTG6t72FHFPC0eS6hLXNyllDK+Ynqp61lJT8Sg27Y1YvMHmnrKIBt4aCvIX7h3 JjxoZy0s9GPDDbjA6vMFI3sFw2nC2pvesDm3h7IMewBhFhgkh0W+WYn8h998NrCK s3oIw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeffedrtdeggdduiedulecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpuffrtefokffrpgfnqfghnecuuegr ihhlohhuthemuceftddtnecunecujfgurhephffvvefufffkofgjfhgggfestdekredtre dttdenucfhrhhomhepvfgrkhgrshhhihcuufgrkhgrmhhothhouceoohdqthgrkhgrshhh ihesshgrkhgrmhhotggthhhirdhjpheqnecuggftrfgrthhtvghrnhepvdejgfejuedvgf duudekleevtefgtdevhfdtffefiefgveeuteffiedvffekvddtnecuvehluhhsthgvrhfu ihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepohdqthgrkhgrshhhihesshgrkh grmhhotggthhhirdhjphdpnhgspghrtghpthhtohepvddpmhhouggvpehsmhhtphhouhht pdhrtghpthhtoheplhhinhhugidufeelgedquggvvhgvlheslhhishhtshdrshhouhhrtg gvfhhorhhgvgdrnhgvthdprhgtphhtthhopehlihhnuhigqdhkvghrnhgvlhesvhhgvghr rdhkvghrnhgvlhdrohhrgh X-ME-Proxy: Feedback-ID: ie8e14432:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Sun, 7 Sep 2025 21:21:19 -0400 (EDT) From: Takashi Sakamoto To: linux1394-devel@lists.sourceforge.net Cc: linux-kernel@vger.kernel.org Subject: [PATCH 05/11] firewire: core: use cleanup function in bm_work Date: Mon, 8 Sep 2025 10:21:02 +0900 Message-ID: <20250908012108.514698-6-o-takashi@sakamocchi.jp> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250908012108.514698-1-o-takashi@sakamocchi.jp> References: <20250908012108.514698-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" In "bm_work" function, the references to fw_card and fw_node are released at last. This is achieved by using goto statements. For this case, the kernel cleanup framework is available. This commit uses the framework to remove these statements. Signed-off-by: Takashi Sakamoto --- drivers/firewire/core-card.c | 33 ++++++++++++++++----------------- 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/drivers/firewire/core-card.c b/drivers/firewire/core-card.c index 4a4210cda571..5bd89ddf5018 100644 --- a/drivers/firewire/core-card.c +++ b/drivers/firewire/core-card.c @@ -280,14 +280,17 @@ void fw_schedule_bm_work(struct fw_card *card, unsign= ed long delay) fw_card_put(card); } =20 +DEFINE_FREE(node_unref, struct fw_node *, if (_T) fw_node_put(_T)) +DEFINE_FREE(card_unref, struct fw_card *, if (_T) fw_card_put(_T)) + static void bm_work(struct work_struct *work) { static const char gap_count_table[] =3D { 63, 5, 7, 8, 10, 13, 16, 18, 21, 24, 26, 29, 32, 35, 37, 40 }; - struct fw_card *card =3D from_work(card, work, bm_work.work); + struct fw_card *card __free(card_unref) =3D from_work(card, work, bm_work= .work); struct fw_device *root_device, *irm_device; - struct fw_node *root_node; + struct fw_node *root_node __free(node_unref) =3D NULL; int root_id, new_root_id, irm_id, bm_id, local_id; int gap_count, generation, grace, rcode; bool do_reset =3D false; @@ -297,11 +300,13 @@ static void bm_work(struct work_struct *work) bool keep_this_irm; __be32 transaction_data[2]; =20 + lockdep_assert_held(&card->lock); + spin_lock_irq(&card->lock); =20 if (card->local_node =3D=3D NULL) { spin_unlock_irq(&card->lock); - goto out_put_card; + return; } =20 generation =3D card->generation; @@ -366,9 +371,9 @@ static void bm_work(struct work_struct *work) CSR_REGISTER_BASE + CSR_BUS_MANAGER_ID, transaction_data, 8); =20 + // Another bus reset, BM work has been rescheduled. if (rcode =3D=3D RCODE_GENERATION) - /* Another bus reset, BM work has been rescheduled. */ - goto out; + return; =20 bm_id =3D be32_to_cpu(transaction_data[0]); =20 @@ -382,8 +387,7 @@ static void bm_work(struct work_struct *work) /* Somebody else is BM. Only act as IRM. */ if (local_id =3D=3D irm_id) allocate_broadcast_channel(card, generation); - - goto out; + return; } =20 if (rcode =3D=3D RCODE_SEND_ERROR) { @@ -393,7 +397,7 @@ static void bm_work(struct work_struct *work) * that the problem has gone away by then. */ fw_schedule_bm_work(card, DIV_ROUND_UP(HZ, 8)); - goto out; + return; } =20 spin_lock_irq(&card->lock); @@ -417,7 +421,7 @@ static void bm_work(struct work_struct *work) */ spin_unlock_irq(&card->lock); fw_schedule_bm_work(card, DIV_ROUND_UP(HZ, 8)); - goto out; + return; } =20 /* @@ -455,7 +459,7 @@ static void bm_work(struct work_struct *work) * and let's try again once that's done. */ spin_unlock_irq(&card->lock); - goto out; + return; } else if (root_device_is_cmc) { /* * We will send out a force root packet for this @@ -512,7 +516,7 @@ static void bm_work(struct work_struct *work) */ reset_bus(card, card->gap_count !=3D 0); /* Will allocate broadcast channel after the reset. */ - goto out; + return; } =20 if (root_device_is_cmc) { @@ -525,16 +529,11 @@ static void bm_work(struct work_struct *work) CSR_REGISTER_BASE + CSR_STATE_SET, transaction_data, 4); if (rcode =3D=3D RCODE_GENERATION) - goto out; + return; } =20 if (local_id =3D=3D irm_id) allocate_broadcast_channel(card, generation); - - out: - fw_node_put(root_node); - out_put_card: - fw_card_put(card); } =20 void fw_card_initialize(struct fw_card *card, --=20 2.48.1 From nobody Fri Oct 3 02:17:19 2025 Received: from fout-a3-smtp.messagingengine.com (fout-a3-smtp.messagingengine.com [103.168.172.146]) (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 3B9B71EF363 for ; Mon, 8 Sep 2025 01:21:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=103.168.172.146 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757294485; cv=none; b=Kw514XuX3nOSpfAtu1AvuxZMOtRWDZ5WKeRWNJMFmkPuLo7QGw66AQMnPc9lmTLn0t672/gQ+PmBRaWCDB5FeQNjnZVlRu9pJvVlg/vMh96GMRMWoHeeH/67W4FTFbEa951RkWGorW4FqSjrYmqHDNhh3fCQvhERYUlecO9bbYw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757294485; c=relaxed/simple; bh=HK13AI7lto+XHviTa3mTQZBaSkUYEU5SGXjshS1kmcw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=U65X0lz+JgCqEylflbQwRUPvvl5yM9HSs3AqiONt6cxbCx3vtplHjjvvS/yZaR+kALsRB+rI7N48X1mjzppDIoUbuLD3kMDVpCcpwdPNUo+f459+spYAPEsK8Z8WsOcYTcHprEJa1d1pXjxVSXMhz8GNBK07QSzggLd27l/GmLc= 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=O1KJoKCL; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=HpXuwSvs; arc=none smtp.client-ip=103.168.172.146 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="O1KJoKCL"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="HpXuwSvs" Received: from phl-compute-11.internal (phl-compute-11.internal [10.202.2.51]) by mailfout.phl.internal (Postfix) with ESMTP id 5C0F3EC008A; Sun, 7 Sep 2025 21:21:22 -0400 (EDT) Received: from phl-mailfrontend-01 ([10.202.2.162]) by phl-compute-11.internal (MEProxy); Sun, 07 Sep 2025 21:21:22 -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=fm1; t=1757294482; x= 1757380882; bh=zb78927kFIsqfW6PLd6meqtF4v0FQTdlwbh5TO1B41c=; b=O 1KJoKCLxsJg3rI03pQG0AAgff3cTaJQFAS6wWfBd0omYQnr+YleRTvJxGS+QmEAI LjjHZTrhIludes7n0a6cU2F5WdB+5GRpyAH/EPwqh8DMYrgSEXqcL6zVu99UfYi4 9ILvbLQBzRkZVQMZZ4apKjVDFB+/pyEogoQSky0ikGFcfRWrbL2A1LW/HDPoSobD VAlIyZRcGgk8E5/5bloSQyj1LjAhNH1PApc810VCe8qXWYPlfdCf96rRNqEqTB8W G3SpNYfNyMnJp4lC7goWgxIKis738Ggn6maSGrTDojdjhdi3N58yBcJ465KlJdS2 68cyZ+499nEa9kvs2Rsow== 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=fm1; t=1757294482; x=1757380882; bh=z b78927kFIsqfW6PLd6meqtF4v0FQTdlwbh5TO1B41c=; b=HpXuwSvsmPf8nW2E+ MDTBuhbhaHACVJBJS3ZiMliilPqBYGnylGFOyqMTKh0YN5cgYhUKr8Wuy7r+J/Vj T5VL4xTk1O1TzhseOIppyV8BdhoEJ2iwWe0u63HRn0c1d6sKT/HRfpq1u1e3Qlsw JtKdkSJbnqw40rIWMD9jk8++yvF+Gnw8OJTBjTSqP3ne43511xeemiwsEHWgqhd1 k/yx9e0tQEcYuam9+n6qwEjEi0rrCJX+/Xi1VD0s3y5XKpIAdT7kWnUzAcLFo9IA sGl081Ga1UH70rweLJBlTwmEHL9jMkk5m0dgF+ba56wZlm3oQVPA5+VAg1UK3GCB azB7g== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeffedrtdeggdduiedulecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpuffrtefokffrpgfnqfghnecuuegr ihhlohhuthemuceftddtnecunecujfgurhephffvvefufffkofgjfhgggfestdekredtre dttdenucfhrhhomhepvfgrkhgrshhhihcuufgrkhgrmhhothhouceoohdqthgrkhgrshhh ihesshgrkhgrmhhotggthhhirdhjpheqnecuggftrfgrthhtvghrnhepvdejgfejuedvgf duudekleevtefgtdevhfdtffefiefgveeuteffiedvffekvddtnecuvehluhhsthgvrhfu ihiivgepudenucfrrghrrghmpehmrghilhhfrhhomhepohdqthgrkhgrshhhihesshgrkh grmhhotggthhhirdhjphdpnhgspghrtghpthhtohepvddpmhhouggvpehsmhhtphhouhht pdhrtghpthhtoheplhhinhhugidufeelgedquggvvhgvlheslhhishhtshdrshhouhhrtg gvfhhorhhgvgdrnhgvthdprhgtphhtthhopehlihhnuhigqdhkvghrnhgvlhesvhhgvghr rdhkvghrnhgvlhdrohhrgh X-ME-Proxy: Feedback-ID: ie8e14432:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Sun, 7 Sep 2025 21:21:21 -0400 (EDT) From: Takashi Sakamoto To: linux1394-devel@lists.sourceforge.net Cc: linux-kernel@vger.kernel.org Subject: [PATCH 06/11] firewire: ohci: localize transaction data and rcode per condition branch Date: Mon, 8 Sep 2025 10:21:03 +0900 Message-ID: <20250908012108.514698-7-o-takashi@sakamocchi.jp> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250908012108.514698-1-o-takashi@sakamocchi.jp> References: <20250908012108.514698-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 function local variable, transaction_data, in bm_work function is conditionally used. In the case, the branch-level variable is sometimes useful. This commit uses this idea. Signed-off-by: Takashi Sakamoto --- drivers/firewire/core-card.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/drivers/firewire/core-card.c b/drivers/firewire/core-card.c index 5bd89ddf5018..b98797e4f1d4 100644 --- a/drivers/firewire/core-card.c +++ b/drivers/firewire/core-card.c @@ -292,13 +292,12 @@ static void bm_work(struct work_struct *work) struct fw_device *root_device, *irm_device; struct fw_node *root_node __free(node_unref) =3D NULL; int root_id, new_root_id, irm_id, bm_id, local_id; - int gap_count, generation, grace, rcode; + int gap_count, generation, grace; bool do_reset =3D false; bool root_device_is_running; bool root_device_is_cmc; bool irm_is_1394_1995_only; bool keep_this_irm; - __be32 transaction_data[2]; =20 lockdep_assert_held(&card->lock); =20 @@ -346,6 +345,11 @@ static void bm_work(struct work_struct *work) * gap count. That could well save a reset in the * next generation. */ + __be32 data[2] =3D { + cpu_to_be32(0x3f), + cpu_to_be32(local_id), + }; + int rcode; =20 if (!card->irm_node->link_on) { new_root_id =3D local_id; @@ -361,21 +365,18 @@ static void bm_work(struct work_struct *work) goto pick_me; } =20 - transaction_data[0] =3D cpu_to_be32(0x3f); - transaction_data[1] =3D cpu_to_be32(local_id); - spin_unlock_irq(&card->lock); =20 rcode =3D fw_run_transaction(card, TCODE_LOCK_COMPARE_SWAP, irm_id, generation, SCODE_100, CSR_REGISTER_BASE + CSR_BUS_MANAGER_ID, - transaction_data, 8); + data, sizeof(data)); =20 // Another bus reset, BM work has been rescheduled. if (rcode =3D=3D RCODE_GENERATION) return; =20 - bm_id =3D be32_to_cpu(transaction_data[0]); + bm_id =3D be32_to_cpu(data[0]); =20 scoped_guard(spinlock_irq, &card->lock) { if (rcode =3D=3D RCODE_COMPLETE && generation =3D=3D card->generation) @@ -523,11 +524,11 @@ static void bm_work(struct work_struct *work) /* * Make sure that the cycle master sends cycle start packets. */ - transaction_data[0] =3D cpu_to_be32(CSR_STATE_BIT_CMSTR); - rcode =3D fw_run_transaction(card, TCODE_WRITE_QUADLET_REQUEST, + __be32 data =3D cpu_to_be32(CSR_STATE_BIT_CMSTR); + int rcode =3D fw_run_transaction(card, TCODE_WRITE_QUADLET_REQUEST, root_id, generation, SCODE_100, CSR_REGISTER_BASE + CSR_STATE_SET, - transaction_data, 4); + &data, sizeof(data)); if (rcode =3D=3D RCODE_GENERATION) return; } --=20 2.48.1 From nobody Fri Oct 3 02:17:19 2025 Received: from fout-a3-smtp.messagingengine.com (fout-a3-smtp.messagingengine.com [103.168.172.146]) (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 6CCC31FCF41 for ; Mon, 8 Sep 2025 01:21:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=103.168.172.146 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757294486; cv=none; b=XkvVTSj7IfRDNyMwWFYVZAlOq9T8CI8H+jWD5Ref4hFaNMTkBTkAxtGqKkpKd1n1g8i1k/NuCEwAw1dL7TC0pJ1Xt5qq2TComnp2B6GqW6Yg5QYhbkRTfxzefrLaMUiKp0bcx0ZgeqMaqc1wcDXO3pEWjR/HST26JSvM731+vwY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757294486; c=relaxed/simple; bh=cjOUV30BSaxnY+cJZFkMewTeK9ZEwIEEIzAbj78kSus=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=fHtLMpv+4K30sd8qAeJTz+iL+FwVg5VYYDhCLYa3RP3TtDwLzQcz5XI/hvccOo0MdmhYWXAyHG7qp3x3LrEV11vzBrKyl8CreMpISAw+U/H139bmB6UfuWBhn2U4LfbheCuWgE3hp3kh/uYNOUq/qYU7JAkTYcugzbF6rrbaq2w= 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=YMvdIEpz; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=EnfghvmP; arc=none smtp.client-ip=103.168.172.146 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="YMvdIEpz"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="EnfghvmP" Received: from phl-compute-12.internal (phl-compute-12.internal [10.202.2.52]) by mailfout.phl.internal (Postfix) with ESMTP id D53CFEC0093; Sun, 7 Sep 2025 21:21:23 -0400 (EDT) Received: from phl-mailfrontend-01 ([10.202.2.162]) by phl-compute-12.internal (MEProxy); Sun, 07 Sep 2025 21:21:23 -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=fm1; t=1757294483; x= 1757380883; bh=0N90Rbsw2sPw8qtfBi7whVAKvBSkffqx0sYFg+fnBGA=; b=Y MvdIEpzb3KFvEP8Urb7tXDkwlq4JaDP5cGQWHoDLdCW08oVaS3mFkwFceVah55wU s1QTGmLi1Qiza7vxl5D4Cmx40Wp1gOZqP4rGCaP5O/6w+AnV/O6llNOybhImIR/U +HsJr6mrXv6YK/MC/Odr8B8cLsKqZZUlR6OdNy0Zf1U5osEwPncI/k8593vvBmJ6 Tg89qf1q+kR/mOuTinqjW+u/CzEeYe/DOk5bJbGbY1I0O+JjLOqedVS7RVLUOj2Z c8cSevT4VQBAlvU48IUb4cgoaop39NhJJTWsGlHMYtgNAHZnFoeCTl5dZ9bmRO9k WGXS6TIv57kQPGWIfa9GA== 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=fm1; t=1757294483; x=1757380883; bh=0 N90Rbsw2sPw8qtfBi7whVAKvBSkffqx0sYFg+fnBGA=; b=EnfghvmPediAiD8IG 1s6PQ9Y/qePC05SIUf22/IMezFGu5BBf2nhUcPol0qU0hnAOQ/zr9sko73QKw0UD jTtC9WEIcrgRSZQt3gQydz194BobSHDu9LpXjjmzrM+aveTJG54x7PDlThJti+wp yOxVwbkiSboF/g7YqjWLvPqLiYPOvT5VMWndFuPwcdh3XZwu6SNwsr3Q/Gh46KD3 TBHFRg4JRe7oFD/5/cOGcBd4D3vm9PWozYtUACTXJN26NLtrX6eIgfKH+pnInZUR FSwmFunytCvzPiSX+vytBYwS/3pnvSBt9jopxn6IpBx0koQikX0ciKpF38f5Pzlz DMk9w== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeffedrtdeggdduiedvtdcutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpuffrtefokffrpgfnqfghnecuuegr ihhlohhuthemuceftddtnecunecujfgurhephffvvefufffkofgjfhgggfestdekredtre dttdenucfhrhhomhepvfgrkhgrshhhihcuufgrkhgrmhhothhouceoohdqthgrkhgrshhh ihesshgrkhgrmhhotggthhhirdhjpheqnecuggftrfgrthhtvghrnhepvdejgfejuedvgf duudekleevtefgtdevhfdtffefiefgveeuteffiedvffekvddtnecuvehluhhsthgvrhfu ihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepohdqthgrkhgrshhhihesshgrkh grmhhotggthhhirdhjphdpnhgspghrtghpthhtohepvddpmhhouggvpehsmhhtphhouhht pdhrtghpthhtoheplhhinhhugidufeelgedquggvvhgvlheslhhishhtshdrshhouhhrtg gvfhhorhhgvgdrnhgvthdprhgtphhtthhopehlihhnuhigqdhkvghrnhgvlhesvhhgvghr rdhkvghrnhgvlhdrohhrgh X-ME-Proxy: Feedback-ID: ie8e14432:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Sun, 7 Sep 2025 21:21:22 -0400 (EDT) From: Takashi Sakamoto To: linux1394-devel@lists.sourceforge.net Cc: linux-kernel@vger.kernel.org Subject: [PATCH 07/11] firewire: core: code refactoring to evaluate transaction result to CSR_BUS_MANAGER_ID Date: Mon, 8 Sep 2025 10:21:04 +0900 Message-ID: <20250908012108.514698-8-o-takashi@sakamocchi.jp> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250908012108.514698-1-o-takashi@sakamocchi.jp> References: <20250908012108.514698-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 call of bm_work should be done after acquiring spin lock of fw_card. For asynchronous transaction, the lock should be released temporarily due to event waiting. A commit 27310d561622 ("firewire: core: use guard macro to maintain properties of fw_card") applied scoped_guard() to the bm_work function, however it looks hard to follow to the control flow. This commit refactors the spin lock acquisition after the transaction. Signed-off-by: Takashi Sakamoto --- drivers/firewire/core-card.c | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/drivers/firewire/core-card.c b/drivers/firewire/core-card.c index b98797e4f1d4..e1a7a151b109 100644 --- a/drivers/firewire/core-card.c +++ b/drivers/firewire/core-card.c @@ -291,7 +291,7 @@ static void bm_work(struct work_struct *work) struct fw_card *card __free(card_unref) =3D from_work(card, work, bm_work= .work); struct fw_device *root_device, *irm_device; struct fw_node *root_node __free(node_unref) =3D NULL; - int root_id, new_root_id, irm_id, bm_id, local_id; + int root_id, new_root_id, irm_id, local_id; int gap_count, generation, grace; bool do_reset =3D false; bool root_device_is_running; @@ -376,19 +376,22 @@ static void bm_work(struct work_struct *work) if (rcode =3D=3D RCODE_GENERATION) return; =20 - bm_id =3D be32_to_cpu(data[0]); + spin_lock_irq(&card->lock); =20 - scoped_guard(spinlock_irq, &card->lock) { - if (rcode =3D=3D RCODE_COMPLETE && generation =3D=3D card->generation) - card->bm_node_id =3D - bm_id =3D=3D 0x3f ? local_id : 0xffc0 | bm_id; - } + if (rcode =3D=3D RCODE_COMPLETE) { + int bm_id =3D be32_to_cpu(data[0]); =20 - if (rcode =3D=3D RCODE_COMPLETE && bm_id !=3D 0x3f) { - /* Somebody else is BM. Only act as IRM. */ - if (local_id =3D=3D irm_id) - allocate_broadcast_channel(card, generation); - return; + if (generation =3D=3D card->generation) + card->bm_node_id =3D bm_id =3D=3D 0x3f ? local_id : 0xffc0 | bm_id; + + if (bm_id !=3D 0x3f) { + spin_unlock_irq(&card->lock); + + // Somebody else is BM. Only act as IRM. + if (local_id =3D=3D irm_id) + allocate_broadcast_channel(card, generation); + return; + } } =20 if (rcode =3D=3D RCODE_SEND_ERROR) { @@ -397,12 +400,11 @@ static void bm_work(struct work_struct *work) * some local problem. Let's try again later and hope * that the problem has gone away by then. */ + spin_unlock_irq(&card->lock); fw_schedule_bm_work(card, DIV_ROUND_UP(HZ, 8)); return; } =20 - spin_lock_irq(&card->lock); - if (rcode !=3D RCODE_COMPLETE && !keep_this_irm) { /* * The lock request failed, maybe the IRM --=20 2.48.1 From nobody Fri Oct 3 02:17:19 2025 Received: from fout-a3-smtp.messagingengine.com (fout-a3-smtp.messagingengine.com [103.168.172.146]) (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 0DE33204583 for ; Mon, 8 Sep 2025 01:21:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=103.168.172.146 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757294487; cv=none; b=PxkFctEfd15hm8WPgiaYvp1jFkD0nBNzIZVcbLD8+Bu6jWMQC3XLkUnzhu4eAVYVtqWWxiNrMK359bCtTvb8Mzq506yW/W4wOyfK7Yt6WIqXoRt4ncTe2MDg9t13imcvPjscUjn4e9NqDAMuouBSQ9/ApkjDTydEjqlDwZgCCa0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757294487; c=relaxed/simple; bh=o60qmQF5po3Njkng1yM+IUo0Nvd7xga7cXxWjTwFSvM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=a43YdP9Z9zROm6JsPmKrSoh9Ai0dY5vOdoQz2C+LNBOKZ5o+jY2Yw7zVd2e1ed6o8PEjinC/lnIIxAj9d/4k2Rbffm5wU+qONV48Isz0q2owSN3DogGLRvHlZ1ItbX8CeElNFADHiJCLI0ZpiFZyEmUxA/ueMhvfzvQKWHVKC24= 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=OgQPv7Ax; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=hOfliCo+; arc=none smtp.client-ip=103.168.172.146 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="OgQPv7Ax"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="hOfliCo+" Received: from phl-compute-12.internal (phl-compute-12.internal [10.202.2.52]) by mailfout.phl.internal (Postfix) with ESMTP id 3D752EC003B; Sun, 7 Sep 2025 21:21:25 -0400 (EDT) Received: from phl-mailfrontend-01 ([10.202.2.162]) by phl-compute-12.internal (MEProxy); Sun, 07 Sep 2025 21:21:25 -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=fm1; t=1757294485; x= 1757380885; bh=mSnUVpxCiJr1+TG9UdtbcF0qEHQfcBsU1XskFAkRnUI=; b=O gQPv7Axo6GC5o+5fd6uXfDkTbODAwvx2Juq2+WctbytnEsN9ULYnoLNER6Qjld0k MVU76TGmKfSiu17hl+Ogh4CV/IaOdLIKjoDB9V/iC4uODJV3er+WzbCZZJ97p58l 1vX05D86G9ioIfWuOow/wKN+B/Pt3P8uOxRPkx+eB1jLmOxl90J0wE/dn7n732tm 2nRlOhKr1dli333m9GKrz6wUyZrmaDoXe4HKPvgf2S9dAZ3+s4qOInSuuKh9xApk c9AvhqK0/fGeQoTP7/W/yktNp1KzewyoghLhe85bywKfRdW9rUxmdKnC5ITFK/w1 YlHF3KUpQNQC3O5wX4NjA== 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=fm1; t=1757294485; x=1757380885; bh=m SnUVpxCiJr1+TG9UdtbcF0qEHQfcBsU1XskFAkRnUI=; b=hOfliCo+TS2DbMB1N fYjbtoVbwSmv1HcJBKEN59B/7Wy8Ywm2ADJ9d5cWxIJy60MKGo4tQ/RidELTry1t D4oIhGEB0qa01Q9GdbHEBXCezCbaWdpDljvi9ASzHlcqjXfpEs1AQwLLUh50kqo7 EgdoZO87lQYuLDnDeVBe/bvvTRkoUgsJ9pBCjsHXeeHpW9z+Hj2ld96CZFpzziT5 8ob3G/Za9i3jiXcsKCaAupUFEAi1iGV45JZKppFpT4HCIXPZtbQueKBBqnKZrl1d dvOkx5IfWpFsdX7SlUBwJ5g2VVl4e9GPHwc1n/WPJbZq4X0lRBxYSRRfV5NB8i4f BYVMA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeffedrtdeggdduiedvtdcutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpuffrtefokffrpgfnqfghnecuuegr ihhlohhuthemuceftddtnecunecujfgurhephffvvefufffkofgjfhgggfestdekredtre dttdenucfhrhhomhepvfgrkhgrshhhihcuufgrkhgrmhhothhouceoohdqthgrkhgrshhh ihesshgrkhgrmhhotggthhhirdhjpheqnecuggftrfgrthhtvghrnhepvdejgfejuedvgf duudekleevtefgtdevhfdtffefiefgveeuteffiedvffekvddtnecuvehluhhsthgvrhfu ihiivgepudenucfrrghrrghmpehmrghilhhfrhhomhepohdqthgrkhgrshhhihesshgrkh grmhhotggthhhirdhjphdpnhgspghrtghpthhtohepvddpmhhouggvpehsmhhtphhouhht pdhrtghpthhtoheplhhinhhugidufeelgedquggvvhgvlheslhhishhtshdrshhouhhrtg gvfhhorhhgvgdrnhgvthdprhgtphhtthhopehlihhnuhigqdhkvghrnhgvlhesvhhgvghr rdhkvghrnhgvlhdrohhrgh X-ME-Proxy: Feedback-ID: ie8e14432:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Sun, 7 Sep 2025 21:21:24 -0400 (EDT) From: Takashi Sakamoto To: linux1394-devel@lists.sourceforge.net Cc: linux-kernel@vger.kernel.org Subject: [PATCH 08/11] firewire: core: refer fw_card member to initiate bus reset under acquiring lock Date: Mon, 8 Sep 2025 10:21:05 +0900 Message-ID: <20250908012108.514698-9-o-takashi@sakamocchi.jp> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250908012108.514698-1-o-takashi@sakamocchi.jp> References: <20250908012108.514698-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 gap_count member of fw_card structure is referred when initiate bus reset. This reference is done out of acquiring lock. This is not good. This commit takes the reference within the acquiring lock, with additional code refactoring. Signed-off-by: Takashi Sakamoto --- drivers/firewire/core-card.c | 52 ++++++++++++++++++------------------ 1 file changed, 26 insertions(+), 26 deletions(-) diff --git a/drivers/firewire/core-card.c b/drivers/firewire/core-card.c index e1a7a151b109..630e229c9cc2 100644 --- a/drivers/firewire/core-card.c +++ b/drivers/firewire/core-card.c @@ -292,7 +292,7 @@ static void bm_work(struct work_struct *work) struct fw_device *root_device, *irm_device; struct fw_node *root_node __free(node_unref) =3D NULL; int root_id, new_root_id, irm_id, local_id; - int gap_count, generation, grace; + int expected_gap_count, generation, grace; bool do_reset =3D false; bool root_device_is_running; bool root_device_is_cmc; @@ -485,9 +485,9 @@ static void bm_work(struct work_struct *work) */ if (!card->beta_repeaters_present && root_node->max_hops < ARRAY_SIZE(gap_count_table)) - gap_count =3D gap_count_table[root_node->max_hops]; + expected_gap_count =3D gap_count_table[root_node->max_hops]; else - gap_count =3D 63; + expected_gap_count =3D 63; =20 /* * Finally, figure out if we should do a reset or not. If we have @@ -495,16 +495,17 @@ static void bm_work(struct work_struct *work) * have either a new root or a new gap count setting, let's do it. */ =20 - if (card->bm_retries++ < 5 && - (card->gap_count !=3D gap_count || new_root_id !=3D root_id)) + if (card->bm_retries++ < 5 && (card->gap_count !=3D expected_gap_count ||= new_root_id !=3D root_id)) do_reset =3D true; =20 - spin_unlock_irq(&card->lock); - if (do_reset) { + int card_gap_count =3D card->gap_count; + + spin_unlock_irq(&card->lock); + fw_notice(card, "phy config: new root=3D%x, gap_count=3D%d\n", - new_root_id, gap_count); - fw_send_phy_config(card, new_root_id, generation, gap_count); + new_root_id, expected_gap_count); + fw_send_phy_config(card, new_root_id, generation, expected_gap_count); /* * Where possible, use a short bus reset to minimize * disruption to isochronous transfers. But in the event @@ -517,26 +518,25 @@ static void bm_work(struct work_struct *work) * may treat it as two, causing a gap count inconsistency * again. Using a long bus reset prevents this. */ - reset_bus(card, card->gap_count !=3D 0); + reset_bus(card, card_gap_count !=3D 0); /* Will allocate broadcast channel after the reset. */ - return; - } + } else { + spin_unlock_irq(&card->lock); =20 - if (root_device_is_cmc) { - /* - * Make sure that the cycle master sends cycle start packets. - */ - __be32 data =3D cpu_to_be32(CSR_STATE_BIT_CMSTR); - int rcode =3D fw_run_transaction(card, TCODE_WRITE_QUADLET_REQUEST, - root_id, generation, SCODE_100, - CSR_REGISTER_BASE + CSR_STATE_SET, - &data, sizeof(data)); - if (rcode =3D=3D RCODE_GENERATION) - return; - } + if (root_device_is_cmc) { + // Make sure that the cycle master sends cycle start packets. + __be32 data =3D cpu_to_be32(CSR_STATE_BIT_CMSTR); + int rcode =3D fw_run_transaction(card, TCODE_WRITE_QUADLET_REQUEST, + root_id, generation, SCODE_100, + CSR_REGISTER_BASE + CSR_STATE_SET, + &data, sizeof(data)); + if (rcode =3D=3D RCODE_GENERATION) + return; + } =20 - if (local_id =3D=3D irm_id) - allocate_broadcast_channel(card, generation); + if (local_id =3D=3D irm_id) + allocate_broadcast_channel(card, generation); + } } =20 void fw_card_initialize(struct fw_card *card, --=20 2.48.1 From nobody Fri Oct 3 02:17:19 2025 Received: from fhigh-a2-smtp.messagingengine.com (fhigh-a2-smtp.messagingengine.com [103.168.172.153]) (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 34637215075 for ; Mon, 8 Sep 2025 01:21:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=103.168.172.153 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757294489; cv=none; b=hJnu+1I4sTfzaF4F7ltbbDOuVm8ihrUOqtab1Z1/l1x149b8OegpgB7KKkIBGIEZip4lNMz60xRy4OKT1/7IjJYtjEvT3P22Q4UNklO68kPH/xO1aDPmE43tlw9jsVdeNlnHATR6vfWbbT1T4ysChJ5MnLlC7GDCASwIbJ3hRFs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757294489; c=relaxed/simple; bh=o043vB0nEdY6KeO3hY529DM5oKPHJ7yYdHTHN0FTD4g=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=J0ViJ5SSMwcN1AG2LGeDGzKa7mU3WfHBHwCUeqdZ21w56vvyZnQys45/76EiCMccySiwndJSPmADsSpSUip0U1cwrSPWmOoMNJl1AMzb018EXuJVrq9Tr97kBdqSg0KrPZM6C1GdbPoVIFshl/4nEOwyT+1yce9PVdDLOSImovI= 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=m7B31nOY; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=ckb0ObfG; arc=none smtp.client-ip=103.168.172.153 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="m7B31nOY"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="ckb0ObfG" Received: from phl-compute-04.internal (phl-compute-04.internal [10.202.2.44]) by mailfhigh.phl.internal (Postfix) with ESMTP id 919CC140002E; Sun, 7 Sep 2025 21:21:26 -0400 (EDT) Received: from phl-mailfrontend-01 ([10.202.2.162]) by phl-compute-04.internal (MEProxy); Sun, 07 Sep 2025 21:21:26 -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=fm1; t=1757294486; x= 1757380886; bh=i2fSL7FZl4IrRcqRg9Av1sKqTFCfIV6J8l4HksJ8U3I=; b=m 7B31nOYiGpUueddbEtaTbBFbav6qNI4LO8rTRAPctjaBOruSjKdb6Uch0oSoxDuA qSV/QhqA73b5IOxp8cdER7mYZFcm7bGMxkUNSX25nhwtaQjG+cbm+d7UyntpU123 rC2ML1WVeIZVgCC4ln/COqb3KwJUijHEFFvBCQ3F2bk3UN7AC62STbzwFG0Bv+l3 o1NfpQTZU80MG3vk63J36WUQGc0Lyw5gFymgIUYH95DS8zS+8WPCtebkXvsGFHNH ET48Gx45AzgIggf8QN88iHEMT4/s/GClxEDbX9qOAvPJZEI31gOCzS70Ls877Ru1 trvDiAzlN25QiSYkh2Kew== 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=fm1; t=1757294486; x=1757380886; bh=i 2fSL7FZl4IrRcqRg9Av1sKqTFCfIV6J8l4HksJ8U3I=; b=ckb0ObfG0jxnwcpAO 17wFfCOoKMKMpM5kPaPo9RTNs4FVDdh/Ppf1LEXxgq12t16yMaN1m63w3QcPLisB 55/hGWvRZrgUFkw6avSQ1F1FXFzJ8I0s5ozcK5MadU4p0Ef7rx6FcNeS7a2eSiZL N+dGvX91GjgAVyQUSDsM1jaW/fY+dbfJcD1lafhOh7M+gWec4GC9l/ZGQJBLc3uG g55h8yhk3uKFiL8MAapyJ5Fdi8wICsDUNHlmrbTVdHCB15AKPG3homDB2IxXcGl5 zgPAt4pOApT9NoUK6mwLiEJ//YxKFKA+egDWbKGCdooZCoHF00D8LQaf1Y96H9UD ovzdA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeffedrtdeggdduiedulecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpuffrtefokffrpgfnqfghnecuuegr ihhlohhuthemuceftddtnecunecujfgurhephffvvefufffkofgjfhgggfestdekredtre dttdenucfhrhhomhepvfgrkhgrshhhihcuufgrkhgrmhhothhouceoohdqthgrkhgrshhh ihesshgrkhgrmhhotggthhhirdhjpheqnecuggftrfgrthhtvghrnhepvdejgfejuedvgf duudekleevtefgtdevhfdtffefiefgveeuteffiedvffekvddtnecuvehluhhsthgvrhfu ihiivgepudenucfrrghrrghmpehmrghilhhfrhhomhepohdqthgrkhgrshhhihesshgrkh grmhhotggthhhirdhjphdpnhgspghrtghpthhtohepvddpmhhouggvpehsmhhtphhouhht pdhrtghpthhtoheplhhinhhugidufeelgedquggvvhgvlheslhhishhtshdrshhouhhrtg gvfhhorhhgvgdrnhgvthdprhgtphhtthhopehlihhnuhigqdhkvghrnhgvlhesvhhgvghr rdhkvghrnhgvlhdrohhrgh X-ME-Proxy: Feedback-ID: ie8e14432:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Sun, 7 Sep 2025 21:21:25 -0400 (EDT) From: Takashi Sakamoto To: linux1394-devel@lists.sourceforge.net Cc: linux-kernel@vger.kernel.org Subject: [PATCH 09/11] firewire: core: code refactoring to detect both IEEE 1394:1995 IRM and Canon MV5i Date: Mon, 8 Sep 2025 10:21:06 +0900 Message-ID: <20250908012108.514698-10-o-takashi@sakamocchi.jp> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250908012108.514698-1-o-takashi@sakamocchi.jp> References: <20250908012108.514698-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 detection of IEEE 1394:1995 and Canon MV5i is just required within some of the condition branches. In this case, these check can be capsulated within these branches. This commit refactors the checks. Signed-off-by: Takashi Sakamoto --- drivers/firewire/core-card.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/drivers/firewire/core-card.c b/drivers/firewire/core-card.c index 630e229c9cc2..99aa98f195ba 100644 --- a/drivers/firewire/core-card.c +++ b/drivers/firewire/core-card.c @@ -289,15 +289,13 @@ static void bm_work(struct work_struct *work) 63, 5, 7, 8, 10, 13, 16, 18, 21, 24, 26, 29, 32, 35, 37, 40 }; struct fw_card *card __free(card_unref) =3D from_work(card, work, bm_work= .work); - struct fw_device *root_device, *irm_device; + struct fw_device *root_device; struct fw_node *root_node __free(node_unref) =3D NULL; int root_id, new_root_id, irm_id, local_id; int expected_gap_count, generation, grace; bool do_reset =3D false; bool root_device_is_running; bool root_device_is_cmc; - bool irm_is_1394_1995_only; - bool keep_this_irm; =20 lockdep_assert_held(&card->lock); =20 @@ -316,14 +314,6 @@ static void bm_work(struct work_struct *work) atomic_read(&root_device->state) =3D=3D FW_DEVICE_RUNNING; root_device_is_cmc =3D root_device && root_device->cmc; =20 - irm_device =3D fw_node_get_device(card->irm_node); - irm_is_1394_1995_only =3D irm_device && irm_device->config_rom && - (irm_device->config_rom[2] & 0x000000f0) =3D=3D 0; - - /* Canon MV5i works unreliably if it is not root node. */ - keep_this_irm =3D irm_device && irm_device->config_rom && - irm_device->config_rom[3] >> 8 =3D=3D CANON_OUI; - root_id =3D root_node->node_id; irm_id =3D card->irm_node->node_id; local_id =3D card->local_node->node_id; @@ -349,6 +339,9 @@ static void bm_work(struct work_struct *work) cpu_to_be32(0x3f), cpu_to_be32(local_id), }; + struct fw_device *irm_device =3D fw_node_get_device(card->irm_node); + bool irm_is_1394_1995_only =3D false; + bool keep_this_irm =3D false; int rcode; =20 if (!card->irm_node->link_on) { @@ -358,6 +351,13 @@ static void bm_work(struct work_struct *work) goto pick_me; } =20 + if (irm_device && irm_device->config_rom) { + irm_is_1394_1995_only =3D (irm_device->config_rom[2] & 0x000000f0) =3D= =3D 0; + + // Canon MV5i works unreliably if it is not root node. + keep_this_irm =3D irm_device->config_rom[3] >> 8 =3D=3D CANON_OUI; + } + if (irm_is_1394_1995_only && !keep_this_irm) { new_root_id =3D local_id; fw_notice(card, "%s, making local node (%02x) root\n", --=20 2.48.1 From nobody Fri Oct 3 02:17:19 2025 Received: from fout-a3-smtp.messagingengine.com (fout-a3-smtp.messagingengine.com [103.168.172.146]) (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 C75BC21C19E for ; Mon, 8 Sep 2025 01:21:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=103.168.172.146 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757294490; cv=none; b=ftGjaqDZHNHBntGq9p6nZd+w8cw0OoHJ0HOZYUrreixPyGEOReMnQ9rVIIfbv4P1lXFPWlNJgfyFC+0Mev5AfClXLOUdi+u9X0fYEXZenpHU8sbfkjMhgsXbNSxVleSr3FZZBPyXS6BYfdvwgiX8yG8mqQT3lXKmJME5RT4yR18= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757294490; c=relaxed/simple; bh=PQQtFBgT54vCCIwCV7Eck4GoIN5bf9W23kR7uRuXUWg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=qz5hxcskLs5Ay6NRm1CjsWKowbDYsOc9jpXXBwkj6GtoixX9BTl6DGHzYvOypaEgdgrmFpX8rgfamcujNhTK7u1hP7/cBNbx91lFZBEfDnFpXSZs7/DKf/x/HylJPCKpJwmSsakXoDZZ2T5e51JwblmOr34YusCnEXr4VIqtBss= 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=fI3hC+9G; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=MUBM5r+8; arc=none smtp.client-ip=103.168.172.146 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="fI3hC+9G"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="MUBM5r+8" Received: from phl-compute-06.internal (phl-compute-06.internal [10.202.2.46]) by mailfout.phl.internal (Postfix) with ESMTP id F0CD9EC00A6; Sun, 7 Sep 2025 21:21:27 -0400 (EDT) Received: from phl-mailfrontend-01 ([10.202.2.162]) by phl-compute-06.internal (MEProxy); Sun, 07 Sep 2025 21:21:27 -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=fm1; t=1757294487; x= 1757380887; bh=UQnp+k+Zo5z2StVUHwUJPpMC87ruLHT+ma6kU7RfeZs=; b=f I3hC+9Gie2KnUrH3MNouwnweFat5ZaeaPTnbe7K3BOw2Ce8699YFahZ9spBWOHAp oIqmgiGHa/2ulr47ix7doP1/qY7YTBB3PIii4zlHm131vsEZUDMQTAIDaVweEXsb 2aY5svVE684TZ63ZVmrYUDXf0l7OGv9m1CLdgK0ksGfrC9SoWrlltNGS6Kjtn+yB Ea6BfMV8AERck/5iG3cbMcsLRw73hiaihIojpqDu5A9UZY7xJ2BWUgvywHtX+hEV 54pXxqvJXYcep6znKzNVPmPxjvrJcnpIxidl2hbV3JnW9TFHebQdWYDT5U3Zmpfz /58HPMzLP6f/r2KZoopfA== 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=fm1; t=1757294487; x=1757380887; bh=U Qnp+k+Zo5z2StVUHwUJPpMC87ruLHT+ma6kU7RfeZs=; b=MUBM5r+86MmeexnXr HSgMMi4QjGvfZMB6qKnyqqjeF7yJMTh9+mCmYhR8xJXX0wVcS+ZaQgNNfzRxLiVD tXIG6Awhy4jedF53OdCt6slj4ylTHvAf6p+0Y4fOsD/89G+e70SzEUP1eTfIPn8+ 3HdxRIe/aZ5VcrEwyIno0EYx3zQHD6WdWB/iyMuGv4xOkwsCixwcU0ruxB5JtuQa gjz+qCemlaWeWHaNOQsoyP/9p8jDHHu4m1es6qrNYFT+xZrUDG0dLJE8dW2r5v3q tgxPohyV+M7oKSkUmHL+zechz/7Eqo4FnZO2v7RdJDcA6hEMgQQOTYF6Q0S82z+t 4VkaA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeffedrtdeggdduiedvtdcutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpuffrtefokffrpgfnqfghnecuuegr ihhlohhuthemuceftddtnecunecujfgurhephffvvefufffkofgjfhgggfestdekredtre dttdenucfhrhhomhepvfgrkhgrshhhihcuufgrkhgrmhhothhouceoohdqthgrkhgrshhh ihesshgrkhgrmhhotggthhhirdhjpheqnecuggftrfgrthhtvghrnhepvdejgfejuedvgf duudekleevtefgtdevhfdtffefiefgveeuteffiedvffekvddtnecuvehluhhsthgvrhfu ihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepohdqthgrkhgrshhhihesshgrkh grmhhotggthhhirdhjphdpnhgspghrtghpthhtohepvddpmhhouggvpehsmhhtphhouhht pdhrtghpthhtoheplhhinhhugidufeelgedquggvvhgvlheslhhishhtshdrshhouhhrtg gvfhhorhhgvgdrnhgvthdprhgtphhtthhopehlihhnuhigqdhkvghrnhgvlhesvhhgvghr rdhkvghrnhgvlhdrohhrgh X-ME-Proxy: Feedback-ID: ie8e14432:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Sun, 7 Sep 2025 21:21:26 -0400 (EDT) From: Takashi Sakamoto To: linux1394-devel@lists.sourceforge.net Cc: linux-kernel@vger.kernel.org Subject: [PATCH 10/11] firewire: core: code refactoring to investigate root node for bus manager Date: Mon, 8 Sep 2025 10:21:07 +0900 Message-ID: <20250908012108.514698-11-o-takashi@sakamocchi.jp> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250908012108.514698-1-o-takashi@sakamocchi.jp> References: <20250908012108.514698-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" In the middle of bm_work function, both the value of gap_count and the state of root node are investigated. Current implementation is not a good shape since the investigation is aligned to be flat. This commit refactors the investigation with two large branches. Signed-off-by: Takashi Sakamoto --- drivers/firewire/core-card.c | 56 +++++++++++++++++------------------- 1 file changed, 27 insertions(+), 29 deletions(-) diff --git a/drivers/firewire/core-card.c b/drivers/firewire/core-card.c index 99aa98f195ba..b430a70a7eeb 100644 --- a/drivers/firewire/core-card.c +++ b/drivers/firewire/core-card.c @@ -294,7 +294,6 @@ static void bm_work(struct work_struct *work) int root_id, new_root_id, irm_id, local_id; int expected_gap_count, generation, grace; bool do_reset =3D false; - bool root_device_is_running; bool root_device_is_cmc; =20 lockdep_assert_held(&card->lock); @@ -310,8 +309,6 @@ static void bm_work(struct work_struct *work) =20 root_node =3D fw_node_get(card->root_node); root_device =3D fw_node_get_device(root_node); - root_device_is_running =3D root_device && - atomic_read(&root_device->state) =3D=3D FW_DEVICE_RUNNING; root_device_is_cmc =3D root_device && root_device->cmc; =20 root_id =3D root_node->node_id; @@ -450,34 +447,35 @@ static void bm_work(struct work_struct *work) * is inconsistent, so bypass the 5-reset limit. */ card->bm_retries =3D 0; - } else if (root_device =3D=3D NULL) { - /* - * Either link_on is false, or we failed to read the - * config rom. In either case, pick another root. - */ - new_root_id =3D local_id; - } else if (!root_device_is_running) { - /* - * If we haven't probed this device yet, bail out now - * and let's try again once that's done. - */ - spin_unlock_irq(&card->lock); - return; - } else if (root_device_is_cmc) { - /* - * We will send out a force root packet for this - * node as part of the gap count optimization. - */ - new_root_id =3D root_id; } else { - /* - * Current root has an active link layer and we - * successfully read the config rom, but it's not - * cycle master capable. - */ - new_root_id =3D local_id; - } + // Now investigate root node. + struct fw_device *root_device =3D fw_node_get_device(root_node); + + if (root_device =3D=3D NULL) { + // Either link_on is false, or we failed to read the + // config rom. In either case, pick another root. + new_root_id =3D local_id; + } else { + bool root_device_is_running =3D + atomic_read(&root_device->state) =3D=3D FW_DEVICE_RUNNING; =20 + if (!root_device_is_running) { + // If we haven't probed this device yet, bail out now + // and let's try again once that's done. + spin_unlock_irq(&card->lock); + return; + } else if (root_device->cmc) { + // We will send out a force root packet for this + // node as part of the gap count optimization. + new_root_id =3D root_id; + } else { + // Current root has an active link layer and we + // successfully read the config rom, but it's not + // cycle master capable. + new_root_id =3D local_id; + } + } + } pick_me: /* * Pick a gap count from 1394a table E-1. The table doesn't cover --=20 2.48.1 From nobody Fri Oct 3 02:17:19 2025 Received: from fout-a3-smtp.messagingengine.com (fout-a3-smtp.messagingengine.com [103.168.172.146]) (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 0AAFF22068F for ; Mon, 8 Sep 2025 01:21:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=103.168.172.146 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757294491; cv=none; b=BUh08CYhUTUlopHtl8PAQ7WL7LUwAEA12zjVnvSaV+RYQS3j5lxbBUNYuKrAL4TGXocigi6/IIk9GIEo8t/M7wIbdXTtCF+YmAvhK9LZwRmCXIkUZAToRcb/fVeQbrxP/DoJmcEz0YOvp1asg509XrX+Kxm4f9tYmS5BhXPeo54= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757294491; c=relaxed/simple; bh=a1AyLT7I4XXLIPIgADTKrxLpHqie4VNbgm3DilVFebM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=DoJmoUPPpRrgcwNKT3msCQwVEtnJ6c3jpc+dWqY4PKuBQptEXWuxrxEgrKur57cX6+V8xR4SPwrGJLZhVe6NYBZ9UST5Rjh31riwXf7Nm6SSALoG+LCuoRd2FIbVJAK/6m6B6X4WExK8f/KY4HX63ZHJkTsQuATikk+vRe6EtK8= 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=Fb/14rQt; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=f/KFz+JV; arc=none smtp.client-ip=103.168.172.146 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="Fb/14rQt"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="f/KFz+JV" Received: from phl-compute-04.internal (phl-compute-04.internal [10.202.2.44]) by mailfout.phl.internal (Postfix) with ESMTP id 46959EC004E; Sun, 7 Sep 2025 21:21:29 -0400 (EDT) Received: from phl-mailfrontend-01 ([10.202.2.162]) by phl-compute-04.internal (MEProxy); Sun, 07 Sep 2025 21:21:29 -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=fm1; t=1757294489; x= 1757380889; bh=tDcax/H5j3jJmh1j7DVnANT3twhs5JmjfUedN9rNnbE=; b=F b/14rQtFpCxKN91ZDbhRnW6H4tGR2/oHlbjoiCYvM06Tqpa/O0fvkrHSOcKW+EJL a6FhylUvzzTklWx1kW5+nl+14sP7r4xvty6tXfY3II8EK2lSTAxAoqcWpF9DsDJt 1zClwHMd3lAxEXCASIvJ7wwiKh9PraEVCp+lD24N6QW56l9/lW+/C4O9tMaZyqYj K3Kbsd8ocPlAY6cYZALzOPAj2hcWLZxjnyN9m/o1oMpWI2Rc/KNLnv5ZzZpPu6y6 gLUs0c/+z377tpYMfpg+CZ44Z/uz650TLa316iC4aU4R57no7bgC98j3JYZ/1P03 jQ7PJhDKQmLQjOvvMiTsg== 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=fm1; t=1757294489; x=1757380889; bh=t Dcax/H5j3jJmh1j7DVnANT3twhs5JmjfUedN9rNnbE=; b=f/KFz+JVF6X8XZDYm UFcLLfu/c+X2LPenQUM+/fbA2mvB8J/sd+zr6yxJHUbRoNP3NIL0bi5Hggsncv9R vkqr7KComwyk318ugz0qoJDFPGVW/O3MG1naX55b5cEmUufP37vuzTW93ZoN9PrE GHLR6bePEznp8qp9iwLSZYvr4ivqezxnI0P4YQ8W3MnRNToj8MlrDHQ5shmn1z1d tJeNIIOZhnNdm2jWzWKH1vO3q82lxLtGRbd33Sz9y3e1Cftkz065bkGlPC7VWE+B fyNEk9emF0h0k5TJXsEGfUjzG3d1puldSSy8UKo/QUY2P5fXYpG90fCDgPa7a9OD cRn2g== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeffedrtdeggdduiedulecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpuffrtefokffrpgfnqfghnecuuegr ihhlohhuthemuceftddtnecunecujfgurhephffvvefufffkofgjfhgggfestdekredtre dttdenucfhrhhomhepvfgrkhgrshhhihcuufgrkhgrmhhothhouceoohdqthgrkhgrshhh ihesshgrkhgrmhhotggthhhirdhjpheqnecuggftrfgrthhtvghrnhepvdejgfejuedvgf duudekleevtefgtdevhfdtffefiefgveeuteffiedvffekvddtnecuvehluhhsthgvrhfu ihiivgepudenucfrrghrrghmpehmrghilhhfrhhomhepohdqthgrkhgrshhhihesshgrkh grmhhotggthhhirdhjphdpnhgspghrtghpthhtohepvddpmhhouggvpehsmhhtphhouhht pdhrtghpthhtoheplhhinhhugidufeelgedquggvvhgvlheslhhishhtshdrshhouhhrtg gvfhhorhhgvgdrnhgvthdprhgtphhtthhopehlihhnuhigqdhkvghrnhgvlhesvhhgvghr rdhkvghrnhgvlhdrohhrgh X-ME-Proxy: Feedback-ID: ie8e14432:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Sun, 7 Sep 2025 21:21:28 -0400 (EDT) From: Takashi Sakamoto To: linux1394-devel@lists.sourceforge.net Cc: linux-kernel@vger.kernel.org Subject: [PATCH 11/11] firewire: core: code refactoring whether root node is cycle master capable Date: Mon, 8 Sep 2025 10:21:08 +0900 Message-ID: <20250908012108.514698-12-o-takashi@sakamocchi.jp> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250908012108.514698-1-o-takashi@sakamocchi.jp> References: <20250908012108.514698-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 check of cycle master capability in root node is currently just in a condition branch. In this case, the required variable should be within the branch. This commit is just for the purpose. Signed-off-by: Takashi Sakamoto --- drivers/firewire/core-card.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/drivers/firewire/core-card.c b/drivers/firewire/core-card.c index b430a70a7eeb..474d8066e090 100644 --- a/drivers/firewire/core-card.c +++ b/drivers/firewire/core-card.c @@ -289,12 +289,10 @@ static void bm_work(struct work_struct *work) 63, 5, 7, 8, 10, 13, 16, 18, 21, 24, 26, 29, 32, 35, 37, 40 }; struct fw_card *card __free(card_unref) =3D from_work(card, work, bm_work= .work); - struct fw_device *root_device; struct fw_node *root_node __free(node_unref) =3D NULL; int root_id, new_root_id, irm_id, local_id; int expected_gap_count, generation, grace; bool do_reset =3D false; - bool root_device_is_cmc; =20 lockdep_assert_held(&card->lock); =20 @@ -308,8 +306,6 @@ static void bm_work(struct work_struct *work) generation =3D card->generation; =20 root_node =3D fw_node_get(card->root_node); - root_device =3D fw_node_get_device(root_node); - root_device_is_cmc =3D root_device && root_device->cmc; =20 root_id =3D root_node->node_id; irm_id =3D card->irm_node->node_id; @@ -519,9 +515,11 @@ static void bm_work(struct work_struct *work) reset_bus(card, card_gap_count !=3D 0); /* Will allocate broadcast channel after the reset. */ } else { + struct fw_device *root_device =3D fw_node_get_device(root_node); + spin_unlock_irq(&card->lock); =20 - if (root_device_is_cmc) { + if (root_device && root_device->cmc) { // Make sure that the cycle master sends cycle start packets. __be32 data =3D cpu_to_be32(CSR_STATE_BIT_CMSTR); int rcode =3D fw_run_transaction(card, TCODE_WRITE_QUADLET_REQUEST, --=20 2.48.1