Deleted Added
full compact
randomdev.c (104354) randomdev.c (109623)
1/*-
2 * Copyright (c) 2000 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

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

18 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
19 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
20 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
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 *
1/*-
2 * Copyright (c) 2000 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

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

18 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
19 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
20 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
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 * $FreeBSD: head/sys/dev/random/randomdev.c 104354 2002-10-02 07:44:29Z scottl $
26 * $FreeBSD: head/sys/dev/random/randomdev.c 109623 2003-01-21 08:56:16Z alfred $
27 */
28
29#include <sys/param.h>
30#include <sys/systm.h>
31#include <sys/bus.h>
32#include <sys/conf.h>
33#include <sys/fcntl.h>
34#include <sys/filio.h>

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

182 error = EWOULDBLOCK;
183 else
184 error = tsleep(&random_systat, PUSER|PCATCH,
185 "block", 0);
186 if (error != 0)
187 return error;
188 }
189 c = uio->uio_resid < PAGE_SIZE ? uio->uio_resid : PAGE_SIZE;
27 */
28
29#include <sys/param.h>
30#include <sys/systm.h>
31#include <sys/bus.h>
32#include <sys/conf.h>
33#include <sys/fcntl.h>
34#include <sys/filio.h>

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

182 error = EWOULDBLOCK;
183 else
184 error = tsleep(&random_systat, PUSER|PCATCH,
185 "block", 0);
186 if (error != 0)
187 return error;
188 }
189 c = uio->uio_resid < PAGE_SIZE ? uio->uio_resid : PAGE_SIZE;
190 random_buf = (void *)malloc((u_long)c, M_TEMP, M_WAITOK);
190 random_buf = (void *)malloc((u_long)c, M_TEMP, 0);
191 while (uio->uio_resid > 0 && error == 0) {
192 ret = read_random_real(random_buf, c);
193 error = uiomove(random_buf, ret, uio);
194 }
195 free(random_buf, M_TEMP);
196 return error;
197}
198
199/* ARGSUSED */
200static int
201random_write(dev_t dev __unused, struct uio *uio, int flag __unused)
202{
203 int c;
204 int error;
205 void *random_buf;
206
207 error = 0;
191 while (uio->uio_resid > 0 && error == 0) {
192 ret = read_random_real(random_buf, c);
193 error = uiomove(random_buf, ret, uio);
194 }
195 free(random_buf, M_TEMP);
196 return error;
197}
198
199/* ARGSUSED */
200static int
201random_write(dev_t dev __unused, struct uio *uio, int flag __unused)
202{
203 int c;
204 int error;
205 void *random_buf;
206
207 error = 0;
208 random_buf = (void *)malloc(PAGE_SIZE, M_TEMP, M_WAITOK);
208 random_buf = (void *)malloc(PAGE_SIZE, M_TEMP, 0);
209 while (uio->uio_resid > 0) {
210 c = (int)(uio->uio_resid < PAGE_SIZE
211 ? uio->uio_resid
212 : PAGE_SIZE);
213 error = uiomove(random_buf, c, uio);
214 if (error)
215 break;
216 random_write_internal(random_buf, c);

--- 229 unchanged lines hidden ---
209 while (uio->uio_resid > 0) {
210 c = (int)(uio->uio_resid < PAGE_SIZE
211 ? uio->uio_resid
212 : PAGE_SIZE);
213 error = uiomove(random_buf, c, uio);
214 if (error)
215 break;
216 random_write_internal(random_buf, c);

--- 229 unchanged lines hidden ---