/* If the status lines take on the desired values before the timeout period elapses, parport_poll_peripheral() returns zero immediately. A return value greater than zero indicates a timeout. An error code (less than zero) indicates an error, most likely a signal that arrived, and the caller should finish what it is doing as soon as possible.  */
int parport_poll_peripheral(struct parport *port, unsigned char mask, unsigned char result, int usec)
/* If the status lines take on the desired values before the timeout period elapses, parport_poll_peripheral() returns zero immediately. A return value greater than zero indicates a timeout. An error code (less than zero) indicates an error, most likely a signal that arrived, and the caller should finish what it is doing as soon as possible.  */
int parport_poll_peripheral(struct parport *port, unsigned char mask, unsigned char result, int usec)
{
	int count = usec / 5 + 2;
	int i;
	unsigned char status;
	for (i = 0; i < count; i++) {
		status = parport_read_status (port);
		if ((status & mask) == result)
			return 0;
		if (signal_pending (current))
			return -EINTR;
		if (need_resched())
			break;
		if (i >= 2)
			udelay (5);
	}
	return 1;
}