From: "Thomas Weißschuh" <linux@weissschuh.net>
To: John Stultz <jstultz@google.com>,
Thomas Gleixner <tglx@kernel.org>,
Stephen Boyd <sboyd@kernel.org>,
Miroslav Lichvar <mlichvar@redhat.com>
Cc: linux-kernel@vger.kernel.org, "Thomas Weißschuh" <linux@weissschuh.net>
Subject: [PATCH 2/3] alarmtimer: Return early if platform_device_register_data() fails
Date: Mon, 02 Nov 2026 06:11:55 +0000 [thread overview]
Message-ID: <20261102-alarmtimer-locking-v1-2-3c79a698aeae@weissschuh.net> (raw)
In-Reply-To: <20261102-alarmtimer-locking-v1-0-3c79a698aeae@weissschuh.net>
Simplify the logic by returning on error instead of having to handle the
potential error in each following operation.
Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
---
kernel/time/alarmtimer.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/kernel/time/alarmtimer.c b/kernel/time/alarmtimer.c
index e60c626e326b..9ab1b053a2fb 100644
--- a/kernel/time/alarmtimer.c
+++ b/kernel/time/alarmtimer.c
@@ -89,10 +89,12 @@ static int alarmtimer_rtc_add_device(struct device *dev)
pdev = platform_device_register_data(dev, "alarmtimer",
PLATFORM_DEVID_AUTO, NULL, 0);
- if (!IS_ERR(pdev))
- device_init_wakeup(&pdev->dev, true);
+ if (IS_ERR(pdev))
+ return PTR_ERR(pdev);
- if (!IS_ERR(pdev) && try_module_get(rtc->owner)) {
+ device_init_wakeup(&pdev->dev, true);
+
+ if (try_module_get(rtc->owner)) {
WRITE_ONCE(rtcdev, rtc);
/* hold a reference so it doesn't go away */
get_device(dev);
--
2.56.0
next prev parent reply other threads:[~2026-11-02 6:13 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-02 6:11 [PATCH 0/3] alarmtimer: Drop the spinlock around the rtcdev variable Thomas Weißschuh
2026-11-02 6:11 ` [PATCH 1/3] " Thomas Weißschuh
2026-11-02 6:11 ` Thomas Weißschuh [this message]
2026-11-02 6:11 ` [PATCH 3/3] alarmtimer: Return early if try_module_get() fails Thomas Weißschuh
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=20261102-alarmtimer-locking-v1-2-3c79a698aeae@weissschuh.net \
--to=linux@weissschuh.net \
--cc=jstultz@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mlichvar@redhat.com \
--cc=sboyd@kernel.org \
--cc=tglx@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
all inboxes | Powered by JetHome®