/* Returns the value of the register or a negative error code.  */
static int NCR5380_poll_politely(struct Scsi_Host *instance, int reg, int bit, int val, int t)
/* Returns the value of the register or a negative error code.  */
static int NCR5380_poll_politely(struct Scsi_Host *instance, int reg, int bit, int val, int t)
{
	NCR5380_local_declare();
	int n = 500;
	unsigned long end = jiffies + t;
	int r;
	NCR5380_setup(instance);
	while( n-- > 0)
	{
		r = NCR5380_read(reg);
		if((r & bit) == val)
			return 0;
		cpu_relax();
	}
	while(time_before(jiffies, end))
	{
		r = NCR5380_read(reg);
		if((r & bit) == val)
			return 0;
		if(!in_interrupt())
			cond_resched();
		else
			cpu_relax();
	}
	return -ETIMEDOUT;
}