[PATCH 3/8] platform/x86: pmt_crashlog: switch to devm_mutex_init()

From: chitranshmandhaniya

Date: Fri Oct 30 2026 - 04:23:58 EST


From: Chitransh Mandhaniya <Chitransh_Mandhaniya@xxxxxxxx>

Replace mutex_init() with devm_mutex_init() so the mutex lifecycle is
managed by devres. This removes the need for the manual
mutex_destroy() call in pmt_crashlog_remove().

Signed-off-by: Chitransh Mandhaniya <Chitransh_Mandhaniya@xxxxxxxx>
---
drivers/platform/x86/intel/pmt/crashlog.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/platform/x86/intel/pmt/crashlog.c b/drivers/platform/x86/intel/pmt/crashlog.c
index d7018b495217..1071320ce6be 100644
--- a/drivers/platform/x86/intel/pmt/crashlog.c
+++ b/drivers/platform/x86/intel/pmt/crashlog.c
@@ -591,13 +591,16 @@ static int pmt_crashlog_pre_decode(struct intel_vsec_device *ivdev,
struct crashlog_entry *crashlog;
u32 version;
u32 type;
+ int ret;

if (!pmt_crashlog_supported(entry, &type, &version))
return 1;

/* initialize the crashlog struct */
crashlog = container_of(entry, struct crashlog_entry, entry);
- mutex_init(&crashlog->control_mutex);
+ ret = devm_mutex_init(&ivdev->auxdev.dev, &crashlog->control_mutex);
+ if (ret)
+ return ret;

crashlog->info = select_crashlog_info(type, version);
entry->attr_grp = crashlog->info->attr_grp;
@@ -641,7 +644,6 @@ static void pmt_crashlog_remove(struct auxiliary_device *auxdev)
struct crashlog_entry *crashlog = &priv->entry[i];

intel_pmt_dev_destroy(&crashlog->entry, &pmt_crashlog_ns);
- mutex_destroy(&crashlog->control_mutex);
}
}

--
2.43.0