FreeBSD/sys/kern/subr_bus.c
/*
 * The read channel for this device is used to report changes to
 * userland in realtime.  We are required to free the data as well as
 * the n1 object because we allocate them separately.  Also note that
 * we return one record at a time.  If you try to read this device a
 * character at a time, you will lose the rest of the data.  Listening
 * programs are expected to cope.
 */
The read channel for this device is used to report changes to
userland in realtime.  We are required to free the data as well as
the n1 object because we allocate them separately.  Also note that
we return one record at a time.  If you try to read this device a
character at a time, you will lose the rest of the data.  Listening
programs are expected to cope.
The read channel for this device is used to report changes to userland in realtime . We are required to free the data as well as the n1 object because we allocate them separately . Also note that we return one record at a time . If you try to read this device a character at a time you will lose the rest of the data . Listening programs are expected to cope .
static int
devread(struct cdev *dev, struct uio *uio, int ioflag)
{
	struct dev_event_info *n1;
	int rv;
	mtx_lock(&devsoftc.mtx);
	while (TAILQ_EMPTY(&devsoftc.devq)) {
		if (devsoftc.nonblock) {
			mtx_unlock(&devsoftc.mtx);
			return (EAGAIN);
		}
		rv = cv_wait_sig(&devsoftc.cv, &devsoftc.mtx);
		if (rv) {
			mtx_unlock(&devsoftc.mtx);
			return (rv);
		}
	}
	n1 = TAILQ_FIRST(&devsoftc.devq);
	TAILQ_REMOVE(&devsoftc.devq, n1, dei_link);
	devsoftc.queued--;
	mtx_unlock(&devsoftc.mtx);
	rv = uiomove(n1->dei_data, strlen(n1->dei_data), uio);
	free(n1->dei_data, M_BUS);
	free(n1, M_BUS);
	return (rv);
}
static int devread ( struct cdev * dev , struct uio * uio , int ioflag ) { struct dev_event_info * n1 ; int rv ; mtx_lock ( & devsoftc . mtx ) ; while ( TAILQ_EMPTY ( & devsoftc . devq ) ) { if ( devsoftc . nonblock ) { mtx_unlock ( & devsoftc . mtx ) ; return ( EAGAIN ) ; } rv = cv_wait_sig ( & devsoftc . cv , & devsoftc . mtx ) ; if ( rv ) { mtx_unlock ( & devsoftc . mtx ) ; return ( rv ) ; } } n1 = TAILQ_FIRST ( & devsoftc . devq ) ; TAILQ_REMOVE ( & devsoftc . devq , n1 , dei_link ) ; devsoftc . queued -- ; mtx_unlock ( & devsoftc . mtx ) ; rv = uiomove ( n1 -> dei_data , strlen ( n1 -> dei_data ) , uio ) ; free ( n1 -> dei_data , M_BUS ) ; free ( n1 , M_BUS ) ; return ( rv ) ; }
The read channel for this device is used to report changes to
 userland in realtime.
The read channel for this device is used to report changes to userland in realtime .
/*
			 * Need to translate ERESTART to EINTR here? -- jake
			 */