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 17F04218858; Thu, 26 Jun 2025 14:42:00 +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=1750948921; cv=none; b=aROavpeOFlYwkz4WLXRQpBkFJ9JukRM0ICj0njKXzxDLbJYBv5x9owa2FwbmQbrHncJDvdUghNC7YUoAYXyq2HOBX271INLPEw+xTZMVX4Fsrcl3Us7BwmI7B2tDNDt5z4V0KvG/9ekTR/0mOAQnJDs8TjLJQMNdefEqriSRboM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750948921; c=relaxed/simple; bh=42OjuS98WxGG89iYw29vlodU1GzD56kRmxMHKIDo8Ao=; h=Mime-Version:Content-Type:Date:Message-Id:To:Cc:Subject:From: References:In-Reply-To; b=DELwbyFsoglM9bVPVgNJvF9IfxwwCXiw1lBTY86kUbRUJFBqQtIZjwJSVaepQuG8NySCvHXk082ks7RNBprWpjG9RIsDfIeToX49Adu24r6ELdL7eEOqbdt0FKhVfuJgE8rbCdAJn8kGxomRkRy3F4NfLGZd/gh+8sL02Vu31dw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=F2kAUTRm; 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="F2kAUTRm" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 26455C4CEEB; Thu, 26 Jun 2025 14:41:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1750948920; bh=42OjuS98WxGG89iYw29vlodU1GzD56kRmxMHKIDo8Ao=; h=Date:To:Cc:Subject:From:References:In-Reply-To:From; b=F2kAUTRmhh2r5WO93+pK/HVDynCmy/G5fdUgNn6aGkfu4+HaoBuU5QGoRvNQeZOa7 cUygQT6QTn7ATW8GkraAtLkiCgK/jHG72B1GEB++fEhZHiOkaay11eoGgGHFe7d56Z l2u8v3F7fFn48HfEALXXMcgnsnDjmRW19qx1PzSyrbwNqamJubXcQJWN1TmTHMZNGF LB6gtaTdVWeFqPUWYVJ3ok31gBbDjBnLeIup9lGfiHn5ZoutzvsHYNZao65naIz6tS w6zJjdslGbxYDOuNwzdXoTT2TQyKfXY6Dv8FPDb587vqTxwCN7woYt3M/OBHp9jKGG 8gRmwsvvsgOhw== Precedence: bulk X-Mailing-List: linux-pci@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: Thu, 26 Jun 2025 16:41:55 +0200 Message-Id: To: "Danilo Krummrich" Cc: , , , , , , , , , , , , , , , , , Subject: Re: [PATCH v3 4/4] rust: devres: implement register_release() From: "Benno Lossin" X-Mailer: aerc 0.20.1 References: <20250624215600.221167-1-dakr@kernel.org> <20250624215600.221167-5-dakr@kernel.org> In-Reply-To: On Thu Jun 26, 2025 at 4:02 PM CEST, Danilo Krummrich wrote: > On Thu, Jun 26, 2025 at 01:15:34PM +0200, Danilo Krummrich wrote: >> On Thu, Jun 26, 2025 at 12:36:23PM +0200, Benno Lossin wrote: >> > Or, we could change `Release` to be: >> >=20 >> > pub trait Release { >> > type Ptr: ForeignOwnable; >> >=20 >> > fn release(this: Self::Ptr); >> > } >> >=20 >> > and then `register_release` is: >> >=20 >> > pub fn register_release(dev: &Device, data: T::= Ptr) -> Result >> >=20 >> > This way, one can store a `Box` and get access to the `T` at the en= d. >>=20 >> I think this was also the case before? Well, it was P::Borrowed instead. >>=20 >> > Or if they store the value in an `Arc`, they have the option to clo= ne >> > it and give it to somewhere else. >>=20 >> Anyways, I really like this proposal of implementing the Release trait. > > One downside seems to be that the compiler cannot infer T anymore with th= is > function signature. Yeah... That's a bit annoying. We might be able to add an associated type to `ForeignOwnable` like `Target` or `Inner` or whatever. Then we could do: pub fn register_release

(dev: &Device, data: P) -> Result where P: ForeignOwnable, P::Inner: Release, --- Cheers, Benno