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 02B9F436352; Fri, 27 Feb 2026 15:09:46 +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=1772204987; cv=none; b=JGMtxZ+g5ULapOrG3ZJbHMqXNoiIflg0YOjnD/wKvDsMr9/6h/Aychs4Y5hWUiz9lv261KOEv9MzuR4aiG/MA2pYasW8I8rcD8H5XHbqdZwZmcP5Di6tr7uancSQPmGhKNlHMnbvluwIWMyTQko7SERZbSo+ebwojqnrFUl1duE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772204987; c=relaxed/simple; bh=0yqN5dTX/ixzOtodz7NizEgEOEjte8QFyiCaU6F6XTQ=; h=Mime-Version:Content-Type:Date:Message-Id:Cc:Subject:From:To: References:In-Reply-To; b=SeFPE+gfmAnzh0lL3V+PSZ6Eo3nRSUUt4Hj/5csSyvAiPeLQyw6XQCJqO3uiA5dI0ZGzo92++yYx8wurvWI2GXQPCcR5mUhvVrdu/6hjYqeAd9WcpsZUMi/JepNQePYPeZn3YqYRJWNPTG/DFh/aMw4YfXQ7b3gXgCF12WuA9UU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=fWNPPCGu; 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="fWNPPCGu" Received: by smtp.kernel.org (Postfix) with ESMTPSA id A2228C19422; Fri, 27 Feb 2026 15:09:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1772204986; bh=0yqN5dTX/ixzOtodz7NizEgEOEjte8QFyiCaU6F6XTQ=; h=Date:Cc:Subject:From:To:References:In-Reply-To:From; b=fWNPPCGuHNVc1p17psub485eGCIrdMelnqPja5XEvxMNQCATVPa1XBdtgfy+c3HIb k04n4wBbHbLFP6GlD2Xwwp6hL/NOeNtt5UGfaNZ3GCotTP7GH4GUXqQNFF4I/Adt/f zaGyigVs7mF9pENt1+pOII9HssyXNj2cTpQxBbKZn4tuFqrmdWmIbeNmg3pwSlGxK2 6WXj4WNEJ3ZxMt6UYThrtFZCpjL44Ngib+OuGSb2G8GMSgn1ZdwG8FGKb8+PAgjX3W m2rUMqvL4SF4tFZlP0Cy2w5ZeHJaEQneeyZ4PhpA+HMDeTKRKhW/PbNlv/rj6b5CY/ gPFeipVM6jX/g== 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: Fri, 27 Feb 2026 16:09:41 +0100 Message-Id: Cc: "Alexandre Belloni" , "Alvin Sun" , "Miguel Ojeda" , "Boqun Feng" , "Gary Guo" , =?utf-8?q?Bj=C3=B6rn_Roy_Baron?= , "Andreas Hindborg" , "Alice Ryhl" , "Trevor Gross" , , , "Greg Kroah-Hartman" Subject: Re: [RFC PATCH v3 1/5] rtc: add device selector for rtc_class_ops callbacks From: "Benno Lossin" To: "Danilo Krummrich" , "Rafael J. Wysocki" X-Mailer: aerc 0.21.0 References: <20260221111619162a41a1@mail.local> <20260222000556ea1938c0@mail.local> <2026022415010804e28202@mail.local> <20260224172822de7f4569@mail.local> In-Reply-To: On Wed Feb 25, 2026 at 5:26 PM CET, Danilo Krummrich wrote: > For the future we will also be able to support references within initiali= zers to > other pinned fields, which make things a bit more convinient, so you coul= d do > things like this: > > let irq_data =3D impl_pin_init!(SampleIrqData { > io <- pdev.iomap_region_sized::(0, c"my_rtc/bar0")?, > hw_variant: VendorVariant::StV1, > }); > > let rtc_data =3D impl_pin_init!(SampleRtcData { > irq <- irq::Registration::new(..., irq_data), > io: &irq.io, > ..., > }); > > let rtc =3D rtc::Device::new(dev, rtc_data)?; > > Note the additional `io: &irq.io,` in the rtc_data initializer. This woul= d be > legal as we know that `irq` is pinned within `rtc_data`, hence it is vali= d to > hold a reference to one of its pinned fields. > > I am not sure how far we are from having this supported, I assume Benno a= nd Gary > can say more about this. We added that support in 42415d163e5d ("rust: pin-init: add references to previously initialized fields"). Note that any references created during the initializer are only valid inside of that initializer. You can convert into a raw pointer though and if the struct is `!Unpin` it is sound to use that pointer at the same time as references to the pinned value. Cheers, Benno