From 0e1cd3d9f82eb5440d32d4c0f12c65403b956cb5 Mon Sep 17 00:00:00 2001 From: Xiongfeng Wang Date: Fri, 4 Aug 2023 15:56:30 +0800 Subject: cxl: Use pci_find_vsec_capability() to simplify the code PCI core add pci_find_vsec_capability() to query VSEC. We can use that core API to simplify the code. The only logical change is that pci_find_vsec_capability check the Vendor ID before finding the VSEC. PCI spec rev 5.0 says in 7.9.5.2 Vendor-Specific Header: VSEC ID - This field is a vendor-defined ID number that indicates the nature and format of the VSEC structure Software must qualify the Vendor ID before interpreting this field. Signed-off-by: Xiongfeng Wang Reviewed-by: Andrew Donnellan Signed-off-by: Michael Ellerman Link: https://msgid.link/20230804075630.186054-1-wangxiongfeng2@huawei.com --- drivers/misc/cxl/pci.c | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) (limited to 'drivers/misc/cxl/pci.c') diff --git a/drivers/misc/cxl/pci.c b/drivers/misc/cxl/pci.c index 0ff944860dda..4cf9e7c42a24 100644 --- a/drivers/misc/cxl/pci.c +++ b/drivers/misc/cxl/pci.c @@ -150,16 +150,7 @@ static inline resource_size_t p2_size(struct pci_dev *dev) static int find_cxl_vsec(struct pci_dev *dev) { - int vsec = 0; - u16 val; - - while ((vsec = pci_find_next_ext_capability(dev, vsec, PCI_EXT_CAP_ID_VNDR))) { - pci_read_config_word(dev, vsec + 0x4, &val); - if (val == CXL_PCI_VSEC_ID) - return vsec; - } - return 0; - + return pci_find_vsec_capability(dev, PCI_VENDOR_ID_IBM, CXL_PCI_VSEC_ID); } static void dump_cxl_config_space(struct pci_dev *dev) -- cgit v1.2.3