Skip to content

Commit 2a3351d

Browse files
committed
platform/x86:intel/pmc: Move error handling to init function
JIRA: https://issues.redhat.com/browse/RHEL-110838 commit 1e24546 Author: Xi Pardee <xi.pardee@linux.intel.com> Date: Fri Apr 25 12:52:32 2025 -0700 platform/x86:intel/pmc: Move error handling to init function Move error handling code to generic_core_init() function. The previous implementation is that init function called for "full cleanup" function when error occurs which is error prone. The init function should handle the error path itself to improve code maintainability. Signed-off-by: Xi Pardee <xi.pardee@linux.intel.com> Link: https://lore.kernel.org/r/20250425195237.493129-5-xi.pardee@linux.intel.com Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com> Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com> Signed-off-by: Steve Best <sbest@redhat.com>
1 parent 007d5f0 commit 2a3351d

File tree

1 file changed

+19
-3
lines changed
  • drivers/platform/x86/intel/pmc

1 file changed

+19
-3
lines changed

drivers/platform/x86/intel/pmc/core.c

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1583,10 +1583,26 @@ int generic_core_init(struct pmc_dev *pmcdev, struct pmc_dev_info *pmc_dev_info)
15831583
if (pmc_dev_info->dmu_guid)
15841584
pmc_core_punit_pmt_init(pmcdev, pmc_dev_info->dmu_guid);
15851585

1586-
if (ssram)
1587-
return pmc_core_ssram_get_lpm_reqs(pmcdev, pmc_dev_info->pci_func);
1586+
if (ssram) {
1587+
ret = pmc_core_ssram_get_lpm_reqs(pmcdev, pmc_dev_info->pci_func);
1588+
if (ret)
1589+
goto unmap_regbase;
1590+
}
15881591

15891592
return 0;
1593+
1594+
unmap_regbase:
1595+
for (unsigned int i = 0; i < ARRAY_SIZE(pmcdev->pmcs); ++i) {
1596+
struct pmc *pmc = pmcdev->pmcs[i];
1597+
1598+
if (pmc && pmc->regbase)
1599+
iounmap(pmc->regbase);
1600+
}
1601+
1602+
if (pmcdev->punit_ep)
1603+
pmt_telem_unregister_endpoint(pmcdev->punit_ep);
1604+
1605+
return ret;
15901606
}
15911607

15921608
static const struct x86_cpu_id intel_pmc_core_ids[] = {
@@ -1735,7 +1751,7 @@ static int pmc_core_probe(struct platform_device *pdev)
17351751
ret = generic_core_init(pmcdev, pmc_dev_info);
17361752

17371753
if (ret) {
1738-
pmc_core_clean_structure(pdev);
1754+
platform_set_drvdata(pdev, NULL);
17391755
return ret;
17401756
}
17411757

0 commit comments

Comments
 (0)