From: "Alexandre Courbot" <acourbot@nvidia.com>
To: "Daniel Almeida" <daniel.almeida@collabora.com>,
"Miguel Ojeda" <ojeda@kernel.org>,
"Alex Gaynor" <alex.gaynor@gmail.com>,
"Boqun Feng" <boqun.feng@gmail.com>,
"Gary Guo" <gary@garyguo.net>,
"Björn Roy Baron" <bjorn3_gh@protonmail.com>,
"Benno Lossin" <benno.lossin@proton.me>,
"Andreas Hindborg" <a.hindborg@kernel.org>,
"Alice Ryhl" <aliceryhl@google.com>,
"Trevor Gross" <tmgross@umich.edu>,
"Danilo Krummrich" <dakr@kernel.org>
Cc: <linux-kernel@vger.kernel.org>, <rust-for-linux@vger.kernel.org>,
"Fiona Behrens" <me@kloenk.dev>
Subject: Re: [PATCH v5] rust: kernel: add support for bits/genmask macros
Date: Wed, 21 May 2025 16:53:44 +0900 [thread overview]
Message-ID: <DA1OD24LT9GX.2JYOBUQUMQ8YC@nvidia.com> (raw)
In-Reply-To: <20250326-topic-panthor-rs-genmask-v5-1-bfa6140214da@collabora.com>
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
next prev parent reply other threads:[~2025-05-21 7:53 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-26 14:06 [PATCH v5] rust: kernel: add support for bits/genmask macros Daniel Almeida
2025-03-27 21:27 ` Miguel Ojeda
2025-05-13 18:52 ` Daniel Almeida
2025-05-19 17:57 ` Miguel Ojeda
2025-05-22 5:01 ` Alexandre Courbot
2025-05-21 7:53 ` Alexandre Courbot [this message]
2025-05-22 3:17 ` Alexandre Courbot
2025-05-22 8:21 ` Miguel Ojeda
2025-05-22 8:23 ` Alexandre Courbot
2025-05-22 8:37 ` Miguel Ojeda
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=DA1OD24LT9GX.2JYOBUQUMQ8YC@nvidia.com \
--to=acourbot@nvidia.com \
--cc=a.hindborg@kernel.org \
--cc=alex.gaynor@gmail.com \
--cc=aliceryhl@google.com \
--cc=benno.lossin@proton.me \
--cc=bjorn3_gh@protonmail.com \
--cc=boqun.feng@gmail.com \
--cc=dakr@kernel.org \
--cc=daniel.almeida@collabora.com \
--cc=gary@garyguo.net \
--cc=linux-kernel@vger.kernel.org \
--cc=me@kloenk.dev \
--cc=ojeda@kernel.org \
--cc=rust-for-linux@vger.kernel.org \
--cc=tmgross@umich.edu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox