From nobody Tue Jun 16 20:39:28 2026 Received: from fout-a1-smtp.messagingengine.com (fout-a1-smtp.messagingengine.com [103.168.172.144]) (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 4DFEE392825 for ; Wed, 29 Apr 2026 09:34:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=103.168.172.144 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777455298; cv=none; b=Omlrykv0lwpz+k/X8GI2wWa/y3XfRIglBPZ+f45fsuIwMTx1NDiA2+xdDl4y2nUxkJMVJSg0PjxCFBKXAUuEVfVvlKPv0TITw9GdVa0GKuaAmQJOvL2SG9KPvOkfivZ5fNbG1/7p6rxrpebSafQBFexZL9BgF294v/XIn/jPw4o= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777455298; c=relaxed/simple; bh=Nih+1o1H+wa/3nmDh9kJQBeZts9Mw1BUAlGh/ZasQYI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=thTSlp1/5Ju4oNFDHOobM/+gk8XvshZzsUY5TnlyBv13DsRZF6ZTtOsBdpnpuHsvmwbF8nNqb/a8tBnl2Q+ld3WLj36ZoGwCqdkQwdbE8a4gUeYF0Ylv+KpocIbLKPN1zzq+DYo4L/GF22qvlR6NQIojGL7HbjqQLd+MWn/r24M= 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=gxj7ar75; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=Jsev29FB; arc=none smtp.client-ip=103.168.172.144 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="gxj7ar75"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="Jsev29FB" Received: from phl-compute-04.internal (phl-compute-04.internal [10.202.2.44]) by mailfout.phl.internal (Postfix) with ESMTP id 7531CEC0197; Wed, 29 Apr 2026 05:34:55 -0400 (EDT) Received: from phl-frontend-04 ([10.202.2.163]) by phl-compute-04.internal (MEProxy); Wed, 29 Apr 2026 05:34:55 -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=fm2; t=1777455295; x= 1777541695; bh=lCoiG1y8GvthHZ+IXnyjvnIwvTB7KwAmo9ojiPaeOQs=; b=g xj7ar75iErYcV/v8w22DUbZ7s2HZ3AikmwxjzYuqUrphp4IghYY/s3jgf+T+3uiU N3j9ZguFOnVSz7R1Kad49pn86LVTkCiBi8aCD/MLOGYG8da5s7S0+xB5gQmWiu6D hMKs3kkN8EI7K7adFwFiwFi7oD6HRPLJ+/bA+4f5D3Pn+3oX+XlILrk2SZDBMuNH +7hxRGF8m5Nt0zuqc+88DRVP+moqGObU7eUiu+a/6SAhJnxjrVSx8jvk6W0qThkb 5s516l3vfv/CpY5kwHhWc4WaobimU7A4ST0ksffmCrYrr2QjdiMwWLiC8rkdLDyO VinYh9Vv006huxQTcWe0Q== 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=fm2; t=1777455295; x=1777541695; bh=l CoiG1y8GvthHZ+IXnyjvnIwvTB7KwAmo9ojiPaeOQs=; b=Jsev29FB5ob03/apd vr6J1DJmHtzzbryAd83UL+mxLD2L2VFAZdvzUQSwoCosBxzZu/1Y3vu9TfBNEv5R YTlSXgjlSkmqcySnVpZFIZ+fMhc1zO1rnLTGywpG4w1FwuxC7WB1Bm48+SGyDaUv uMsXAe3WzMZ1+2wAa/wxmeKEoqYT9C/+AL3+T9mnW4FSFvA/XXiLNKRdB29uqKpi SPkYhvpIm+CUbKoqoNV8ZWhG8pzmwHrfm1RFR7yVuM9dN3xGb4mevPcRn8m7fhoL +jcXhb5tKVCJhgz04mHLu7JTg6jHRbuhjIkOjbNFoOTo1Piod5LGR9yQ4DwLtLGK IfVdA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefhedrtddtgdekgedtlecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpuffrtefokffrpgfnqfghnecuuegr ihhlohhuthemuceftddtnecunecujfgurhephffvvefufffkofgjfhgggfestdekredtre dttdenucfhrhhomhepvfgrkhgrshhhihcuufgrkhgrmhhothhouceoohdqthgrkhgrshhh ihesshgrkhgrmhhotggthhhirdhjpheqnecuggftrfgrthhtvghrnhepvdejgfejuedvgf duudekleevtefgtdevhfdtffefiefgveeuteffiedvffekvddtnecuvehluhhsthgvrhfu ihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepohdqthgrkhgrshhhihesshgrkh grmhhotggthhhirdhjphdpnhgspghrtghpthhtohepgedpmhhouggvpehsmhhtphhouhht pdhrtghpthhtoheplhhinhhugidufeelgedquggvvhgvlheslhhishhtshdrshhouhhrtg gvfhhorhhgvgdrnhgvthdprhgtphhtthhopehshhhurghnghhpvghnghdrkhgvrhhnvghl sehgmhgrihhlrdgtohhmpdhrtghpthhtohepughinhhgihhsohdrkhgvrhhnvghlsehgmh grihhlrdgtohhmpdhrtghpthhtoheplhhinhhugidqkhgvrhhnvghlsehvghgvrhdrkhgv rhhnvghlrdhorhhg X-ME-Proxy: Feedback-ID: ie8e14432:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 29 Apr 2026 05:34:53 -0400 (EDT) From: Takashi Sakamoto To: linux1394-devel@lists.sourceforge.net Cc: shuangpeng.kernel@gmail.com, dingiso.kernel@gmail.com, linux-kernel@vger.kernel.org Subject: [PATCH 1/7] firewire: core: code refactoring for early return at client resource allocation Date: Wed, 29 Apr 2026 18:34:42 +0900 Message-ID: <20260429093449.160545-2-o-takashi@sakamocchi.jp> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260429093449.160545-1-o-takashi@sakamocchi.jp> References: <20260429093449.160545-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 add_client_resource() function returns zero at success or negative value at error. The critical section is already protected by scoped_guard() macro. In this case, the programming pattern of early return improves code readability. Signed-off-by: Takashi Sakamoto --- drivers/firewire/core-cdev.c | 35 +++++++++++++++++------------------ 1 file changed, 17 insertions(+), 18 deletions(-) diff --git a/drivers/firewire/core-cdev.c b/drivers/firewire/core-cdev.c index f791db4c8dff..144625c34be2 100644 --- a/drivers/firewire/core-cdev.c +++ b/drivers/firewire/core-cdev.c @@ -507,31 +507,30 @@ static int ioctl_get_info(struct client *client, unio= n ioctl_arg *arg) static int add_client_resource(struct client *client, struct client_resour= ce *resource, gfp_t gfp_mask) { - int ret; - scoped_guard(spinlock_irqsave, &client->lock) { u32 index; + int ret; + + if (client->in_shutdown) + return -ECANCELED; =20 - if (client->in_shutdown) { - ret =3D -ECANCELED; + if (gfpflags_allow_blocking(gfp_mask)) { + ret =3D xa_alloc(&client->resource_xa, &index, resource, xa_limit_32b, + GFP_NOWAIT); } else { - if (gfpflags_allow_blocking(gfp_mask)) { - ret =3D xa_alloc(&client->resource_xa, &index, resource, xa_limit_32b, - GFP_NOWAIT); - } else { - ret =3D xa_alloc_bh(&client->resource_xa, &index, resource, - xa_limit_32b, GFP_NOWAIT); - } - } - if (ret >=3D 0) { - resource->handle =3D index; - client_get(client); - if (is_iso_resource(resource)) - schedule_iso_resource(to_iso_resource(resource), 0); + ret =3D xa_alloc_bh(&client->resource_xa, &index, resource, + xa_limit_32b, GFP_NOWAIT); } + if (ret < 0) + return ret; + + resource->handle =3D index; + client_get(client); + if (is_iso_resource(resource)) + schedule_iso_resource(to_iso_resource(resource), 0); } =20 - return ret < 0 ? ret : 0; + return 0; } =20 static int release_client_resource(struct client *client, u32 handle, --=20 2.53.0 From nobody Tue Jun 16 20:39:28 2026 Received: from fhigh-a6-smtp.messagingengine.com (fhigh-a6-smtp.messagingengine.com [103.168.172.157]) (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 B9FCB395D84 for ; Wed, 29 Apr 2026 09:34:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=103.168.172.157 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777455299; cv=none; b=nJMEbz0m43l0N19pxwRYQD/GbSzEuUQs3dp03fkGPfUMtp1BusCYhCGDMOJtJ53YPg/hRdNSLrdUaXjVhs+IRMUwGKkAVc9Ovkhjpctvr2DJ+crfLOzwGQ9MjfzqIpJ4UkZFa+dNcSuamdU6H1wMw7Km+ic723TMuqOlJQ/xG+I= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777455299; c=relaxed/simple; bh=nUYth5y4YzechWkyDH9FWnrOsvLH+wd/pyG6E+KeXEk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=m+BXsyUQPAjwBqs6DSZ8w5MVm6GMjAUQ7WNn9hdtUh9DeSpUoPLwLwv8y5e1TyMIVmYRL19gFMByczXKa39xVHSENzv+7f5D4xufXhNACGZ9Tr0bUewLXIjeJGdINGViLpUZHoEhF+xi8pRU6o/7bCnZPG/kpNTKdhGSP2AZTwE= 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=gfbu7WJ9; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=bWDDYVtW; arc=none smtp.client-ip=103.168.172.157 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="gfbu7WJ9"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="bWDDYVtW" Received: from phl-compute-09.internal (phl-compute-09.internal [10.202.2.49]) by mailfhigh.phl.internal (Postfix) with ESMTP id 16BDC1400041; Wed, 29 Apr 2026 05:34:57 -0400 (EDT) Received: from phl-frontend-04 ([10.202.2.163]) by phl-compute-09.internal (MEProxy); Wed, 29 Apr 2026 05:34:57 -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=fm2; t=1777455297; x= 1777541697; bh=xnJHF3q0EV3mTcRvsT29Ye1XRknJ05vRFufwjT8gOdk=; b=g fbu7WJ9la/4ta6fCA0xZJPAagAhkvxnjhfe+rByVyDrUz0qohFVowtK/NWBlKlJZ p+9WRexEmTTihIQW0agUsOxIOu+sQf1VEAFq1kQ4QIm569mQlQWBM/aWSFxAcqZX O147/jP7a8Akq5DtEOfs0PQZPACXXmESGb0Qtm1tWquogF41s0+y7eRGeLLfIdiY XH7ye6NbTbw+KGcYwwIvr5ZhnX2MV2lNG7rgArtV7IbLL+g+sbuzgea/lgNACDIF 52SV7D6WQU0PcbaBldgAQnKOO22L+px3lJHV9mXs8URbrfoY+ld7vvsdcW5G/MuN niRyArMFswSyxbgCfIA8A== 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=fm2; t=1777455297; x=1777541697; bh=x nJHF3q0EV3mTcRvsT29Ye1XRknJ05vRFufwjT8gOdk=; b=bWDDYVtWvw+YQiES0 x9kYTUUivhwG16qjus6PoAhF5ggIHxuFm28X6PBGjywZuHpUUCzx2Kr77InI6Ite z2leiW+kor0U2vTV5ZPtH7umA5hZZPjR2e79JaCBfprDuA8tCiL+7RKVadEwpsZv VZfXPIncvIX4A2SzsgHRmoUtTiZY3Zv1FrO4lsVJ6wf82NogGpKlFJDNgrQ57/7F FixUgreYzO0XWzU6S9auOlLtxxclb7ujoGu1QNnwq2C2A7tSRnTgE9mdjxE9+Ez9 9AJ1g5a4drHVYxF+n/jYR0rvAp13t8uFMOpXk7dMtH5XD3+9ZuFSTljftock2a8v a7B+Q== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefhedrtddtgdekgedtlecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpuffrtefokffrpgfnqfghnecuuegr ihhlohhuthemuceftddtnecunecujfgurhephffvvefufffkofgjfhgggfestdekredtre dttdenucfhrhhomhepvfgrkhgrshhhihcuufgrkhgrmhhothhouceoohdqthgrkhgrshhh ihesshgrkhgrmhhotggthhhirdhjpheqnecuggftrfgrthhtvghrnhepvdejgfejuedvgf duudekleevtefgtdevhfdtffefiefgveeuteffiedvffekvddtnecuvehluhhsthgvrhfu ihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepohdqthgrkhgrshhhihesshgrkh grmhhotggthhhirdhjphdpnhgspghrtghpthhtohepgedpmhhouggvpehsmhhtphhouhht pdhrtghpthhtoheplhhinhhugidufeelgedquggvvhgvlheslhhishhtshdrshhouhhrtg gvfhhorhhgvgdrnhgvthdprhgtphhtthhopehshhhurghnghhpvghnghdrkhgvrhhnvghl sehgmhgrihhlrdgtohhmpdhrtghpthhtohepughinhhgihhsohdrkhgvrhhnvghlsehgmh grihhlrdgtohhmpdhrtghpthhtoheplhhinhhugidqkhgvrhhnvghlsehvghgvrhdrkhgv rhhnvghlrdhorhhg X-ME-Proxy: Feedback-ID: ie8e14432:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 29 Apr 2026 05:34:55 -0400 (EDT) From: Takashi Sakamoto To: linux1394-devel@lists.sourceforge.net Cc: shuangpeng.kernel@gmail.com, dingiso.kernel@gmail.com, linux-kernel@vger.kernel.org Subject: [PATCH 2/7] firewire: core: code refactoring to queue work item for iso_resource Date: Wed, 29 Apr 2026 18:34:43 +0900 Message-ID: <20260429093449.160545-3-o-takashi@sakamocchi.jp> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260429093449.160545-1-o-takashi@sakamocchi.jp> References: <20260429093449.160545-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 add_client_resource() function checks the type of client resource every time to be called. If the type is for iso_resource, it schedules work item. However, the iso_resource client resource is only added by the call of init_iso_resource(). There is no need to check the type every time adding any client resource. Signed-off-by: Takashi Sakamoto --- drivers/firewire/core-cdev.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/firewire/core-cdev.c b/drivers/firewire/core-cdev.c index 144625c34be2..8391c7efab2c 100644 --- a/drivers/firewire/core-cdev.c +++ b/drivers/firewire/core-cdev.c @@ -526,8 +526,6 @@ static int add_client_resource(struct client *client, s= truct client_resource *re =20 resource->handle =3D index; client_get(client); - if (is_iso_resource(resource)) - schedule_iso_resource(to_iso_resource(resource), 0); } =20 return 0; @@ -1438,8 +1436,9 @@ static int init_iso_resource(struct client *client, } else { r->resource.release =3D NULL; r->resource.handle =3D -1; - schedule_iso_resource(r, 0); } + schedule_iso_resource(r, 0); + request->handle =3D r->resource.handle; =20 return 0; --=20 2.53.0 From nobody Tue Jun 16 20:39:28 2026 Received: from fhigh-a6-smtp.messagingengine.com (fhigh-a6-smtp.messagingengine.com [103.168.172.157]) (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 5D49036403C for ; Wed, 29 Apr 2026 09:34:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=103.168.172.157 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777455301; cv=none; b=gwfstaHkE6OsNi6fHoWneDwbz3HTE3EUbbUWwtSA2VwSGUYfnjA2CtULRYDmuxn1Aujo2TFUWJxypNzp1vKqJZbCr8awt0Aq61k2ACpWw3DciMGqeS3bcNLTVASepNeYOzNOSrjCYRCgGuUoPu349q+cBPuUg00BxqFeUTNF1sI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777455301; c=relaxed/simple; bh=OlYX7dgeCZ1G5jM+4SCF1T8oIiTX/4QiFs67QS7vBmM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ISh52DMgbn2dlKXBXO/NfRmum0tzXZqzzqWeyYJcLWefPEr/DeppvMc35PP440a7Ufe3ldcg0aVE2Eh9HAeEJM4bLlMPwCmAcfbLbGUJKLJJyeWEVa+FN7f51mD2KVT1FvkeLpiw05OIeTzEUg3P2RfAaFzOT5QI0f32hIz7pEs= 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=KFgC2zkr; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=EbUjQY8G; arc=none smtp.client-ip=103.168.172.157 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="KFgC2zkr"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="EbUjQY8G" Received: from phl-compute-02.internal (phl-compute-02.internal [10.202.2.42]) by mailfhigh.phl.internal (Postfix) with ESMTP id AA95F140002E; Wed, 29 Apr 2026 05:34:58 -0400 (EDT) Received: from phl-frontend-04 ([10.202.2.163]) by phl-compute-02.internal (MEProxy); Wed, 29 Apr 2026 05:34:58 -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=fm2; t=1777455298; x= 1777541698; bh=N62dO2IkgYEvWkqr+r1yC3Y9QmJvm4a9il4UNRzq2B4=; b=K FgC2zkr5FDVxekXfRn1T2FiLPjl1yE4I63YwZhJJEZC35RYH5Mq7UL7CK+LXito6 VDiGq/JPfrAF2znQVvAxvAYIQ28m7KlrIL33vt7VlfH9VF6ZtrFcl1nfple0tajA uPpTK8GPirO5ptOswWzm32r4OfdBZJtjnT3zUb6qmHPHXsnIXjeoq3S/GHDLExYO BUVPoUqvuYYduhUgjuvV7MvPYOPIapY2SZJ2dTdA2WhtovgluIZOnosLRBFJHexy ClrcUSoZ0iquL7pS/2ij/ejyjrGZKeeK63nZk/pCYFibo+8xBRGjtaTdk6NqJlD/ 6ew9tbf+Dcw8DEy6hg7sQ== 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=fm2; t=1777455298; x=1777541698; bh=N 62dO2IkgYEvWkqr+r1yC3Y9QmJvm4a9il4UNRzq2B4=; b=EbUjQY8GfG2sMLEM7 YeMC1ArU9pWWspieCR1aK7JywH3iCVyuatxSEXCsIOyYRcYNIVTSfoxfc5fFw7hb K/JiC1h0GWIGztjAv2D4EZLmZU345pRIhmtnJcn+QrtXhWQY+unvAIuajk50rEg/ izVrJZLGT/EkjmJDuCaskNjYVoFdy0POA4ATt+QA3bpG7Dmnld0kciquJnZS9J84 w9T84f3NR2wkYD2A653YKEuplAuHAN19R3BfAefnomIXK25+alWGwFTEK39QqeQc hBq8rbwzOTPAT7Mxg6WQca38zOzRTWQtrWFeuyvTctMgI+2ZIgcwjUhxYuNc5Z/G BlHQA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefhedrtddtgdekgedtlecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpuffrtefokffrpgfnqfghnecuuegr ihhlohhuthemuceftddtnecunecujfgurhephffvvefufffkofgjfhgggfestdekredtre dttdenucfhrhhomhepvfgrkhgrshhhihcuufgrkhgrmhhothhouceoohdqthgrkhgrshhh ihesshgrkhgrmhhotggthhhirdhjpheqnecuggftrfgrthhtvghrnhepvdejgfejuedvgf duudekleevtefgtdevhfdtffefiefgveeuteffiedvffekvddtnecuvehluhhsthgvrhfu ihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepohdqthgrkhgrshhhihesshgrkh grmhhotggthhhirdhjphdpnhgspghrtghpthhtohepgedpmhhouggvpehsmhhtphhouhht pdhrtghpthhtoheplhhinhhugidufeelgedquggvvhgvlheslhhishhtshdrshhouhhrtg gvfhhorhhgvgdrnhgvthdprhgtphhtthhopehshhhurghnghhpvghnghdrkhgvrhhnvghl sehgmhgrihhlrdgtohhmpdhrtghpthhtohepughinhhgihhsohdrkhgvrhhnvghlsehgmh grihhlrdgtohhmpdhrtghpthhtoheplhhinhhugidqkhgvrhhnvghlsehvghgvrhdrkhgv rhhnvghlrdhorhhg X-ME-Proxy: Feedback-ID: ie8e14432:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 29 Apr 2026 05:34:57 -0400 (EDT) From: Takashi Sakamoto To: linux1394-devel@lists.sourceforge.net Cc: shuangpeng.kernel@gmail.com, dingiso.kernel@gmail.com, linux-kernel@vger.kernel.org Subject: [PATCH 3/7] firewire: core: code refactoring for helper function to fill iso_resource parameters Date: Wed, 29 Apr 2026 18:34:44 +0900 Message-ID: <20260429093449.160545-4-o-takashi@sakamocchi.jp> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260429093449.160545-1-o-takashi@sakamocchi.jp> References: <20260429093449.160545-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" This change is a preparation for future changes. The added helper function will be reused in the changes to fill iso_resource parameters according to the users' request. Signed-off-by: Takashi Sakamoto --- drivers/firewire/core-cdev.c | 45 ++++++++++++++++++++++++------------ 1 file changed, 30 insertions(+), 15 deletions(-) diff --git a/drivers/firewire/core-cdev.c b/drivers/firewire/core-cdev.c index 8391c7efab2c..effa03739679 100644 --- a/drivers/firewire/core-cdev.c +++ b/drivers/firewire/core-cdev.c @@ -128,6 +128,12 @@ struct descriptor_resource { u32 data[]; }; =20 +struct iso_resource_params { + int generation; + u64 channels; + s32 bandwidth; +}; + struct iso_resource { struct client_resource resource; struct client *client; @@ -135,9 +141,7 @@ struct iso_resource { struct delayed_work work; enum {ISO_RES_ALLOC, ISO_RES_REALLOC, ISO_RES_DEALLOC, ISO_RES_ALLOC_ONCE, ISO_RES_DEALLOC_ONCE,} todo; - int generation; - u64 channels; - s32 bandwidth; + struct iso_resource_params params; struct iso_resource_event *e_alloc, *e_dealloc; }; =20 @@ -1290,6 +1294,20 @@ static int ioctl_get_cycle_timer(struct client *clie= nt, union ioctl_arg *arg) return 0; } =20 +static int fill_iso_resource_params(struct iso_resource_params *params, + struct fw_cdev_allocate_iso_resource *request) +{ + if ((request->channels =3D=3D 0 && request->bandwidth =3D=3D 0) || + request->bandwidth > BANDWIDTH_AVAILABLE_INITIAL) + return -EINVAL; + + params->generation =3D -1; + params->channels =3D request->channels; + params->bandwidth =3D request->bandwidth; + + return 0; +} + static void iso_resource_work(struct work_struct *work) { struct iso_resource_event *e; @@ -1310,21 +1328,21 @@ static void iso_resource_work(struct work_struct *w= ork) } else { // We could be called twice within the same generation. skip =3D todo =3D=3D ISO_RES_REALLOC && - r->generation =3D=3D generation; + r->params.generation =3D=3D generation; } free =3D todo =3D=3D ISO_RES_DEALLOC || todo =3D=3D ISO_RES_ALLOC_ONCE || todo =3D=3D ISO_RES_DEALLOC_ONCE; - r->generation =3D generation; + r->params.generation =3D generation; } =20 if (skip) goto out; =20 - bandwidth =3D r->bandwidth; + bandwidth =3D r->params.bandwidth; =20 fw_iso_resource_manage(client->device->card, generation, - r->channels, &channel, &bandwidth, + r->params.channels, &channel, &bandwidth, todo =3D=3D ISO_RES_ALLOC || todo =3D=3D ISO_RES_REALLOC || todo =3D=3D ISO_RES_ALLOC_ONCE); @@ -1355,7 +1373,7 @@ static void iso_resource_work(struct work_struct *wor= k) } =20 if (todo =3D=3D ISO_RES_ALLOC && channel >=3D 0) - r->channels =3D 1ULL << channel; + r->params.channels =3D 1ULL << channel; =20 if (todo =3D=3D ISO_RES_REALLOC && success) goto out; @@ -1402,10 +1420,6 @@ static int init_iso_resource(struct client *client, struct iso_resource *r; int ret; =20 - if ((request->channels =3D=3D 0 && request->bandwidth =3D=3D 0) || - request->bandwidth > BANDWIDTH_AVAILABLE_INITIAL) - return -EINVAL; - r =3D kmalloc_obj(*r); e1 =3D kmalloc_obj(*e1); e2 =3D kmalloc_obj(*e2); @@ -1414,12 +1428,13 @@ static int init_iso_resource(struct client *client, goto fail; } =20 + ret =3D fill_iso_resource_params(&r->params, request); + if (ret < 0) + goto fail; + INIT_DELAYED_WORK(&r->work, iso_resource_work); r->client =3D client; r->todo =3D todo; - r->generation =3D -1; - r->channels =3D request->channels; - r->bandwidth =3D request->bandwidth; r->e_alloc =3D e1; r->e_dealloc =3D e2; =20 --=20 2.53.0 From nobody Tue Jun 16 20:39:28 2026 Received: from fout-a1-smtp.messagingengine.com (fout-a1-smtp.messagingengine.com [103.168.172.144]) (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 174B339C64E for ; Wed, 29 Apr 2026 09:35:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=103.168.172.144 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777455302; cv=none; b=uDmcWYoOt/SYDfj96/rCzBePSgKRkQkoTKwVT46nOvqFRWZj77li0EI2f1waGNZZOFefiRbJg4CxngkRmGI4pQTs2lOzPym74tnTKdRXCdqhrmDtQ14VuqEBbA+bD4Kz0cx4v3tQZd5G4jc9blXG6AdwFzE+wJAQM1OxMiQSM88= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777455302; c=relaxed/simple; bh=iYa6QPtbbOReHXjXjRm4CjQz2tV9O4+eMiCG6rUHd5Q=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=fBeCuLOhr2siS+i5XfQBFny63xUN9LyZJqEmeQ3OYHYxjMvXXUlhc6UZ7cenIucQetp6xKullXPDOhPfHUdSOk1ElJsLMHm+WslmvbcmbQtIuL3Uc+ZlSzwULCPdsTWwsM85vLSkIv+y3OFY7tjp31G2qzUnv0MIMwZKVKf0HsM= 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=zalnqAQP; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=r/qTv3CD; arc=none smtp.client-ip=103.168.172.144 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="zalnqAQP"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="r/qTv3CD" Received: from phl-compute-03.internal (phl-compute-03.internal [10.202.2.43]) by mailfout.phl.internal (Postfix) with ESMTP id 4B614EC0198; Wed, 29 Apr 2026 05:35:00 -0400 (EDT) Received: from phl-frontend-04 ([10.202.2.163]) by phl-compute-03.internal (MEProxy); Wed, 29 Apr 2026 05:35:00 -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=fm2; t=1777455300; x= 1777541700; bh=xctR9ZNAUKqbPu11yo5cMMsj9hUwz8Ko5NoLApkNrto=; b=z alnqAQPKJi4YK4AwuVEKfrCWk4TKxAcfgvAbnHN3k1vRaMZDycNWMxhrtkgatSCt dKKu+1Z6fu4lJA08Wo1TcgOh6WIk12K/ovwbQzsVWTmGaGSx3LwpDMwqhN1HvWv4 ip1fFQQCEMm/ac1oTrZ9soFAqhRCE61HPf+Rh4Zsg5yX5rePRtACN7G/G5lNYXrZ OnblkVXz5GLBWoycdwTWtR/2gqhfU5HHK0dOV8D+fscI05OibJ6u0BlIxMfKgQjU nCCo6CS2WdypIOUBBTizCBqwBDgjXsWQdXHMCdn8RLlDUjV7kYVZW8gO0nWkAtBQ ftrV4pGlxZZWDLtDA0v1Q== 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=fm2; t=1777455300; x=1777541700; bh=x ctR9ZNAUKqbPu11yo5cMMsj9hUwz8Ko5NoLApkNrto=; b=r/qTv3CDjSRqNfDJq d3LbQtAAr3jNV6kA1my+7BlzzirYb/04uIW13pRMbsqp9PvvKQe50YHYV2cJi+iJ WVoaG3NLr8oJm6R0wmJtDYy33/EfOtwLX6Qx6AW7jPDJuDpot2B23v4qatV8yXDS a2btbgmolTqa8GeKx2HEnfPJRvJt0PoV4smy84+PDJ0yAZfv5P2LiVAryt4kJ4wO EyXehZ5/UO+1ORFwOxv29J3ApQh44cObrL+L9mBrG/iSuqPmGdbcBb+unhWtN//G bQJMNKnAUH+Nk5a5DjZRhOtQR8TFv/IFEw5o5KuDh4cTrPSJDbNEBAVc1uaGEtZA 1WBwg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefhedrtddtgdekgedtlecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpuffrtefokffrpgfnqfghnecuuegr ihhlohhuthemuceftddtnecunecujfgurhephffvvefufffkofgjfhgggfestdekredtre dttdenucfhrhhomhepvfgrkhgrshhhihcuufgrkhgrmhhothhouceoohdqthgrkhgrshhh ihesshgrkhgrmhhotggthhhirdhjpheqnecuggftrfgrthhtvghrnhepvdejgfejuedvgf duudekleevtefgtdevhfdtffefiefgveeuteffiedvffekvddtnecuvehluhhsthgvrhfu ihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepohdqthgrkhgrshhhihesshgrkh grmhhotggthhhirdhjphdpnhgspghrtghpthhtohepgedpmhhouggvpehsmhhtphhouhht pdhrtghpthhtoheplhhinhhugidufeelgedquggvvhgvlheslhhishhtshdrshhouhhrtg gvfhhorhhgvgdrnhgvthdprhgtphhtthhopehshhhurghnghhpvghnghdrkhgvrhhnvghl sehgmhgrihhlrdgtohhmpdhrtghpthhtohepughinhhgihhsohdrkhgvrhhnvghlsehgmh grihhlrdgtohhmpdhrtghpthhtoheplhhinhhugidqkhgvrhhnvghlsehvghgvrhdrkhgv rhhnvghlrdhorhhg X-ME-Proxy: Feedback-ID: ie8e14432:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 29 Apr 2026 05:34:58 -0400 (EDT) From: Takashi Sakamoto To: linux1394-devel@lists.sourceforge.net Cc: shuangpeng.kernel@gmail.com, dingiso.kernel@gmail.com, linux-kernel@vger.kernel.org Subject: [PATCH 4/7] firewire: core: split functions for iso_resource once operation Date: Wed, 29 Apr 2026 18:34:45 +0900 Message-ID: <20260429093449.160545-5-o-takashi@sakamocchi.jp> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260429093449.160545-1-o-takashi@sakamocchi.jp> References: <20260429093449.160545-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" Unlike FW_CDEV_IOC_ALLOCATE_ISO_RESOURCE operation, the operations of FW_CDEV_IOC_[DE]ALLOCATE_ISO_RESOURCE_ONCE require no client resource, thus they keeps no handle value. This commit adds the series of functions to separate these operations, according to divide-and-conquer methodology. Signed-off-by: Takashi Sakamoto --- drivers/firewire/core-cdev.c | 83 ++++++++++++++++++++++++++++++++++-- 1 file changed, 79 insertions(+), 4 deletions(-) diff --git a/drivers/firewire/core-cdev.c b/drivers/firewire/core-cdev.c index effa03739679..478e8f6400f0 100644 --- a/drivers/firewire/core-cdev.c +++ b/drivers/firewire/core-cdev.c @@ -145,6 +145,18 @@ struct iso_resource { struct iso_resource_event *e_alloc, *e_dealloc; }; =20 +struct iso_resource_once { + struct client *client; + // Schedule work and access todo only with client->lock held. + struct delayed_work work; + enum { + ISO_RES_ONCE_ALLOC, + ISO_RES_ONCE_DEALLOC, + } todo; + struct iso_resource_params params; + struct iso_resource_event *event; +}; + static struct address_handler_resource *to_address_handler_resource(struct= client_resource *resource) { return container_of(resource, struct address_handler_resource, resource); @@ -1479,18 +1491,81 @@ static int ioctl_deallocate_iso_resource(struct cli= ent *client, arg->deallocate.handle, release_iso_resource, NULL); } =20 +#define UNAVAILABLE_HANDLE -1 + +static void iso_resource_once_work(struct work_struct *work) +{ + struct iso_resource_once *r =3D from_work(r, work, work.work); + struct client *client =3D r->client; + struct iso_resource_event *e =3D r->event; + int generation, channel, bandwidth; + + scoped_guard(spinlock_irq, &client->lock) + generation =3D client->device->generation; + + r->params.generation =3D generation; + bandwidth =3D r->params.bandwidth; + + fw_iso_resource_manage(client->device->card, generation, r->params.channe= ls, &channel, + &bandwidth, r->todo =3D=3D ISO_RES_ONCE_ALLOC); + + e->iso_resource.handle =3D UNAVAILABLE_HANDLE; + e->iso_resource.channel =3D channel; + e->iso_resource.bandwidth =3D bandwidth; + + queue_event(client, &e->event, &e->iso_resource, sizeof(e->iso_resource),= NULL, 0); + + cancel_delayed_work(&r->work); + kfree(r); + + client_put(client); +} + +static int init_iso_resource_once(struct client *client, + struct fw_cdev_allocate_iso_resource *request, int todo) +{ + struct iso_resource_event *e __free(kfree) =3D kmalloc_obj(*e); + struct iso_resource_once *r __free(kfree) =3D kmalloc_obj(*r); + int err; + + if (!r || !e) + return -ENOMEM; + + err =3D fill_iso_resource_params(&r->params, request); + if (err < 0) + return err; + + INIT_DELAYED_WORK(&r->work, iso_resource_once_work); + r->client =3D client; + r->todo =3D todo; + + if (todo =3D=3D ISO_RES_ONCE_ALLOC) + e->iso_resource.type =3D FW_CDEV_EVENT_ISO_RESOURCE_ALLOCATED; + else + e->iso_resource.type =3D FW_CDEV_EVENT_ISO_RESOURCE_DEALLOCATED; + e->iso_resource.closure =3D request->closure; + r->event =3D no_free_ptr(e); + + // Keep the client until work item finishing. + client_get(r->client); + + queue_delayed_work(fw_workqueue, &no_free_ptr(r)->work, 0); + + request->handle =3D UNAVAILABLE_HANDLE; + + return 0; +} + static int ioctl_allocate_iso_resource_once(struct client *client, union ioctl_arg *arg) { - return init_iso_resource(client, - &arg->allocate_iso_resource, ISO_RES_ALLOC_ONCE); + return init_iso_resource_once(client, &arg->allocate_iso_resource, ISO_RE= S_ONCE_ALLOC); } =20 static int ioctl_deallocate_iso_resource_once(struct client *client, union ioctl_arg *arg) { - return init_iso_resource(client, - &arg->allocate_iso_resource, ISO_RES_DEALLOC_ONCE); + return init_iso_resource_once(client, &arg->allocate_iso_resource, ISO_RE= S_ONCE_DEALLOC); } =20 /* --=20 2.53.0 From nobody Tue Jun 16 20:39:28 2026 Received: from fout-a1-smtp.messagingengine.com (fout-a1-smtp.messagingengine.com [103.168.172.144]) (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 D512F3C1400 for ; Wed, 29 Apr 2026 09:35:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=103.168.172.144 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777455306; cv=none; b=QJDAIRw240bgNQOjZCkzqWMxgqv7oil5jyxbOENssYQ1DwjXWsnn8lvbBLKhWP2ZCutV/cbuk1NNztiG5i+wOpw4W7qqbkFXZyKBS0fmq4oF5sKyAlCEaShScMRqN2eaJZWCPf/vKrbucPY8J70/I1uqSlAzC7TdbmhJWwg8HMk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777455306; c=relaxed/simple; bh=PgumEpuJgiEEXsFlhSN9t0D8HYFwl1p57ZX5tELWrOE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=BbdASl1soj6E6LAwPm9zM7fbppRZEJLIP2J1Zqn3DniYbiO/8p0hxWrePKIuvHUn9x5tI1E7Xv0jQIRNvUW9nQavoYXDg8jpDyOvvoulKkQxrZe2O6qljdZGkQCTx3J6v3drd23+AOZZLQbE7PngO0fRFlFXTfysEd7LFXq8pkU= 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=WkfmlsJf; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=bpLBLeSZ; arc=none smtp.client-ip=103.168.172.144 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="WkfmlsJf"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="bpLBLeSZ" Received: from phl-compute-05.internal (phl-compute-05.internal [10.202.2.45]) by mailfout.phl.internal (Postfix) with ESMTP id 3E3EDEC0199; Wed, 29 Apr 2026 05:35:04 -0400 (EDT) Received: from phl-frontend-04 ([10.202.2.163]) by phl-compute-05.internal (MEProxy); Wed, 29 Apr 2026 05:35:04 -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=fm2; t=1777455304; x= 1777541704; bh=iuqm6Mto8XQ8IViIXoCEFeQcanTIs2wV6yPnAFt6EFk=; b=W kfmlsJfYZ/l+JEWaP49YyFgnPrPe1PlaHmcSsVkoRmpMKdMlZaO/iwxH/xjdHD8k IcYQlKNXkzacygFur4YiQsNIz+yA7NhO0ADlMMWicOPkDZtgBIYV0HTQjQ1pCjGY khUHk2RzeNKW4YSs2Ba59v2vxdX6Ix/n3N8jV/QI2l9d2pXAmWCXDuoDyMsaXWxU pGcoCQz6j0l3dFg1WzLaNlNRVdPYRpjI2koF7Clm7GL+CdrrPsKkhsr2XIXes2Ma +QndP6COnFVaq4a6m1MgrdyG9Ps8A1EnbKSbq6OerV/F58lIp1eRJjBUEjrUF+hI /Fz8Qa27UPLWBfMPNStTA== 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=fm2; t=1777455304; x=1777541704; bh=i uqm6Mto8XQ8IViIXoCEFeQcanTIs2wV6yPnAFt6EFk=; b=bpLBLeSZxFUBzPDir MrXvdHVxWmiFy9jTpwaclxZO4tWmr1lR39IUPBlJRtnEHX2w/uRw0FpgenPUGg/b gnFs8/reWWecsFJpvJ9PlGi1K+9dgvvQUvKnu+ry7qUU7cvJvZ72+Ikh+fKii11S F6AMrVSiNTTeEnVmsrVR4S+wOuOoxHv/dXVwFO8wBKQILcK1Yjy3SquExyU3DFsz zCQ7YL+RcVQN9G2ZCHUMQ8w4ODaSETJ7JT8N/oIPCEnD6gfYHAEN1cA4iZ0Gj2YQ hp60qAM+Kgl5rxO4RUVGxe66A/0IcgzzNTFOMy5RGCANBeh++gj3k8zOSm0OWQgL 49lgQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefhedrtddtgdekgedtlecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpuffrtefokffrpgfnqfghnecuuegr ihhlohhuthemuceftddtnecunecujfgurhephffvvefufffkofgjfhgggfestdekredtre dttdenucfhrhhomhepvfgrkhgrshhhihcuufgrkhgrmhhothhouceoohdqthgrkhgrshhh ihesshgrkhgrmhhotggthhhirdhjpheqnecuggftrfgrthhtvghrnhepvdejgfejuedvgf duudekleevtefgtdevhfdtffefiefgveeuteffiedvffekvddtnecuvehluhhsthgvrhfu ihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepohdqthgrkhgrshhhihesshgrkh grmhhotggthhhirdhjphdpnhgspghrtghpthhtohepgedpmhhouggvpehsmhhtphhouhht pdhrtghpthhtoheplhhinhhugidufeelgedquggvvhgvlheslhhishhtshdrshhouhhrtg gvfhhorhhgvgdrnhgvthdprhgtphhtthhopehshhhurghnghhpvghnghdrkhgvrhhnvghl sehgmhgrihhlrdgtohhmpdhrtghpthhtohepughinhhgihhsohdrkhgvrhhnvghlsehgmh grihhlrdgtohhmpdhrtghpthhtoheplhhinhhugidqkhgvrhhnvghlsehvghgvrhdrkhgv rhhnvghlrdhorhhg X-ME-Proxy: Feedback-ID: ie8e14432:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 29 Apr 2026 05:35:00 -0400 (EDT) From: Takashi Sakamoto To: linux1394-devel@lists.sourceforge.net Cc: shuangpeng.kernel@gmail.com, dingiso.kernel@gmail.com, linux-kernel@vger.kernel.org Subject: [PATCH 5/7] firewire: core: code cleanup to remove old implementations for once operation Date: Wed, 29 Apr 2026 18:34:46 +0900 Message-ID: <20260429093449.160545-6-o-takashi@sakamocchi.jp> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260429093449.160545-1-o-takashi@sakamocchi.jp> References: <20260429093449.160545-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 functions for iso_resource allocation and work item still include codes for once operation. This commit refactors them to remove the old implementations. Signed-off-by: Takashi Sakamoto --- drivers/firewire/core-cdev.c | 37 +++++++++++++++--------------------- 1 file changed, 15 insertions(+), 22 deletions(-) diff --git a/drivers/firewire/core-cdev.c b/drivers/firewire/core-cdev.c index 478e8f6400f0..f81a8aa4bcbc 100644 --- a/drivers/firewire/core-cdev.c +++ b/drivers/firewire/core-cdev.c @@ -139,8 +139,11 @@ struct iso_resource { struct client *client; /* Schedule work and access todo only with client->lock held. */ struct delayed_work work; - enum {ISO_RES_ALLOC, ISO_RES_REALLOC, ISO_RES_DEALLOC, - ISO_RES_ALLOC_ONCE, ISO_RES_DEALLOC_ONCE,} todo; + enum { + ISO_RES_ALLOC, + ISO_RES_REALLOC, + ISO_RES_DEALLOC, + } todo; struct iso_resource_params params; struct iso_resource_event *e_alloc, *e_dealloc; }; @@ -1342,9 +1345,7 @@ static void iso_resource_work(struct work_struct *wor= k) skip =3D todo =3D=3D ISO_RES_REALLOC && r->params.generation =3D=3D generation; } - free =3D todo =3D=3D ISO_RES_DEALLOC || - todo =3D=3D ISO_RES_ALLOC_ONCE || - todo =3D=3D ISO_RES_DEALLOC_ONCE; + free =3D todo =3D=3D ISO_RES_DEALLOC; r->params.generation =3D generation; } =20 @@ -1356,8 +1357,7 @@ static void iso_resource_work(struct work_struct *wor= k) fw_iso_resource_manage(client->device->card, generation, r->params.channels, &channel, &bandwidth, todo =3D=3D ISO_RES_ALLOC || - todo =3D=3D ISO_RES_REALLOC || - todo =3D=3D ISO_RES_ALLOC_ONCE); + todo =3D=3D ISO_RES_REALLOC); /* * Is this generation outdated already? As long as this resource sticks * in the xarray, it will be scheduled again for a newer generation or at @@ -1390,7 +1390,7 @@ static void iso_resource_work(struct work_struct *wor= k) if (todo =3D=3D ISO_RES_REALLOC && success) goto out; =20 - if (todo =3D=3D ISO_RES_ALLOC || todo =3D=3D ISO_RES_ALLOC_ONCE) { + if (todo =3D=3D ISO_RES_ALLOC) { e =3D r->e_alloc; r->e_alloc =3D NULL; } else { @@ -1425,8 +1425,7 @@ static void release_iso_resource(struct client *clien= t, schedule_iso_resource(r, 0); } =20 -static int init_iso_resource(struct client *client, - struct fw_cdev_allocate_iso_resource *request, int todo) +static int init_iso_resource(struct client *client, struct fw_cdev_allocat= e_iso_resource *request) { struct iso_resource_event *e1, *e2; struct iso_resource *r; @@ -1446,7 +1445,7 @@ static int init_iso_resource(struct client *client, =20 INIT_DELAYED_WORK(&r->work, iso_resource_work); r->client =3D client; - r->todo =3D todo; + r->todo =3D ISO_RES_ALLOC; r->e_alloc =3D e1; r->e_dealloc =3D e2; =20 @@ -1455,15 +1454,10 @@ static int init_iso_resource(struct client *client, e2->iso_resource.closure =3D request->closure; e2->iso_resource.type =3D FW_CDEV_EVENT_ISO_RESOURCE_DEALLOCATED; =20 - if (todo =3D=3D ISO_RES_ALLOC) { - r->resource.release =3D release_iso_resource; - ret =3D add_client_resource(client, &r->resource, GFP_KERNEL); - if (ret < 0) - goto fail; - } else { - r->resource.release =3D NULL; - r->resource.handle =3D -1; - } + r->resource.release =3D release_iso_resource; + ret =3D add_client_resource(client, &r->resource, GFP_KERNEL); + if (ret < 0) + goto fail; schedule_iso_resource(r, 0); =20 request->handle =3D r->resource.handle; @@ -1480,8 +1474,7 @@ static int init_iso_resource(struct client *client, static int ioctl_allocate_iso_resource(struct client *client, union ioctl_arg *arg) { - return init_iso_resource(client, - &arg->allocate_iso_resource, ISO_RES_ALLOC); + return init_iso_resource(client, &arg->allocate_iso_resource); } =20 static int ioctl_deallocate_iso_resource(struct client *client, --=20 2.53.0 From nobody Tue Jun 16 20:39:28 2026 Received: from fhigh-a6-smtp.messagingengine.com (fhigh-a6-smtp.messagingengine.com [103.168.172.157]) (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 AA9313A783D for ; Wed, 29 Apr 2026 09:35:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=103.168.172.157 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777455308; cv=none; b=twSUNFitQ4sXXq12IW7TZUA/A0R9U+GrmjATHjcmhWZPyrPja0fYuGGzlPOkGuFdiTPxRqX2BPmxNNIkJJ68J8NpzlTxjNKuc4D386mW8+okVFsKOJJpSDCCzpXzSWxdKJ7XA9GHK0Ug2FWdaOEzW2wZmO5hMHocM/NO7f6t9ow= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777455308; c=relaxed/simple; bh=7XqWU6LhyhSWj0GMiYX8EHvKrBVvkQvML+73QNo80k4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=CEsMfoZ0JqwZfOfBAAVedlTUDRRb1mSpStriy5izY0xxYMdQ9qy2TU3rkEkzdtJ/gjr4PSbyh78lIY0bBFpYK4NgTqirFMVHhOR2QbUA/w9lPEpz5kyDPwsKU/SnHQlu1aGNThrgooJG6+7FiTSlPgdusCV3VgyGWLTLLlYEHpc= 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=wfxeENO0; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=empm6ATe; arc=none smtp.client-ip=103.168.172.157 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="wfxeENO0"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="empm6ATe" Received: from phl-compute-02.internal (phl-compute-02.internal [10.202.2.42]) by mailfhigh.phl.internal (Postfix) with ESMTP id E168A1400095; Wed, 29 Apr 2026 05:35:05 -0400 (EDT) Received: from phl-frontend-04 ([10.202.2.163]) by phl-compute-02.internal (MEProxy); Wed, 29 Apr 2026 05:35:05 -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=fm2; t=1777455305; x= 1777541705; bh=u9dutGyrxvpl/+wEZGAjAiJE8FtOcf5iL19WV67sTIQ=; b=w fxeENO0KlmA7jGkspdSQwqB9q3eXYYmV8rSjip5yCnTixv3g0s2PEbspC0D3KRl3 SPgqvd/vCe9sKN0BZypQnq94MEaakaCdIV8kQqisPeK6xFyGZSEzgad5JJfM20pF F5s5wEZVBId1Xu8Fu+eaVS2omW58d87uiyBmKBMljBN8wWNxnzD7BDIQnligY4mY gn9LX4r2OSnbgnstKHDXJJRch6M8n1lMGzubm3FK1o04Z+zxnD/MHrt9QjRHqf4H 151RSVvTC8fAaE97rcEHubZpQRUDBc7HrMbPbBR5EcdfjXPLOd3Jh1lonyrOWMjf GI8rsmS0sozWKnJORukTg== 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=fm2; t=1777455305; x=1777541705; bh=u 9dutGyrxvpl/+wEZGAjAiJE8FtOcf5iL19WV67sTIQ=; b=empm6ATeY1hI3M5kM x2A0XB3p5TENk5mmXUKPEGwPNijVXRi+84/59ASX+mqJQCNIFv8ZEr/5GhOD4Fix Geim3gJPXX6aRDs8gE/pKcHlPJpVL6lBlYGRa9gxFqdff0qQeN6JImlMkcTp30i/ ZC0x/osIa2RgrUCR1vQ3JjIS4L2uLyboyJk7NM/GtlaqvhObp57Vrog/qq0hxHmf /ltg3P7BINYtOGSFNmCEShcE7A8xHPYaxVEZvoRMtIz0ScI77DQGlRY3G+HM6sre anGgPEMc14C7MdU8Aj6yn5M+NO9gcC4gFIDsfk46zkQTor59RUCo69GpaLgJC93m rZv4g== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefhedrtddtgdekgedtlecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpuffrtefokffrpgfnqfghnecuuegr ihhlohhuthemuceftddtnecunecujfgurhephffvvefufffkofgjfhgggfestdekredtre dttdenucfhrhhomhepvfgrkhgrshhhihcuufgrkhgrmhhothhouceoohdqthgrkhgrshhh ihesshgrkhgrmhhotggthhhirdhjpheqnecuggftrfgrthhtvghrnhepvdejgfejuedvgf duudekleevtefgtdevhfdtffefiefgveeuteffiedvffekvddtnecuvehluhhsthgvrhfu ihiivgepudenucfrrghrrghmpehmrghilhhfrhhomhepohdqthgrkhgrshhhihesshgrkh grmhhotggthhhirdhjphdpnhgspghrtghpthhtohepgedpmhhouggvpehsmhhtphhouhht pdhrtghpthhtoheplhhinhhugidufeelgedquggvvhgvlheslhhishhtshdrshhouhhrtg gvfhhorhhgvgdrnhgvthdprhgtphhtthhopehshhhurghnghhpvghnghdrkhgvrhhnvghl sehgmhgrihhlrdgtohhmpdhrtghpthhtohepughinhhgihhsohdrkhgvrhhnvghlsehgmh grihhlrdgtohhmpdhrtghpthhtoheplhhinhhugidqkhgvrhhnvghlsehvghgvrhdrkhgv rhhnvghlrdhorhhg X-ME-Proxy: Feedback-ID: ie8e14432:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 29 Apr 2026 05:35:04 -0400 (EDT) From: Takashi Sakamoto To: linux1394-devel@lists.sourceforge.net Cc: shuangpeng.kernel@gmail.com, dingiso.kernel@gmail.com, linux-kernel@vger.kernel.org Subject: [PATCH 6/7] firewire: core: append _auto suffix for non-once iso resource operations Date: Wed, 29 Apr 2026 18:34:47 +0900 Message-ID: <20260429093449.160545-7-o-takashi@sakamocchi.jp> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260429093449.160545-1-o-takashi@sakamocchi.jp> References: <20260429093449.160545-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 functions for iso_resource once operations are carefully split from another type of operation. This commit adds _auto suffix to functions for the another type so that it is easily to distinguish them. Signed-off-by: Takashi Sakamoto --- drivers/firewire/core-cdev.c | 75 ++++++++++++++++++------------------ 1 file changed, 37 insertions(+), 38 deletions(-) diff --git a/drivers/firewire/core-cdev.c b/drivers/firewire/core-cdev.c index f81a8aa4bcbc..b3ce34d777c3 100644 --- a/drivers/firewire/core-cdev.c +++ b/drivers/firewire/core-cdev.c @@ -134,15 +134,15 @@ struct iso_resource_params { s32 bandwidth; }; =20 -struct iso_resource { +struct iso_resource_auto { struct client_resource resource; struct client *client; /* Schedule work and access todo only with client->lock held. */ struct delayed_work work; enum { - ISO_RES_ALLOC, - ISO_RES_REALLOC, - ISO_RES_DEALLOC, + ISO_RES_AUTO_ALLOC, + ISO_RES_AUTO_REALLOC, + ISO_RES_AUTO_DEALLOC, } todo; struct iso_resource_params params; struct iso_resource_event *e_alloc, *e_dealloc; @@ -175,16 +175,16 @@ static struct descriptor_resource *to_descriptor_reso= urce(struct client_resource return container_of(resource, struct descriptor_resource, resource); } =20 -static struct iso_resource *to_iso_resource(struct client_resource *resour= ce) +static struct iso_resource_auto *to_iso_resource_auto(struct client_resour= ce *resource) { - return container_of(resource, struct iso_resource, resource); + return container_of(resource, struct iso_resource_auto, resource); } =20 -static void release_iso_resource(struct client *, struct client_resource *= ); +static void release_iso_resource_auto(struct client *, struct client_resou= rce *); =20 -static int is_iso_resource(const struct client_resource *resource) +static int is_iso_resource_auto(const struct client_resource *resource) { - return resource->release =3D=3D release_iso_resource; + return resource->release =3D=3D release_iso_resource_auto; } =20 static void release_transaction(struct client *client, @@ -195,7 +195,7 @@ static int is_outbound_transaction_resource(const struc= t client_resource *resour return resource->release =3D=3D release_transaction; } =20 -static void schedule_iso_resource(struct iso_resource *r, unsigned long de= lay) +static void schedule_iso_resource_auto(struct iso_resource_auto *r, unsign= ed long delay) { client_get(r->client); if (!queue_delayed_work(fw_workqueue, &r->work, delay)) @@ -443,8 +443,8 @@ static void queue_bus_reset_event(struct client *client) guard(spinlock_irq)(&client->lock); =20 xa_for_each(&client->resource_xa, index, resource) { - if (is_iso_resource(resource)) - schedule_iso_resource(to_iso_resource(resource), 0); + if (is_iso_resource_auto(resource)) + schedule_iso_resource_auto(to_iso_resource_auto(resource), 0); } } =20 @@ -1323,10 +1323,10 @@ static int fill_iso_resource_params(struct iso_reso= urce_params *params, return 0; } =20 -static void iso_resource_work(struct work_struct *work) +static void iso_resource_auto_work(struct work_struct *work) { struct iso_resource_event *e; - struct iso_resource *r =3D from_work(r, work, work.work); + struct iso_resource_auto *r =3D from_work(r, work, work.work); struct client *client =3D r->client; unsigned long index =3D r->resource.handle; int generation, channel, bandwidth, todo; @@ -1336,16 +1336,16 @@ static void iso_resource_work(struct work_struct *w= ork) generation =3D client->device->generation; todo =3D r->todo; // Allow 1000ms grace period for other reallocations. - if (todo =3D=3D ISO_RES_ALLOC && + if (todo =3D=3D ISO_RES_AUTO_ALLOC && time_is_after_jiffies64(client->device->card->reset_jiffies + secs_t= o_jiffies(1))) { - schedule_iso_resource(r, msecs_to_jiffies(333)); + schedule_iso_resource_auto(r, msecs_to_jiffies(333)); skip =3D true; } else { // We could be called twice within the same generation. - skip =3D todo =3D=3D ISO_RES_REALLOC && + skip =3D todo =3D=3D ISO_RES_AUTO_REALLOC && r->params.generation =3D=3D generation; } - free =3D todo =3D=3D ISO_RES_DEALLOC; + free =3D todo =3D=3D ISO_RES_AUTO_DEALLOC; r->params.generation =3D generation; } =20 @@ -1356,15 +1356,15 @@ static void iso_resource_work(struct work_struct *w= ork) =20 fw_iso_resource_manage(client->device->card, generation, r->params.channels, &channel, &bandwidth, - todo =3D=3D ISO_RES_ALLOC || - todo =3D=3D ISO_RES_REALLOC); + todo =3D=3D ISO_RES_AUTO_ALLOC || + todo =3D=3D ISO_RES_AUTO_REALLOC); /* * Is this generation outdated already? As long as this resource sticks * in the xarray, it will be scheduled again for a newer generation or at * shutdown. */ if (channel =3D=3D -EAGAIN && - (todo =3D=3D ISO_RES_ALLOC || todo =3D=3D ISO_RES_REALLOC)) + (todo =3D=3D ISO_RES_AUTO_ALLOC || todo =3D=3D ISO_RES_AUTO_REALLOC)) goto out; =20 success =3D channel >=3D 0 || bandwidth > 0; @@ -1372,11 +1372,11 @@ static void iso_resource_work(struct work_struct *w= ork) scoped_guard(spinlock_irq, &client->lock) { // Transit from allocation to reallocation, except if the client // requested deallocation in the meantime. - if (r->todo =3D=3D ISO_RES_ALLOC) - r->todo =3D ISO_RES_REALLOC; + if (r->todo =3D=3D ISO_RES_AUTO_ALLOC) + r->todo =3D ISO_RES_AUTO_REALLOC; // Allocation or reallocation failure? Pull this resource out of the // xarray and prepare for deletion, unless the client is shutting down. - if (r->todo =3D=3D ISO_RES_REALLOC && !success && + if (r->todo =3D=3D ISO_RES_AUTO_REALLOC && !success && !client->in_shutdown && xa_erase(&client->resource_xa, index)) { client_put(client); @@ -1384,13 +1384,13 @@ static void iso_resource_work(struct work_struct *w= ork) } } =20 - if (todo =3D=3D ISO_RES_ALLOC && channel >=3D 0) + if (todo =3D=3D ISO_RES_AUTO_ALLOC && channel >=3D 0) r->params.channels =3D 1ULL << channel; =20 - if (todo =3D=3D ISO_RES_REALLOC && success) + if (todo =3D=3D ISO_RES_AUTO_REALLOC && success) goto out; =20 - if (todo =3D=3D ISO_RES_ALLOC) { + if (todo =3D=3D ISO_RES_AUTO_ALLOC) { e =3D r->e_alloc; r->e_alloc =3D NULL; } else { @@ -1414,21 +1414,20 @@ static void iso_resource_work(struct work_struct *w= ork) client_put(client); } =20 -static void release_iso_resource(struct client *client, - struct client_resource *resource) +static void release_iso_resource_auto(struct client *client, struct client= _resource *resource) { - struct iso_resource *r =3D to_iso_resource(resource); + struct iso_resource_auto *r =3D to_iso_resource_auto(resource); =20 guard(spinlock_irq)(&client->lock); =20 - r->todo =3D ISO_RES_DEALLOC; - schedule_iso_resource(r, 0); + r->todo =3D ISO_RES_AUTO_DEALLOC; + schedule_iso_resource_auto(r, 0); } =20 static int init_iso_resource(struct client *client, struct fw_cdev_allocat= e_iso_resource *request) { struct iso_resource_event *e1, *e2; - struct iso_resource *r; + struct iso_resource_auto *r; int ret; =20 r =3D kmalloc_obj(*r); @@ -1443,9 +1442,9 @@ static int init_iso_resource(struct client *client, s= truct fw_cdev_allocate_iso_ if (ret < 0) goto fail; =20 - INIT_DELAYED_WORK(&r->work, iso_resource_work); + INIT_DELAYED_WORK(&r->work, iso_resource_auto_work); r->client =3D client; - r->todo =3D ISO_RES_ALLOC; + r->todo =3D ISO_RES_AUTO_ALLOC; r->e_alloc =3D e1; r->e_dealloc =3D e2; =20 @@ -1454,11 +1453,11 @@ static int init_iso_resource(struct client *client,= struct fw_cdev_allocate_iso_ e2->iso_resource.closure =3D request->closure; e2->iso_resource.type =3D FW_CDEV_EVENT_ISO_RESOURCE_DEALLOCATED; =20 - r->resource.release =3D release_iso_resource; + r->resource.release =3D release_iso_resource_auto; ret =3D add_client_resource(client, &r->resource, GFP_KERNEL); if (ret < 0) goto fail; - schedule_iso_resource(r, 0); + schedule_iso_resource_auto(r, 0); =20 request->handle =3D r->resource.handle; =20 @@ -1481,7 +1480,7 @@ static int ioctl_deallocate_iso_resource(struct clien= t *client, union ioctl_arg *arg) { return release_client_resource(client, - arg->deallocate.handle, release_iso_resource, NULL); + arg->deallocate.handle, release_iso_resource_auto, NULL); } =20 #define UNAVAILABLE_HANDLE -1 --=20 2.53.0 From nobody Tue Jun 16 20:39:28 2026 Received: from fout-a1-smtp.messagingengine.com (fout-a1-smtp.messagingengine.com [103.168.172.144]) (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 2EC9A3C344B for ; Wed, 29 Apr 2026 09:35:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=103.168.172.144 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777455309; cv=none; b=tI5SdIVHONNJeealsbNc9iVBhPMbZ5ifc6SW1cQm2wPWLXRoPRC2DLJ4MQeyGAlVON+LTzDXSVnSmDfBmX+crCPPqVh+/06zh7xasHh2sag8EMmVnRiNpG5C+HxUbAk8jrjDwiy9DmCDVbiMTwlYhXFp6rH7XBIrNMUdfQDyXBQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777455309; c=relaxed/simple; bh=EM9nnFXTbDCnB8v6FyFhfupaqXXW69Pi3zQ3C/wn/8Y=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=dHn7f+8hUmyjgWpAJ8yHQxyqBLR5cw/p+tgZ/tq4k+AkSDtsNV4PcwvcyNCaCMd/PcBQcYrhF+gC3D0vYxpBvHI7YirUI4xkYZvcxza0sR6AsjZ6bsSHohZ6713ttZmo3KgpwRmAmU43WosTNUm1CqqfSpj79rMCvq2vGelauhg= 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=YsfCGQ16; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=n4+N79tB; arc=none smtp.client-ip=103.168.172.144 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="YsfCGQ16"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="n4+N79tB" Received: from phl-compute-03.internal (phl-compute-03.internal [10.202.2.43]) by mailfout.phl.internal (Postfix) with ESMTP id 77993EC018B; Wed, 29 Apr 2026 05:35:07 -0400 (EDT) Received: from phl-frontend-04 ([10.202.2.163]) by phl-compute-03.internal (MEProxy); Wed, 29 Apr 2026 05:35:07 -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=fm2; t=1777455307; x= 1777541707; bh=t2AJD7aqTYWwry01+yWFnn6syfnaMGDFOvYniO+xe8M=; b=Y sfCGQ169IdtzULatD1y6FITSW+IYeLsZlyHCkZVXMCt9fw1ycTVx6fgy94s7/o0x oPGEpf3rRhXKYqoiMG3euIWplpho4lye7eV4WdoZY8a9E6nReDSJfyxMOCHueWma N+091X9avGYpnsdpiJPVZDKUL2mTHPrIAqF13m4muSdIkqB/iJmufh74/nehFKln 3diFIqzlToM23kYA4IqjymqYxzLdme2obw7v9HQfmM5LRO9XkoQhzl4wcINTdOe5 VbEtq3nEJssTNS6hDhZprGl1iv80tkecPjvrYmi+pZ+n2qHcagEeBQ9N8KarHvEA /WyW51g22lHoCwb23JasA== 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=fm2; t=1777455307; x=1777541707; bh=t 2AJD7aqTYWwry01+yWFnn6syfnaMGDFOvYniO+xe8M=; b=n4+N79tBDb/nyc+3J YssuewLM/aLZGp2BU/Ak9K8gWW2jEFZXkl6rWuxeFIlHLiEovGk86YIMlRN2lyxu 9vM7FUTjl52MGcb+PRD0Dvqab3MpWiSIsEKQl05JjfVSuCYCBZ2eVZWfq9mLn7Kp bvvPIuycF5jFHXbTomi/8U0gnUlepSps7iH6elZDQBCfIBX82stj1cH6+PfI4HV+ /P4CtjJ5Nsl6vsT2PcxLdmr3ZAjM7AJoal8h3awe76hRI/YhXtyRyumgaZ3728b3 TPYk4R1VO8MU15ntErjU1HwB2rjTFwphCssaqBVvepiQpz6J65Kwh1IcWpfYw+r6 YLrew== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefhedrtddtgdekgedtlecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpuffrtefokffrpgfnqfghnecuuegr ihhlohhuthemuceftddtnecunecujfgurhephffvvefufffkofgjfhgggfestdekredtre dttdenucfhrhhomhepvfgrkhgrshhhihcuufgrkhgrmhhothhouceoohdqthgrkhgrshhh ihesshgrkhgrmhhotggthhhirdhjpheqnecuggftrfgrthhtvghrnhepvdejgfejuedvgf duudekleevtefgtdevhfdtffefiefgveeuteffiedvffekvddtnecuvehluhhsthgvrhfu ihiivgepudenucfrrghrrghmpehmrghilhhfrhhomhepohdqthgrkhgrshhhihesshgrkh grmhhotggthhhirdhjphdpnhgspghrtghpthhtohepgedpmhhouggvpehsmhhtphhouhht pdhrtghpthhtoheplhhinhhugidufeelgedquggvvhgvlheslhhishhtshdrshhouhhrtg gvfhhorhhgvgdrnhgvthdprhgtphhtthhopehshhhurghnghhpvghnghdrkhgvrhhnvghl sehgmhgrihhlrdgtohhmpdhrtghpthhtohepughinhhgihhsohdrkhgvrhhnvghlsehgmh grihhlrdgtohhmpdhrtghpthhtoheplhhinhhugidqkhgvrhhnvghlsehvghgvrhdrkhgv rhhnvghlrdhorhhg X-ME-Proxy: Feedback-ID: ie8e14432:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 29 Apr 2026 05:35:06 -0400 (EDT) From: Takashi Sakamoto To: linux1394-devel@lists.sourceforge.net Cc: shuangpeng.kernel@gmail.com, dingiso.kernel@gmail.com, linux-kernel@vger.kernel.org Subject: [PATCH 7/7] firewire: core: code cleanup for iso resource auto creation Date: Wed, 29 Apr 2026 18:34:48 +0900 Message-ID: <20260429093449.160545-8-o-takashi@sakamocchi.jp> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260429093449.160545-1-o-takashi@sakamocchi.jp> References: <20260429093449.160545-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 init_iso_resource function is only called by ioctl_allocate_iso_resource(), thus no need to be unique. This commit unifies them with minor code refactoring. Signed-off-by: Takashi Sakamoto --- drivers/firewire/core-cdev.c | 53 ++++++++++++++---------------------- 1 file changed, 20 insertions(+), 33 deletions(-) diff --git a/drivers/firewire/core-cdev.c b/drivers/firewire/core-cdev.c index b3ce34d777c3..bcfb20b770df 100644 --- a/drivers/firewire/core-cdev.c +++ b/drivers/firewire/core-cdev.c @@ -1424,23 +1424,20 @@ static void release_iso_resource_auto(struct client= *client, struct client_resou schedule_iso_resource_auto(r, 0); } =20 -static int init_iso_resource(struct client *client, struct fw_cdev_allocat= e_iso_resource *request) +static int ioctl_allocate_iso_resource(struct client *client, union ioctl_= arg *arg) { - struct iso_resource_event *e1, *e2; - struct iso_resource_auto *r; - int ret; + struct fw_cdev_allocate_iso_resource *request =3D &arg->allocate_iso_reso= urce; + struct iso_resource_event *e1 __free(kfree) =3D kmalloc_obj(*e1); + struct iso_resource_event *e2 __free(kfree) =3D kmalloc_obj(*e2); + struct iso_resource_auto *r __free(kfree) =3D kmalloc_obj(*r); + int err; =20 - r =3D kmalloc_obj(*r); - e1 =3D kmalloc_obj(*e1); - e2 =3D kmalloc_obj(*e2); - if (r =3D=3D NULL || e1 =3D=3D NULL || e2 =3D=3D NULL) { - ret =3D -ENOMEM; - goto fail; - } + if (!r || !e1 || !e2) + return -ENOMEM; =20 - ret =3D fill_iso_resource_params(&r->params, request); - if (ret < 0) - goto fail; + err =3D fill_iso_resource_params(&r->params, request); + if (err < 0) + return err; =20 INIT_DELAYED_WORK(&r->work, iso_resource_auto_work); r->client =3D client; @@ -1449,31 +1446,21 @@ static int init_iso_resource(struct client *client,= struct fw_cdev_allocate_iso_ r->e_dealloc =3D e2; =20 e1->iso_resource.closure =3D request->closure; - e1->iso_resource.type =3D FW_CDEV_EVENT_ISO_RESOURCE_ALLOCATED; + e1->iso_resource.type =3D FW_CDEV_EVENT_ISO_RESOURCE_ALLOCATED; e2->iso_resource.closure =3D request->closure; - e2->iso_resource.type =3D FW_CDEV_EVENT_ISO_RESOURCE_DEALLOCATED; + e2->iso_resource.type =3D FW_CDEV_EVENT_ISO_RESOURCE_DEALLOCATED; =20 r->resource.release =3D release_iso_resource_auto; - ret =3D add_client_resource(client, &r->resource, GFP_KERNEL); - if (ret < 0) - goto fail; - schedule_iso_resource_auto(r, 0); - + err =3D add_client_resource(client, &r->resource, GFP_KERNEL); + if (err < 0) + return err; request->handle =3D r->resource.handle; =20 - return 0; - fail: - kfree(r); - kfree(e1); - kfree(e2); - - return ret; -} + retain_and_null_ptr(e1); + retain_and_null_ptr(e2); + schedule_iso_resource_auto(no_free_ptr(r), 0); =20 -static int ioctl_allocate_iso_resource(struct client *client, - union ioctl_arg *arg) -{ - return init_iso_resource(client, &arg->allocate_iso_resource); + return 0; } =20 static int ioctl_deallocate_iso_resource(struct client *client, --=20 2.53.0