From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 3EDDB183CA6; Sun, 22 Jun 2025 22:29:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750631398; cv=none; b=QLPLZCLoq3xysulMRnwqNoUYuPQ618dY9g2aKXgg7cExelMitrixFoGVgK9xX7Z5uKzYArzMjfDzyPy71G3tYOMbUhNRSSx1cWUGdE5FeM0gpVn4bbStoe8GL9HK5kMVOlRQfKv8yDqvc1SyGnmG1h7QrHDssTPDsmapLHIfvfU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750631398; c=relaxed/simple; bh=OYu+AAgQhYC87NCbElQfdkmObnYbtApn+25dtMrUN0U=; h=Mime-Version:Content-Type:Date:Message-Id:Cc:Subject:From:To: References:In-Reply-To; b=rmmJ6TClMM/QzVVEmRt7wwgW7qqIMiizBNwcTxb9EeclO1FWsu7LvVAPEPFbUyPUqfR2TGDfEMbAiZsd8QeR1V9NyYaHQWPIQQPzJUVAH0BT+1m3+bXBgb2c092npeCfVIDzBbd5Q2MBue3vKNAj2D9LlL5oPD1+yLKyVC8/bVk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=coGzih47; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="coGzih47" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 82A84C4CEE3; Sun, 22 Jun 2025 22:29:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1750631398; bh=OYu+AAgQhYC87NCbElQfdkmObnYbtApn+25dtMrUN0U=; h=Date:Cc:Subject:From:To:References:In-Reply-To:From; b=coGzih47BfetxAdLNbHQqy1DJXPtnmoVvGRkqITYjWychHIFjmPRbjc2dYVjxMpEP ld1gurh4xqFu/SCFBY11uiNNLXipApZK0ZZqIkQkr3dfXAZcDcR4fm0O8VM6pSymSC F/pyeoddxP0JYuzvOqn7f121WNLQJlhwdJ1OsuLtloclCRwId3VyJTtAwky46AXJPw TLDD4JkGRtqg8VM6Z9Cg7Lizc38IfXDLyHWqkTeTVtbrwHX34fnUriqvgZXvMtWFBj h/Ek9QR1nVjl/SyEOb/fxtQvvxp7l/L4M+Nw4juWXydoVxxrSSra+MUlQFD6jSeguP jGm04KNrW+5pg== Precedence: bulk X-Mailing-List: rust-for-linux@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 Date: Mon, 23 Jun 2025 00:29:52 +0200 Message-Id: Cc: , , , , , , , , , , , , , , , , , Subject: Re: [PATCH v2 4/4] rust: devres: implement register_release() From: "Benno Lossin" To: "Danilo Krummrich" X-Mailer: aerc 0.20.1 References: <20250622164050.20358-1-dakr@kernel.org> <20250622164050.20358-5-dakr@kernel.org> In-Reply-To: On Sun Jun 22, 2025 at 11:24 PM CEST, Danilo Krummrich wrote: > On Sun, Jun 22, 2025 at 11:12:28PM +0200, Danilo Krummrich wrote: >> On Sun, Jun 22, 2025 at 10:47:55PM +0200, Benno Lossin wrote: >> > And maybe a closure design is better, depending on how much code is >> > usually run in `release`, if it's a lot, then we should use the trait >> > design. If it's only 1-5 lines, then a closure would also be fine. I >> > don't have a strong preference, but if it's mostly one liners, then >> > closures would be better. >>=20 >> It should usually be rather short, so probably makes sense. > > Quickly tried how it turns out with a closure: The only way I know to cap= ture > the closure within the > > unsafe extern "C" fn callback

(ptr: *mut kernel::ffi::c_void) > > is with another dynamic allocation, which isn't worth it. > > Unless there's another way I'm not aware of, I'd keep the Release trait. Ah right that makes sens. --- Cheers, Benno