cxl/core/pci: Move reading of control register to immediately before usage

Relocate the reading of the DVSEC control register to immediately
before usage and avoid unnecessary PCI config access from the read
if DVSEC capability check, hdm_count check, or device validity check
results in failure.

Signed-off-by: Foryun Ma <foryun.ma@jaguarmicro.com>
Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Reviewed-by: Alison Schofield <alison.schofield@intel.com>
Link: https://patch.msgid.link/20240604032151.655-1-foryun.ma@jaguarmicro.com
Signed-off-by: Dave Jiang <dave.jiang@intel.com>

authored by Foryun Ma and committed by Dave Jiang a0328b39 56478475

+4 -4
+4 -4
drivers/cxl/core/pci.c
··· 338 if (rc) 339 return rc; 340 341 - rc = pci_read_config_word(pdev, d + CXL_DVSEC_CTRL_OFFSET, &ctrl); 342 - if (rc) 343 - return rc; 344 - 345 if (!(cap & CXL_DVSEC_MEM_CAPABLE)) { 346 dev_dbg(dev, "Not MEM Capable\n"); 347 return -ENXIO; ··· 364 * disabled, and they will remain moot after the HDM Decoder 365 * capability is enabled. 366 */ 367 info->mem_enabled = FIELD_GET(CXL_DVSEC_MEM_ENABLE, ctrl); 368 if (!info->mem_enabled) 369 return 0;
··· 338 if (rc) 339 return rc; 340 341 if (!(cap & CXL_DVSEC_MEM_CAPABLE)) { 342 dev_dbg(dev, "Not MEM Capable\n"); 343 return -ENXIO; ··· 368 * disabled, and they will remain moot after the HDM Decoder 369 * capability is enabled. 370 */ 371 + rc = pci_read_config_word(pdev, d + CXL_DVSEC_CTRL_OFFSET, &ctrl); 372 + if (rc) 373 + return rc; 374 + 375 info->mem_enabled = FIELD_GET(CXL_DVSEC_MEM_ENABLE, ctrl); 376 if (!info->mem_enabled) 377 return 0;