From: Joe Perches <joe@perches.com>
To: Neel Bullywon <neelb2403@gmail.com>, apw@canonical.com
Cc: dwaipayanray1@gmail.com, lukas.bulwahn@gmail.com,
andriy.shevchenko@intel.com, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] checkpatch: suggest fsleep() for short msleep() calls
Date: Sun, 08 Feb 2026 08:36:05 -0800 [thread overview]
Message-ID: <67577c238ead009b3b061a43d443dc69da2aee64.camel@perches.com> (raw)
In-Reply-To: <20260208155935.72687-1-neelb2403@gmail.com>
On Sun, 2026-02-08 at 10:59 -0500, Neel Bullywon wrote:
> Update the MSLEEP warning to suggest fsleep() as a duration based
> sleep API. fsleep() autoselects the best sleep mechanism (udelay,
> usleep_range, or msleep) based on the requested duration, making
> it the preferred replacement for short msleep() calls.
[]
> diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
[]
> @@ -6636,7 +6636,7 @@ sub process {
> if ($line =~ /\bmsleep\s*\((\d+)\);/) {
> if ($1 < 20) {
> WARN("MSLEEP",
> - "msleep < 20ms can sleep for up to 20ms; see function description of msleep().\n" . $herecurr);
> + "msleep < 20ms can sleep for up to 20ms; see function description of fsleep().\n" . $herecurr);
> }
> }
maybe change msleep to a #define macro so if the argument is
constant call fsleep instead
Something like:
#define msleep(msecs) \
do { \
if (__builtin_constant_p(msecs) && (msecs) < 20) \
fsleep((msecs) * 1000UL); \
else \
msleep(msecs); \
} while (0)
and change the definition of void msleep(unsigned int msecs) to
void (msleep)(unsigned int msecs)
{
etc...
}
and remove the checkpatch test.
next prev parent reply other threads:[~2026-02-08 16:36 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-08 15:59 Neel Bullywon
2026-02-08 16:36 ` Joe Perches [this message]
2026-02-08 18:41 ` Neel Bullywon
2026-02-08 18:44 ` Joe Perches
2026-02-09 8:32 ` Andy Shevchenko
2026-02-09 8:34 ` Andy Shevchenko
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=67577c238ead009b3b061a43d443dc69da2aee64.camel@perches.com \
--to=joe@perches.com \
--cc=andriy.shevchenko@intel.com \
--cc=apw@canonical.com \
--cc=dwaipayanray1@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=lukas.bulwahn@gmail.com \
--cc=neelb2403@gmail.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®