public inbox for rust-for-linux@vger.kernel.org
 help / color / mirror / Atom feed
From: "Uwe Kleine-König" <u.kleine-koenig@baylibre.com>
To: Miguel Ojeda <ojeda@kernel.org>,
	 Michal Wilczynski <m.wilczynski@samsung.com>
Cc: "Drew Fustini" <fustini@kernel.org>,
	"Guo Ren" <guoren@kernel.org>, "Fu Wei" <wefu@redhat.com>,
	linux-riscv@lists.infradead.org,
	"Boqun Feng" <boqun.feng@gmail.com>,
	"Gary Guo" <gary@garyguo.net>,
	"Björn Roy Baron" <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>,
	"Danilo Krummrich" <dakr@kernel.org>,
	rust-for-linux@vger.kernel.org, "Mark Brown" <broonie@kernel.org>,
	linux-pwm@vger.kernel.org
Subject: Re: [PATCH] pwm: th1520: fix `CLIPPY=1` warning
Date: Mon, 9 Feb 2026 09:56:22 +0100	[thread overview]
Message-ID: <aYmgjEWaLrdsubKM@monoceros> (raw)
In-Reply-To: <20260121183719.71659-1-ojeda@kernel.org>

[-- Attachment #1: Type: text/plain, Size: 2032 bytes --]

Hello Miguel,

On Wed, Jan 21, 2026 at 07:37:19PM +0100, Miguel Ojeda wrote:
> The Rust kernel code should be kept `CLIPPY=1`-clean [1].
> 
> Clippy reports:
> 
>     error: this pattern reimplements `Option::unwrap_or`
>       --> drivers/pwm/pwm_th1520.rs:64:5
>        |
>     64 | /     (match ns.checked_mul(rate_hz) {
>     65 | |         Some(product) => product,
>     66 | |         None => u64::MAX,
>     67 | |     }) / NSEC_PER_SEC_U64
>        | |______^ help: replace with: `ns.checked_mul(rate_hz).unwrap_or(u64::MAX)`
>        |
>        = help: for further information visit https://rust-lang.github.io/rust-clippy/rust-1.92.0/index.html#manual_unwrap_or
>        = note: `-D clippy::manual-unwrap-or` implied by `-D warnings`
>        = help: to override `-D warnings` add `#[allow(clippy::manual_unwrap_or)]`
> 
> Applying the suggestion then triggers:
> 
>     error: manual saturating arithmetic
>       --> drivers/pwm/pwm_th1520.rs:64:5
>        |
>     64 |     ns.checked_mul(rate_hz).unwrap_or(u64::MAX) / NSEC_PER_SEC_U64
>        |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `saturating_mul`: `ns.saturating_mul(rate_hz)`
>        |
>        = help: for further information visit https://rust-lang.github.io/rust-clippy/rust-1.92.0/index.html#manual_saturating_arithmetic
>        = note: `-D clippy::manual-saturating-arithmetic` implied by `-D warnings`
>        = help: to override `-D warnings` add `#[allow(clippy::manual_saturating_arithmetic)]`
> 
> Thus fix it by using saturating arithmatic, which simplifies the code
> as well.
> 
> Link: https://rust-for-linux.com/contributing#submit-checklist-addendum [1]
> Fixes: e03724aac758 ("pwm: Add Rust driver for T-HEAD TH1520 SoC")
> Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
> ---

Looks good to me. I'll wait for Michal to add his blessing and then when
picking it up tend to drop the Fixes line. Or do we also care about
CLIPPY-cleanness in stable?

Best regards
Uwe

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

  parent reply	other threads:[~2026-02-09  8:56 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-01-21 18:37 [PATCH] pwm: th1520: fix `CLIPPY=1` warning Miguel Ojeda
2026-01-25 16:24 ` Danilo Krummrich
2026-02-08 11:13 ` Miguel Ojeda
2026-02-09  8:56 ` Uwe Kleine-König [this message]
2026-02-09  8:58   ` Alice Ryhl
2026-02-09  9:24   ` Michal Wilczynski
2026-02-09 13:02   ` Miguel Ojeda
2026-03-28 13:53   ` Miguel Ojeda
2026-03-29  7:36     ` Uwe Kleine-König
2026-03-29 12:01       ` Miguel Ojeda
2026-03-18  8:41 ` Benno Lossin

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=aYmgjEWaLrdsubKM@monoceros \
    --to=u.kleine-koenig@baylibre.com \
    --cc=a.hindborg@kernel.org \
    --cc=aliceryhl@google.com \
    --cc=bjorn3_gh@protonmail.com \
    --cc=boqun.feng@gmail.com \
    --cc=broonie@kernel.org \
    --cc=dakr@kernel.org \
    --cc=fustini@kernel.org \
    --cc=gary@garyguo.net \
    --cc=guoren@kernel.org \
    --cc=linux-pwm@vger.kernel.org \
    --cc=linux-riscv@lists.infradead.org \
    --cc=lossin@kernel.org \
    --cc=m.wilczynski@samsung.com \
    --cc=ojeda@kernel.org \
    --cc=rust-for-linux@vger.kernel.org \
    --cc=tmgross@umich.edu \
    --cc=wefu@redhat.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