linux-pci.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Wei Yang <weiyang@linux.vnet.ibm.com>
To: linux-pci@vger.kernel.org, bhelgaas@google.com
Cc: Wei Yang <weiyang@linux.vnet.ibm.com>
Subject: [PATCH V2 4/4] PCI: consolidate return value check for pci_find_(ext_)capability
Date: Tue, 30 Jun 2015 09:16:44 +0800	[thread overview]
Message-ID: <1435627004-6029-5-git-send-email-weiyang@linux.vnet.ibm.com> (raw)
In-Reply-To: <1435627004-6029-1-git-send-email-weiyang@linux.vnet.ibm.com>

The return value of the pci_find_(ext_)capability is the position of this
Cap.  After previous two patches clean up, the position returned is an
unsigned value. Only 0 indicates the Cap is not presented.

This patch consolidates the form of check from (pos <= 0)to (!pos).

Signed-off-by: Wei Yang <weiyang@linux.vnet.ibm.com>
---
 drivers/pci/pci.c |    6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
index 4bd3a0c..e1282aa 100644
--- a/drivers/pci/pci.c
+++ b/drivers/pci/pci.c
@@ -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);
@@ -995,7 +995,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];
 
@@ -2159,7 +2159,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);
-- 
1.7.9.5


  parent reply	other threads:[~2015-06-30  1:18 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-06-30  1:16 [PATCH V2 0/4] PCI: code clean up on pci configuration space Wei Yang
2015-06-30  1:16 ` [PATCH V2 1/4] PCI: move PCI_FIND_CAP_TTL to pci.h and use it in quirks Wei Yang
2015-07-14 21:57   ` Bjorn Helgaas
2015-06-30  1:16 ` [PATCH V2 2/4] PCI: use u8 to represent pci configuration space pos and cap Wei Yang
2015-06-30  1:16 ` [PATCH V2 3/4] PCI: use u16 to represent pci express extended capabilities " Wei Yang
2015-06-30  1:16 ` Wei Yang [this message]
2015-07-14 22:00   ` [PATCH V2 4/4] PCI: consolidate return value check for pci_find_(ext_)capability Bjorn Helgaas
2015-07-15  2:02     ` Wei Yang
2015-07-15  2:11       ` Bjorn Helgaas
2015-07-15  5:46         ` Wei Yang
2015-07-14 21:37 ` [PATCH V2 0/4] PCI: code clean up on pci configuration space Bjorn Helgaas
2015-07-15  2:08   ` Wei Yang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1435627004-6029-5-git-send-email-weiyang@linux.vnet.ibm.com \
    --to=weiyang@linux.vnet.ibm.com \
    --cc=bhelgaas@google.com \
    --cc=linux-pci@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).