summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitry Torokhov <dmitry.torokhov@gmail.com>2024-05-30 11:07:19 -0700
committerDmitry Torokhov <dmitry.torokhov@gmail.com>2024-06-06 14:35:01 -0700
commitc76494768761aef7630e7e0db820ba7b375964da (patch)
tree392ca942ec8ee4f1cd3389b4e967a87d80ec7077
parenta38297e3fb012ddfa7ce0321a7e5a8daeb1872b6 (diff)
downloadlwn-c76494768761aef7630e7e0db820ba7b375964da.tar.gz
lwn-c76494768761aef7630e7e0db820ba7b375964da.zip
linux/interrupt.h: allow "guard" notation to disable and reenable IRQ
Drivers often need to first disable an interrupt, carry out some action, and then reenable the interrupt. Introduce support for the "guard" notation for this so that the following is possible: ... scoped_cond_guard(mutex_intr, return -EINTR, &data->sysfs_mutex) { guard(disable_irq)(&client->irq); error = elan_acquire_baseline(data); if (error) return error; } ... Reviewed-by: Thomas Gleixner <tglx@linutronix.de> Link: https://lore.kernel.org/r/ZljAV6HjkPSEhWSw@google.com Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
-rw-r--r--include/linux/interrupt.h4
1 files changed, 4 insertions, 0 deletions
diff --git a/include/linux/interrupt.h b/include/linux/interrupt.h
index 5c9bdd3ffccc..3a36e64119c8 100644
--- a/include/linux/interrupt.h
+++ b/include/linux/interrupt.h
@@ -5,6 +5,7 @@
#include <linux/kernel.h>
#include <linux/bitops.h>
+#include <linux/cleanup.h>
#include <linux/cpumask.h>
#include <linux/irqreturn.h>
#include <linux/irqnr.h>
@@ -235,6 +236,9 @@ extern void enable_percpu_irq(unsigned int irq, unsigned int type);
extern bool irq_percpu_is_enabled(unsigned int irq);
extern void irq_wake_thread(unsigned int irq, void *dev_id);
+DEFINE_LOCK_GUARD_1(disable_irq, int,
+ disable_irq(*_T->lock), enable_irq(*_T->lock))
+
extern void disable_nmi_nosync(unsigned int irq);
extern void disable_percpu_nmi(unsigned int irq);
extern void enable_nmi(unsigned int irq);