/* If an interrupt occurs before the timeout period elapses, this function returns zero immediately. If it times out, it returns one. An error code less than zero indicates an error (most likely a pending signal), and the calling code should finish what it's doing as soon as it can.  */
int parport_wait_event(struct parport *port, signed long timeout)
/* If an interrupt occurs before the timeout period elapses, this function returns zero immediately. If it times out, it returns one. An error code less than zero indicates an error (most likely a pending signal), and the calling code should finish what it's doing as soon as it can.  */
int parport_wait_event(struct parport *port, signed long timeout)
{
	int ret;
	struct timer_list timer;
	if (!port->physport->cad->timeout)
		return 1;
	init_timer_on_stack(&timer);
	timer.expires = jiffies + timeout;
	timer.function = timeout_waiting_on_port;
	port_from_cookie[port->number % PARPORT_MAX] = port;
	timer.data = port->number;
	add_timer (&timer);
	ret = down_interruptible (&port->physport->ieee1284.irq);
	if (!del_timer_sync(&timer) && !ret)
		ret = 1;
	destroy_timer_on_stack(&timer);
	return ret;
}