[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CANiq72nUiizxo3YFgxUZ1jiczRNbY2ATao2YUBiCEC7k5hbv6Q@mail.gmail.com>
Date: Tue, 21 Oct 2025 17:13:20 +0200
From: Miguel Ojeda <miguel.ojeda.sandonis@...il.com>
To: Danilo Krummrich <dakr@...nel.org>
Cc: FUJITA Tomonori <fujita.tomonori@...il.com>, aliceryhl@...gle.com,
daniel.almeida@...labora.com, a.hindborg@...nel.org, alex.gaynor@...il.com,
ojeda@...nel.org, anna-maria@...utronix.de, bjorn3_gh@...tonmail.com,
boqun.feng@...il.com, frederic@...nel.org, gary@...yguo.net,
jstultz@...gle.com, linux-kernel@...r.kernel.org, lossin@...nel.org,
lyude@...hat.com, rust-for-linux@...r.kernel.org, sboyd@...nel.org,
tglx@...utronix.de, tmgross@...ch.edu,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>
Subject: Re: [PATCH v2 1/2] rust: add udelay() function
On Tue, Oct 21, 2025 at 5:09 PM Danilo Krummrich <dakr@...nel.org> wrote:
>
> I'm not even sure we want that necessarily. I'd probably go for just documenting
> that the value will be clamped to 0 <= value <= MAX_UDELAY_MS plus an internal
> pr_debug!().
>
> This way the function can also explicitly used in cases where the driver isn't
> sure whether the value is in range and use it without duplicating the clamp
> logic that the function already does internally anyways.
That would mean we cannot catch bugs in the common case where I would
expect callers to know what the delay range is.
i.e. if they aren't sure what the value is, then I would prefer they
clamp it explicitly on the callee side (or we provide an explicitly
clamped version if it is a common case, but it seems to me runtime
values are already the minority).
i.e. EB is useful because it allows us to catch bugs. If we remove the
EB, then it means things are more ambiguous and thus bugs cannot be
easily be caught anymore because one can actually rely on the
behavior.
Cheers,
Miguel
Powered by blists - more mailing lists