Hello all,

I'm in the process of cleaning up all the "timeout" code in the
comedi drivers.  The general form of the timeout code in all
the drivers is:

static int foo_eoc(struct comedi_device *dev, unsigned long timeout)
{
        unsigned int status;
        while (timeout--) {
                status = inb(dev->iobase + STATUS_REG);
                if (status & EOC)
                        return 0;
                udelay(1);
        }
        return -ETIMEDOUT;
}

My question is about the 'udelay()'. Is this the preferred way to
delay between each check of the status register of would
something like a 'cpu_relax()' be better?

Also, the 'timeout' values used in the comedi drivers vary a lot.
I have seen value of 3, 5, 10, 100, 1000, 10000, 40000, and 100000.
Usually the smaller values have the udelay(1) in the loop, the
larger values don't. Assuming cpu_relax() would be a better way
to handle the delays, would it be a good idea to standardize the
timeout wait to a set number of loops?

Thanks,
Hartley

_______________________________________________
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

Reply via email to