Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

fpga: altera-cvp: Use pci_find_vsec_capability() when probing FPGA device

Currently altera_cvp_probe() open-codes pci_find_vsec_capability().
Refactor the former to use the latter.

With that done:
- use the VSEC ID as per datasheet [1]
- update the error message accordingly

Link: https://www.intel.com/content/www/us/en/docs/programmable/683763/23-1/vendor-specific-header-register.html [1]
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://lore.kernel.org/r/20251109201729.3220460-1-andriy.shevchenko@linux.intel.com
Reviewed-by: Xu Yilun <yilun.xu@intel.com>
Signed-off-by: Xu Yilun <yilun.xu@linux.intel.com>

authored by

Andy Shevchenko and committed by
Xu Yilun
c9243d6d 2cf07ffe

+5 -15
+5 -15
drivers/fpga/altera-cvp.c
··· 22 22 #define TIMEOUT_US 2000 /* CVP STATUS timeout for USERMODE polling */ 23 23 24 24 /* Vendor Specific Extended Capability Registers */ 25 - #define VSE_PCIE_EXT_CAP_ID 0x0 26 - #define VSE_PCIE_EXT_CAP_ID_VAL 0x000b /* 16bit */ 27 - 28 25 #define VSE_CVP_STATUS 0x1c /* 32bit */ 29 26 #define VSE_CVP_STATUS_CFG_RDY BIT(18) /* CVP_CONFIG_READY */ 30 27 #define VSE_CVP_STATUS_CFG_ERR BIT(19) /* CVP_CONFIG_ERROR */ ··· 574 577 { 575 578 struct altera_cvp_conf *conf; 576 579 struct fpga_manager *mgr; 577 - int ret, offset; 578 - u16 cmd, val; 580 + u16 cmd, offset; 579 581 u32 regval; 580 - 581 - /* Discover the Vendor Specific Offset for this device */ 582 - offset = pci_find_next_ext_capability(pdev, 0, PCI_EXT_CAP_ID_VNDR); 583 - if (!offset) { 584 - dev_err(&pdev->dev, "No Vendor Specific Offset.\n"); 585 - return -ENODEV; 586 - } 582 + int ret; 587 583 588 584 /* 589 585 * First check if this is the expected FPGA device. PCI config 590 586 * space access works without enabling the PCI device, memory 591 587 * space access is enabled further down. 592 588 */ 593 - pci_read_config_word(pdev, offset + VSE_PCIE_EXT_CAP_ID, &val); 594 - if (val != VSE_PCIE_EXT_CAP_ID_VAL) { 595 - dev_err(&pdev->dev, "Wrong EXT_CAP_ID value 0x%x\n", val); 589 + offset = pci_find_vsec_capability(pdev, PCI_VENDOR_ID_ALTERA, 0x1172); 590 + if (!offset) { 591 + dev_err(&pdev->dev, "Wrong VSEC ID value\n"); 596 592 return -ENODEV; 597 593 } 598 594