The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: "Gary Guo" <gary@garyguo.net>
To: "Alexandre Courbot" <acourbot@nvidia.com>,
	"Danilo Krummrich" <dakr@kernel.org>,
	"Alice Ryhl" <aliceryhl@google.com>,
	"Daniel Almeida" <daniel.almeida@collabora.com>,
	"David Airlie" <airlied@gmail.com>,
	"Simona Vetter" <simona@ffwll.ch>,
	"Yury Norov" <yury.norov@gmail.com>,
	"Miguel Ojeda" <ojeda@kernel.org>,
	"Boqun Feng" <boqun@kernel.org>, "Gary Guo" <gary@garyguo.net>,
	"Björn Roy Baron" <bjorn3_gh@protonmail.com>,
	"Benno Lossin" <lossin@kernel.org>,
	"Andreas Hindborg" <a.hindborg@kernel.org>,
	"Trevor Gross" <tmgross@umich.edu>,
	"Tamir Duberstein" <tamird@kernel.org>,
	"Onur Özkan" <work@onurozkan.dev>
Cc: <rust-for-linux@vger.kernel.org>, <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] rust: bitfield: add conversions to Bounded of matching width
Date: Fri, 27 Nov 2026 20:05:04 +0000	[thread overview]
Message-ID: <DN69HD9F475C.2WM5C5Z573NO2@garyguo.net> (raw)
In-Reply-To: <20261127-bitfield-conversions-v1-1-2f0b127c0857@nvidia.com>

On Fri Nov 27, 2026 at 12:05 PM GMT, Alexandre Courbot wrote:
> `From`/`Into` implementations already exist between a bitfield type and
> its storage type, but these are not enough to support nested bitfields,
> since every field is a `Bounded`. This resulted in some ad-hoc
> implementations to enable this kind of declaration:
> 
>     bitfield! {
>         pub struct Version(u8) {
>             7:4 major;
>             3:0 minor;
>         }
>     }
> 
>     bitfield! {
>         pub struct Id(u16) {
>             15:8 vendor;
>             7:0 version => Version;
>         }
>     }
> 
> Generate these conversions automatically through the `bitfield!` macro,
> as these tend to be useful.
> 
> Tyr had such ad-hoc implementations, so remove them to avoid conflicts.
> 
> Signed-off-by: Alexandre Courbot <acourbot@nvidia.com>

Reviewed-by: Gary Guo <gary@garyguo.net>

> ---
>  drivers/gpu/drm/tyr/regs.rs | 30 +++++------------
>  rust/kernel/bitfield.rs     | 82 ++++++++++++++++++++++++++++++++++++++++++++-
>  2 files changed, 89 insertions(+), 23 deletions(-)


  parent reply	other threads:[~2026-11-27 20:05 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-27 12:05 [PATCH] rust: bitfield: add conversions to Bounded of matching width Alexandre Courbot
2026-11-27 17:15 ` Alice Ryhl
2026-11-27 20:05 ` Gary Guo [this message]
2026-11-27 20:36 ` Yury Norov

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=DN69HD9F475C.2WM5C5Z573NO2@garyguo.net \
    --to=gary@garyguo.net \
    --cc=a.hindborg@kernel.org \
    --cc=acourbot@nvidia.com \
    --cc=airlied@gmail.com \
    --cc=aliceryhl@google.com \
    --cc=bjorn3_gh@protonmail.com \
    --cc=boqun@kernel.org \
    --cc=dakr@kernel.org \
    --cc=daniel.almeida@collabora.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lossin@kernel.org \
    --cc=ojeda@kernel.org \
    --cc=rust-for-linux@vger.kernel.org \
    --cc=simona@ffwll.ch \
    --cc=tamird@kernel.org \
    --cc=tmgross@umich.edu \
    --cc=work@onurozkan.dev \
    --cc=yury.norov@gmail.com \
    /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