Re: [PATCH] checkpatch: Add warnings for use of mdelay()

From: Jonathan Corbet
Date: Tue Jul 27 2010 - 13:31:40 EST

On Tue, 27 Jul 2010 10:11:11 -0700
Israel Schlesinger <israels@xxxxxxxxxxxxxx> wrote:

> 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

Once upon a time, msleep(1) would sleep for 20ms, while mdelay(1) gave
a 1ms delay. My patch to fix msleep() at that time didn't get in due
to concerns about the cost of using hrtimers. Perhaps msleep() has
gotten better, but, if not, actually getting a 1ms delay remains a
valid reason for using mdelay() instead IMO. It made a difference of a
few seconds at open time for a driver I was doing at the time.

To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at
Please read the FAQ at