[PATCH] gpu: nova-core: simplify and_then with condition to filter

Eliot Courtney posted 1 patch 1 month, 3 weeks ago
drivers/gpu/nova-core/firmware.rs | 8 +-------
1 file changed, 1 insertion(+), 7 deletions(-)
[PATCH] gpu: nova-core: simplify and_then with condition to filter
Posted by Eliot Courtney 1 month, 3 weeks ago
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>
Re: [PATCH] gpu: nova-core: simplify and_then with condition to filter
Posted by Alice Ryhl 1 month, 2 weeks ago
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
Re: [PATCH] gpu: nova-core: simplify and_then with condition to filter
Posted by Danilo Krummrich 1 month, 2 weeks ago
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>
Re: [PATCH] gpu: nova-core: simplify and_then with condition to filter
Posted by Alice Ryhl 1 month, 2 weeks ago
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>
Re: [PATCH] gpu: nova-core: simplify and_then with condition to filter
Posted by Gary Guo 1 month, 3 weeks ago
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(-)