Skip to content

Commit 294c1e4

Browse files
committed
PCI: Simplify pcie_capability_clear_and_set_word() control flow
Return early for errors in pcie_capability_clear_and_set_word_unlocked() and pcie_capability_clear_and_set_dword() to simplify the control flow. No functional change intended. Link: https://lore.kernel.org/r/20230824193712.542167-13-helgaas@kernel.org Signed-off-by: Bjorn Helgaas <bhelgaas@google.com> Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
1 parent da54556 commit 294c1e4

File tree

1 file changed

+10
-12
lines changed

1 file changed

+10
-12
lines changed

drivers/pci/access.c

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -504,13 +504,12 @@ int pcie_capability_clear_and_set_word_unlocked(struct pci_dev *dev, int pos,
504504
u16 val;
505505

506506
ret = pcie_capability_read_word(dev, pos, &val);
507-
if (!ret) {
508-
val &= ~clear;
509-
val |= set;
510-
ret = pcie_capability_write_word(dev, pos, val);
511-
}
507+
if (ret)
508+
return ret;
512509

513-
return ret;
510+
val &= ~clear;
511+
val |= set;
512+
return pcie_capability_write_word(dev, pos, val);
514513
}
515514
EXPORT_SYMBOL(pcie_capability_clear_and_set_word_unlocked);
516515

@@ -535,13 +534,12 @@ int pcie_capability_clear_and_set_dword(struct pci_dev *dev, int pos,
535534
u32 val;
536535

537536
ret = pcie_capability_read_dword(dev, pos, &val);
538-
if (!ret) {
539-
val &= ~clear;
540-
val |= set;
541-
ret = pcie_capability_write_dword(dev, pos, val);
542-
}
537+
if (ret)
538+
return ret;
543539

544-
return ret;
540+
val &= ~clear;
541+
val |= set;
542+
return pcie_capability_write_dword(dev, pos, val);
545543
}
546544
EXPORT_SYMBOL(pcie_capability_clear_and_set_dword);
547545

0 commit comments

Comments
 (0)