* [PATCH] x86/msi: Use guard() instead of mutex_lock() to simplify code
@ 2025-09-01 13:21 Liao Yuanhong
0 siblings, 0 replies; only message in thread
From: Liao Yuanhong @ 2025-09-01 13:21 UTC (permalink / raw)
To: Thomas Gleixner, Ingo Molnar, Borislav Petkov, Dave Hansen,
maintainer:X86 ARCHITECTURE (32-BIT AND 64-BIT), H. Peter Anvin,
Steve Wahl, Wei Liu,
open list:X86 ARCHITECTURE (32-BIT AND 64-BIT)
Cc: Liao Yuanhong
Using guard(mutex) instead of mutex_lock/mutex_unlock pair. Simplifies the
error handling to just return in case of error. No need for the 'out' label
anymore so remove it.
Signed-off-by: Liao Yuanhong <liaoyuanhong@vivo.com>
---
arch/x86/kernel/apic/msi.c | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/arch/x86/kernel/apic/msi.c b/arch/x86/kernel/apic/msi.c
index 66bc5d3e79db..e11523cfdbc5 100644
--- a/arch/x86/kernel/apic/msi.c
+++ b/arch/x86/kernel/apic/msi.c
@@ -346,9 +346,9 @@ static struct irq_domain *dmar_get_irq_domain(void)
static DEFINE_MUTEX(dmar_lock);
struct fwnode_handle *fn;
- mutex_lock(&dmar_lock);
+ guard(mutex)(&dmar_lock);
if (dmar_domain)
- goto out;
+ return dmar_domain;
fn = irq_domain_alloc_named_fwnode("DMAR-MSI");
if (fn) {
@@ -357,8 +357,7 @@ static struct irq_domain *dmar_get_irq_domain(void)
if (!dmar_domain)
irq_domain_free_fwnode(fn);
}
-out:
- mutex_unlock(&dmar_lock);
+
return dmar_domain;
}
--
2.34.1
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2025-09-01 13:21 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-09-01 13:21 [PATCH] x86/msi: Use guard() instead of mutex_lock() to simplify code Liao Yuanhong
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).