linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] checkpatch: Add warnings for use of mdelay()
@ 2010-07-27 17:11 Israel Schlesinger
  2010-07-27 17:22 ` Joe Perches
  2010-07-27 17:31 ` Jonathan Corbet
  0 siblings, 2 replies; 11+ messages in thread
From: Israel Schlesinger @ 2010-07-27 17:11 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..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

^ permalink raw reply related	[flat|nested] 11+ messages in thread
* [PATCH] checkpatch: Add warnings for use of mdelay()
@ 2018-07-04 18:18 Prakruthi Deepak Heragu
  2018-07-04 18:30 ` Joe Perches
  0 siblings, 1 reply; 11+ messages in thread
From: Prakruthi Deepak Heragu @ 2018-07-04 18:18 UTC (permalink / raw)
  To: apw, joe
  Cc: linux-kernel, ckadabi, tsoni, bryanh, Israel Schlesinger,
	Stepan Moskovchenko, Prakruthi Deepak Heragu

mdelay() is not a preferred API to be used to insert delay in the kernel
code unless the context is atomic. Instead, msleep() API can be used.
This patch introduces this warning.

Signed-off-by: Israel Schlesinger <israels@codeaurora.org>
Signed-off-by: Stepan Moskovchenko <stepanm@codeaurora.org>
Signed-off-by: Prakruthi Deepak Heragu <pheragu@codeaurora.org>
---
 scripts/checkpatch.pl | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index a9c0550..14bba3f 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -5572,6 +5572,12 @@ sub process {
 			     "Comparing get_jiffies_64() is almost always wrong; prefer time_after64, time_before64 and friends\n" . $herecurr);
 		}
 
+# check the patch for use of mdelay
+		if ($line =~ /\bmdelay\s*\(/) {
+			WARN("MDELAY",
+			     "use of mdelay() found: msleep() is the preferred API.\n" . $herecurr );
+		}
+
 # warn about #ifdefs in C files
 #		if ($line =~ /^.\s*\#\s*if(|n)def/ && ($realfile =~ /\.c$/)) {
 #			print "#ifdef in C files should be avoided\n";
-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project


^ permalink raw reply related	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2018-07-07 12:38 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-07-27 17:11 [PATCH] checkpatch: Add warnings for use of mdelay() Israel Schlesinger
2010-07-27 17:22 ` 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

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).