From: Markus Elfring <Markus.Elfring@web.de>
To: linux-rtc@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
Alexandre Belloni <alexandre.belloni@bootlin.com>,
Arnd Bergmann <arnd@arndb.de>,
Boris Brezillon <bbrezillon@kernel.org>,
Claudiu Beznea <claudiu.beznea@tuxon.dev>,
Johan Hovold <johan@kernel.org>,
Nicolas Ferre <nicolas.ferre@microchip.com>
Cc: LKML <linux-kernel@vger.kernel.org>,
kernel-janitors@vger.kernel.org,
Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
Christophe Jaillet <christophe.jaillet@wanadoo.fr>,
Florian Fainelli <f.fainelli@gmail.com>,
Frank Li <Frank.Li@kernel.org>
Subject: [PATCH] rtc: at91sam9: Use devm_clk_get_enabled() in at91_rtc_probe()
Date: Tue, 24 Nov 2026 08:20:10 +0100 [thread overview]
Message-ID: <d16d0991-d1d7-4828-8e05-8d8826cbb222@web.de> (raw)
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 24 Nov 2026 08:01:48 +0100
* Reuse existing functionality from devm_clk_get_enabled() instead of
keeping duplicate source code.
* Delete a clk_disable_unprepare() call on an error handling path
and in the implementation of the function “at91_rtc_remove”.
* Omit the label “err_clk”.
This issue was detected by using the Coccinelle software.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
drivers/rtc/rtc-at91sam9.c | 26 +++++---------------------
1 file changed, 5 insertions(+), 21 deletions(-)
diff --git a/drivers/rtc/rtc-at91sam9.c b/drivers/rtc/rtc-at91sam9.c
index cbd2f1a6c54a..6628335d6f46 100644
--- a/drivers/rtc/rtc-at91sam9.c
+++ b/drivers/rtc/rtc-at91sam9.c
@@ -375,21 +375,14 @@ static int at91_rtc_probe(struct platform_device *pdev)
return -ENOMEM;
}
- rtc->sclk = devm_clk_get(&pdev->dev, NULL);
+ rtc->sclk = devm_clk_get_enabled(&pdev->dev, NULL);
if (IS_ERR(rtc->sclk))
return PTR_ERR(rtc->sclk);
- ret = clk_prepare_enable(rtc->sclk);
- if (ret) {
- dev_err(&pdev->dev, "Could not enable slow clock\n");
- return ret;
- }
-
sclk_rate = clk_get_rate(rtc->sclk);
if (!sclk_rate || sclk_rate > AT91_RTT_RTPRES) {
dev_err(&pdev->dev, "Invalid slow clock rate\n");
- ret = -EINVAL;
- goto err_clk;
+ return -EINVAL;
}
mr = rtt_readl(rtc, MR);
@@ -405,10 +398,8 @@ static int at91_rtc_probe(struct platform_device *pdev)
rtt_writel(rtc, MR, mr);
rtc->rtcdev = devm_rtc_allocate_device(&pdev->dev);
- if (IS_ERR(rtc->rtcdev)) {
- ret = PTR_ERR(rtc->rtcdev);
- goto err_clk;
- }
+ if (IS_ERR(rtc->rtcdev))
+ return PTR_ERR(rtc->rtcdev);
rtc->rtcdev->ops = &at91_rtc_ops;
rtc->rtcdev->range_max = U32_MAX;
@@ -419,7 +410,7 @@ static int at91_rtc_probe(struct platform_device *pdev)
dev_name(&rtc->rtcdev->dev), rtc);
if (ret) {
dev_dbg(&pdev->dev, "can't share IRQ %d?\n", rtc->irq);
- goto err_clk;
+ return ret;
}
/* NOTE: sam9260 rev A silicon has a ROM bug which resets the
@@ -433,11 +424,6 @@ static int at91_rtc_probe(struct platform_device *pdev)
dev_name(&rtc->rtcdev->dev));
return devm_rtc_register_device(rtc->rtcdev);
-
-err_clk:
- clk_disable_unprepare(rtc->sclk);
-
- return ret;
}
/*
@@ -450,8 +436,6 @@ static void at91_rtc_remove(struct platform_device *pdev)
/* disable all interrupts */
rtt_writel(rtc, MR, mr & ~(AT91_RTT_ALMIEN | AT91_RTT_RTTINCIEN));
-
- clk_disable_unprepare(rtc->sclk);
}
static void at91_rtc_shutdown(struct platform_device *pdev)
--
2.56.1
next reply other threads:[~2026-11-24 7:21 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-24 7:20 Markus Elfring [this message]
2026-11-24 7:23 ` [PATCH] rtc: at91sam9: Use devm_clk_get_enabled() in at91_rtc_probe() 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=d16d0991-d1d7-4828-8e05-8d8826cbb222@web.de \
--to=markus.elfring@web.de \
--cc=Frank.Li@kernel.org \
--cc=alexandre.belloni@bootlin.com \
--cc=andriy.shevchenko@linux.intel.com \
--cc=arnd@arndb.de \
--cc=bbrezillon@kernel.org \
--cc=christophe.jaillet@wanadoo.fr \
--cc=claudiu.beznea@tuxon.dev \
--cc=f.fainelli@gmail.com \
--cc=johan@kernel.org \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rtc@vger.kernel.org \
--cc=nicolas.ferre@microchip.com \
/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