[PATCH V2 3/4] PCI: use u16 to represent pci express extended capabilities pos and cap

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



For pci express devices, it could have extended capabilities. The position
of extended 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@xxxxxxxxxxxxxxxxxx>
---
 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 ee0ebff..db85fbe 100644
--- a/drivers/pci/iov.c
+++ b/drivers/pci/iov.c
@@ -529,7 +529,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 3f7770a..4bd3a0c 100644
--- a/drivers/pci/pci.c
+++ b/drivers/pci/pci.c
@@ -272,11 +272,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;
@@ -327,7 +327,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);
 }
@@ -2151,7 +2151,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)
@@ -2265,7 +2265,7 @@ void pci_request_acs(void)
  */
 static int pci_std_enable_acs(struct pci_dev *dev)
 {
-	int pos;
+	u16 pos;
 	u16 cap;
 	u16 ctrl;
 
@@ -2310,7 +2310,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 ea253fa..092cf93 100644
--- a/drivers/pci/probe.c
+++ b/drivers/pci/probe.c
@@ -1577,7 +1577,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 b36de1f..223f253 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -827,8 +827,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);
@@ -1409,7 +1409,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

--
To unsubscribe from this list: send the line "unsubscribe linux-pci" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [DMA Engine]     [Linux Coverity]     [Linux USB]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Greybus]

  Powered by Linux