{"id":2229211,"url":"http://patchwork.ozlabs.org/api/1.1/patches/2229211/?format=json","web_url":"http://patchwork.ozlabs.org/project/linux-pwm/patch/20260427221155.2144848-13-dakr@kernel.org/","project":{"id":38,"url":"http://patchwork.ozlabs.org/api/1.1/projects/38/?format=json","name":"Linux PWM development","link_name":"linux-pwm","list_id":"linux-pwm.vger.kernel.org","list_email":"linux-pwm@vger.kernel.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<20260427221155.2144848-13-dakr@kernel.org>","date":"2026-04-27T22:11:10","name":"[12/24] rust: platform: make Driver trait lifetime-parameterized","commit_ref":null,"pull_url":null,"state":"new","archived":false,"hash":"8cb70338bf792c2ebce22a7530d5815f23d5e11d","submitter":{"id":89037,"url":"http://patchwork.ozlabs.org/api/1.1/people/89037/?format=json","name":"Danilo Krummrich","email":"dakr@kernel.org"},"delegate":{"id":161009,"url":"http://patchwork.ozlabs.org/api/1.1/users/161009/?format=json","username":"mwilczynski","first_name":"Michał","last_name":"Wilczyński","email":"michalw628@gmail.com"},"mbox":"http://patchwork.ozlabs.org/project/linux-pwm/patch/20260427221155.2144848-13-dakr@kernel.org/mbox/","series":[{"id":501734,"url":"http://patchwork.ozlabs.org/api/1.1/series/501734/?format=json","web_url":"http://patchwork.ozlabs.org/project/linux-pwm/list/?series=501734","date":"2026-04-27T22:10:58","name":"rust: device: Higher-Ranked Lifetime Types for device drivers","version":1,"mbox":"http://patchwork.ozlabs.org/series/501734/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/2229211/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/2229211/checks/","tags":{},"headers":{"Return-Path":"\n <linux-pwm+bounces-8715-incoming=patchwork.ozlabs.org@vger.kernel.org>","X-Original-To":["incoming@patchwork.ozlabs.org","linux-pwm@vger.kernel.org"],"Delivered-To":"patchwork-incoming@legolas.ozlabs.org","Authentication-Results":["legolas.ozlabs.org;\n\tdkim=pass (2048-bit key;\n unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256\n header.s=k20201202 header.b=XtvLu9O5;\n\tdkim-atps=neutral","legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org\n (client-ip=172.232.135.74; helo=sto.lore.kernel.org;\n envelope-from=linux-pwm+bounces-8715-incoming=patchwork.ozlabs.org@vger.kernel.org;\n receiver=patchwork.ozlabs.org)","smtp.subspace.kernel.org;\n\tdkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org\n header.b=\"XtvLu9O5\"","smtp.subspace.kernel.org;\n arc=none smtp.client-ip=10.30.226.201"],"Received":["from sto.lore.kernel.org (sto.lore.kernel.org [172.232.135.74])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\t key-exchange x25519)\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4g4HsT4Dw7z1xrS\n\tfor <incoming@patchwork.ozlabs.org>; Tue, 28 Apr 2026 08:14:05 +1000 (AEST)","from smtp.subspace.kernel.org (conduit.subspace.kernel.org\n [100.90.174.1])\n\tby sto.lore.kernel.org (Postfix) with ESMTP id 3DABC3016D01\n\tfor <incoming@patchwork.ozlabs.org>; Mon, 27 Apr 2026 22:13:38 +0000 (UTC)","from localhost.localdomain (localhost.localdomain [127.0.0.1])\n\tby smtp.subspace.kernel.org (Postfix) with ESMTP id 6BA953AD512;\n\tMon, 27 Apr 2026 22:13:24 +0000 (UTC)","from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org\n [10.30.226.201])\n\t(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))\n\t(No client certificate requested)\n\tby smtp.subspace.kernel.org (Postfix) with ESMTPS id 44D1D3ACEE1;\n\tMon, 27 Apr 2026 22:13:23 +0000 (UTC)","by smtp.kernel.org (Postfix) with ESMTPSA id 0439AC2BCB6;\n\tMon, 27 Apr 2026 22:13:17 +0000 (UTC)"],"ARC-Seal":"i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116;\n\tt=1777328004; cv=none;\n b=SwMo+4GNQfP6fRhRQmOecFMxUnczuiy19eo1wkyTRbu3IRIcDKmOaa79Mpsuj7JbyhBQyfHkSw3jaI7kj5BFKkkTYq4rIStVxpZoQsnL6YQBqSmwr+TE/pYssapuurij+ZKiZS9KGlb0Eag2bbsEK7YPbAcJ2LvpKWbZtrOaAX0=","ARC-Message-Signature":"i=1; a=rsa-sha256; d=subspace.kernel.org;\n\ts=arc-20240116; t=1777328004; c=relaxed/simple;\n\tbh=SbAAS0eADHxx3DW9A0GSuIcQ7Z1EZxALrR6avIv2uEo=;\n\th=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References:\n\t MIME-Version;\n b=UAW8zJHHtk7Eupa0rrR7Zj9qUHaTXNXS1Ue7vOml+xfkp0f5wg+RkYOgcwMusRpc7rXmKlW/ZXlNOhZbYHxXhMFCd094tRIKS4T9gCQjDMMzNP7JzuLpRD0Esi3U3dmRtX5Heaf3BVPVuUvrb45nS29tF0j0JJToBGYY0sS4l9U=","ARC-Authentication-Results":"i=1; smtp.subspace.kernel.org;\n dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org\n header.b=XtvLu9O5; arc=none smtp.client-ip=10.30.226.201","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org;\n\ts=k20201202; t=1777328003;\n\tbh=SbAAS0eADHxx3DW9A0GSuIcQ7Z1EZxALrR6avIv2uEo=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=XtvLu9O5wx83IVLI0xcCL+XYbcSgk9I7l5pDwudA4ugR8IetY1J7ZP8JkK3RelTx5\n\t 9wTDlKBWIrCIzCj6fGlPo0d134QQy+1a8G64zqw0nXox7H4WuwbbuHHEtbZb3rUp76\n\t S8QO3p/shJ/YSjj/FQadgMGjxkAQnTb5JQnAyRLY/eE0qWrZ2/a6Eby8IUzWQgfUN4\n\t tTyMV5R0+Eb8qIRq3NaiIvBBqMnn98jHE8LInbEGqkNa4YKnVchAzZRlHv63azmKQN\n\t TMfNpFFYWlfzuY6MVl6jB9vf17xFKY92pFKUuQECSdJP6djwmw/oZ83bYpDKdmB3r5\n\t weUJforu5dQ7w==","From":"Danilo Krummrich <dakr@kernel.org>","To":"gregkh@linuxfoundation.org,\n\trafael@kernel.org,\n\tacourbot@nvidia.com,\n\taliceryhl@google.com,\n\tdavid.m.ertman@intel.com,\n\tira.weiny@intel.com,\n\tleon@kernel.org,\n\tviresh.kumar@linaro.org,\n\tm.wilczynski@samsung.com,\n\tukleinek@kernel.org,\n\tbhelgaas@google.com,\n\tkwilczynski@kernel.org,\n\tabdiel.janulgue@gmail.com,\n\trobin.murphy@arm.com,\n\tmarkus.probst@posteo.de,\n\tojeda@kernel.org,\n\tboqun@kernel.org,\n\tgary@garyguo.net,\n\tbjorn3_gh@protonmail.com,\n\tlossin@kernel.org,\n\ta.hindborg@kernel.org,\n\ttmgross@umich.edu","Cc":"driver-core@lists.linux.dev,\n\tlinux-kernel@vger.kernel.org,\n\tnova-gpu@lists.linux.dev,\n\tdri-devel@lists.freedesktop.org,\n\tlinux-pm@vger.kernel.org,\n\tlinux-pwm@vger.kernel.org,\n\tlinux-pci@vger.kernel.org,\n\trust-for-linux@vger.kernel.org,\n\tDanilo Krummrich <dakr@kernel.org>","Subject":"[PATCH 12/24] rust: platform: make Driver trait\n lifetime-parameterized","Date":"Tue, 28 Apr 2026 00:11:10 +0200","Message-ID":"<20260427221155.2144848-13-dakr@kernel.org>","X-Mailer":"git-send-email 2.54.0","In-Reply-To":"<20260427221155.2144848-1-dakr@kernel.org>","References":"<20260427221155.2144848-1-dakr@kernel.org>","Precedence":"bulk","X-Mailing-List":"linux-pwm@vger.kernel.org","List-Id":"<linux-pwm.vger.kernel.org>","List-Subscribe":"<mailto:linux-pwm+subscribe@vger.kernel.org>","List-Unsubscribe":"<mailto:linux-pwm+unsubscribe@vger.kernel.org>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit"},"content":"Make platform::Driver take a lifetime parameter 'a that ties device\nresources to the binding scope.\n\nInternally, Adapter<T: Driver> becomes Adapter<F: ForLt> with a bound\nfor<'a> F::Of<'a>: Driver<'a>; module_platform_driver! wraps the driver\ntype in ForLt!() so drivers don't have to.\n\nSigned-off-by: Danilo Krummrich <dakr@kernel.org>\n---\n drivers/cpufreq/rcpufreq_dt.rs       | 10 +--\n drivers/gpu/drm/tyr/driver.rs        | 10 +--\n drivers/pwm/pwm_th1520.rs            | 10 +--\n rust/kernel/cpufreq.rs               |  8 +--\n rust/kernel/driver.rs                |  9 ++-\n rust/kernel/io/mem.rs                | 16 ++---\n rust/kernel/platform.rs              | 92 ++++++++++++++++++----------\n samples/rust/rust_debugfs.rs         | 10 +--\n samples/rust/rust_driver_platform.rs | 12 ++--\n samples/rust/rust_i2c_client.rs      | 12 ++--\n samples/rust/rust_soc.rs             | 12 ++--\n 11 files changed, 116 insertions(+), 85 deletions(-)","diff":"diff --git a/drivers/cpufreq/rcpufreq_dt.rs b/drivers/cpufreq/rcpufreq_dt.rs\nindex f17bf64c22e2..06c05f946829 100644\n--- a/drivers/cpufreq/rcpufreq_dt.rs\n+++ b/drivers/cpufreq/rcpufreq_dt.rs\n@@ -195,18 +195,18 @@ fn register_em(policy: &mut cpufreq::Policy) {\n kernel::of_device_table!(\n     OF_TABLE,\n     MODULE_OF_TABLE,\n-    <CPUFreqDTDriver as platform::Driver>::IdInfo,\n+    <CPUFreqDTDriver as platform::Driver<'_>>::IdInfo,\n     [(of::DeviceId::new(c\"operating-points-v2\"), ())]\n );\n \n-impl platform::Driver for CPUFreqDTDriver {\n+impl<'a> platform::Driver<'a> for CPUFreqDTDriver {\n     type IdInfo = ();\n     const OF_ID_TABLE: Option<of::IdTable<Self::IdInfo>> = Some(&OF_TABLE);\n \n     fn probe(\n-        pdev: &platform::Device<Core>,\n-        _id_info: Option<&Self::IdInfo>,\n-    ) -> impl PinInit<Self, Error> {\n+        pdev: &'a platform::Device<Core>,\n+        _id_info: Option<&'a Self::IdInfo>,\n+    ) -> impl PinInit<Self, Error> + 'a {\n         cpufreq::Registration::<CPUFreqDTDriver>::new_foreign_owned(pdev.as_ref())?;\n         Ok(Self {})\n     }\ndiff --git a/drivers/gpu/drm/tyr/driver.rs b/drivers/gpu/drm/tyr/driver.rs\nindex 279710b36a10..7cc47ec76863 100644\n--- a/drivers/gpu/drm/tyr/driver.rs\n+++ b/drivers/gpu/drm/tyr/driver.rs\n@@ -82,21 +82,21 @@ fn issue_soft_reset(dev: &Device<Bound>, iomem: &Devres<IoMem>) -> Result {\n kernel::of_device_table!(\n     OF_TABLE,\n     MODULE_OF_TABLE,\n-    <TyrPlatformDriverData as platform::Driver>::IdInfo,\n+    <TyrPlatformDriverData as platform::Driver<'_>>::IdInfo,\n     [\n         (of::DeviceId::new(c\"rockchip,rk3588-mali\"), ()),\n         (of::DeviceId::new(c\"arm,mali-valhall-csf\"), ())\n     ]\n );\n \n-impl platform::Driver for TyrPlatformDriverData {\n+impl<'a> platform::Driver<'a> for TyrPlatformDriverData {\n     type IdInfo = ();\n     const OF_ID_TABLE: Option<of::IdTable<Self::IdInfo>> = Some(&OF_TABLE);\n \n     fn probe(\n-        pdev: &platform::Device<Core>,\n-        _info: Option<&Self::IdInfo>,\n-    ) -> impl PinInit<Self, Error> {\n+        pdev: &'a platform::Device<Core>,\n+        _info: Option<&'a Self::IdInfo>,\n+    ) -> impl PinInit<Self, Error> + 'a {\n         let core_clk = Clk::get(pdev.as_ref(), Some(c\"core\"))?;\n         let stacks_clk = OptionalClk::get(pdev.as_ref(), Some(c\"stacks\"))?;\n         let coregroup_clk = OptionalClk::get(pdev.as_ref(), Some(c\"coregroup\"))?;\ndiff --git a/drivers/pwm/pwm_th1520.rs b/drivers/pwm/pwm_th1520.rs\nindex ddd44a5ce497..7139f3f4373d 100644\n--- a/drivers/pwm/pwm_th1520.rs\n+++ b/drivers/pwm/pwm_th1520.rs\n@@ -310,18 +310,18 @@ fn drop(self: Pin<&mut Self>) {\n kernel::of_device_table!(\n     OF_TABLE,\n     MODULE_OF_TABLE,\n-    <Th1520PwmPlatformDriver as platform::Driver>::IdInfo,\n+    <Th1520PwmPlatformDriver as platform::Driver<'_>>::IdInfo,\n     [(of::DeviceId::new(c\"thead,th1520-pwm\"), ())]\n );\n \n-impl platform::Driver for Th1520PwmPlatformDriver {\n+impl<'a> platform::Driver<'a> for Th1520PwmPlatformDriver {\n     type IdInfo = ();\n     const OF_ID_TABLE: Option<of::IdTable<Self::IdInfo>> = Some(&OF_TABLE);\n \n     fn probe(\n-        pdev: &platform::Device<Core>,\n-        _id_info: Option<&Self::IdInfo>,\n-    ) -> impl PinInit<Self, Error> {\n+        pdev: &'a platform::Device<Core>,\n+        _id_info: Option<&'a Self::IdInfo>,\n+    ) -> impl PinInit<Self, Error> + 'a {\n         let dev = pdev.as_ref();\n         let request = pdev.io_request_by_index(0).ok_or(ENODEV)?;\n \ndiff --git a/rust/kernel/cpufreq.rs b/rust/kernel/cpufreq.rs\nindex d8d26870bea2..ac59cdfd633c 100644\n--- a/rust/kernel/cpufreq.rs\n+++ b/rust/kernel/cpufreq.rs\n@@ -886,14 +886,14 @@ fn register_em(_policy: &mut Policy) {\n ///     }\n /// }\n ///\n-/// impl platform::Driver for SampleDriver {\n+/// impl<'a> platform::Driver<'a> for SampleDriver {\n ///     type IdInfo = ();\n ///     const OF_ID_TABLE: Option<of::IdTable<Self::IdInfo>> = None;\n ///\n ///     fn probe(\n-///         pdev: &platform::Device<Core>,\n-///         _id_info: Option<&Self::IdInfo>,\n-///     ) -> impl PinInit<Self, Error> {\n+///         pdev: &'a platform::Device<Core>,\n+///         _id_info: Option<&'a Self::IdInfo>,\n+///     ) -> impl PinInit<Self, Error> + 'a {\n ///         cpufreq::Registration::<SampleDriver>::new_foreign_owned(pdev.as_ref())?;\n ///         Ok(Self {})\n ///     }\ndiff --git a/rust/kernel/driver.rs b/rust/kernel/driver.rs\nindex 91490040d77e..03974690406b 100644\n--- a/rust/kernel/driver.rs\n+++ b/rust/kernel/driver.rs\n@@ -13,7 +13,7 @@\n //! The main driver interface is defined by a bus specific driver trait. For instance:\n //!\n //! ```ignore\n-//! pub trait Driver: Send {\n+//! pub trait Driver<'a>: Send {\n //!     /// The type holding information about each device ID supported by the driver.\n //!     type IdInfo: 'static;\n //!\n@@ -24,10 +24,13 @@\n //!     const ACPI_ID_TABLE: Option<acpi::IdTable<Self::IdInfo>> = None;\n //!\n //!     /// Driver probe.\n-//!     fn probe(dev: &Device<device::Core>, id_info: &Self::IdInfo) -> impl PinInit<Self, Error>;\n+//!     fn probe(\n+//!         dev: &'a Device<device::Core>,\n+//!         id_info: &'a Self::IdInfo,\n+//!     ) -> impl PinInit<Self, Error> + 'a;\n //!\n //!     /// Driver unbind (optional).\n-//!     fn unbind(dev: &Device<device::Core>, this: Pin<&Self>) {\n+//!     fn unbind(dev: &'a Device<device::Core>, this: Pin<&'a Self>) {\n //!         let _ = (dev, this);\n //!     }\n //! }\ndiff --git a/rust/kernel/io/mem.rs b/rust/kernel/io/mem.rs\nindex 7dc78d547f7a..a483e59054e8 100644\n--- a/rust/kernel/io/mem.rs\n+++ b/rust/kernel/io/mem.rs\n@@ -60,13 +60,13 @@ pub(crate) unsafe fn new(device: &'a Device<Bound>, resource: &'a Resource) -> S\n     /// };\n     /// struct SampleDriver;\n     ///\n-    /// impl platform::Driver for SampleDriver {\n+    /// impl<'a> platform::Driver<'a> for SampleDriver {\n     ///    # type IdInfo = ();\n     ///\n     ///    fn probe(\n-    ///       pdev: &platform::Device<Core>,\n-    ///       info: Option<&Self::IdInfo>,\n-    ///    ) -> impl PinInit<Self, Error> {\n+    ///       pdev: &'a platform::Device<Core>,\n+    ///       info: Option<&'a Self::IdInfo>,\n+    ///    ) -> impl PinInit<Self, Error> + 'a {\n     ///       let offset = 0; // Some offset.\n     ///\n     ///       // If the size is known at compile time, use [`Self::iomap_sized`].\n@@ -124,13 +124,13 @@ pub fn iomap_exclusive_sized<const SIZE: usize>(\n     /// };\n     /// struct SampleDriver;\n     ///\n-    /// impl platform::Driver for SampleDriver {\n+    /// impl<'a> platform::Driver<'a> for SampleDriver {\n     ///    # type IdInfo = ();\n     ///\n     ///    fn probe(\n-    ///       pdev: &platform::Device<Core>,\n-    ///       info: Option<&Self::IdInfo>,\n-    ///    ) -> impl PinInit<Self, Error> {\n+    ///       pdev: &'a platform::Device<Core>,\n+    ///       info: Option<&'a Self::IdInfo>,\n+    ///    ) -> impl PinInit<Self, Error> + 'a {\n     ///       let offset = 0; // Some offset.\n     ///\n     ///       // Unlike [`Self::iomap_sized`], here the size of the memory region\ndiff --git a/rust/kernel/platform.rs b/rust/kernel/platform.rs\nindex ae648304eb5b..ec41886b0ba3 100644\n--- a/rust/kernel/platform.rs\n+++ b/rust/kernel/platform.rs\n@@ -44,33 +44,45 @@\n };\n \n /// An adapter for the registration of platform drivers.\n-pub struct Adapter<T: Driver>(T);\n+///\n+/// `F` is a [`ForLt`](trait@ForLt) type that maps lifetimes to the driver's device\n+/// private data type, i.e. `F::Of<'a>` is the driver struct parameterized by `'a`. The macro\n+/// `module_platform_driver!` generates this automatically via `ForLt!()`.\n+pub struct Adapter<F>(PhantomData<F>);\n \n // SAFETY:\n // - `bindings::platform_driver` is a C type declared as `repr(C)`.\n-// - `T` is the type of the driver's device private data.\n+// - `F::Of<'static>` is the stored type of the driver's device private data.\n // - `struct platform_driver` embeds a `struct device_driver`.\n // - `DEVICE_DRIVER_OFFSET` is the correct byte offset to the embedded `struct device_driver`.\n-unsafe impl<T: Driver + 'static> driver::DriverLayout for Adapter<T> {\n+unsafe impl<F> driver::DriverLayout for Adapter<F>\n+where\n+    F: ForLt + 'static,\n+    for<'a> F::Of<'a>: Driver<'a>,\n+{\n     type DriverType = bindings::platform_driver;\n-    type DriverData = ForLt!(T);\n+    type DriverData = F;\n     const DEVICE_DRIVER_OFFSET: usize = core::mem::offset_of!(Self::DriverType, driver);\n }\n \n // SAFETY: A call to `unregister` for a given instance of `DriverType` is guaranteed to be valid if\n // a preceding call to `register` has been successful.\n-unsafe impl<T: Driver + 'static> driver::RegistrationOps for Adapter<T> {\n+unsafe impl<F> driver::RegistrationOps for Adapter<F>\n+where\n+    F: ForLt + 'static,\n+    for<'a> F::Of<'a>: Driver<'a>,\n+{\n     unsafe fn register(\n         pdrv: &Opaque<Self::DriverType>,\n         name: &'static CStr,\n         module: &'static ThisModule,\n     ) -> Result {\n-        let of_table = match T::OF_ID_TABLE {\n+        let of_table = match <F::Of<'static> as Driver<'static>>::OF_ID_TABLE {\n             Some(table) => table.as_ptr(),\n             None => core::ptr::null(),\n         };\n \n-        let acpi_table = match T::ACPI_ID_TABLE {\n+        let acpi_table = match <F::Of<'static> as Driver<'static>>::ACPI_ID_TABLE {\n             Some(table) => table.as_ptr(),\n             None => core::ptr::null(),\n         };\n@@ -94,19 +106,23 @@ unsafe fn unregister(pdrv: &Opaque<Self::DriverType>) {\n     }\n }\n \n-impl<T: Driver + 'static> Adapter<T> {\n+impl<F> Adapter<F>\n+where\n+    F: ForLt + 'static,\n+    for<'a> F::Of<'a>: Driver<'a>,\n+{\n     extern \"C\" fn probe_callback(pdev: *mut bindings::platform_device) -> kernel::ffi::c_int {\n         // SAFETY: The platform bus only ever calls the probe callback with a valid pointer to a\n         // `struct platform_device`.\n         //\n         // INVARIANT: `pdev` is valid for the duration of `probe_callback()`.\n         let pdev = unsafe { &*pdev.cast::<Device<device::CoreInternal>>() };\n-        let info = <Self as driver::Adapter<'_>>::id_info(pdev.as_ref());\n \n         from_result(|| {\n-            let data = T::probe(pdev, info);\n+            let info = <Self as driver::Adapter<'_>>::id_info(pdev.as_ref());\n+            let data = <F::Of<'_> as Driver<'_>>::probe(pdev, info);\n \n-            pdev.as_ref().set_drvdata::<ForLt!(T)>(data)?;\n+            pdev.as_ref().set_drvdata::<F>(data)?;\n             Ok(0)\n         })\n     }\n@@ -119,28 +135,34 @@ extern \"C\" fn remove_callback(pdev: *mut bindings::platform_device) {\n         let pdev = unsafe { &*pdev.cast::<Device<device::CoreInternal>>() };\n \n         // SAFETY: `remove_callback` is only ever called after a successful call to\n-        // `probe_callback`, hence it's guaranteed that `Device::set_drvdata()` has been called\n-        // and stored a `Pin<KBox<T>>`.\n-        let data = unsafe { pdev.as_ref().drvdata_borrow::<ForLt!(T)>() };\n+        // `probe_callback`, hence it's guaranteed that drvdata has been set.\n+        let data = unsafe { pdev.as_ref().drvdata_borrow::<F>() };\n \n-        T::unbind(pdev, data);\n+        <F::Of<'_> as Driver<'_>>::unbind(pdev, data);\n     }\n }\n \n-impl<'a, T: Driver + 'static> driver::Adapter<'a> for Adapter<T> {\n-    type IdInfo = T::IdInfo;\n+impl<'a, F> driver::Adapter<'a> for Adapter<F>\n+where\n+    F: ForLt + 'static,\n+    for<'b> F::Of<'b>: Driver<'b>,\n+{\n+    type IdInfo = <F::Of<'a> as Driver<'a>>::IdInfo;\n \n     fn of_id_table() -> Option<of::IdTable<Self::IdInfo>> {\n-        T::OF_ID_TABLE\n+        <F::Of<'a> as Driver<'a>>::OF_ID_TABLE\n     }\n \n     fn acpi_id_table() -> Option<acpi::IdTable<Self::IdInfo>> {\n-        T::ACPI_ID_TABLE\n+        <F::Of<'a> as Driver<'a>>::ACPI_ID_TABLE\n     }\n }\n \n /// Declares a kernel module that exposes a single platform driver.\n ///\n+/// The `type` field accepts a driver type, optionally with a lifetime placeholder `'_` for\n+/// lifetime-parameterized drivers. The macro wraps it in [`ForLt!`] automatically.\n+///\n /// # Examples\n ///\n /// ```ignore\n@@ -152,10 +174,16 @@ fn acpi_id_table() -> Option<acpi::IdTable<Self::IdInfo>> {\n ///     license: \"GPL v2\",\n /// }\n /// ```\n+///\n+/// [`ForLt!`]: macro@ForLt\n+/// [`ForLt`]: trait@ForLt\n #[macro_export]\n macro_rules! module_platform_driver {\n-    ($($f:tt)*) => {\n-        $crate::module_driver!(<T>, $crate::platform::Adapter<T>, { $($f)* });\n+    (type: $type:ty, $($rest:tt)*) => {\n+        $crate::module_driver!(<T>, $crate::platform::Adapter<T>, {\n+            type: $crate::types::ForLt!($type),\n+            $($rest)*\n+        });\n     };\n }\n \n@@ -178,7 +206,7 @@ macro_rules! module_platform_driver {\n /// kernel::of_device_table!(\n ///     OF_TABLE,\n ///     MODULE_OF_TABLE,\n-///     <MyDriver as platform::Driver>::IdInfo,\n+///     <MyDriver as platform::Driver<'_>>::IdInfo,\n ///     [\n ///         (of::DeviceId::new(c\"test,device\"), ())\n ///     ]\n@@ -187,26 +215,26 @@ macro_rules! module_platform_driver {\n /// kernel::acpi_device_table!(\n ///     ACPI_TABLE,\n ///     MODULE_ACPI_TABLE,\n-///     <MyDriver as platform::Driver>::IdInfo,\n+///     <MyDriver as platform::Driver<'_>>::IdInfo,\n ///     [\n ///         (acpi::DeviceId::new(c\"LNUXBEEF\"), ())\n ///     ]\n /// );\n ///\n-/// impl platform::Driver for MyDriver {\n+/// impl<'a> platform::Driver<'a> for MyDriver {\n ///     type IdInfo = ();\n ///     const OF_ID_TABLE: Option<of::IdTable<Self::IdInfo>> = Some(&OF_TABLE);\n ///     const ACPI_ID_TABLE: Option<acpi::IdTable<Self::IdInfo>> = Some(&ACPI_TABLE);\n ///\n ///     fn probe(\n-///         _pdev: &platform::Device<Core>,\n-///         _id_info: Option<&Self::IdInfo>,\n-///     ) -> impl PinInit<Self, Error> {\n+///         _pdev: &'a platform::Device<Core>,\n+///         _id_info: Option<&'a Self::IdInfo>,\n+///     ) -> impl PinInit<Self, Error> + 'a {\n ///         Err(ENODEV)\n ///     }\n /// }\n ///```\n-pub trait Driver: Send {\n+pub trait Driver<'a>: Send {\n     /// The type holding driver private data about each device id supported by the driver.\n     // TODO: Use associated_type_defaults once stabilized:\n     //\n@@ -226,9 +254,9 @@ pub trait Driver: Send {\n     /// Called when a new platform device is added or discovered.\n     /// Implementers should attempt to initialize the device here.\n     fn probe(\n-        dev: &Device<device::Core>,\n-        id_info: Option<&Self::IdInfo>,\n-    ) -> impl PinInit<Self, Error>;\n+        dev: &'a Device<device::Core>,\n+        id_info: Option<&'a Self::IdInfo>,\n+    ) -> impl PinInit<Self, Error> + 'a;\n \n     /// Platform driver unbind.\n     ///\n@@ -240,7 +268,7 @@ fn probe(\n     /// operations to gracefully tear down the device.\n     ///\n     /// Otherwise, release operations for driver resources should be performed in `Self::drop`.\n-    fn unbind(dev: &Device<device::Core>, this: Pin<&Self>) {\n+    fn unbind(dev: &'a Device<device::Core>, this: Pin<&'a Self>) {\n         let _ = (dev, this);\n     }\n }\ndiff --git a/samples/rust/rust_debugfs.rs b/samples/rust/rust_debugfs.rs\nindex 0963efe19f93..0d88a9aaa957 100644\n--- a/samples/rust/rust_debugfs.rs\n+++ b/samples/rust/rust_debugfs.rs\n@@ -111,19 +111,19 @@ fn from_str(s: &str) -> Result<Self> {\n kernel::acpi_device_table!(\n     ACPI_TABLE,\n     MODULE_ACPI_TABLE,\n-    <RustDebugFs as platform::Driver>::IdInfo,\n+    <RustDebugFs as platform::Driver<'_>>::IdInfo,\n     [(acpi::DeviceId::new(c\"LNUXBEEF\"), ())]\n );\n \n-impl platform::Driver for RustDebugFs {\n+impl<'a> platform::Driver<'a> for RustDebugFs {\n     type IdInfo = ();\n     const OF_ID_TABLE: Option<of::IdTable<Self::IdInfo>> = None;\n     const ACPI_ID_TABLE: Option<acpi::IdTable<Self::IdInfo>> = Some(&ACPI_TABLE);\n \n     fn probe(\n-        pdev: &platform::Device<Core>,\n-        _info: Option<&Self::IdInfo>,\n-    ) -> impl PinInit<Self, Error> {\n+        pdev: &'a platform::Device<Core>,\n+        _info: Option<&'a Self::IdInfo>,\n+    ) -> impl PinInit<Self, Error> + 'a {\n         RustDebugFs::new(pdev).pin_chain(|this| {\n             this.counter.store(91, Relaxed);\n             {\ndiff --git a/samples/rust/rust_driver_platform.rs b/samples/rust/rust_driver_platform.rs\nindex f2229d176fb9..cf9177bf3202 100644\n--- a/samples/rust/rust_driver_platform.rs\n+++ b/samples/rust/rust_driver_platform.rs\n@@ -88,26 +88,26 @@ struct SampleDriver {\n kernel::of_device_table!(\n     OF_TABLE,\n     MODULE_OF_TABLE,\n-    <SampleDriver as platform::Driver>::IdInfo,\n+    <SampleDriver as platform::Driver<'_>>::IdInfo,\n     [(of::DeviceId::new(c\"test,rust-device\"), Info(42))]\n );\n \n kernel::acpi_device_table!(\n     ACPI_TABLE,\n     MODULE_ACPI_TABLE,\n-    <SampleDriver as platform::Driver>::IdInfo,\n+    <SampleDriver as platform::Driver<'_>>::IdInfo,\n     [(acpi::DeviceId::new(c\"LNUXBEEF\"), Info(0))]\n );\n \n-impl platform::Driver for SampleDriver {\n+impl<'a> platform::Driver<'a> for SampleDriver {\n     type IdInfo = Info;\n     const OF_ID_TABLE: Option<of::IdTable<Self::IdInfo>> = Some(&OF_TABLE);\n     const ACPI_ID_TABLE: Option<acpi::IdTable<Self::IdInfo>> = Some(&ACPI_TABLE);\n \n     fn probe(\n-        pdev: &platform::Device<Core>,\n-        info: Option<&Self::IdInfo>,\n-    ) -> impl PinInit<Self, Error> {\n+        pdev: &'a platform::Device<Core>,\n+        info: Option<&'a Self::IdInfo>,\n+    ) -> impl PinInit<Self, Error> + 'a {\n         let dev = pdev.as_ref();\n \n         dev_dbg!(dev, \"Probe Rust Platform driver sample.\\n\");\ndiff --git a/samples/rust/rust_i2c_client.rs b/samples/rust/rust_i2c_client.rs\nindex 8d2c12e535b0..342755df8b95 100644\n--- a/samples/rust/rust_i2c_client.rs\n+++ b/samples/rust/rust_i2c_client.rs\n@@ -88,14 +88,14 @@ struct SampleDriver {\n kernel::of_device_table!(\n     OF_TABLE,\n     MODULE_OF_TABLE,\n-    <SampleDriver as platform::Driver>::IdInfo,\n+    <SampleDriver as platform::Driver<'_>>::IdInfo,\n     [(of::DeviceId::new(c\"test,rust-device\"), ())]\n );\n \n kernel::acpi_device_table!(\n     ACPI_TABLE,\n     MODULE_ACPI_TABLE,\n-    <SampleDriver as platform::Driver>::IdInfo,\n+    <SampleDriver as platform::Driver<'_>>::IdInfo,\n     [(acpi::DeviceId::new(c\"LNUXBEEF\"), ())]\n );\n \n@@ -104,15 +104,15 @@ struct SampleDriver {\n const BOARD_INFO: i2c::I2cBoardInfo =\n     i2c::I2cBoardInfo::new(c\"rust_driver_i2c\", SAMPLE_I2C_CLIENT_ADDR);\n \n-impl platform::Driver for SampleDriver {\n+impl<'a> platform::Driver<'a> for SampleDriver {\n     type IdInfo = ();\n     const OF_ID_TABLE: Option<of::IdTable<Self::IdInfo>> = Some(&OF_TABLE);\n     const ACPI_ID_TABLE: Option<acpi::IdTable<Self::IdInfo>> = Some(&ACPI_TABLE);\n \n     fn probe(\n-        pdev: &platform::Device<device::Core>,\n-        _info: Option<&Self::IdInfo>,\n-    ) -> impl PinInit<Self, Error> {\n+        pdev: &'a platform::Device<device::Core>,\n+        _info: Option<&'a Self::IdInfo>,\n+    ) -> impl PinInit<Self, Error> + 'a {\n         dev_info!(\n             pdev.as_ref(),\n             \"Probe Rust I2C Client registration sample.\\n\"\ndiff --git a/samples/rust/rust_soc.rs b/samples/rust/rust_soc.rs\nindex 8079c1c48416..16f1e4bcfa36 100644\n--- a/samples/rust/rust_soc.rs\n+++ b/samples/rust/rust_soc.rs\n@@ -24,26 +24,26 @@ struct SampleSocDriver {\n kernel::of_device_table!(\n     OF_TABLE,\n     MODULE_OF_TABLE,\n-    <SampleSocDriver as platform::Driver>::IdInfo,\n+    <SampleSocDriver as platform::Driver<'_>>::IdInfo,\n     [(of::DeviceId::new(c\"test,rust-device\"), ())]\n );\n \n kernel::acpi_device_table!(\n     ACPI_TABLE,\n     MODULE_ACPI_TABLE,\n-    <SampleSocDriver as platform::Driver>::IdInfo,\n+    <SampleSocDriver as platform::Driver<'_>>::IdInfo,\n     [(acpi::DeviceId::new(c\"LNUXBEEF\"), ())]\n );\n \n-impl platform::Driver for SampleSocDriver {\n+impl<'a> platform::Driver<'a> for SampleSocDriver {\n     type IdInfo = ();\n     const OF_ID_TABLE: Option<of::IdTable<Self::IdInfo>> = Some(&OF_TABLE);\n     const ACPI_ID_TABLE: Option<acpi::IdTable<Self::IdInfo>> = Some(&ACPI_TABLE);\n \n     fn probe(\n-        pdev: &platform::Device<Core>,\n-        _info: Option<&Self::IdInfo>,\n-    ) -> impl PinInit<Self, Error> {\n+        pdev: &'a platform::Device<Core>,\n+        _info: Option<&'a Self::IdInfo>,\n+    ) -> impl PinInit<Self, Error> + 'a {\n         dev_dbg!(pdev, \"Probe Rust SoC driver sample.\\n\");\n \n         let pdev = pdev.into();\n","prefixes":["12/24"]}