[PATCH 01/19] rtc: introduce rtc_device.ops_lock guard()

From: alexandre . belloni

Date: Mon Oct 19 2026 - 17:23:18 EST


From: Alexandre Belloni <alexandre.belloni@xxxxxxxxxxx>

Add guard class for rtc_device.ops_lock locks. This allows to simplify
error handling in interrupt handlers.

Signed-off-by: Alexandre Belloni <alexandre.belloni@xxxxxxxxxxx>
---
include/linux/rtc.h | 3 +++
1 file changed, 3 insertions(+)

diff --git a/include/linux/rtc.h b/include/linux/rtc.h
index 0f43b5027235..169d93520dbd 100644
--- a/include/linux/rtc.h
+++ b/include/linux/rtc.h
@@ -168,6 +168,9 @@ struct rtc_device {
#define rtc_lock(d) mutex_lock(&d->ops_lock)
#define rtc_unlock(d) mutex_unlock(&d->ops_lock)

+DEFINE_GUARD(rtc_ops, struct rtc_device *, mutex_lock(&_T->ops_lock),
+ mutex_unlock(&_T->ops_lock))
+
/* useful timestamps */
#define RTC_TIMESTAMP_BEGIN_0000 -62167219200ULL /* 0000-01-01 00:00:00 */
#define RTC_TIMESTAMP_BEGIN_1900 -2208988800LL /* 1900-01-01 00:00:00 */
--
2.56.0