All of lore.kernel.org
 help / color / mirror / Atom feed
From: Joel Fernandes <joelagnelf@nvidia.com>
To: Miguel Ojeda <miguel.ojeda.sandonis@gmail.com>
Cc: linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org,
	dakr@kernel.org, acourbot@nvidia.com,
	Alistair Popple <apopple@nvidia.com>,
	Miguel Ojeda <ojeda@kernel.org>,
	Alex Gaynor <alex.gaynor@gmail.com>,
	Boqun Feng <boqun.feng@gmail.com>, Gary Guo <gary@garyguo.net>,
	bjorn3_gh@protonmail.com, Benno Lossin <lossin@kernel.org>,
	Andreas Hindborg <a.hindborg@kernel.org>,
	Alice Ryhl <aliceryhl@google.com>,
	Trevor Gross <tmgross@umich.edu>,
	David Airlie <airlied@gmail.com>, Simona Vetter <simona@ffwll.ch>,
	Maarten Lankhorst <maarten.lankhorst@linux.intel.com>,
	Maxime Ripard <mripard@kernel.org>,
	Thomas Zimmermann <tzimmermann@suse.de>,
	John Hubbard <jhubbard@nvidia.com>, Timur Tabi <ttabi@nvidia.com>,
	joel@joelfernandes.org, Elle Rhumsaa <elle@weathered-steel.dev>,
	Daniel Almeida <daniel.almeida@collabora.com>,
	nouveau@lists.freedesktop.org, rust-for-linux@vger.kernel.org
Subject: Re: [PATCH v2 4/4] rust: Move register and bitstruct macros out of Nova
Date: Mon, 8 Sep 2025 13:06:12 -0400	[thread overview]
Message-ID: <a2c990ff-e05c-4d09-aaeb-5a2fc16ecb77@nvidia.com> (raw)
In-Reply-To: <CANiq72mx7NA1KD5fw98kba+3oENHW44QXVGO1VmvPPUKin2LPg@mail.gmail.com>



On 9/7/2025 2:14 PM, Miguel Ojeda wrote:
> Hi Joel,
> 
> I didn't check the macros, but a couple nits I noticed in this patch
> in particular given it moved it to `kernel`...
> 
> On Wed, Sep 3, 2025 at 11:54 PM Joel Fernandes <joelagnelf@nvidia.com> wrote:
>>
>> +//! A library that provides support for defining bit fields in Rust
> 
> What about just "Support for defining bit fields in ..." or similar?
> 
>> +//! structures. Also used from things that need bitfields like register macro.

Ok, I changed it to:
"Also used from things that need bitfields like [`register!`] macro." for next
revision.

> 
> The "register macro" part sounds like it should be formatted with
> Markdown plus an intra-doc link.
> 
>> -            ::kernel::build_assert!(
>> +            build_assert!(
> 
> Is this path unqualified for some reason? Does it mean the user needs
> to have imported the prelude?

Yes, for register macro importing prelude is required (I commented more below).

> 
>> +pub use super::{bitstruct, register};
> 
> Please justify in the commit message why we want them in the prelude,
> e.g. are they expected to be common? Does it simplify some code? etc.
> 
The issue I ran into is, without adding it to prelude, the users of register!
macro will have to import both bitfield! and register! macros explictly, even
though they're only using register!. I tried to make it work without adding to
prelude, but couldn't:

  use kernel::{bitfield, register};

Also not adding it to prelude, means register! macro has to invoke bitfield with
$crate prefixed  ($crate::bitfield).

I think the prelude-way is clean, but let me know if there's any other trick I
can try.

I will also add this rationale to the commit message as you suggested.

Thanks!

 - Joel


  reply	other threads:[~2025-10-06 20:47 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-09-03 21:54 [PATCH v2 0/4] Improve bitfield support in Rust Joel Fernandes
2025-09-03 21:54 ` [PATCH v2 1/4] nova-core: bitstruct: Move bitfield-specific code from register! into new macro Joel Fernandes
2025-09-08  3:12   ` Alexandre Courbot
2025-09-08 17:16     ` Joel Fernandes
2025-09-09  2:37       ` Alexandre Courbot
2025-09-09 18:55         ` Joel Fernandes
2025-09-10 13:25           ` Alexandre Courbot
2025-09-10 14:19             ` Joel Fernandes
2025-09-03 21:54 ` [PATCH v2 2/4] nova-core: bitstruct: Add support for different storage widths Joel Fernandes
2025-09-05 22:21   ` Elle Rhumsaa
2025-09-08  3:26   ` Alexandre Courbot
2025-09-09 18:26     ` Joel Fernandes
2025-09-03 21:54 ` [PATCH v2 3/4] nova-core: bitstruct: Add support for custom visiblity Joel Fernandes
2025-09-05 22:22   ` Elle Rhumsaa
2025-09-05 22:23   ` Elle Rhumsaa
2025-09-08  3:40   ` Alexandre Courbot
2025-09-08  3:46     ` Alexandre Courbot
2025-09-09 19:05       ` Joel Fernandes
2025-09-09 18:30     ` Joel Fernandes
2025-09-03 21:54 ` [PATCH v2 4/4] rust: Move register and bitstruct macros out of Nova Joel Fernandes
2025-09-03 21:56   ` Daniel Almeida
2025-09-03 21:57     ` Joel Fernandes
2025-09-05 22:24   ` Elle Rhumsaa
2025-09-07 18:14   ` Miguel Ojeda
2025-09-08 17:06     ` Joel Fernandes [this message]
2025-09-08 18:39       ` Miguel Ojeda
2025-09-08 20:40         ` Joel Fernandes
2025-09-08 21:24         ` Joel Fernandes
2025-09-08  3:52   ` Alexandre Courbot
2025-09-08 20:14     ` Joel Fernandes

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=a2c990ff-e05c-4d09-aaeb-5a2fc16ecb77@nvidia.com \
    --to=joelagnelf@nvidia.com \
    --cc=a.hindborg@kernel.org \
    --cc=acourbot@nvidia.com \
    --cc=airlied@gmail.com \
    --cc=alex.gaynor@gmail.com \
    --cc=aliceryhl@google.com \
    --cc=apopple@nvidia.com \
    --cc=bjorn3_gh@protonmail.com \
    --cc=boqun.feng@gmail.com \
    --cc=dakr@kernel.org \
    --cc=daniel.almeida@collabora.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=elle@weathered-steel.dev \
    --cc=gary@garyguo.net \
    --cc=jhubbard@nvidia.com \
    --cc=joel@joelfernandes.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lossin@kernel.org \
    --cc=maarten.lankhorst@linux.intel.com \
    --cc=miguel.ojeda.sandonis@gmail.com \
    --cc=mripard@kernel.org \
    --cc=nouveau@lists.freedesktop.org \
    --cc=ojeda@kernel.org \
    --cc=rust-for-linux@vger.kernel.org \
    --cc=simona@ffwll.ch \
    --cc=tmgross@umich.edu \
    --cc=ttabi@nvidia.com \
    --cc=tzimmermann@suse.de \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.