* [PATCH 02/19] rtc: ac100: use guard
2026-10-19 21:18 [PATCH 01/19] rtc: introduce rtc_device.ops_lock guard() alexandre.belloni
@ 2026-10-19 21:18 ` alexandre.belloni
2026-10-19 21:22 ` sashiko-bot
2026-10-19 21:18 ` [PATCH 03/19] rtc: asm9260: " alexandre.belloni
` (17 subsequent siblings)
18 siblings, 1 reply; 38+ messages in thread
From: alexandre.belloni @ 2026-10-19 21:18 UTC (permalink / raw)
To: Alexandre Belloni; +Cc: linux-rtc, linux-kernel
From: Alexandre Belloni <alexandre.belloni@bootlin.com>
Use guard() to simplify error handling
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
---
drivers/rtc/rtc-ac100.c | 10 ++++------
1 file changed, 4 insertions(+), 6 deletions(-)
diff --git a/drivers/rtc/rtc-ac100.c b/drivers/rtc/rtc-ac100.c
index bba7115ff3ad..ee9fdb7fb63b 100644
--- a/drivers/rtc/rtc-ac100.c
+++ b/drivers/rtc/rtc-ac100.c
@@ -529,12 +529,12 @@ static irqreturn_t ac100_rtc_irq(int irq, void *data)
unsigned int val = 0;
int ret;
- rtc_lock(chip->rtc);
+ guard(rtc_ops)(chip->rtc);
/* read status */
ret = regmap_read(regmap, AC100_ALM_INT_STA, &val);
if (ret)
- goto out;
+ return IRQ_HANDLED;
if (val & AC100_ALM_INT_ENABLE) {
/* signal rtc framework */
@@ -543,16 +543,14 @@ static irqreturn_t ac100_rtc_irq(int irq, void *data)
/* clear status */
ret = regmap_write(regmap, AC100_ALM_INT_STA, val);
if (ret)
- goto out;
+ return IRQ_HANDLED;
/* disable interrupt */
ret = ac100_rtc_alarm_irq_enable(chip->dev, 0);
if (ret)
- goto out;
+ return IRQ_HANDLED;
}
-out:
- rtc_unlock(chip->rtc);
return IRQ_HANDLED;
}
--
2.56.0
^ permalink raw reply related [flat|nested] 38+ messages in thread* [PATCH 03/19] rtc: asm9260: use guard
2026-10-19 21:18 [PATCH 01/19] rtc: introduce rtc_device.ops_lock guard() alexandre.belloni
2026-10-19 21:18 ` [PATCH 02/19] rtc: ac100: use guard alexandre.belloni
@ 2026-10-19 21:18 ` alexandre.belloni
2026-10-19 21:23 ` sashiko-bot
2026-10-19 21:18 ` [PATCH 04/19] rtc: atcrtc100: " alexandre.belloni
` (16 subsequent siblings)
18 siblings, 1 reply; 38+ messages in thread
From: alexandre.belloni @ 2026-10-19 21:18 UTC (permalink / raw)
To: Krzysztof Kozlowski, Alexandre Belloni
Cc: linux-arm-kernel, linux-rtc, linux-kernel
From: Alexandre Belloni <alexandre.belloni@bootlin.com>
Use guard() to simplify error handling
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
---
drivers/rtc/rtc-asm9260.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/drivers/rtc/rtc-asm9260.c b/drivers/rtc/rtc-asm9260.c
index 705470ae8428..422c2e5d83aa 100644
--- a/drivers/rtc/rtc-asm9260.c
+++ b/drivers/rtc/rtc-asm9260.c
@@ -116,15 +116,13 @@ static irqreturn_t asm9260_rtc_irq(int irq, void *dev_id)
u32 isr;
unsigned long events = 0;
- rtc_lock(priv->rtc);
+ guard(rtc_ops)(priv->rtc);
isr = ioread32(priv->iobase + HW_CIIR);
if (!isr) {
- rtc_unlock(priv->rtc);
return IRQ_NONE;
}
iowrite32(0, priv->iobase + HW_CIIR);
- rtc_unlock(priv->rtc);
events |= RTC_AF | RTC_IRQF;
--
2.56.0
^ permalink raw reply related [flat|nested] 38+ messages in thread* [PATCH 04/19] rtc: atcrtc100: use guard
2026-10-19 21:18 [PATCH 01/19] rtc: introduce rtc_device.ops_lock guard() alexandre.belloni
2026-10-19 21:18 ` [PATCH 02/19] rtc: ac100: use guard alexandre.belloni
2026-10-19 21:18 ` [PATCH 03/19] rtc: asm9260: " alexandre.belloni
@ 2026-10-19 21:18 ` alexandre.belloni
2026-10-19 21:22 ` sashiko-bot
2026-10-19 21:18 ` [PATCH 05/19] rtc: ds1305: " alexandre.belloni
` (15 subsequent siblings)
18 siblings, 1 reply; 38+ messages in thread
From: alexandre.belloni @ 2026-10-19 21:18 UTC (permalink / raw)
To: CL Wang, Alexandre Belloni; +Cc: linux-rtc, linux-kernel
From: Alexandre Belloni <alexandre.belloni@bootlin.com>
Use guard() to simplify locking
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
---
drivers/rtc/rtc-atcrtc100.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/drivers/rtc/rtc-atcrtc100.c b/drivers/rtc/rtc-atcrtc100.c
index 9808fc2c5a49..2433df386c40 100644
--- a/drivers/rtc/rtc-atcrtc100.c
+++ b/drivers/rtc/rtc-atcrtc100.c
@@ -147,7 +147,7 @@ static void atcrtc_alarm_clear(struct work_struct *work)
container_of(work, struct atcrtc_dev, rtc_work);
int ret;
- rtc_lock(rtc->rtc_dev);
+ guard(rtc_ops)(rtc->rtc_dev);
if (!rtc->alarm_en) {
ret = atcrtc_check_write_done(rtc);
@@ -159,7 +159,6 @@ static void atcrtc_alarm_clear(struct work_struct *work)
regmap_update_bits(rtc->regmap, RTC_CR,
ALARM_WAKEUP | ALARM_INT, 0);
}
- rtc_unlock(rtc->rtc_dev);
}
static int atcrtc_read_time(struct device *dev, struct rtc_time *tm)
--
2.56.0
^ permalink raw reply related [flat|nested] 38+ messages in thread* [PATCH 05/19] rtc: ds1305: use guard
2026-10-19 21:18 [PATCH 01/19] rtc: introduce rtc_device.ops_lock guard() alexandre.belloni
` (2 preceding siblings ...)
2026-10-19 21:18 ` [PATCH 04/19] rtc: atcrtc100: " alexandre.belloni
@ 2026-10-19 21:18 ` alexandre.belloni
2026-10-19 21:23 ` sashiko-bot
2026-10-19 21:18 ` [PATCH 06/19] rtc: ds1307: " alexandre.belloni
` (14 subsequent siblings)
18 siblings, 1 reply; 38+ messages in thread
From: alexandre.belloni @ 2026-10-19 21:18 UTC (permalink / raw)
To: Alexandre Belloni; +Cc: linux-rtc, linux-kernel
From: Alexandre Belloni <alexandre.belloni@bootlin.com>
Use guard() to simplify locking
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
---
drivers/rtc/rtc-ds1305.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/drivers/rtc/rtc-ds1305.c b/drivers/rtc/rtc-ds1305.c
index d4de401548b4..19a32d3476b5 100644
--- a/drivers/rtc/rtc-ds1305.c
+++ b/drivers/rtc/rtc-ds1305.c
@@ -440,7 +440,7 @@ static void ds1305_work(struct work_struct *work)
int status;
/* lock to protect ds1305->ctrl */
- rtc_lock(ds1305->rtc);
+ guard(rtc_ops)(ds1305->rtc);
/* Disable the IRQ, and clear its status ... for now, we "know"
* that if more than one alarm is active, they're in sync.
@@ -458,8 +458,6 @@ static void ds1305_work(struct work_struct *work)
if (status < 0)
dev_dbg(&spi->dev, "clear irq --> %d\n", status);
- rtc_unlock(ds1305->rtc);
-
if (!test_bit(FLAG_EXITING, &ds1305->flags))
enable_irq(spi->irq);
--
2.56.0
^ permalink raw reply related [flat|nested] 38+ messages in thread* [PATCH 06/19] rtc: ds1307: use guard
2026-10-19 21:18 [PATCH 01/19] rtc: introduce rtc_device.ops_lock guard() alexandre.belloni
` (3 preceding siblings ...)
2026-10-19 21:18 ` [PATCH 05/19] rtc: ds1305: " alexandre.belloni
@ 2026-10-19 21:18 ` alexandre.belloni
2026-10-19 21:22 ` sashiko-bot
2026-10-19 21:18 ` [PATCH 07/19] rtc: ds1343: " alexandre.belloni
` (13 subsequent siblings)
18 siblings, 1 reply; 38+ messages in thread
From: alexandre.belloni @ 2026-10-19 21:18 UTC (permalink / raw)
To: Alexandre Belloni; +Cc: linux-rtc, linux-kernel
From: Alexandre Belloni <alexandre.belloni@bootlin.com>
Use guard() to simplify error handling
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
---
drivers/rtc/rtc-ds1307.c | 13 ++++++-------
1 file changed, 6 insertions(+), 7 deletions(-)
diff --git a/drivers/rtc/rtc-ds1307.c b/drivers/rtc/rtc-ds1307.c
index 522f7eef3b4a..0cf4836b81b1 100644
--- a/drivers/rtc/rtc-ds1307.c
+++ b/drivers/rtc/rtc-ds1307.c
@@ -579,28 +579,27 @@ static irqreturn_t rx8130_irq(int irq, void *dev_id)
u8 ctl[3];
int ret;
- rtc_lock(ds1307->rtc);
+ guard(rtc_ops)(ds1307->rtc);
/* Read control registers. */
ret = regmap_bulk_read(ds1307->regmap, RX8130_REG_EXTENSION, ctl,
sizeof(ctl));
if (ret < 0)
- goto out;
+ return IRQ_HANDLED;
+
if (!(ctl[1] & RX8130_REG_FLAG_AF))
- goto out;
+ return IRQ_HANDLED;
+
ctl[1] &= ~RX8130_REG_FLAG_AF;
ctl[2] &= ~RX8130_REG_CONTROL0_AIE;
ret = regmap_bulk_write(ds1307->regmap, RX8130_REG_EXTENSION, ctl,
sizeof(ctl));
if (ret < 0)
- goto out;
+ return IRQ_HANDLED;
rtc_update_irq(ds1307->rtc, 1, RTC_AF | RTC_IRQF);
-out:
- rtc_unlock(ds1307->rtc);
-
return IRQ_HANDLED;
}
--
2.56.0
^ permalink raw reply related [flat|nested] 38+ messages in thread* [PATCH 07/19] rtc: ds1343: use guard
2026-10-19 21:18 [PATCH 01/19] rtc: introduce rtc_device.ops_lock guard() alexandre.belloni
` (4 preceding siblings ...)
2026-10-19 21:18 ` [PATCH 06/19] rtc: ds1307: " alexandre.belloni
@ 2026-10-19 21:18 ` alexandre.belloni
2026-10-19 21:22 ` sashiko-bot
2026-10-19 21:18 ` [PATCH 08/19] rtc: ds1685: " alexandre.belloni
` (12 subsequent siblings)
18 siblings, 1 reply; 38+ messages in thread
From: alexandre.belloni @ 2026-10-19 21:18 UTC (permalink / raw)
To: Alexandre Belloni; +Cc: linux-rtc, linux-kernel
From: Alexandre Belloni <alexandre.belloni@bootlin.com>
Use guard() to simplify error handling
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
---
drivers/rtc/rtc-ds1343.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/drivers/rtc/rtc-ds1343.c b/drivers/rtc/rtc-ds1343.c
index 54f6af7886a8..22abec4ba656 100644
--- a/drivers/rtc/rtc-ds1343.c
+++ b/drivers/rtc/rtc-ds1343.c
@@ -312,11 +312,11 @@ static irqreturn_t ds1343_thread(int irq, void *dev_id)
unsigned int stat;
int res = 0;
- rtc_lock(priv->rtc);
+ guard(rtc_ops)(priv->rtc);
res = regmap_read(priv->map, DS1343_STATUS_REG, &stat);
if (res)
- goto out;
+ return IRQ_HANDLED;
if (stat & DS1343_IRQF0) {
stat &= ~DS1343_IRQF0;
@@ -328,8 +328,6 @@ static irqreturn_t ds1343_thread(int irq, void *dev_id)
DS1343_A0IE, 0);
}
-out:
- rtc_unlock(priv->rtc);
return IRQ_HANDLED;
}
--
2.56.0
^ permalink raw reply related [flat|nested] 38+ messages in thread* [PATCH 08/19] rtc: ds1685: use guard
2026-10-19 21:18 [PATCH 01/19] rtc: introduce rtc_device.ops_lock guard() alexandre.belloni
` (5 preceding siblings ...)
2026-10-19 21:18 ` [PATCH 07/19] rtc: ds1343: " alexandre.belloni
@ 2026-10-19 21:18 ` alexandre.belloni
2026-10-19 21:22 ` sashiko-bot
2026-10-19 21:18 ` [PATCH 09/19] rtc: ds3232: " alexandre.belloni
` (11 subsequent siblings)
18 siblings, 1 reply; 38+ messages in thread
From: alexandre.belloni @ 2026-10-19 21:18 UTC (permalink / raw)
To: Joshua Kinard, Alexandre Belloni; +Cc: linux-rtc, linux-kernel
From: Alexandre Belloni <alexandre.belloni@bootlin.com>
Use guard() to simplify locking
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
---
drivers/rtc/rtc-ds1685.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/drivers/rtc/rtc-ds1685.c b/drivers/rtc/rtc-ds1685.c
index 5fc8e36b1abf..284815e5f478 100644
--- a/drivers/rtc/rtc-ds1685.c
+++ b/drivers/rtc/rtc-ds1685.c
@@ -666,7 +666,7 @@ ds1685_rtc_irq_handler(int irq, void *dev_id)
if (unlikely(!rtc))
return IRQ_HANDLED;
- rtc_lock(rtc->dev);
+ guard(rtc_ops)(rtc->dev);
/* Ctrlb holds the interrupt-enable bits and ctrlc the flag bits. */
ctrlb = rtc->read(rtc, RTC_CTRL_B);
@@ -711,7 +711,6 @@ ds1685_rtc_irq_handler(int irq, void *dev_id)
}
}
rtc_update_irq(rtc->dev, num_irqs, events);
- rtc_unlock(rtc->dev);
return events ? IRQ_HANDLED : IRQ_NONE;
}
--
2.56.0
^ permalink raw reply related [flat|nested] 38+ messages in thread* [PATCH 09/19] rtc: ds3232: use guard
2026-10-19 21:18 [PATCH 01/19] rtc: introduce rtc_device.ops_lock guard() alexandre.belloni
` (6 preceding siblings ...)
2026-10-19 21:18 ` [PATCH 08/19] rtc: ds1685: " alexandre.belloni
@ 2026-10-19 21:18 ` alexandre.belloni
2026-10-19 21:22 ` sashiko-bot
2026-10-19 21:18 ` [PATCH 10/19] rtc: hym8563: " alexandre.belloni
` (10 subsequent siblings)
18 siblings, 1 reply; 38+ messages in thread
From: alexandre.belloni @ 2026-10-19 21:18 UTC (permalink / raw)
To: Alexandre Belloni; +Cc: linux-rtc, linux-kernel
From: Alexandre Belloni <alexandre.belloni@bootlin.com>
Use guard() to simplify error handling
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
---
drivers/rtc/rtc-ds3232.c | 50 ++++++++++++++++++----------------------
1 file changed, 22 insertions(+), 28 deletions(-)
diff --git a/drivers/rtc/rtc-ds3232.c b/drivers/rtc/rtc-ds3232.c
index d1ef9e0dad34..f6407c631d6d 100644
--- a/drivers/rtc/rtc-ds3232.c
+++ b/drivers/rtc/rtc-ds3232.c
@@ -389,45 +389,39 @@ static irqreturn_t ds3232_irq(int irq, void *dev_id)
int ret;
int stat, control;
- rtc_lock(ds3232->rtc);
+ guard(rtc_ops)(ds3232->rtc);
ret = regmap_read(ds3232->regmap, DS3232_REG_SR, &stat);
if (ret)
- goto unlock;
+ return IRQ_HANDLED;
if (stat & DS3232_REG_SR_A1F) {
ret = regmap_read(ds3232->regmap, DS3232_REG_CR, &control);
if (ret) {
dev_warn(ds3232->dev,
"Read Control Register error %d\n", ret);
- } else {
- /* disable alarm1 interrupt */
- control &= ~(DS3232_REG_CR_A1IE);
- ret = regmap_write(ds3232->regmap, DS3232_REG_CR,
- control);
- if (ret) {
- dev_warn(ds3232->dev,
- "Write Control Register error %d\n",
- ret);
- goto unlock;
- }
-
- /* clear the alarm pend flag */
- stat &= ~DS3232_REG_SR_A1F;
- ret = regmap_write(ds3232->regmap, DS3232_REG_SR, stat);
- if (ret) {
- dev_warn(ds3232->dev,
- "Write Status Register error %d\n",
- ret);
- goto unlock;
- }
-
- rtc_update_irq(ds3232->rtc, 1, RTC_AF | RTC_IRQF);
+ return IRQ_HANDLED;
+ }
+ /* disable alarm1 interrupt */
+ control &= ~(DS3232_REG_CR_A1IE);
+ ret = regmap_write(ds3232->regmap, DS3232_REG_CR, control);
+ if (ret) {
+ dev_warn(ds3232->dev,
+ "Write Control Register error %d\n", ret);
+ return IRQ_HANDLED;
}
- }
-unlock:
- rtc_unlock(ds3232->rtc);
+ /* clear the alarm pend flag */
+ stat &= ~DS3232_REG_SR_A1F;
+ ret = regmap_write(ds3232->regmap, DS3232_REG_SR, stat);
+ if (ret) {
+ dev_warn(ds3232->dev,
+ "Write Status Register error %d\n", ret);
+ return IRQ_HANDLED;
+ }
+
+ rtc_update_irq(ds3232->rtc, 1, RTC_AF | RTC_IRQF);
+ }
return IRQ_HANDLED;
}
--
2.56.0
^ permalink raw reply related [flat|nested] 38+ messages in thread* [PATCH 10/19] rtc: hym8563: use guard
2026-10-19 21:18 [PATCH 01/19] rtc: introduce rtc_device.ops_lock guard() alexandre.belloni
` (7 preceding siblings ...)
2026-10-19 21:18 ` [PATCH 09/19] rtc: ds3232: " alexandre.belloni
@ 2026-10-19 21:18 ` alexandre.belloni
2026-10-19 21:22 ` sashiko-bot
2026-10-19 21:18 ` [PATCH 11/19] rtc: m41t80: " alexandre.belloni
` (9 subsequent siblings)
18 siblings, 1 reply; 38+ messages in thread
From: alexandre.belloni @ 2026-10-19 21:18 UTC (permalink / raw)
To: Alexandre Belloni; +Cc: linux-rtc, linux-kernel
From: Alexandre Belloni <alexandre.belloni@bootlin.com>
Use guard() to simplify error handling
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
---
drivers/rtc/rtc-hym8563.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/drivers/rtc/rtc-hym8563.c b/drivers/rtc/rtc-hym8563.c
index 1d52cc3def02..e3d7ca477e75 100644
--- a/drivers/rtc/rtc-hym8563.c
+++ b/drivers/rtc/rtc-hym8563.c
@@ -417,7 +417,7 @@ static irqreturn_t hym8563_irq(int irq, void *dev_id)
struct i2c_client *client = hym8563->client;
int data, ret;
- rtc_lock(hym8563->rtc);
+ guard(rtc_ops)(hym8563->rtc);
/* Clear the alarm flag */
@@ -425,7 +425,7 @@ static irqreturn_t hym8563_irq(int irq, void *dev_id)
if (data < 0) {
dev_err(&client->dev, "%s: error reading i2c data %d\n",
__func__, data);
- goto out;
+ return IRQ_HANDLED;
}
data &= ~HYM8563_CTL2_AF;
@@ -436,8 +436,6 @@ static irqreturn_t hym8563_irq(int irq, void *dev_id)
__func__, ret);
}
-out:
- rtc_unlock(hym8563->rtc);
return IRQ_HANDLED;
}
--
2.56.0
^ permalink raw reply related [flat|nested] 38+ messages in thread* [PATCH 11/19] rtc: m41t80: use guard
2026-10-19 21:18 [PATCH 01/19] rtc: introduce rtc_device.ops_lock guard() alexandre.belloni
` (8 preceding siblings ...)
2026-10-19 21:18 ` [PATCH 10/19] rtc: hym8563: " alexandre.belloni
@ 2026-10-19 21:18 ` alexandre.belloni
2026-10-19 21:22 ` sashiko-bot
2026-10-19 21:18 ` [PATCH 12/19] rtc: mcp795: " alexandre.belloni
` (8 subsequent siblings)
18 siblings, 1 reply; 38+ messages in thread
From: alexandre.belloni @ 2026-10-19 21:18 UTC (permalink / raw)
To: Alexandre Belloni; +Cc: linux-rtc, linux-kernel
From: Alexandre Belloni <alexandre.belloni@bootlin.com>
Use guard() to simplify error handling
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
---
drivers/rtc/rtc-m41t80.c | 12 +++---------
1 file changed, 3 insertions(+), 9 deletions(-)
diff --git a/drivers/rtc/rtc-m41t80.c b/drivers/rtc/rtc-m41t80.c
index ec86ca3f2c4c..1385cb43864b 100644
--- a/drivers/rtc/rtc-m41t80.c
+++ b/drivers/rtc/rtc-m41t80.c
@@ -162,19 +162,15 @@ static irqreturn_t m41t80_handle_irq(int irq, void *dev_id)
unsigned long events = 0;
int flags, flags_afe;
- rtc_lock(m41t80->rtc);
+ guard(rtc_ops)(m41t80->rtc);
flags_afe = i2c_smbus_read_byte_data(client, M41T80_REG_ALARM_MON);
- if (flags_afe < 0) {
- rtc_unlock(m41t80->rtc);
+ if (flags_afe < 0)
return IRQ_NONE;
- }
flags = i2c_smbus_read_byte_data(client, M41T80_REG_FLAGS);
- if (flags <= 0) {
- rtc_unlock(m41t80->rtc);
+ if (flags <= 0)
return IRQ_NONE;
- }
if (flags & M41T80_FLAGS_AF) {
flags &= ~M41T80_FLAGS_AF;
@@ -189,8 +185,6 @@ static irqreturn_t m41t80_handle_irq(int irq, void *dev_id)
flags_afe);
}
- rtc_unlock(m41t80->rtc);
-
return IRQ_HANDLED;
}
--
2.56.0
^ permalink raw reply related [flat|nested] 38+ messages in thread* [PATCH 12/19] rtc: mcp795: use guard
2026-10-19 21:18 [PATCH 01/19] rtc: introduce rtc_device.ops_lock guard() alexandre.belloni
` (9 preceding siblings ...)
2026-10-19 21:18 ` [PATCH 11/19] rtc: m41t80: " alexandre.belloni
@ 2026-10-19 21:18 ` alexandre.belloni
2026-10-19 21:22 ` sashiko-bot
2026-10-19 21:18 ` [PATCH 13/19] rtc: nct6694: " alexandre.belloni
` (7 subsequent siblings)
18 siblings, 1 reply; 38+ messages in thread
From: alexandre.belloni @ 2026-10-19 21:18 UTC (permalink / raw)
To: Alexandre Belloni; +Cc: linux-rtc, linux-kernel
From: Alexandre Belloni <alexandre.belloni@bootlin.com>
Use guard() to simplify locking
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
---
drivers/rtc/rtc-mcp795.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/drivers/rtc/rtc-mcp795.c b/drivers/rtc/rtc-mcp795.c
index e12f0f806ec4..9b5b36b88122 100644
--- a/drivers/rtc/rtc-mcp795.c
+++ b/drivers/rtc/rtc-mcp795.c
@@ -352,7 +352,7 @@ static irqreturn_t mcp795_irq(int irq, void *data)
struct rtc_device *rtc = spi_get_drvdata(spi);
int ret;
- rtc_lock(rtc);
+ guard(rtc_ops)(rtc);
/* Disable alarm.
* There is no need to clear ALM0IF (Alarm 0 Interrupt Flag) bit,
@@ -364,7 +364,6 @@ static irqreturn_t mcp795_irq(int irq, void *data)
"Failed to disable alarm in IRQ (ret=%d)\n", ret);
rtc_update_irq(rtc, 1, RTC_AF | RTC_IRQF);
- rtc_unlock(rtc);
return IRQ_HANDLED;
}
--
2.56.0
^ permalink raw reply related [flat|nested] 38+ messages in thread* [PATCH 13/19] rtc: nct6694: use guard
2026-10-19 21:18 [PATCH 01/19] rtc: introduce rtc_device.ops_lock guard() alexandre.belloni
` (10 preceding siblings ...)
2026-10-19 21:18 ` [PATCH 12/19] rtc: mcp795: " alexandre.belloni
@ 2026-10-19 21:18 ` alexandre.belloni
2026-10-19 21:21 ` sashiko-bot
2026-10-19 21:18 ` [PATCH 14/19] rtc: pcf2123: " alexandre.belloni
` (6 subsequent siblings)
18 siblings, 1 reply; 38+ messages in thread
From: alexandre.belloni @ 2026-10-19 21:18 UTC (permalink / raw)
To: Ming Yu, Alexandre Belloni; +Cc: linux-rtc, linux-kernel
From: Alexandre Belloni <alexandre.belloni@bootlin.com>
Use guard() to simplify locking
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
---
drivers/rtc/rtc-nct6694.c | 8 ++------
1 file changed, 2 insertions(+), 6 deletions(-)
diff --git a/drivers/rtc/rtc-nct6694.c b/drivers/rtc/rtc-nct6694.c
index 35401a0d9cf5..1cf9b672256a 100644
--- a/drivers/rtc/rtc-nct6694.c
+++ b/drivers/rtc/rtc-nct6694.c
@@ -210,20 +210,16 @@ static irqreturn_t nct6694_irq(int irq, void *dev_id)
};
int ret;
- rtc_lock(data->rtc);
+ guard(rtc_ops)(data->rtc);
sts->irq_en = NCT6694_RTC_IRQ_EN;
sts->irq_pend = NCT6694_RTC_IRQ_STS;
ret = nct6694_write_msg(data->nct6694, &cmd_hd, sts);
- if (ret) {
- rtc_unlock(data->rtc);
+ if (ret)
return IRQ_NONE;
- }
rtc_update_irq(data->rtc, 1, RTC_IRQF | RTC_AF);
- rtc_unlock(data->rtc);
-
return IRQ_HANDLED;
}
--
2.56.0
^ permalink raw reply related [flat|nested] 38+ messages in thread* [PATCH 14/19] rtc: pcf2123: use guard
2026-10-19 21:18 [PATCH 01/19] rtc: introduce rtc_device.ops_lock guard() alexandre.belloni
` (11 preceding siblings ...)
2026-10-19 21:18 ` [PATCH 13/19] rtc: nct6694: " alexandre.belloni
@ 2026-10-19 21:18 ` alexandre.belloni
2026-10-19 21:22 ` sashiko-bot
2026-10-19 21:18 ` [PATCH 15/19] rtc: rv3029c2: " alexandre.belloni
` (5 subsequent siblings)
18 siblings, 1 reply; 38+ messages in thread
From: alexandre.belloni @ 2026-10-19 21:18 UTC (permalink / raw)
To: Alexandre Belloni; +Cc: linux-rtc, linux-kernel
From: Alexandre Belloni <alexandre.belloni@bootlin.com>
Use guard() to simplify locking
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
---
drivers/rtc/rtc-pcf2123.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/drivers/rtc/rtc-pcf2123.c b/drivers/rtc/rtc-pcf2123.c
index e714661e61a9..22c626d57090 100644
--- a/drivers/rtc/rtc-pcf2123.c
+++ b/drivers/rtc/rtc-pcf2123.c
@@ -310,7 +310,8 @@ static irqreturn_t pcf2123_rtc_irq(int irq, void *dev)
unsigned int val = 0;
int ret = IRQ_NONE;
- rtc_lock(pcf2123->rtc);
+ guard(rtc_ops)(pcf2123->rtc);
+
regmap_read(pcf2123->map, PCF2123_REG_CTRL2, &val);
/* Alarm? */
@@ -323,8 +324,6 @@ static irqreturn_t pcf2123_rtc_irq(int irq, void *dev)
rtc_update_irq(pcf2123->rtc, 1, RTC_IRQF | RTC_AF);
}
- rtc_unlock(pcf2123->rtc);
-
return ret;
}
--
2.56.0
^ permalink raw reply related [flat|nested] 38+ messages in thread* [PATCH 15/19] rtc: rv3029c2: use guard
2026-10-19 21:18 [PATCH 01/19] rtc: introduce rtc_device.ops_lock guard() alexandre.belloni
` (12 preceding siblings ...)
2026-10-19 21:18 ` [PATCH 14/19] rtc: pcf2123: " alexandre.belloni
@ 2026-10-19 21:18 ` alexandre.belloni
2026-10-19 21:22 ` sashiko-bot
2026-10-19 21:18 ` [PATCH 16/19] rtc: rx8010: " alexandre.belloni
` (4 subsequent siblings)
18 siblings, 1 reply; 38+ messages in thread
From: alexandre.belloni @ 2026-10-19 21:18 UTC (permalink / raw)
To: Alexandre Belloni; +Cc: linux-rtc, linux-kernel
From: Alexandre Belloni <alexandre.belloni@bootlin.com>
Use guard() to simplify error handling
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
---
drivers/rtc/rtc-rv3029c2.c | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)
diff --git a/drivers/rtc/rtc-rv3029c2.c b/drivers/rtc/rtc-rv3029c2.c
index 98953af2a24a..c348b31928e9 100644
--- a/drivers/rtc/rtc-rv3029c2.c
+++ b/drivers/rtc/rtc-rv3029c2.c
@@ -270,19 +270,17 @@ static irqreturn_t rv3029_handle_irq(int irq, void *dev_id)
unsigned long events = 0;
int ret;
- rtc_lock(rv3029->rtc);
+ guard(rtc_ops)(rv3029->rtc);
ret = regmap_read(rv3029->regmap, RV3029_IRQ_CTRL, &controls);
if (ret) {
dev_warn(dev, "Read IRQ Control Register error %d\n", ret);
- rtc_unlock(rv3029->rtc);
return IRQ_NONE;
}
ret = regmap_read(rv3029->regmap, RV3029_IRQ_FLAGS, &flags);
if (ret) {
dev_warn(dev, "Read IRQ Flags Register error %d\n", ret);
- rtc_unlock(rv3029->rtc);
return IRQ_NONE;
}
@@ -297,7 +295,6 @@ static irqreturn_t rv3029_handle_irq(int irq, void *dev_id)
regmap_write(rv3029->regmap, RV3029_IRQ_FLAGS, flags);
regmap_write(rv3029->regmap, RV3029_IRQ_CTRL, controls);
}
- rtc_unlock(rv3029->rtc);
return IRQ_HANDLED;
}
--
2.56.0
^ permalink raw reply related [flat|nested] 38+ messages in thread* [PATCH 16/19] rtc: rx8010: use guard
2026-10-19 21:18 [PATCH 01/19] rtc: introduce rtc_device.ops_lock guard() alexandre.belloni
` (13 preceding siblings ...)
2026-10-19 21:18 ` [PATCH 15/19] rtc: rv3029c2: " alexandre.belloni
@ 2026-10-19 21:18 ` alexandre.belloni
2026-10-19 21:22 ` sashiko-bot
2026-10-19 21:18 ` [PATCH 17/19] rtc: rx8025: " alexandre.belloni
` (3 subsequent siblings)
18 siblings, 1 reply; 38+ messages in thread
From: alexandre.belloni @ 2026-10-19 21:18 UTC (permalink / raw)
To: Alexandre Belloni; +Cc: linux-rtc, linux-kernel
From: Alexandre Belloni <alexandre.belloni@bootlin.com>
Use guard() to simplify error handling
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
---
drivers/rtc/rtc-rx8010.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/drivers/rtc/rtc-rx8010.c b/drivers/rtc/rtc-rx8010.c
index ce3954132336..0a9be6ea62d0 100644
--- a/drivers/rtc/rtc-rx8010.c
+++ b/drivers/rtc/rtc-rx8010.c
@@ -73,11 +73,10 @@ static irqreturn_t rx8010_irq_1_handler(int irq, void *dev_id)
struct rx8010_data *rx8010 = i2c_get_clientdata(client);
int flagreg, err;
- rtc_lock(rx8010->rtc);
+ guard(rtc_ops)(rx8010->rtc);
err = regmap_read(rx8010->regs, RX8010_FLAG, &flagreg);
if (err) {
- rtc_unlock(rx8010->rtc);
return IRQ_NONE;
}
@@ -100,7 +99,6 @@ static irqreturn_t rx8010_irq_1_handler(int irq, void *dev_id)
}
err = regmap_write(rx8010->regs, RX8010_FLAG, flagreg);
- rtc_unlock(rx8010->rtc);
return err ? IRQ_NONE : IRQ_HANDLED;
}
--
2.56.0
^ permalink raw reply related [flat|nested] 38+ messages in thread* [PATCH 17/19] rtc: rx8025: use guard
2026-10-19 21:18 [PATCH 01/19] rtc: introduce rtc_device.ops_lock guard() alexandre.belloni
` (14 preceding siblings ...)
2026-10-19 21:18 ` [PATCH 16/19] rtc: rx8010: " alexandre.belloni
@ 2026-10-19 21:18 ` alexandre.belloni
2026-10-19 21:22 ` sashiko-bot
2026-10-19 21:18 ` [PATCH 18/19] rtc: stm32: " alexandre.belloni
` (2 subsequent siblings)
18 siblings, 1 reply; 38+ messages in thread
From: alexandre.belloni @ 2026-10-19 21:18 UTC (permalink / raw)
To: Alexandre Belloni; +Cc: linux-rtc, linux-kernel
From: Alexandre Belloni <alexandre.belloni@bootlin.com>
Use guard() to simplify error handling
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
---
drivers/rtc/rtc-rx8025.c | 10 ++++------
1 file changed, 4 insertions(+), 6 deletions(-)
diff --git a/drivers/rtc/rtc-rx8025.c b/drivers/rtc/rtc-rx8025.c
index 5eeaa929f3ef..2f2deb59cbee 100644
--- a/drivers/rtc/rtc-rx8025.c
+++ b/drivers/rtc/rtc-rx8025.c
@@ -180,10 +180,11 @@ static irqreturn_t rx8025_handle_irq(int irq, void *dev_id)
struct rx8025_data *rx8025 = i2c_get_clientdata(client);
int status, xstp;
- rtc_lock(rx8025->rtc);
+ guard(rtc_ops)(rx8025->rtc);
+
status = rx8025_read_reg(client, RX8025_REG_CTRL2);
if (status < 0)
- goto out;
+ return IRQ_HANDLED;
xstp = rx8025_is_osc_stopped(rx8025->model, status);
if (xstp)
@@ -201,13 +202,10 @@ static irqreturn_t rx8025_handle_irq(int irq, void *dev_id)
status &= RX8025_BIT_CTRL2_DAFG;
if (rx8025_write_reg(client, RX8025_REG_CTRL1,
rx8025->ctrl1 & ~RX8025_BIT_CTRL1_DALE))
- goto out;
+ return IRQ_HANDLED;
rtc_update_irq(rx8025->rtc, 1, RTC_AF | RTC_IRQF);
}
-out:
- rtc_unlock(rx8025->rtc);
-
return IRQ_HANDLED;
}
--
2.56.0
^ permalink raw reply related [flat|nested] 38+ messages in thread* [PATCH 18/19] rtc: stm32: use guard
2026-10-19 21:18 [PATCH 01/19] rtc: introduce rtc_device.ops_lock guard() alexandre.belloni
` (15 preceding siblings ...)
2026-10-19 21:18 ` [PATCH 17/19] rtc: rx8025: " alexandre.belloni
@ 2026-10-19 21:18 ` alexandre.belloni
2026-10-19 21:22 ` sashiko-bot
2026-10-19 21:18 ` [PATCH 19/19] rtc: abx80x: simplify locking alexandre.belloni
2026-10-19 21:22 ` [PATCH 01/19] rtc: introduce rtc_device.ops_lock guard() sashiko-bot
18 siblings, 1 reply; 38+ messages in thread
From: alexandre.belloni @ 2026-10-19 21:18 UTC (permalink / raw)
To: Alexandre Belloni, Maxime Coquelin, Alexandre Torgue
Cc: linux-rtc, linux-stm32, linux-arm-kernel, linux-kernel
From: Alexandre Belloni <alexandre.belloni@bootlin.com>
Use guard() to simplify locking
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
---
drivers/rtc/rtc-stm32.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/drivers/rtc/rtc-stm32.c b/drivers/rtc/rtc-stm32.c
index d4ebf3eb54aa..1c4e4bd7afe4 100644
--- a/drivers/rtc/rtc-stm32.c
+++ b/drivers/rtc/rtc-stm32.c
@@ -465,7 +465,7 @@ static irqreturn_t stm32_rtc_alarm_irq(int irq, void *dev_id)
const struct stm32_rtc_events *evts = &rtc->data->events;
unsigned int status, cr;
- rtc_lock(rtc->rtc_dev);
+ guard(rtc_ops)(rtc->rtc_dev);
status = readl_relaxed(rtc->base + regs->sr);
cr = readl_relaxed(rtc->base + regs->cr);
@@ -482,8 +482,6 @@ static irqreturn_t stm32_rtc_alarm_irq(int irq, void *dev_id)
stm32_rtc_clear_event_flags(rtc, evts->alra);
}
- rtc_unlock(rtc->rtc_dev);
-
return IRQ_HANDLED;
}
--
2.56.0
^ permalink raw reply related [flat|nested] 38+ messages in thread* [PATCH 19/19] rtc: abx80x: simplify locking
2026-10-19 21:18 [PATCH 01/19] rtc: introduce rtc_device.ops_lock guard() alexandre.belloni
` (16 preceding siblings ...)
2026-10-19 21:18 ` [PATCH 18/19] rtc: stm32: " alexandre.belloni
@ 2026-10-19 21:18 ` alexandre.belloni
2026-10-19 21:25 ` sashiko-bot
2026-10-19 21:22 ` [PATCH 01/19] rtc: introduce rtc_device.ops_lock guard() sashiko-bot
18 siblings, 1 reply; 38+ messages in thread
From: alexandre.belloni @ 2026-10-19 21:18 UTC (permalink / raw)
To: Alexandre Belloni; +Cc: linux-rtc, linux-kernel
From: Alexandre Belloni <alexandre.belloni@bootlin.com>
Use the ops_lock that is used by the core to lock operations. This ensures
we will never get any ABBA deadlock.
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
---
drivers/rtc/rtc-abx80x.c | 27 +++++++--------------------
1 file changed, 7 insertions(+), 20 deletions(-)
diff --git a/drivers/rtc/rtc-abx80x.c b/drivers/rtc/rtc-abx80x.c
index 718e6b8555f5..1c69d0e2f940 100644
--- a/drivers/rtc/rtc-abx80x.c
+++ b/drivers/rtc/rtc-abx80x.c
@@ -15,7 +15,6 @@
#include <linux/i2c.h>
#include <linux/kstrtox.h>
#include <linux/module.h>
-#include <linux/mutex.h>
#include <linux/of.h>
#include <linux/regmap.h>
#include <linux/rtc.h>
@@ -138,7 +137,6 @@ struct abx80x_priv {
struct rtc_device *rtc;
struct regmap *regmap;
struct watchdog_device wdog;
- struct mutex lock;
int irq;
};
@@ -249,8 +247,6 @@ static int abx80x_rtc_set_time(struct device *dev, struct rtc_time *tm)
buf[ABX8XX_REG_YR] = bin2bcd(tm->tm_year - 100);
buf[ABX8XX_REG_WD] = tm->tm_wday;
- guard(mutex)(&priv->lock);
-
err = regmap_bulk_write(priv->regmap, ABX8XX_REG_HTH, buf,
sizeof(buf));
if (err < 0) {
@@ -274,7 +270,7 @@ static irqreturn_t abx80x_handle_irq(int irq, void *dev_id)
unsigned int status, status_flags_clear;
int err;
- guard(mutex)(&priv->lock);
+ guard(rtc_ops)(rtc);
err = regmap_read(priv->regmap, ABX8XX_REG_STATUS, &status);
if (err < 0)
@@ -349,8 +345,6 @@ static int abx80x_set_alarm(struct device *dev, struct rtc_wkalrm *t)
alarm[4] = bin2bcd(t->time.tm_mday);
alarm[5] = bin2bcd(t->time.tm_mon + 1);
- guard(mutex)(&priv->lock);
-
err = regmap_bulk_write(priv->regmap, ABX8XX_REG_AHTH,
alarm, sizeof(alarm));
if (err < 0) {
@@ -391,7 +385,7 @@ static int abx80x_rtc_set_autocalibration(struct device *dev,
flags |= (ABX8XX_OSC_ACAL_1024 | ABX8XX_OSC_ACAL_512);
}
- guard(mutex)(&priv->lock);
+ guard(rtc_ops)(priv->rtc);
/* Unlock write access to Oscillator Control Register */
if (abx80x_write_config_key(dev, ABX8XX_CFG_KEY_OSC) < 0)
@@ -473,7 +467,7 @@ static ssize_t oscillator_store(struct device *dev,
return -EINVAL;
}
- guard(mutex)(&priv->lock);
+ guard(rtc_ops)(priv->rtc);
/* Unlock write access on Oscillator Control register */
if (abx80x_write_config_key(dev->parent, ABX8XX_CFG_KEY_OSC) < 0)
@@ -523,8 +517,6 @@ static int abx80x_alarm_irq_enable(struct device *dev, unsigned int enabled)
struct abx80x_priv *priv = dev_get_drvdata(dev);
int err;
- guard(mutex)(&priv->lock);
-
if (enabled)
err = regmap_write(priv->regmap, ABX8XX_REG_IRQ,
ABX8XX_IRQ_IM_1_4 | ABX8XX_IRQ_AIE);
@@ -551,10 +543,8 @@ static int abx80x_ioctl(struct device *dev, unsigned int cmd, unsigned long arg)
return put_user(tmp, (unsigned int __user *)arg);
case RTC_VL_CLR:
- scoped_guard(mutex, &priv->lock) {
- err = regmap_update_bits(priv->regmap, ABX8XX_REG_STATUS,
- ABX8XX_STATUS_BLF, 0);
- }
+ err = regmap_update_bits(priv->regmap, ABX8XX_REG_STATUS,
+ ABX8XX_STATUS_BLF, 0);
return err;
@@ -623,7 +613,7 @@ static int __abx80x_wdog_set_timeout(struct watchdog_device *wdog,
struct abx80x_priv *priv = watchdog_get_drvdata(wdog);
u8 val = ABX8XX_WDT_WDS | timeout_bits(timeout);
- guard(mutex)(&priv->lock);
+ guard(rtc_ops)(priv->rtc);
/*
* Writing any timeout to the WDT register resets the watchdog timer.
@@ -710,7 +700,7 @@ static int abx80x_nvmem_xfer(struct abx80x_priv *priv, unsigned int offset,
len = min(lower + bytes, (size_t)ABX8XX_SRAM_WIN_SIZE) - lower;
len = min_t(u8, len, I2C_SMBUS_BLOCK_MAX);
- guard(mutex)(&priv->lock);
+ guard(rtc_ops)(priv->rtc);
ret = regmap_update_bits(priv->regmap, ABX8XX_REG_EXTRAM,
ABX8XX_EXTRAM_XADS, upper);
@@ -806,9 +796,6 @@ static int abx80x_probe(struct device *dev, struct regmap *regmap, int irq,
priv->rtc->ops = &abx80x_rtc_ops;
priv->irq = irq;
priv->regmap = regmap;
- err = devm_mutex_init(dev, &priv->lock);
- if (err)
- return err;
dev_set_drvdata(dev, priv);
--
2.56.0
^ permalink raw reply related [flat|nested] 38+ messages in thread* Re: [PATCH 01/19] rtc: introduce rtc_device.ops_lock guard()
2026-10-19 21:18 [PATCH 01/19] rtc: introduce rtc_device.ops_lock guard() alexandre.belloni
` (17 preceding siblings ...)
2026-10-19 21:18 ` [PATCH 19/19] rtc: abx80x: simplify locking alexandre.belloni
@ 2026-10-19 21:22 ` sashiko-bot
18 siblings, 0 replies; 38+ messages in thread
From: sashiko-bot @ 2026-10-19 21:22 UTC (permalink / raw)
To: alexandre.belloni; +Cc: linux-rtc
> From: Alexandre Belloni <alexandre.belloni@bootlin.com>
>
> 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@bootlin.com>
Sashiko has reviewed this patch and found no issues.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261019211827.126262-1-alexandre.belloni@bootlin.com?part=1
^ permalink raw reply [flat|nested] 38+ messages in thread