public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: "Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>
To: Xi Pardee <xi.pardee@linux.intel.com>
Cc: irenic.rajneesh@gmail.com, david.e.box@linux.intel.com,
	 Hans de Goede <hdegoede@redhat.com>,
	platform-driver-x86@vger.kernel.org,
	 LKML <linux-kernel@vger.kernel.org>,
	linux-pm@vger.kernel.org
Subject: Re: [PATCH v4 3/4] platform/x86:intel/pmc: Move error handling to init function
Date: Thu, 24 Apr 2025 17:02:42 +0300 (EEST)	[thread overview]
Message-ID: <c468af86-4bb8-4a8b-b601-07e29d4907e3@linux.intel.com> (raw)
In-Reply-To: <20250421211100.687250-4-xi.pardee@linux.intel.com>

On Mon, 21 Apr 2025, Xi Pardee wrote:

> 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>
> ---
>  drivers/platform/x86/intel/pmc/core.c | 23 ++++++++++++++++++++---
>  1 file changed, 20 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/platform/x86/intel/pmc/core.c b/drivers/platform/x86/intel/pmc/core.c
> index 042b60c1185f..e09a97564398 100644
> --- a/drivers/platform/x86/intel/pmc/core.c
> +++ b/drivers/platform/x86/intel/pmc/core.c
> @@ -1583,10 +1583,26 @@ int generic_core_init(struct pmc_dev *pmcdev, struct pmc_dev_info *pmc_dev_info)
>  	if (pmc_dev_info->dmu_guid)
>  		pmc_core_punit_pmt_init(pmcdev, pmc_dev_info->dmu_guid);
>  
> -	if (ssram)
> -		return pmc_core_ssram_get_lpm_reqs(pmcdev, pmc_dev_info->pci_func);
> +	if (ssram) {
> +		ret = pmc_core_ssram_get_lpm_reqs(pmcdev, pmc_dev_info->pci_func);
> +		if (ret)
> +			goto unmap_regbase;
> +	}
>  
>  	return 0;
> +
> +unmap_regbase:
> +	for (unsigned int i = 0; i < ARRAY_SIZE(pmcdev->pmcs); ++i) {
> +		struct pmc *pmc = pmcdev->pmcs[i];
> +
> +		if (pmc && pmc->regbase)
> +			iounmap(pmc->regbase);
> +	}
> +
> +	if (pmcdev->punit_ep)
> +		pmt_telem_unregister_endpoint(pmcdev->punit_ep);
> +
> +	return ret;
>  }
>  
>  static const struct x86_cpu_id intel_pmc_core_ids[] = {
> @@ -1734,7 +1750,8 @@ static int pmc_core_probe(struct platform_device *pdev)
>  		ret = generic_core_init(pmcdev, pmc_dev_info);
>  
>  	if (ret) {
> -		pmc_core_clean_structure(pdev);
> +		platform_set_drvdata(pdev, NULL);
> +		mutex_destroy(&pmcdev->lock);

Please change also the mutex init to use devm_mutex_init(), don't forget 
to include error handling for it as it devm_mutex_init() can fail.

>  		return ret;
>  	}
>  
> 

-- 
 i.


  reply	other threads:[~2025-04-24 14:02 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-04-21 21:10 [PATCH v4 0/4] Create Intel PMC SSRAM Telemetry driver Xi Pardee
2025-04-21 21:10 ` [PATCH v4 1/4] platform/x86:intel/vsec: Change return type of intel_vsec_register Xi Pardee
2025-04-21 21:10 ` [PATCH v4 2/4] platform/x86:intel/pmc: Create Intel PMC SSRAM Telemetry driver Xi Pardee
2025-04-24 14:01   ` Ilpo Järvinen
2025-04-24 19:57     ` Xi Pardee
2025-04-21 21:10 ` [PATCH v4 3/4] platform/x86:intel/pmc: Move error handling to init function Xi Pardee
2025-04-24 14:02   ` Ilpo Järvinen [this message]
2025-04-24 19:58     ` Xi Pardee
2025-04-21 21:10 ` [PATCH v4 4/4] platform/x86:intel/pmc: Improve pmc_core_get_lpm_req() Xi Pardee

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=c468af86-4bb8-4a8b-b601-07e29d4907e3@linux.intel.com \
    --to=ilpo.jarvinen@linux.intel.com \
    --cc=david.e.box@linux.intel.com \
    --cc=hdegoede@redhat.com \
    --cc=irenic.rajneesh@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=platform-driver-x86@vger.kernel.org \
    --cc=xi.pardee@linux.intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox