mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Thomas Gleixner <tglx@linutronix.de>
To: Su Hui <suhui@nfschina.com>, jstultz@google.com, sboyd@kernel.org
Cc: Su Hui <suhui@nfschina.com>,
	dan.carpenter@linaro.org, linux-kernel@vger.kernel.org,
	kernel-janitors@vger.kernel.org
Subject: Re: [PATCH v3 3/3] alarmtimer: switch some spin_{lock,unlock}_irqsave() to guard()
Date: Wed, 30 Apr 2025 09:04:58 +0200	[thread overview]
Message-ID: <87v7qmp1t1.ffs@tglx> (raw)
In-Reply-To: <20250430032734.2079290-4-suhui@nfschina.com>

On Wed, Apr 30 2025 at 11:27, Su Hui wrote:
> -	spin_lock_irqsave(&rtcdev_lock, flags);
> -	if (!IS_ERR(pdev) && !rtcdev) {
> -		if (!try_module_get(rtc->owner)) {
> +	scoped_guard(spinlock_irqsave, &rtcdev_lock) {
> +		if (!IS_ERR(pdev) && !rtcdev) {
> +			if (!try_module_get(rtc->owner)) {
> +				ret = -1;
> +				break;

This really reads odd and relies on the internals of scoped_guard(). I
actually had to look at the scoped_guard() implementation to validate
it.

The whole thing can be simplified to:

 	scoped_guard(spinlock_irqsave, &rtcdev_lock) {
		if (!IS_ERR(pdev) && !rtcdev && try_module_get(rtc->owner)) {
 			rtcdev = rtc;
 			/* hold a reference so it doesn't go away */
 			get_device(dev);
                        pdev = NULL;
		} else {
 			ret = -1;
		}

No?

No need to resend. I fixed it up already.

Thanks,

        tglx

  reply	other threads:[~2025-04-30  7:05 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-04-30  3:27 [PATCH v3 0/3] time: some cleanup for jiffies and alarmtimer Su Hui
2025-04-30  3:27 ` [PATCH v3 1/3] time/jiffies: change register_refined_jiffies() to void __init Su Hui
2025-04-30  7:22   ` [tip: timers/core] time/jiffies: Change " tip-bot2 for Su Hui
2025-04-30  3:27 ` [PATCH v3 2/3] alarmtimer: remove dead return value in clock2alarm() Su Hui
2025-04-30  7:22   ` [tip: timers/core] alarmtimer: Remove " tip-bot2 for Su Hui
2025-04-30 22:14   ` [PATCH v3 2/3] alarmtimer: remove " John Stultz
2025-04-30  3:27 ` [PATCH v3 3/3] alarmtimer: switch some spin_{lock,unlock}_irqsave() to guard() Su Hui
2025-04-30  7:04   ` Thomas Gleixner [this message]
2025-04-30  7:19     ` Su Hui
2025-04-30  7:22   ` [tip: timers/core] alarmtimer: Switch spin_{lock,unlock}_irqsave() to guards tip-bot2 for Su Hui

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=87v7qmp1t1.ffs@tglx \
    --to=tglx@linutronix.de \
    --cc=dan.carpenter@linaro.org \
    --cc=jstultz@google.com \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=sboyd@kernel.org \
    --cc=suhui@nfschina.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

all inboxes | Powered by JetHome®