[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <D96AFO7XG0S5.9YOG2JPIWDIZ@proton.me>
Date: Mon, 14 Apr 2025 10:26:21 +0000
From: Benno Lossin <benno.lossin@...ton.me>
To: Danilo Krummrich <dakr@...nel.org>, bhelgaas@...gle.com, kwilczynski@...nel.org, gregkh@...uxfoundation.org, rafael@...nel.org, abdiel.janulgue@...il.com
Cc: ojeda@...nel.org, alex.gaynor@...il.com, boqun.feng@...il.com, gary@...yguo.net, bjorn3_gh@...tonmail.com, a.hindborg@...nel.org, aliceryhl@...gle.com, tmgross@...ch.edu, daniel.almeida@...labora.com, robin.murphy@....com, linux-pci@...r.kernel.org, rust-for-linux@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH v2 2/9] rust: device: implement impl_device_context_into_aref!
On Sun Apr 13, 2025 at 7:36 PM CEST, Danilo Krummrich wrote:
> Implement a macro to implement all From conversions of a certain device
> to ARef<Device>.
>
> This avoids unnecessary boiler plate code for every device
> implementation.
>
> Signed-off-by: Danilo Krummrich <dakr@...nel.org>
One nit below, with that fixed:
Reviewed-by: Benno Lossin <benno.lossin@...ton.me>
> ---
> rust/kernel/device.rs | 21 +++++++++++++++++++++
> rust/kernel/pci.rs | 7 +------
> rust/kernel/platform.rs | 9 ++-------
> 3 files changed, 24 insertions(+), 13 deletions(-)
>
> diff --git a/rust/kernel/device.rs b/rust/kernel/device.rs
> index 7cb6f0fc005d..26e71224460b 100644
> --- a/rust/kernel/device.rs
> +++ b/rust/kernel/device.rs
> @@ -279,6 +279,27 @@ macro_rules! impl_device_context_deref {
> };
> }
>
> +#[doc(hidden)]
> +#[macro_export]
> +macro_rules! __impl_device_context_into_aref {
> + ($src:ty, $device:tt) => {
> + impl core::convert::From<&$device<$src>> for $crate::types::ARef<$device> {
Missing `::` in front of `core`.
> + fn from(dev: &$device<$src>) -> Self {
> + (&**dev).into()
> + }
> + }
> + };
> +}
> +
> +/// Implement [`core::convert::From`], such that all `&Device<Ctx>` can be converted to an
> +/// `ARef<Device>`.
> +#[macro_export]
> +macro_rules! impl_device_context_into_aref {
> + ($device:tt) => {
> + kernel::__impl_device_context_into_aref!($crate::device::Core, $device);
> + };
> +}
> +
> #[doc(hidden)]
> #[macro_export]
> macro_rules! dev_printk {
Powered by blists - more mailing lists