Skip to content

Commit

Permalink
PCI: Simplify pci_find_(ext_)capability() return value checks
Browse files Browse the repository at this point in the history
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 <weiyang@linux.vnet.ibm.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
  • Loading branch information
Wei Yang authored and Bjorn Helgaas committed Jul 15, 2015
1 parent fff905f commit 0a1a9b4
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions drivers/pci/pci.c
Original file line number Diff line number Diff line change
Expand Up @@ -971,7 +971,7 @@ static int pci_save_pcix_state(struct pci_dev *dev)
struct pci_cap_saved_state *save_state;

pos = pci_find_capability(dev, PCI_CAP_ID_PCIX);
if (pos <= 0)
if (!pos)
return 0;

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

save_state = pci_find_saved_cap(dev, PCI_CAP_ID_PCIX);
pos = pci_find_capability(dev, PCI_CAP_ID_PCIX);
if (!save_state || pos <= 0)
if (!save_state || !pos)
return;
cap = (u16 *)&save_state->cap.data[0];

Expand Down Expand Up @@ -2158,7 +2158,7 @@ static int _pci_add_cap_save_buffer(struct pci_dev *dev, u16 cap,
else
pos = pci_find_capability(dev, cap);

if (pos <= 0)
if (!pos)
return 0;

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

0 comments on commit 0a1a9b4

Please sign in to comment.