Skip to contentSkip to conversation

PCI: Change return type of pci_find_capability()

PATCH In review Puranjay Mohan 2 participants 2 messages Nov 17, 2020 – Nov 24, 2020 PCI

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 PCI: Change return type of pci_find_capability()

PCI Capabilities are linked in a list that must appear in the first 256 bytes of config space. The Capabilities Pointer register at 0x34 contains the address of the first Capability in the list. Each Capability contains an 8 bit "Next Capability Pointer" that is set to 0x00 in the last item of the list.

Change the return type of pci_find_capability() from int to u8 to match the specification.

---
 drivers/pci/pci.c   | 4 ++--
 include/linux/pci.h | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)
drivers/pci/pci.c +2 -2
index 6d4d5a2f923d..05ac8a493e6b 100644
@@ -477,9 +477,9 @@ static int __pci_bus_find_cap_start(struct pci_bus *bus,
  *  %PCI_CAP_ID_PCIX         PCI-X
  *  %PCI_CAP_ID_EXP          PCI Express
  */
-int pci_find_capability(struct pci_dev *dev, int cap)
+u8 pci_find_capability(struct pci_dev *dev, int cap)
 {
-	int pos;
+	u8 pos;
 
 	pos = __pci_bus_find_cap_start(dev->bus, dev->devfn, dev->hdr_type);
 	if (pos)
include/linux/pci.h +2 -2
index 22207a79762c..19a817702ea9 100644
@@ -1063,7 +1063,7 @@ void pci_sort_breadthfirst(void);
 
 /* Generic PCI functions exported to card drivers */
 
-int pci_find_capability(struct pci_dev *dev, int cap);
+u8 pci_find_capability(struct pci_dev *dev, int cap);
 int pci_find_next_capability(struct pci_dev *dev, u8 pos, int 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);
@@ -1719,7 +1719,7 @@ static inline int __pci_register_driver(struct pci_driver *drv,
 static inline int pci_register_driver(struct pci_driver *drv)
 { return 0; }
 static inline void pci_unregister_driver(struct pci_driver *drv) { }
-static inline int pci_find_capability(struct pci_dev *dev, int cap)
+static inline u8 pci_find_capability(struct pci_dev *dev, int cap)
 { return 0; }
 static inline int pci_find_next_capability(struct pci_dev *dev, u8 post,
 					   int cap)
Signature · 6 lines
2.27.0

_______________________________________________
Linux-kernel-mentees mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees
#1 lore raw
Quoted 5 lines · Puranjay Mohan

PCI Capabilities are linked in a list that must appear in the first 256 bytes of config space. The Capabilities Pointer register at 0x34 contains the address of the first Capability in the list. Each Capability contains an 8 bit "Next Capability Pointer" that is set to 0x00 in the last item of the list.

Change the return type of pci_find_capability() from int to u8 to match the specification.

Nits: Be more specific in subject, e.g., "Return u8 from
pci_find_capability()". Wrap commit log to fit in 78 columns. Add
blank lines between paragraphs. The 0x34 address is accurate but not relevant to this patch.

Quoted 11 lines
---
 drivers/pci/pci.c   | 4 ++--
 include/linux/pci.h | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)
drivers/pci/pci.c +0 -0
index 6d4d5a2f923d..05ac8a493e6b 100644

drivers/pci/pci.c static int __pci_bus_find_cap_start(struct pci_bus *bus, · line 484

Quoted 10 lines
drivers/pci/pci.c +2 -2
@@ -477,9 +477,9 @@ static int __pci_bus_find_cap_start(struct pci_bus *bus,
  *  %PCI_CAP_ID_PCIX         PCI-X
  *  %PCI_CAP_ID_EXP          PCI Express
  */
-int pci_find_capability(struct pci_dev *dev, int cap)
+u8 pci_find_capability(struct pci_dev *dev, int cap)
 {
-	int pos;
+	u8 pos;
 
 	pos = __pci_bus_find_cap_start(dev->bus, dev->devfn, dev->hdr_type);

Also change the signatures of __pci_bus_find_cap_start(), __pci_find_next_cap(), __pci_find_next_cap_ttl() to match.

Quoted 26 lines
drivers/pci/pci.c +0 -0
 	if (pos)
include/linux/pci.h +2 -2
index 22207a79762c..19a817702ea9 100644
@@ -1063,7 +1063,7 @@ void pci_sort_breadthfirst(void);
 
 /* Generic PCI functions exported to card drivers */
 
-int pci_find_capability(struct pci_dev *dev, int cap);
+u8 pci_find_capability(struct pci_dev *dev, int cap);
 int pci_find_next_capability(struct pci_dev *dev, u8 pos, int 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);
@@ -1719,7 +1719,7 @@ static inline int __pci_register_driver(struct pci_driver *drv,
 static inline int pci_register_driver(struct pci_driver *drv)
 { return 0; }
 static inline void pci_unregister_driver(struct pci_driver *drv) { }
-static inline int pci_find_capability(struct pci_dev *dev, int cap)
+static inline u8 pci_find_capability(struct pci_dev *dev, int cap)
 { return 0; }
 static inline int pci_find_next_capability(struct pci_dev *dev, u8 post,
 					   int cap)
Signature · 1 line
2.27.0

_______________________________________________
Linux-kernel-mentees mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees