Skip to content

Commit

Permalink
checkpatch: prefer usleep_range over udelay
Browse files Browse the repository at this point in the history
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

[[email protected]: fix mismatched parentheses]
Signed-off-by: Patrick Pannuto <[email protected]>
Cc: Thomas Gleixner <[email protected]>
Cc: Ingo Molnar <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
Patrick Pannuto authored and torvalds committed Aug 10, 2010
1 parent 8bbea96 commit 1a15a25
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions scripts/checkpatch.pl
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down

0 comments on commit 1a15a25

Please sign in to comment.