Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.9]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 60618189B8C for ; Sun, 13 Jul 2025 17:30:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.9 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1752427808; cv=none; b=h5wfSORuUkG4YMjickpFH4gaDWYW8v1rwl2Vg2btmK6C53ER1g4X0UjsJYrkEfvHHij42uA6TfiwW/9fApG9OB+XXtT8Z2+L8mbCFYkd8CKSWq7288e0gsrZL/xk2hAbZ2xXjHKRHnM9EYLt0ONmyq9iLGBsHMNtEXXvnD/SXtA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1752427808; c=relaxed/simple; bh=oT3Jm2YcLIrEEoTNBNUIreW51zAojhlRHEqzz+kiMug=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=UUvnHulvphOJyYQfmbuHZwWx+Jf3BLbYZrV0ub7kYdfEuZF2yfhiY0xptSNj8lFRlQhm99An/hl0FDwpYn5yxDH5ohCce5+QwbK78Uhz1PBaQ99cHNOx6GlsN0nnl8Tz5wXvEQDLbZ+paTjIchZQSaTWhlcYBHwOYSFNcF8jrDs= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=g7bBtGO/; arc=none smtp.client-ip=192.198.163.9 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="g7bBtGO/" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1752427807; x=1783963807; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=oT3Jm2YcLIrEEoTNBNUIreW51zAojhlRHEqzz+kiMug=; b=g7bBtGO//09Ndlqx0DzpgbNszHooy55zn++5yX84tpGgb3Ln/MvEEP3d aSGx+KKwoiCwn0tkaJhjLUHogOrFC5c76CzdO06fOJXpZX49CPdfw96mC TX1Kjy/pITG/z+YmIlrh3jlW+RtVptmsCBCV9dyYrVQtCVUjQodVqufLY 9jvHPIRAIzT4Rc5MFFqeVM+rcPSRSOL+UNO/saDGb/bbdG6El2LlgANYr zRi044qdXhR0HWuZfNuvR4E+61e0xS68TdvO7lcoNvOj8bMZiJelKsnVF TMXvRr8o4ns6VtA0e7LFjgWFIQV5Z0i5YUnIC/Qb0UtPyaHDQ+IdSTsAm w==; X-CSE-ConnectionGUID: jeDTer2ZTrmpNi48jlyiJg== X-CSE-MsgGUID: EzomXEfASvWK8yXtHYSomQ== X-IronPort-AV: E=McAfee;i="6800,10657,11491"; a="65334137" X-IronPort-AV: E=Sophos;i="6.16,309,1744095600"; d="scan'208";a="65334137" Received: from fmviesa005.fm.intel.com ([10.60.135.145]) by fmvoesa103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Jul 2025 10:30:07 -0700 X-CSE-ConnectionGUID: FjXoBZ0mQ+26bcEZCrjvMQ== X-CSE-MsgGUID: dWhmGTmRQpy9jkZUWcfXNg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.16,309,1744095600"; d="scan'208";a="161069304" Received: from mgoodin-mobl3.amr.corp.intel.com (HELO mjruhl-desk.intel.com) ([10.124.223.19]) by fmviesa005-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Jul 2025 10:30:06 -0700 From: "Michael J. Ruhl" To: platform-driver-x86@vger.kernel.org, intel-xe@lists.freedesktop.org, hdegoede@redhat.com, ilpo.jarvinen@linux.intel.com, lucas.demarchi@intel.com, rodrigo.vivi@intel.com, thomas.hellstrom@linux.intel.com, airlied@gmail.com, simona@ffwll.ch, david.e.box@linux.intel.com Cc: "Michael J. Ruhl" Subject: [PATCH v8 06/13] platform/x86/intel/pmt: use guard(mutex) Date: Sun, 13 Jul 2025 13:29:36 -0400 Message-ID: <20250713172943.7335-7-michael.j.ruhl@intel.com> X-Mailer: git-send-email 2.50.0 In-Reply-To: <20250713172943.7335-1-michael.j.ruhl@intel.com> References: <20250713172943.7335-1-michael.j.ruhl@intel.com> Precedence: bulk X-Mailing-List: platform-driver-x86@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Update the mutex paths to use the new guard() mechanism. With the removal of goto, do some minor cleanup of the current logic path. Reviewed-by: David E. Box Reviewed-by: Ilpo Järvinen Signed-off-by: Michael J. Ruhl --- drivers/platform/x86/intel/pmt/crashlog.c | 33 +++++++++++------------ 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/drivers/platform/x86/intel/pmt/crashlog.c b/drivers/platform/x86/intel/pmt/crashlog.c index 6e32fc1f8f1d..c3ca95854aba 100644 --- a/drivers/platform/x86/intel/pmt/crashlog.c +++ b/drivers/platform/x86/intel/pmt/crashlog.c @@ -9,6 +9,7 @@ */ #include +#include #include #include #include @@ -156,9 +157,9 @@ enable_store(struct device *dev, struct device_attribute *attr, if (result) return result; - mutex_lock(&entry->control_mutex); + guard(mutex)(&entry->control_mutex); + pmt_crashlog_set_disable(&entry->entry, !enabled); - mutex_unlock(&entry->control_mutex); return count; } @@ -190,26 +191,24 @@ trigger_store(struct device *dev, struct device_attribute *attr, if (result) return result; - mutex_lock(&entry->control_mutex); + guard(mutex)(&entry->control_mutex); if (!trigger) { pmt_crashlog_set_clear(&entry->entry); - } else if (pmt_crashlog_complete(&entry->entry)) { - /* we cannot trigger a new crash if one is still pending */ - result = -EEXIST; - goto err; - } else if (pmt_crashlog_disabled(&entry->entry)) { - /* if device is currently disabled, return busy */ - result = -EBUSY; - goto err; - } else { - pmt_crashlog_set_execute(&entry->entry); + return count; } - result = count; -err: - mutex_unlock(&entry->control_mutex); - return result; + /* we cannot trigger a new crash if one is still pending */ + if (pmt_crashlog_complete(&entry->entry)) + return -EEXIST; + + /* if device is currently disabled, return busy */ + if (pmt_crashlog_disabled(&entry->entry)) + return -EBUSY; + + pmt_crashlog_set_execute(&entry->entry); + + return count; } static DEVICE_ATTR_RW(trigger); -- 2.50.0