From 1a15a250862fda3fbdf8454cc7131e24de904e7c Mon Sep 17 00:00:00 2001 From: Patrick Pannuto Date: Mon, 9 Aug 2010 17:21:01 -0700 Subject: checkpatch: prefer usleep_range over udelay When possible, sleeping is (usually) better than delaying; however, don't bother callers of udelay < 10us, as those cases are generally not worth the switch to usleep [akpm@linux-foundation.org: fix mismatched parentheses] Signed-off-by: Patrick Pannuto Cc: Thomas Gleixner Cc: Ingo Molnar Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- scripts/checkpatch.pl | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'scripts/checkpatch.pl') diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index 2018f4349b47..8b69af8a76f9 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl @@ -2584,6 +2584,14 @@ sub process { } } +# prefer usleep_range over udelay + if ($line =~ /\budelay\s*\(\s*(\w+)\s*\)/) { + # ignore udelay's < 10, however + if (! (($1 =~ /(\d+)/) && ($1 < 10)) ) { + CHK("usleep_range is preferred over udelay; see Documentation/timers/timers-howto.txt\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"; -- cgit v1.2.3-55-g7522