]> Git Repo - J-linux.git/commitdiff
ocxl: Use pci core's DVSEC functionality
authorBen Widawsky <[email protected]>
Sat, 9 Oct 2021 16:44:50 +0000 (09:44 -0700)
committerDan Williams <[email protected]>
Fri, 29 Oct 2021 18:53:52 +0000 (11:53 -0700)
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: [email protected]
Cc: Andrew Donnellan <[email protected]>
Acked-by: Frederic Barrat <[email protected]> (v1)
Signed-off-by: Ben Widawsky <[email protected]>
Reviewed-by: Andrew Donnellan <[email protected]>
Link: https://lore.kernel.org/r/163379789065.692348.7117946955275586530.stgit@dwillia2-desk3.amr.corp.intel.com
Signed-off-by: Dan Williams <[email protected]>
arch/powerpc/platforms/powernv/ocxl.c
drivers/misc/ocxl/config.c

index 9105efcf242a90407a91d8fd3d017d0a946d36b7..28b009b46464a8d797f7b42dee8cbb1c9428d49c 100644 (file)
@@ -107,7 +107,8 @@ static int get_max_afu_index(struct pci_dev *dev, int *afu_idx)
        int pos;
        u32 val;
 
-       pos = find_dvsec_from_pos(dev, OCXL_DVSEC_FUNC_ID, 0);
+       pos = pci_find_dvsec_capability(dev, PCI_VENDOR_ID_IBM,
+                                       OCXL_DVSEC_FUNC_ID);
        if (!pos)
                return -ESRCH;
 
index a68738f382521bce16aa79ad1b0653f97e6023fc..e401a51596b9c6f1419f0c5f14d8951e18baa05f 100644 (file)
 
 static int find_dvsec(struct pci_dev *dev, int dvsec_id)
 {
-       int vsec = 0;
-       u16 vendor, id;
-
-       while ((vsec = pci_find_next_ext_capability(dev, vsec,
-                                                   OCXL_EXT_CAP_ID_DVSEC))) {
-               pci_read_config_word(dev, vsec + OCXL_DVSEC_VENDOR_OFFSET,
-                               &vendor);
-               pci_read_config_word(dev, vsec + OCXL_DVSEC_ID_OFFSET, &id);
-               if (vendor == PCI_VENDOR_ID_IBM && id == dvsec_id)
-                       return vsec;
-       }
-       return 0;
+       return pci_find_dvsec_capability(dev, PCI_VENDOR_ID_IBM, dvsec_id);
 }
 
 static int find_dvsec_afu_ctrl(struct pci_dev *dev, u8 afu_idx)
This page took 0.057456 seconds and 4 git commands to generate.