[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <DA1OD24LT9GX.2JYOBUQUMQ8YC@nvidia.com>
Date: Wed, 21 May 2025 16:53:44 +0900
From: "Alexandre Courbot" <acourbot@...dia.com>
To: "Daniel Almeida" <daniel.almeida@...labora.com>, "Miguel Ojeda"
<ojeda@...nel.org>, "Alex Gaynor" <alex.gaynor@...il.com>, "Boqun Feng"
<boqun.feng@...il.com>, "Gary Guo" <gary@...yguo.net>,
Björn Roy Baron <bjorn3_gh@...tonmail.com>, "Benno Lossin"
<benno.lossin@...ton.me>, "Andreas Hindborg" <a.hindborg@...nel.org>,
"Alice Ryhl" <aliceryhl@...gle.com>, "Trevor Gross" <tmgross@...ch.edu>,
"Danilo Krummrich" <dakr@...nel.org>
Cc: <linux-kernel@...r.kernel.org>, <rust-for-linux@...r.kernel.org>, "Fiona
Behrens" <me@...enk.dev>
Subject: Re: [PATCH v5] rust: kernel: add support for bits/genmask macros
Hi Daniel,
On Wed Mar 26, 2025 at 11:06 PM JST, Daniel Almeida wrote:
> In light of bindgen being unable to generate bindings for macros,
> manually define the bit and genmask C macros in Rust.
>
> Bit and genmask are frequently used in drivers, and are simple enough to
> just be redefined. Their implementation is also unlikely to ever change.
>
> These macros are converted from their kernel equivalent. Versions for
> u64, u32, u16 and u8 are provided in order to reduce the number of casts
> for callers.
This looks good to me, my only suggestion would be to try and use a
macro to generate the methods from a shared template, to rule out
copy/paste errors? Similarly to what we do in [1].
I guess this means the examples would need to be copied to another place
(module documentation?) for them to run, although I am not quite sure
whether this is needed.
[1] https://lore.kernel.org/rust-for-linux/20250521-nova-frts-v4-4-05dfd4f39479@nvidia.com/T/#u
Powered by blists - more mailing lists