Skip to content

Commit 0a1a9b4

Browse files
Wei Yangbjorn-helgaas
authored andcommitted
PCI: Simplify pci_find_(ext_)capability() return value checks
The return value of the pci_find_(ext_)capability() is either zero or the position of a capability. It is never negative. This patch consolidates the form of check from (pos <= 0) to (!pos). Signed-off-by: Wei Yang <[email protected]> Signed-off-by: Bjorn Helgaas <[email protected]>
1 parent fff905f commit 0a1a9b4

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

drivers/pci/pci.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -971,7 +971,7 @@ static int pci_save_pcix_state(struct pci_dev *dev)
971971
struct pci_cap_saved_state *save_state;
972972

973973
pos = pci_find_capability(dev, PCI_CAP_ID_PCIX);
974-
if (pos <= 0)
974+
if (!pos)
975975
return 0;
976976

977977
save_state = pci_find_saved_cap(dev, PCI_CAP_ID_PCIX);
@@ -994,7 +994,7 @@ static void pci_restore_pcix_state(struct pci_dev *dev)
994994

995995
save_state = pci_find_saved_cap(dev, PCI_CAP_ID_PCIX);
996996
pos = pci_find_capability(dev, PCI_CAP_ID_PCIX);
997-
if (!save_state || pos <= 0)
997+
if (!save_state || !pos)
998998
return;
999999
cap = (u16 *)&save_state->cap.data[0];
10001000

@@ -2158,7 +2158,7 @@ static int _pci_add_cap_save_buffer(struct pci_dev *dev, u16 cap,
21582158
else
21592159
pos = pci_find_capability(dev, cap);
21602160

2161-
if (pos <= 0)
2161+
if (!pos)
21622162
return 0;
21632163

21642164
save_state = kzalloc(sizeof(*save_state) + size, GFP_KERNEL);

0 commit comments

Comments
 (0)