* [PATCH v2] checkpatch: Add warnings for use of mdelay()
@ 2010-07-27 17:27 Israel Schlesinger
2010-07-28 3:16 ` Américo Wang
0 siblings, 1 reply; 2+ messages in thread
From: Israel Schlesinger @ 2010-07-27 17:27 UTC (permalink / raw)
To: linux-kernel; +Cc: apw, akpm, joe
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..9ce1cb5 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\s*\(/) {
+ 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
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH v2] checkpatch: Add warnings for use of mdelay()
2010-07-27 17:27 [PATCH v2] checkpatch: Add warnings for use of mdelay() Israel Schlesinger
@ 2010-07-28 3:16 ` Américo Wang
0 siblings, 0 replies; 2+ messages in thread
From: Américo Wang @ 2010-07-28 3:16 UTC (permalink / raw)
To: Israel Schlesinger; +Cc: linux-kernel, apw, akpm, joe
On Tue, Jul 27, 2010 at 10:27:10AM -0700, Israel Schlesinger wrote:
>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
>
Then udelay() is also preferred...
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2010-07-28 3:11 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-07-27 17:27 [PATCH v2] checkpatch: Add warnings for use of mdelay() Israel Schlesinger
2010-07-28 3:16 ` Américo Wang
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox