/* Parameter: buf = pointer to buffer. len = number of bytes to read. user = flag, 1: called from userlevel 0: called from kernel. card = pointer to card struct. Return: number of bytes actually transferred.  */
static int isdnloop_readstatus(u_char __user *buf, int len, isdnloop_card *card)
/* Parameter: buf = pointer to buffer. len = number of bytes to read. user = flag, 1: called from userlevel 0: called from kernel. card = pointer to card struct. Return: number of bytes actually transferred.  */
static int isdnloop_readstatus(u_char __user *buf, int len, isdnloop_card *card)
{
	int count;
	u_char __user *p;
	for (p = buf, count = 0; count < len; p++, count++) {
		if (card->msg_buf_read == card->msg_buf_write)
			return count;
		if (put_user(*card->msg_buf_read++, p))
			return -EFAULT;
		if (card->msg_buf_read > card->msg_buf_end)
			card->msg_buf_read = card->msg_buf;
	}
	return count;
}