public inbox for rust-for-linux@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] gpu: nova-core: simplify and_then with condition to filter
@ 2026-04-23  7:11 Eliot Courtney
  2026-04-23 15:04 ` Gary Guo
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Eliot Courtney @ 2026-04-23  7:11 UTC (permalink / raw)
  To: Danilo Krummrich, Alexandre Courbot, Alice Ryhl, David Airlie,
	Simona Vetter
  Cc: John Hubbard, Alistair Popple, Joel Fernandes, Timur Tabi,
	rust-for-linux, dri-devel, linux-kernel, Eliot Courtney

This code is more simply expressed using Option::filter instead of the
and_then with conditional.

Signed-off-by: Eliot Courtney <ecourtney@nvidia.com>
---
 drivers/gpu/nova-core/firmware.rs | 8 +-------
 1 file changed, 1 insertion(+), 7 deletions(-)

diff --git a/drivers/gpu/nova-core/firmware.rs b/drivers/gpu/nova-core/firmware.rs
index 6c2ab69cb605..3aac073efee2 100644
--- a/drivers/gpu/nova-core/firmware.rs
+++ b/drivers/gpu/nova-core/firmware.rs
@@ -388,13 +388,7 @@ fn new(fw: &'a firmware::Firmware) -> Result<Self> {
             // Extract header.
             .and_then(BinHdr::from_bytes_copy)
             // Validate header.
-            .and_then(|hdr| {
-                if hdr.bin_magic == BIN_MAGIC {
-                    Some(hdr)
-                } else {
-                    None
-                }
-            })
+            .filter(|hdr| hdr.bin_magic == BIN_MAGIC)
             .map(|hdr| Self { hdr, fw })
             .ok_or(EINVAL)
     }

---
base-commit: a7a080bb4236ebe577b6776d940d1717912ff6dd
change-id: 20260423-fix-filter-9a96711b734c

Best regards,
--  
Eliot Courtney <ecourtney@nvidia.com>


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] gpu: nova-core: simplify and_then with condition to filter
  2026-04-23  7:11 [PATCH] gpu: nova-core: simplify and_then with condition to filter Eliot Courtney
@ 2026-04-23 15:04 ` Gary Guo
  2026-04-27 15:16 ` Alice Ryhl
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Gary Guo @ 2026-04-23 15:04 UTC (permalink / raw)
  To: Eliot Courtney, Danilo Krummrich, Alexandre Courbot, Alice Ryhl,
	David Airlie, Simona Vetter
  Cc: John Hubbard, Alistair Popple, Joel Fernandes, Timur Tabi,
	rust-for-linux, dri-devel, linux-kernel

On Thu Apr 23, 2026 at 8:11 AM BST, Eliot Courtney wrote:
> This code is more simply expressed using Option::filter instead of the
> and_then with conditional.
> 
> Signed-off-by: Eliot Courtney <ecourtney@nvidia.com>

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

> ---
>  drivers/gpu/nova-core/firmware.rs | 8 +-------
>  1 file changed, 1 insertion(+), 7 deletions(-)


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] gpu: nova-core: simplify and_then with condition to filter
  2026-04-23  7:11 [PATCH] gpu: nova-core: simplify and_then with condition to filter Eliot Courtney
  2026-04-23 15:04 ` Gary Guo
@ 2026-04-27 15:16 ` Alice Ryhl
  2026-04-27 18:23 ` Danilo Krummrich
  2026-04-27 18:46 ` Alice Ryhl
  3 siblings, 0 replies; 5+ messages in thread
From: Alice Ryhl @ 2026-04-27 15:16 UTC (permalink / raw)
  To: Eliot Courtney
  Cc: Danilo Krummrich, Alexandre Courbot, David Airlie, Simona Vetter,
	John Hubbard, Alistair Popple, Joel Fernandes, Timur Tabi,
	rust-for-linux, dri-devel, linux-kernel

On Thu, Apr 23, 2026 at 9:11 AM Eliot Courtney <ecourtney@nvidia.com> wrote:
>
> This code is more simply expressed using Option::filter instead of the
> and_then with conditional.
>
> Signed-off-by: Eliot Courtney <ecourtney@nvidia.com>

Reviewed-by: Alice Ryhl <aliceryhl@google.com>

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] gpu: nova-core: simplify and_then with condition to filter
  2026-04-23  7:11 [PATCH] gpu: nova-core: simplify and_then with condition to filter Eliot Courtney
  2026-04-23 15:04 ` Gary Guo
  2026-04-27 15:16 ` Alice Ryhl
@ 2026-04-27 18:23 ` Danilo Krummrich
  2026-04-27 18:46 ` Alice Ryhl
  3 siblings, 0 replies; 5+ messages in thread
From: Danilo Krummrich @ 2026-04-27 18:23 UTC (permalink / raw)
  To: Eliot Courtney
  Cc: Alexandre Courbot, Alice Ryhl, David Airlie, Simona Vetter,
	John Hubbard, Alistair Popple, Joel Fernandes, Timur Tabi,
	rust-for-linux, dri-devel, linux-kernel

On 4/23/26 9:11 AM, Eliot Courtney wrote:
> This code is more simply expressed using Option::filter instead of the
> and_then with conditional.
> 
> Signed-off-by: Eliot Courtney <ecourtney@nvidia.com>
Acked-by: Danilo Krummrich <dakr@kernel.org>

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] gpu: nova-core: simplify and_then with condition to filter
  2026-04-23  7:11 [PATCH] gpu: nova-core: simplify and_then with condition to filter Eliot Courtney
                   ` (2 preceding siblings ...)
  2026-04-27 18:23 ` Danilo Krummrich
@ 2026-04-27 18:46 ` Alice Ryhl
  3 siblings, 0 replies; 5+ messages in thread
From: Alice Ryhl @ 2026-04-27 18:46 UTC (permalink / raw)
  To: Eliot Courtney
  Cc: Danilo Krummrich, Alexandre Courbot, David Airlie, Simona Vetter,
	John Hubbard, Alistair Popple, Joel Fernandes, Timur Tabi,
	rust-for-linux, dri-devel, linux-kernel

On Thu, Apr 23, 2026 at 04:11:44PM +0900, Eliot Courtney wrote:
> This code is more simply expressed using Option::filter instead of the
> and_then with conditional.
> 
> Signed-off-by: Eliot Courtney <ecourtney@nvidia.com>

Applied to drm-rust, thanks!

I modified the commit message to quote the clippy warning fixed by this
commit and added Fixes:/Cc: stable tags.

Alice

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2026-04-27 18:46 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-23  7:11 [PATCH] gpu: nova-core: simplify and_then with condition to filter Eliot Courtney
2026-04-23 15:04 ` Gary Guo
2026-04-27 15:16 ` Alice Ryhl
2026-04-27 18:23 ` Danilo Krummrich
2026-04-27 18:46 ` Alice Ryhl

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox