mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Timur Tabi <ttabi@nvidia.com>
To: "dakr@kernel.org" <dakr@kernel.org>, John Hubbard <jhubbard@nvidia.com>
Cc: Alexandre Courbot <acourbot@nvidia.com>,
	"lossin@kernel.org" <lossin@kernel.org>,
	"a.hindborg@kernel.org" <a.hindborg@kernel.org>,
	"boqun.feng@gmail.com" <boqun.feng@gmail.com>,
	"aliceryhl@google.com" <aliceryhl@google.com>,
	Zhi Wang <zhiw@nvidia.com>, "simona@ffwll.ch" <simona@ffwll.ch>,
	"alex.gaynor@gmail.com" <alex.gaynor@gmail.com>,
	"ojeda@kernel.org" <ojeda@kernel.org>,
	"tmgross@umich.edu" <tmgross@umich.edu>,
	"nouveau@lists.freedesktop.org" <nouveau@lists.freedesktop.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"rust-for-linux@vger.kernel.org" <rust-for-linux@vger.kernel.org>,
	"bjorn3_gh@protonmail.com" <bjorn3_gh@protonmail.com>,
	Edwin Peer <epeer@nvidia.com>,
	"airlied@gmail.com" <airlied@gmail.com>,
	Joel Fernandes <joelagnelf@nvidia.com>,
	"bhelgaas@google.com" <bhelgaas@google.com>,
	"gary@garyguo.net" <gary@garyguo.net>,
	Alistair Popple <apopple@nvidia.com>
Subject: Re: [PATCH] gpu: nova-core: bitfield: use &mut self setters instead of builder pattern
Date: Wed, 31 Dec 2025 22:33:41 +0000	[thread overview]
Message-ID: <9db27bd6015ccebaa20e51450d8c42eb2864cb2e.camel@nvidia.com> (raw)
In-Reply-To: <20251231214727.448776-1-jhubbard@nvidia.com>

On Wed, 2025-12-31 at 13:47 -0800, John Hubbard wrote:
> The builder-pattern setters (self -> Self) enabled method chaining like:
> 
>     reg.set_foo(x).set_sec(y).write(bar);
> 
> This made separate operations appear as a single expression, obscuring
> that each setter is a distinct mutation. 

So you're concerned about the fact that the compiler is not merging the set_foo(x) and the
set_sec(y) into a single read-modify-write?

> These setters are infallible,
> so the chaining provides no error-propagation benefit—it just obscures
> what are simple, independent assignments.
> 
> Change the bitfield!() macro to generate `&mut self` setters, so each
> operation is a distinct statement:
> 
>     reg.set_foo(x);
>     reg.set_sec(y);
>     reg.write(bar);

Are you sure about this?  It just seems like you're throwing out a neat little feature of Rust and
replacing it with something that's very C-like.  This breaks compatible with all users of the regs
macros.  Seems really disruptive for what seems to me like a cosmetic change.


  reply	other threads:[~2025-12-31 22:33 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-12-31 21:47 John Hubbard
2025-12-31 22:33 ` Timur Tabi [this message]
2025-12-31 22:47   ` John Hubbard
2026-01-01  0:15     ` Joel Fernandes
2026-01-01  0:46       ` John Hubbard
2026-01-01  2:42         ` Joel Fernandes
2026-01-01  2:52           ` John Hubbard
2026-01-01  4:05             ` Joel Fernandes
2026-01-01  4:28               ` Gary Guo
2026-01-01 10:01                 ` Joel Fernandes
2026-01-01  8:42 ` kernel test robot

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=9db27bd6015ccebaa20e51450d8c42eb2864cb2e.camel@nvidia.com \
    --to=ttabi@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=bhelgaas@google.com \
    --cc=bjorn3_gh@protonmail.com \
    --cc=boqun.feng@gmail.com \
    --cc=dakr@kernel.org \
    --cc=epeer@nvidia.com \
    --cc=gary@garyguo.net \
    --cc=jhubbard@nvidia.com \
    --cc=joelagnelf@nvidia.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lossin@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=zhiw@nvidia.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

all inboxes | Powered by JetHome®