Skip to contentSkip to conversation

gpu: nova-core: vbios: Fix clippy error in Vbios::new()

PATCH In review Lyude Paul 2 participants 2 messages May 27 – May 28

Subsystems (4)
lore
Share & tools
lore

Lyude Paul

author
#0 lore raw

PATCH 1/1 gpu: nova-core: vbios: Fix clippy error in Vbios::new()

From clippy:

  error: this `if` can be collapsed into the outer `match`
     --> drivers/gpu/nova-core/vbios.rs:328:21
      |
  328 | /                     if pci_at_image.is_none() {
  329 | |                         pci_at_image = Some(PciAtBiosImage::try_from(image)?);
  330 | |                     }
      | |_____________________^
      |

There should be no functional changes in this patch.

---
 drivers/gpu/nova-core/vbios.rs | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/gpu/nova-core/vbios.rs +2 -4
index c0bc1008ed752..d38d7f138b49d 100644
@@ -323,11 +323,9 @@ pub(crate) fn new(dev: &device::Device, bar0: &Bar0) -> Result<Vbios> {
 
             // Convert to a specific image type
             match BiosImageType::try_from(image.pcir.code_type) {
-                Ok(BiosImageType::PciAt) => {
+                Ok(BiosImageType::PciAt) if pci_at_image.is_none() => {
                     // Silently ignore any extra PCI-AT images.
-                    if pci_at_image.is_none() {
-                        pci_at_image = Some(PciAtBiosImage::try_from(image)?);
-                    }
+                    pci_at_image = Some(PciAtBiosImage::try_from(image)?);
                 }
                 Ok(BiosImageType::FwSec) => fwsec_section = Some(image.data),
                 _ => {

base-commit: 2cf1840b0fa7637b6731fd554529f8d57ea34c04

Signature · 1 line
2.54.0
#1 lore raw

Hi Lyude,

Quoted 26 lines · Lyude Paul

From clippy:

  error: this `if` can be collapsed into the outer `match`
     --> drivers/gpu/nova-core/vbios.rs:328:21
      |
  328 | /                     if pci_at_image.is_none() {
  329 | |                         pci_at_image = Some(PciAtBiosImage::try_from(image)?);
  330 | |                     }
      | |_____________________^
      |

There should be no functional changes in this patch.

---
 drivers/gpu/nova-core/vbios.rs | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/gpu/nova-core/vbios.rs +0 -0
index c0bc1008ed752..d38d7f138b49d 100644
@@ -323,11 +323,9 @@ pub(crate) fn new(dev: &device::Device, bar0: &Bar0) -> Result<Vbios> {
 
             // Convert to a specific image type
             match BiosImageType::try_from(image.pcir.code_type) {

drivers/gpu/nova-core/vbios.rs pub(crate) fn new(dev: &device::Device, bar0: &Bar0) -> Result<Vbios> { · line 331

Quoted 10 lines
drivers/gpu/nova-core/vbios.rs +2 -4
-                Ok(BiosImageType::PciAt) => {
+                Ok(BiosImageType::PciAt) if pci_at_image.is_none() => {
                     // Silently ignore any extra PCI-AT images.
-                    if pci_at_image.is_none() {
-                        pci_at_image = Some(PciAtBiosImage::try_from(image)?);
-                    }
+                    pci_at_image = Some(PciAtBiosImage::try_from(image)?);
                 }
                 Ok(BiosImageType::FwSec) => fwsec_section = Some(image.data),
                 _ => {

This lint should disappear once -rc3 reaches drm-rust-next per [1].

[1] https://lore.kernel.org/all/CANiq72kR0raSG33DgSxMuc-2uMa626dT=-5=ko_HBgmeOrCFZA@mail.gmail.com/