Skip to content

Commit c6d7e13

Browse files
Ben Widawskydjbw
authored andcommitted
ocxl: Use pci core's DVSEC functionality
Reduce maintenance burden of DVSEC query implementation by using the centralized PCI core implementation. There are two obvious places to simply drop in the new core implementation. There remains find_dvsec_from_pos() which would benefit from using a core implementation. As that change is less trivial it is reserved for later. Cc: linuxppc-dev@lists.ozlabs.org Cc: Andrew Donnellan <ajd@linux.ibm.com> Acked-by: Frederic Barrat <fbarrat@linux.ibm.com> (v1) Signed-off-by: Ben Widawsky <ben.widawsky@intel.com> Reviewed-by: Andrew Donnellan <ajd@linux.ibm.com> Link: https://lore.kernel.org/r/163379789065.692348.7117946955275586530.stgit@dwillia2-desk3.amr.corp.intel.com Signed-off-by: Dan Williams <dan.j.williams@intel.com>
1 parent 55006a2 commit c6d7e13

2 files changed

Lines changed: 3 additions & 13 deletions

File tree

arch/powerpc/platforms/powernv/ocxl.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,8 @@ static int get_max_afu_index(struct pci_dev *dev, int *afu_idx)
107107
int pos;
108108
u32 val;
109109

110-
pos = find_dvsec_from_pos(dev, OCXL_DVSEC_FUNC_ID, 0);
110+
pos = pci_find_dvsec_capability(dev, PCI_VENDOR_ID_IBM,
111+
OCXL_DVSEC_FUNC_ID);
111112
if (!pos)
112113
return -ESRCH;
113114

drivers/misc/ocxl/config.c

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -33,18 +33,7 @@
3333

3434
static int find_dvsec(struct pci_dev *dev, int dvsec_id)
3535
{
36-
int vsec = 0;
37-
u16 vendor, id;
38-
39-
while ((vsec = pci_find_next_ext_capability(dev, vsec,
40-
OCXL_EXT_CAP_ID_DVSEC))) {
41-
pci_read_config_word(dev, vsec + OCXL_DVSEC_VENDOR_OFFSET,
42-
&vendor);
43-
pci_read_config_word(dev, vsec + OCXL_DVSEC_ID_OFFSET, &id);
44-
if (vendor == PCI_VENDOR_ID_IBM && id == dvsec_id)
45-
return vsec;
46-
}
47-
return 0;
36+
return pci_find_dvsec_capability(dev, PCI_VENDOR_ID_IBM, dvsec_id);
4837
}
4938

5039
static int find_dvsec_afu_ctrl(struct pci_dev *dev, u8 afu_idx)

0 commit comments

Comments
 (0)