Commit 1a15a250862fda3fbdf8454cc7131e24de904e7c

Authored by Patrick Pannuto
Committed by Linus Torvalds
1 parent 8bbea968f9

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 <ppannuto@codeaurora.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

Showing 1 changed file with 8 additions and 0 deletions Side-by-side Diff

scripts/checkpatch.pl
... ... @@ -2584,6 +2584,14 @@
2584 2584 }
2585 2585 }
2586 2586  
  2587 +# prefer usleep_range over udelay
  2588 + if ($line =~ /\budelay\s*\(\s*(\w+)\s*\)/) {
  2589 + # ignore udelay's < 10, however
  2590 + if (! (($1 =~ /(\d+)/) && ($1 < 10)) ) {
  2591 + CHK("usleep_range is preferred over udelay; see Documentation/timers/timers-howto.txt\n" . $line);
  2592 + }
  2593 + }
  2594 +
2587 2595 # warn about #ifdefs in C files
2588 2596 # if ($line =~ /^.\s*\#\s*if(|n)def/ && ($realfile =~ /\.c$/)) {
2589 2597 # print "#ifdef in C files should be avoided\n";