From: alexandre.belloni@bootlin.com
To: Alexandre Belloni <alexandre.belloni@bootlin.com>
Cc: linux-rtc@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH 09/19] rtc: ds3232: use guard
Date: Mon, 19 Oct 2026 23:18:10 +0200 [thread overview]
Message-ID: <20261019211827.126262-9-alexandre.belloni@bootlin.com> (raw)
In-Reply-To: <20261019211827.126262-1-alexandre.belloni@bootlin.com>
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
next prev parent reply other threads:[~2026-10-19 21:19 UTC|newest]
Thread overview: 38+ messages / expand[flat|nested] mbox.gz Atom feed top
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:22 ` sashiko-bot
2026-10-19 21:18 ` [PATCH 03/19] rtc: asm9260: " alexandre.belloni
2026-10-19 21:23 ` sashiko-bot
2026-10-19 21:18 ` [PATCH 04/19] rtc: atcrtc100: " alexandre.belloni
2026-10-19 21:22 ` sashiko-bot
2026-10-19 21:18 ` [PATCH 05/19] rtc: ds1305: " alexandre.belloni
2026-10-19 21:23 ` sashiko-bot
2026-10-19 21:18 ` [PATCH 06/19] rtc: ds1307: " alexandre.belloni
2026-10-19 21:22 ` sashiko-bot
2026-10-19 21:18 ` [PATCH 07/19] rtc: ds1343: " alexandre.belloni
2026-10-19 21:22 ` sashiko-bot
2026-10-19 21:18 ` [PATCH 08/19] rtc: ds1685: " alexandre.belloni
2026-10-19 21:22 ` sashiko-bot
2026-10-19 21:18 ` alexandre.belloni [this message]
2026-10-19 21:22 ` [PATCH 09/19] rtc: ds3232: " sashiko-bot
2026-10-19 21:18 ` [PATCH 10/19] rtc: hym8563: " alexandre.belloni
2026-10-19 21:22 ` sashiko-bot
2026-10-19 21:18 ` [PATCH 11/19] rtc: m41t80: " alexandre.belloni
2026-10-19 21:22 ` sashiko-bot
2026-10-19 21:18 ` [PATCH 12/19] rtc: mcp795: " alexandre.belloni
2026-10-19 21:22 ` sashiko-bot
2026-10-19 21:18 ` [PATCH 13/19] rtc: nct6694: " alexandre.belloni
2026-10-19 21:21 ` sashiko-bot
2026-10-19 21:18 ` [PATCH 14/19] rtc: pcf2123: " alexandre.belloni
2026-10-19 21:22 ` sashiko-bot
2026-10-19 21:18 ` [PATCH 15/19] rtc: rv3029c2: " alexandre.belloni
2026-10-19 21:22 ` sashiko-bot
2026-10-19 21:18 ` [PATCH 16/19] rtc: rx8010: " alexandre.belloni
2026-10-19 21:22 ` sashiko-bot
2026-10-19 21:18 ` [PATCH 17/19] rtc: rx8025: " alexandre.belloni
2026-10-19 21:22 ` sashiko-bot
2026-10-19 21:18 ` [PATCH 18/19] rtc: stm32: " 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:25 ` sashiko-bot
2026-10-19 21:22 ` [PATCH 01/19] rtc: introduce rtc_device.ops_lock guard() sashiko-bot
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261019211827.126262-9-alexandre.belloni@bootlin.com \
--to=alexandre.belloni@bootlin.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rtc@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox