X86 platform drivers
 help / color / mirror / Atom feed
From: Mario Limonciello <superm1@kernel.org>
To: Shyam Sundar S K <Shyam-sundar.S-k@amd.com>,
	hansg@kernel.org, ilpo.jarvinen@linux.intel.com
Cc: platform-driver-x86@vger.kernel.org, Patil.Reddy@amd.com
Subject: Re: [PATCH v4 2/3] platform/x86/amd/pmf: Use devm_mutex_init() for mutex initialization
Date: Wed, 19 Nov 2025 08:30:54 -0600	[thread overview]
Message-ID: <59882570-5aa8-42cd-8821-87aba696e3e9@kernel.org> (raw)
In-Reply-To: <20251119085813.546813-2-Shyam-sundar.S-k@amd.com>

On 11/19/25 2:58 AM, Shyam Sundar S K wrote:
> Replace mutex_init() with the devm_mutex_init(), to ensure proper mutex
> cleanup during probe failure and driver removal.
> 
> Signed-off-by: Shyam Sundar S K <Shyam-sundar.S-k@amd.com>
Reviewed-by: Mario Limonciello (AMD) <superm1@kernel.org>> ---
> v4:
>   - New patch spinned off from v3
> 
>   drivers/platform/x86/amd/pmf/core.c | 17 +++++++++++------
>   1 file changed, 11 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/platform/x86/amd/pmf/core.c b/drivers/platform/x86/amd/pmf/core.c
> index bc544a4a5266..2ec4cb92e34f 100644
> --- a/drivers/platform/x86/amd/pmf/core.c
> +++ b/drivers/platform/x86/amd/pmf/core.c
> @@ -465,9 +465,17 @@ static int amd_pmf_probe(struct platform_device *pdev)
>   	if (!dev->regbase)
>   		return -ENOMEM;
>   
> -	mutex_init(&dev->lock);
> -	mutex_init(&dev->update_mutex);
> -	mutex_init(&dev->cb_mutex);
> +	err = devm_mutex_init(dev->dev, &dev->lock);
> +	if (err)
> +		return err;
> +
> +	err = devm_mutex_init(dev->dev, &dev->update_mutex);
> +	if (err)
> +		return err;
> +
> +	err = devm_mutex_init(dev->dev, &dev->cb_mutex);
> +	if (err)
> +		return err;
>   
>   	apmf_acpi_init(dev);
>   	platform_set_drvdata(pdev, dev);
> @@ -491,9 +499,6 @@ static void amd_pmf_remove(struct platform_device *pdev)
>   		amd_pmf_notify_sbios_heartbeat_event_v2(dev, ON_UNLOAD);
>   	apmf_acpi_deinit(dev);
>   	amd_pmf_dbgfs_unregister(dev);
> -	mutex_destroy(&dev->lock);
> -	mutex_destroy(&dev->update_mutex);
> -	mutex_destroy(&dev->cb_mutex);
>   }
>   
>   static const struct attribute_group *amd_pmf_driver_groups[] = {


  reply	other threads:[~2025-11-19 14:30 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-11-19  8:58 [PATCH v4 1/3] platform/x86/amd/pmf: Add BIOS_INPUTS_MAX macro to replace hardcoded array size Shyam Sundar S K
2025-11-19  8:58 ` [PATCH v4 2/3] platform/x86/amd/pmf: Use devm_mutex_init() for mutex initialization Shyam Sundar S K
2025-11-19 14:30   ` Mario Limonciello [this message]
2025-11-19  8:58 ` [PATCH v4 3/3] platform/x86/amd/pmf: Use ring buffer to store custom BIOS input values Shyam Sundar S K
2025-11-27 12:09   ` Ilpo Järvinen
2025-11-27 20:40     ` Shyam Sundar S K
2025-11-28  9:48       ` Ilpo Järvinen
2025-11-30 16:14         ` Shyam Sundar S K

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=59882570-5aa8-42cd-8821-87aba696e3e9@kernel.org \
    --to=superm1@kernel.org \
    --cc=Patil.Reddy@amd.com \
    --cc=Shyam-sundar.S-k@amd.com \
    --cc=hansg@kernel.org \
    --cc=ilpo.jarvinen@linux.intel.com \
    --cc=platform-driver-x86@vger.kernel.org \
    /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