summaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorKuppuswamy Sathyanarayanan <sathyanarayanan.kuppuswamy@linux.intel.com>2026-10-13 12:29:28 -0700
committerIlpo Järvinen <ilpo.jarvinen@linux.intel.com>2026-10-15 16:53:45 +0300
commit925ecbd683cb752ee90b2cb076cf5be9e3620454 (patch)
tree58b42337acf7acc9b8495df53e14d5cf5930bec1 /drivers
parent70fb9d0d8177c0a2f9a0f2927fbf75a78c9de38b (diff)
platform/x86/intel/tpmi: Use guard() for tpmi_dev_lock in the status read
tpmi_read_feature_status() takes tpmi_dev_lock explicitly and unwinds through an err_unlock label, which is what forced the two error paths before the mailbox command is issued to be gotos rather than returns. Take the mutex with guard() and return directly from those two paths. The done_proc label stays, because the paths that reach it have already handed the mailbox to the hardware and still owe it the CPL write before dropping the lock. That is unchanged: the two early failures never wrote CPL before either. No functional change intended. Suggested-by: Andy Shevchenko <andriy.shevchenko@intel.com> Suggested-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com> Reviewed-by: Andy Shevchenko <andriy.shevchenko@intel.com> Signed-off-by: Kuppuswamy Sathyanarayanan <sathyanarayanan.kuppuswamy@linux.intel.com> Link: https://patch.msgid.link/20261013192935.2243291-14-sathyanarayanan.kuppuswamy@linux.intel.com Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com> Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/platform/x86/intel/tpmi_common.c9
1 files changed, 3 insertions, 6 deletions
diff --git a/drivers/platform/x86/intel/tpmi_common.c b/drivers/platform/x86/intel/tpmi_common.c
index 7f6cd0fb23d7..00f27ac0a753 100644
--- a/drivers/platform/x86/intel/tpmi_common.c
+++ b/drivers/platform/x86/intel/tpmi_common.c
@@ -272,12 +272,12 @@ static int tpmi_read_feature_status(struct intel_tpmi_info *tpmi_info, int featu
if (!tpmi_info->tpmi_control_mem)
return -EFAULT;
- mutex_lock(&tpmi_dev_lock);
+ guard(mutex)(&tpmi_dev_lock);
/* Wait for owner bit set to 0 (none) */
ret = tpmi_wait_for_owner(tpmi_info, TPMI_OWNER_NONE);
if (ret)
- goto err_unlock;
+ return ret;
/* set command id to 0x10 for TPMI_GET_STATE */
data = FIELD_PREP(TMPI_CONTROL_DATA_CMD, TPMI_CONTROL_GET_STATE_CMD);
@@ -291,7 +291,7 @@ static int tpmi_read_feature_status(struct intel_tpmi_info *tpmi_info, int featu
/* Wait for owner bit set to in-band */
ret = tpmi_wait_for_owner(tpmi_info, TPMI_OWNER_IN_BAND);
if (ret)
- goto err_unlock;
+ return ret;
/* Set Run Busy and packet length of 2 dwords */
control = TPMI_CONTROL_STATUS_RB;
@@ -323,9 +323,6 @@ done_proc:
/* Set CPL "completion" bit */
writeq(TPMI_CONTROL_STATUS_CPL, tpmi_info->tpmi_control_mem + TPMI_CONTROL_STATUS_OFFSET);
-err_unlock:
- mutex_unlock(&tpmi_dev_lock);
-
return ret;
}