Re: [PATCH] lp.c, eexpress.c jiffies cleanup

Andreas Dilger
2001-11-06T21:16:45Z

On Nov 06, 2001 21:04 +0100, Tim Schmielau wrote:
> In eexpress.c I also turned absolute jiffies number into multiples of HZ,
> yet the resulting timeout values still do not always seem reasonable to
> me.

I agree. It seems very ugly. I looked at a few drivers which loop 1 or 2
jiffies, but to busy-loop for 1/10th of a second, or even 20 seconds
is terribly bad. I took a look at the functions scb_rdcmd() and
scb_status() and they are only reading from an I/O port, so no chance
of sleeping/blocking, just busy waiting.

> - unsigned long int oldtime = jiffies;
> - while (scb_rdcmd(dev) && ((jiffies-oldtime)<10));
> + unsigned long timeout = jiffies + HZ/10;
> + while (scb_rdcmd(dev) && (time_before(jiffies, timeout)));
> if (scb_rdcmd(dev)) {
> printk("%s: command didn't clear\n", dev->name);
> }
> @@ -1598,16 +1598,16 @@
> #endif
> - oj = jiffies;
> + timeout = jiffies + 20*HZ;
> while ((SCB_CUstat(scb_status(dev)) == 2) &&
> - ((jiffies-oj) < 2000));
> + time_before(jiffies, timeout));
> if (SCB_CUstat(scb_status(dev)) == 2)
> printk("%s: warning, CU didn't stop\n", dev->name);
> lp->started &= ~(STARTED_CU);

Cheers, Andreas
--
Andreas Dilger