/* No data.  RTAS is hinting at a delay required * between 1-100000 milliseconds */ int ms = 1; for (; status > 9900; status--) ms = ms * 10; /* Use microseconds for reasonable accuracy */ ms *= 1000; wait_time = ms / (1000000/HZ); /* round down is fine */ /* Fall through to sleep */ 
wait_time = rtas_extended_busy_delay_time(status); 
static ssize_t scanlog_read(struct file *file, char __user *buf,			    size_t count, loff_t *ppos){        struct inode * inode = file->f_dentry->d_inode;	struct proc_dir_entry *dp;	unsigned int *data;	int status;	unsigned long len, off;	unsigned int wait_time;        dp = PDE(inode); 	data = (unsigned int *)dp->data;	if (!data) {		printk(KERN_ERR "scanlog: read failed no data\n");		return -EIO;	}	if (count > RTAS_DATA_BUF_SIZE)		count = RTAS_DATA_BUF_SIZE;	if (count < 1024) {		/* This is the min supported by this RTAS call.  Rather		 * than do all the buffering we insist the user code handle		 * larger reads.  As long as cp works... :)		 */		printk(KERN_ERR "scanlog: cannot perform a small read (%ld)\n", count);		return -EINVAL;	}	if (!access_ok(VERIFY_WRITE, buf, count))		return -EFAULT;	for (;;) {		wait_time = HZ/2;	/* default wait if no data */		spin_lock(&rtas_data_buf_lock);		memcpy(rtas_data_buf, data, RTAS_DATA_BUF_SIZE);		status = rtas_call(ibm_scan_log_dump, 2, 1, NULL,				   (u32) __pa(rtas_data_buf), (u32) count);		memcpy(data, rtas_data_buf, RTAS_DATA_BUF_SIZE);		spin_unlock(&rtas_data_buf_lock);		DEBUG("status=%d, data[0]=%x, data[1]=%x, data[2]=%x\n",		      status, data[0], data[1], data[2]);		switch (status) {		    case SCANLOG_COMPLETE:			DEBUG("hit eof\n");			return 0;		    case SCANLOG_HWERROR:			DEBUG("hardware error reading scan log data\n");			return -EIO;		    case SCANLOG_CONTINUE:			/* We may or may not have data yet */			len = data[1];			off = data[2];			if (len > 0) {				if (copy_to_user(buf, ((char *)data)+off, len))					return -EFAULT;				return len;			}			/* Break to sleep default time */			break;		    default:			if (status > 9900 && status <= 9905) {				/* No data.  RTAS is hinting at a delay required				 * between 1-100000 milliseconds				 */				int ms = 1;				for (; status > 9900; status--)					ms = ms * 10;				/* Use microseconds for reasonable accuracy */				ms *= 1000;				wait_time = ms / (1000000/HZ); /* round down is fine */				/* Fall through to sleep */			} else {				printk(KERN_ERR "scanlog: unknown error from rtas: %d\n", status);				return -EIO;			}		}		/* Apparently no data yet.  Wait and try again. */		set_current_state(TASK_INTERRUPTIBLE);		schedule_timeout(wait_time);	}	/*NOTREACHED*/}
4520	/local/tlutelli/issta_data/temp/c/2005_temp/2005/4520/0287ebedfa032a57bb47f4bc5cb5e268ecd844ad/scanlog.c/buggy/arch/ppc64/kernel/scanlog.c