On 11/1/25 7:41 PM, Alexandre Courbot wrote:
On Sun Nov 2, 2025 at 9:34 AM JST, John Hubbard wrote:
On 10/29/25 7:05 AM, Alexandre Courbot wrote:
...

We can always add doccomments in the macro, as in the patch below. These
will be displayed by LSP when one highlights or tries to use one of
these constants.

If you think that's adequate, I will send a patch.

--- a/drivers/gpu/nova-core/bitfield.rs
+++ b/drivers/gpu/nova-core/bitfield.rs
@@ -249,7 +249,10 @@ impl $name {
              { $process:expr } $prim_type:tt $to_type:ty => $res_type:ty $(, 
$comment:literal)?;
      ) => {
          ::kernel::macros::paste!(
+        /// Inclusive range of the bits covered by this field.
          const [<$field:upper _RANGE>]: ::core::ops::RangeInclusive<u8> = 
$lo..=$hi;

Will that let people know that they'll see something like
IMPLEMENTATION_RANGE() for a corresponding .implementation field?

I'm hoping we can somehow create clear and plain documentation for
the various functions that the macro generates.

thanks,
--
John Hubbard

+
+        /// Mask of the bits making up this field.
          const [<$field:upper _MASK>]: $storage = {
              // Generate mask for shifting
              match ::core::mem::size_of::<$storage>() {
@@ -260,6 +263,8 @@ impl $name {
                  _ => ::kernel::build_error!("Unsupported storage type size")
              }
          };
+
+        /// Shift to apply to a value to align it with the start of this field.
          const [<$field:upper _SHIFT>]: u32 = $lo;
          );


Reply via email to