Re: [PATCH 3/4] Checkpatch: prefer usleep over udelay

From: Andrew Morton
Date: Wed Jul 28 2010 - 16:24:45 EST


On Wed, 28 Jul 2010 12:33:06 -0700
Patrick Pannuto <ppannuto@xxxxxxxxxxxxxx> wrote:

> 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
>
> Signed-off-by: Patrick Pannuto <ppannuto@xxxxxxxxxxxxxx>
> ---
> scripts/checkpatch.pl | 8 ++++++++
> 1 files changed, 8 insertions(+), 0 deletions(-)
>
> diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
> index bd88f11..892ae62 100755
> --- a/scripts/checkpatch.pl
> +++ b/scripts/checkpatch.pl
> @@ -2570,6 +2570,14 @@ sub process {
> }
> }
>
> +# prefer usleep over udelay
> + if (($line =~ /\budelay\s*\(\s*(\w+)\s*\)/ {
> + # ignore udelay's < 10, however
> + if (! (($1 =~ /(\d+)/) && ($1 < 10)) ) {
> + CHK("usleep is preferred over udelay; see Documentation/timers/delays.txt\n" . $line);
> + }
> + }

It'd be better to recommend usleep_range(), IMO. To make people aware
of what they're doing, and to think about it.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/