[PATCH] x86/msi: Use guard() instead of mutex_lock() to simplify code

From: Liao Yuanhong
Date: Mon Sep 01 2025 - 09:21:40 EST


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@xxxxxxxx>
---
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