Deleted Added
full compact
randomdev.c (128059) randomdev.c (128151)
1/*-
2 * Copyright (c) 2000-2004 Mark R V Murray
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 12 unchanged lines hidden (view full) ---

21 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
22 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
24 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 *
26 */
27
28#include <sys/cdefs.h>
1/*-
2 * Copyright (c) 2000-2004 Mark R V Murray
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 12 unchanged lines hidden (view full) ---

21 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
22 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
24 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 *
26 */
27
28#include <sys/cdefs.h>
29__FBSDID("$FreeBSD: head/sys/dev/random/randomdev.c 128059 2004-04-09 15:47:10Z markm $");
29__FBSDID("$FreeBSD: head/sys/dev/random/randomdev.c 128151 2004-04-12 09:13:24Z markm $");
30
31#include <sys/param.h>
32#include <sys/systm.h>
33#include <sys/bus.h>
34#include <sys/conf.h>
35#include <sys/fcntl.h>
36#include <sys/filio.h>
37#include <sys/kernel.h>

--- 60 unchanged lines hidden (view full) ---

98}
99
100/* ARGSUSED */
101static int
102random_read(dev_t dev __unused, struct uio *uio, int flag)
103{
104 int c, error = 0;
105
30
31#include <sys/param.h>
32#include <sys/systm.h>
33#include <sys/bus.h>
34#include <sys/conf.h>
35#include <sys/fcntl.h>
36#include <sys/filio.h>
37#include <sys/kernel.h>

--- 60 unchanged lines hidden (view full) ---

98}
99
100/* ARGSUSED */
101static int
102random_read(dev_t dev __unused, struct uio *uio, int flag)
103{
104 int c, error = 0;
105
106 mtx_lock(&random_systat.lock);
107
106 /* Blocking logic */
107 while (!random_systat.seeded && !error) {
108 if (flag & IO_NDELAY)
109 error = EWOULDBLOCK;
110 else
108 /* Blocking logic */
109 while (!random_systat.seeded && !error) {
110 if (flag & IO_NDELAY)
111 error = EWOULDBLOCK;
112 else
111 error = tsleep(&random_systat,
113 error = msleep(&random_systat, &random_systat.lock,
112 PUSER | PCATCH, "block", 0);
113 }
114
115 /* The actual read */
116 if (!error) {
114 PUSER | PCATCH, "block", 0);
115 }
116
117 /* The actual read */
118 if (!error) {
117 mtx_lock(&random_systat.lock);
118 while (uio->uio_resid > 0 && !error) {
119 c = MIN(uio->uio_resid, PAGE_SIZE);
120 c = (*random_systat.read)(random_buf, c);
121 error = uiomove(random_buf, c, uio);
122 }
119 while (uio->uio_resid > 0 && !error) {
120 c = MIN(uio->uio_resid, PAGE_SIZE);
121 c = (*random_systat.read)(random_buf, c);
122 error = uiomove(random_buf, c, uio);
123 }
123 mtx_unlock(&random_systat.lock);
124 }
124 }
125
126 mtx_unlock(&random_systat.lock);
127
125 return (error);
126}
127
128/* ARGSUSED */
129static int
130random_write(dev_t dev __unused, struct uio *uio, int flag __unused)
131{
132 int c, error = 0;

--- 85 unchanged lines hidden ---
128 return (error);
129}
130
131/* ARGSUSED */
132static int
133random_write(dev_t dev __unused, struct uio *uio, int flag __unused)
134{
135 int c, error = 0;

--- 85 unchanged lines hidden ---