Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.14]) (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 0AD132741C9 for ; Tue, 10 Jun 2025 21:12:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.14 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749589970; cv=none; b=GkpZo6MYUxCe0UyLLunCnSfNqWpdQTuHQE+8jGvNGBrK0WsKCOWXazQa/5fMOt5U6wFY+Cen6Yz0xQ44YRQpKCMINx7ihOM4fM7DljLTRpn++vNzCSv346YIxQAtx6HANWCgj6wviFR7BdbGsyo3fWq2IXbb7lVurwjF6i7p1D8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749589970; c=relaxed/simple; bh=rZQayzoi8ONjnqpJLzmJXR2jMABT7CLW7RJ0yrE30Vk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=OBl8nyZhYqGk1Oh8nzZbrlHSNbz78wnth9OId5zRxW4b3pqV+NxrV41E3Zxc+AFXIG79Y1UWaAQugf4XDpP6FzbgYvlJOjJ9qsEDqHFTGT1ENoSkIf6K478uaDatL5Nn5IcBx/ZWYnuAYTiiaNePK4GqFE5wfFVAFS1GKnZZwhI= 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=MypCIgac; arc=none smtp.client-ip=192.198.163.14 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="MypCIgac" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1749589969; x=1781125969; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=rZQayzoi8ONjnqpJLzmJXR2jMABT7CLW7RJ0yrE30Vk=; b=MypCIgact1eGLHATr6lsp+6f1XLMAbGAXxjrqigXD75OCWcmZIxunAiw FdDLsO/FzXpo9MKoofZNVIGa9JjqifszoQaAjI/0mi4V7ZMbxxlxmj8ns Vdt6c+RE1DFXcUcTyCXzblf9LXhJb3/1mGmiX3QoegVBqwFOuNFTk7Zn0 GYS8DXZB//A0kMgm1rBnlpXfBLZt+WUqaJ+Kt2dSBcN/z+45+nO4mhpaD kvuJvUL1o/7D4fyTKxXG1xtmysKKmLnx1CD+wE8AnRzSFJW0L+H9W2vMf ox0HpiFx88YyTX+/SpM34tJYz+sZD61ZOxIgl2LYZnfls2+40AjmEjbvz A==; X-CSE-ConnectionGUID: 0BW7lhKlQ4+pSN+0ngXU7A== X-CSE-MsgGUID: xzIJ8LbUTfK71/NPIjtS3Q== X-IronPort-AV: E=McAfee;i="6800,10657,11460"; a="51816915" X-IronPort-AV: E=Sophos;i="6.16,226,1744095600"; d="scan'208";a="51816915" Received: from orviesa009.jf.intel.com ([10.64.159.149]) by fmvoesa108.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Jun 2025 14:12:49 -0700 X-CSE-ConnectionGUID: tg/7dTh7ST2YllnGKYttZA== X-CSE-MsgGUID: A0sYQmLzRPKWQSkTwDpe8Q== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.16,226,1744095600"; d="scan'208";a="146939774" Received: from mjruhl-desk.amr.corp.intel.com (HELO mjruhl-desk.intel.com) ([10.124.220.88]) by orviesa009-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Jun 2025 14:12:47 -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 v4 04/10] platform/x86/intel/pmt: use guard(mutex) Date: Tue, 10 Jun 2025 17:12:19 -0400 Message-ID: <20250610211225.1085901-5-michael.j.ruhl@intel.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250610211225.1085901-1-michael.j.ruhl@intel.com> References: <20250610211225.1085901-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 d40c8e212733..1525e702e993 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 @@ -155,9 +156,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; } @@ -189,26 +190,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.49.0