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 3/3] PCI: use u16 instead of int for pci express extended capabilities pos and cap
Date: Tue, 14 Oct 2014 14:47:32 +0800 [thread overview]
Message-ID: <1413269253-8990-4-git-send-email-weiyang@linux.vnet.ibm.com> (raw)
In-Reply-To: <1413269253-8990-1-git-send-email-weiyang@linux.vnet.ibm.com>
For pci express devices, it could have extended capabilities. The position of
extened capabilities is 12bit and the cap is 16bit.
This patch does a clean up for pci express extended capabilities by replacing
type int with u16.
Signed-off-by: Wei Yang <weiyang@linux.vnet.ibm.com>
---
drivers/pci/iov.c | 2 +-
drivers/pci/pci.c | 12 ++++++------
drivers/pci/probe.c | 2 +-
include/linux/pci.h | 6 +++---
4 files changed, 11 insertions(+), 11 deletions(-)
diff --git a/drivers/pci/iov.c b/drivers/pci/iov.c
index cb6f247..fffab81 100644
--- a/drivers/pci/iov.c
+++ b/drivers/pci/iov.c
@@ -453,7 +453,7 @@ static void sriov_restore_state(struct pci_dev *dev)
*/
int pci_iov_init(struct pci_dev *dev)
{
- int pos;
+ u16 pos;
if (!pci_is_pcie(dev))
return -ENODEV;
diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
index 47d8d0c..023af40 100644
--- a/drivers/pci/pci.c
+++ b/drivers/pci/pci.c
@@ -266,11 +266,11 @@ EXPORT_SYMBOL(pci_bus_find_capability);
* not support it. Some capabilities can occur several times, e.g., the
* vendor-specific capability, and this provides a way to find them all.
*/
-int pci_find_next_ext_capability(struct pci_dev *dev, int start, int cap)
+u16 pci_find_next_ext_capability(struct pci_dev *dev, int start, u16 cap)
{
u32 header;
int ttl;
- int pos = PCI_CFG_SPACE_SIZE;
+ u16 pos = PCI_CFG_SPACE_SIZE;
/* minimum 8 bytes per capability */
ttl = (PCI_CFG_SPACE_EXP_SIZE - PCI_CFG_SPACE_SIZE) / 8;
@@ -321,7 +321,7 @@ EXPORT_SYMBOL_GPL(pci_find_next_ext_capability);
* %PCI_EXT_CAP_ID_DSN Device Serial Number
* %PCI_EXT_CAP_ID_PWR Power Budgeting
*/
-int pci_find_ext_capability(struct pci_dev *dev, int cap)
+u16 pci_find_ext_capability(struct pci_dev *dev, u16 cap)
{
return pci_find_next_ext_capability(dev, 0, cap);
}
@@ -2119,7 +2119,7 @@ static void pci_add_saved_cap(struct pci_dev *pci_dev,
static int _pci_add_cap_save_buffer(struct pci_dev *dev, u16 cap,
bool extended, unsigned int size)
{
- int pos;
+ u16 pos;
struct pci_cap_saved_state *save_state;
if (extended)
@@ -2233,7 +2233,7 @@ void pci_request_acs(void)
*/
static int pci_std_enable_acs(struct pci_dev *dev)
{
- int pos;
+ u16 pos;
u16 cap;
u16 ctrl;
@@ -2278,7 +2278,7 @@ void pci_enable_acs(struct pci_dev *dev)
static bool pci_acs_flags_enabled(struct pci_dev *pdev, u16 acs_flags)
{
- int pos;
+ u16 pos;
u16 cap, ctrl;
pos = pci_find_ext_capability(pdev, PCI_EXT_CAP_ID_ACS);
diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
index 9b316bf..86147ba 100644
--- a/drivers/pci/probe.c
+++ b/drivers/pci/probe.c
@@ -1425,7 +1425,7 @@ EXPORT_SYMBOL(pci_scan_single_device);
static unsigned next_fn(struct pci_bus *bus, struct pci_dev *dev, unsigned fn)
{
- int pos;
+ u16 pos;
u16 cap = 0;
unsigned next_fn;
diff --git a/include/linux/pci.h b/include/linux/pci.h
index 399a18a..b9a4f40 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -820,8 +820,8 @@ enum pci_lost_interrupt_reason {
enum pci_lost_interrupt_reason pci_lost_interrupt(struct pci_dev *dev);
u8 pci_find_capability(struct pci_dev *dev, u8 cap);
u8 pci_find_next_capability(struct pci_dev *dev, u8 pos, u8 cap);
-int pci_find_ext_capability(struct pci_dev *dev, int cap);
-int pci_find_next_ext_capability(struct pci_dev *dev, int pos, int cap);
+u16 pci_find_ext_capability(struct pci_dev *dev, u16 cap);
+u16 pci_find_next_ext_capability(struct pci_dev *dev, int pos, u16 cap);
u8 pci_find_ht_capability(struct pci_dev *dev, int ht_cap);
u8 pci_find_next_ht_capability(struct pci_dev *dev, u8 pos, int ht_cap);
struct pci_bus *pci_find_next_bus(const struct pci_bus *from);
@@ -1365,7 +1365,7 @@ static inline u8 pci_find_capability(struct pci_dev *dev, u8 cap)
static inline u8 pci_find_next_capability(struct pci_dev *dev, u8 post,
u8 cap)
{ return 0; }
-static inline int pci_find_ext_capability(struct pci_dev *dev, int cap)
+static inline u16 pci_find_ext_capability(struct pci_dev *dev, u16 cap)
{ return 0; }
/* Power management related routines */
--
1.7.9.5
prev parent reply other threads:[~2014-10-14 6:49 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-10-14 6:47 [PATCH 0/3] PCI: code clean up on pci configuration space Wei Yang
2014-10-14 6:47 ` [PATCH 1/3] PCI: move PCI_FIND_CAP_TTL to pci.h and use it in quirks Wei Yang
2014-10-22 23:18 ` Bjorn Helgaas
2014-10-24 3:44 ` Wei Yang
2014-11-06 3:12 ` Wei Yang
2014-11-18 9:16 ` Wei Yang
2014-10-14 6:47 ` [PATCH 2/3] PCI: use u8 instead of int for pci configuration space pos and cap Wei Yang
2014-10-22 23:23 ` Bjorn Helgaas
2014-10-24 3:49 ` Wei Yang
2014-10-14 6:47 ` Wei Yang [this message]
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=1413269253-8990-4-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).