linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Israel Schlesinger <israels@codeaurora.org>
To: linux-kernel@vger.kernel.org
Cc: apw@canonical.com, akpm@linux-foundation.org, joe@perches.com
Subject: [PATCH] checkpatch: Add warnings for use of mdelay()
Date: Tue, 27 Jul 2010 10:11:11 -0700	[thread overview]
Message-ID: <4C4F132F.6020401@codeaurora.org> (raw)

mdelay is a busy-wait loop which is wasteful. If at all possible,
callers should use msleep instead of mdelay.

The only time mdelay is really appropriate is in atomic context,
however, delays of 1ms+ in atomic context are rather expensive, so
a warning for this case is probably appropriate as well to encourage
people to move such expensive delays outside of atomic context

Signed-off-by: Israel Schlesinger <israels@codeaurora.org>
---
 scripts/checkpatch.pl |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index bd88f11..b3f7f71 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -2570,6 +2570,11 @@ sub process {
 			}
 		}
 
+# check the patch for use of mdelay
+		if ($line =~ /\bmdelay\(/) {
+			WARN("use of mdelay() found: msleep() is the preferred API.\n" . $line );
+		}
+
 # warn about #ifdefs in C files
 #		if ($line =~ /^.\s*\#\s*if(|n)def/ && ($realfile =~ /\.c$/)) {
 #			print "#ifdef in C files should be avoided\n";
-- 
1.7.0.2

-- 
Employee of Qualcomm Innovation Center, Inc. 
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum

             reply	other threads:[~2010-07-27 17:11 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-07-27 17:11 Israel Schlesinger [this message]
2010-07-27 17:22 ` [PATCH] checkpatch: Add warnings for use of mdelay() Joe Perches
2010-07-27 17:31 ` Jonathan Corbet
2010-07-27 17:32   ` Patrick Pannuto
2010-07-27 19:16     ` Andrew Morton
2010-07-28  9:44       ` Andy Whitcroft
2018-07-04 18:18 Prakruthi Deepak Heragu
2018-07-04 18:30 ` Joe Perches
2018-07-05  8:19   ` Dan Carpenter
2018-07-06  5:49     ` Julia Lawall
2018-07-07 12:09       ` Jia-Ju Bai

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=4C4F132F.6020401@codeaurora.org \
    --to=israels@codeaurora.org \
    --cc=akpm@linux-foundation.org \
    --cc=apw@canonical.com \
    --cc=joe@perches.com \
    --cc=linux-kernel@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;
as well as URLs for NNTP newsgroup(s).