diff options
author | Stefan Kempf <stefan@cvs.openbsd.org> | 2016-02-15 19:21:47 +0000 |
---|---|---|
committer | Stefan Kempf <stefan@cvs.openbsd.org> | 2016-02-15 19:21:47 +0000 |
commit | 761251c35fea48cee375127af0fd3bd83e12152c (patch) | |
tree | b2272071c83016b68c4a7d696907f66ea76fd403 /sys/dev | |
parent | 18fecf73ee93e75a19e82620bebaa50d4d84d802 (diff) |
Convert to uiomove. From Martin Natano.
Diffstat (limited to 'sys/dev')
-rw-r--r-- | sys/dev/pci/bktr/bktr_core.c | 22 |
1 files changed, 10 insertions, 12 deletions
diff --git a/sys/dev/pci/bktr/bktr_core.c b/sys/dev/pci/bktr/bktr_core.c index 8f59929e433..05d7d9f1700 100644 --- a/sys/dev/pci/bktr/bktr_core.c +++ b/sys/dev/pci/bktr/bktr_core.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bktr_core.c,v 1.36 2015/03/14 03:38:49 jsg Exp $ */ +/* $OpenBSD: bktr_core.c,v 1.37 2016/02/15 19:21:46 stefan Exp $ */ /* $FreeBSD: src/sys/dev/bktr/bktr_core.c,v 1.114 2000/10/31 13:09:56 roger Exp $ */ /* @@ -993,7 +993,7 @@ int video_read(bktr_ptr_t bktr, int unit, dev_t dev, struct uio *uio) { int status; - int count; + size_t count; if (bktr->bigbuf == 0) /* no frame buffer allocated (ioctl failed) */ @@ -1008,7 +1008,7 @@ video_read(bktr_ptr_t bktr, int unit, dev_t dev, struct uio *uio) count = bktr->rows * bktr->cols * pixfmt_table[ bktr->pixfmt ].public.Bpp; - if ((int) uio->uio_iov->iov_len < count) + if (uio->uio_resid < count) return( EINVAL ); bktr->flags &= ~(METEOR_CAP_MASK | METEOR_WANT_MASK); @@ -1027,7 +1027,7 @@ video_read(bktr_ptr_t bktr, int unit, dev_t dev, struct uio *uio) status = tsleep(BKTR_SLEEP, BKTRPRI, "captur", 0); if (!status) /* successful capture */ - status = uiomovei((caddr_t)bktr->bigbuf, count, uio); + status = uiomove((caddr_t)bktr->bigbuf, count, uio); else printf ("%s: read: tsleep error %d\n", bktr_name(bktr), status); @@ -1047,7 +1047,7 @@ video_read(bktr_ptr_t bktr, int unit, dev_t dev, struct uio *uio) int vbi_read(bktr_ptr_t bktr, struct uio *uio, int ioflag) { - int readsize, readsize2; + size_t readsize, readsize2; int status; @@ -1067,22 +1067,20 @@ vbi_read(bktr_ptr_t bktr, struct uio *uio, int ioflag) /* We cannot read more bytes than there are in * the circular buffer */ - readsize = (int)uio->uio_iov->iov_len; - - if (readsize > bktr->vbisize) readsize = bktr->vbisize; + readsize = ulmin(uio->uio_resid, bktr->vbisize); /* Check if we can read this number of bytes without having * to wrap around the circular buffer */ - if((bktr->vbistart + readsize) >= VBI_BUFFER_SIZE) { + if (readsize >= VBI_BUFFER_SIZE - bktr->vbistart) { /* We need to wrap around */ readsize2 = VBI_BUFFER_SIZE - bktr->vbistart; - status = uiomovei((caddr_t)bktr->vbibuffer + bktr->vbistart, readsize2, uio); + status = uiomove((caddr_t)bktr->vbibuffer + bktr->vbistart, readsize2, uio); if (status == 0) - status = uiomovei((caddr_t)bktr->vbibuffer, (readsize - readsize2), uio); + status = uiomove((caddr_t)bktr->vbibuffer, (readsize - readsize2), uio); } else { /* We do not need to wrap around */ - status = uiomovei((caddr_t)bktr->vbibuffer + bktr->vbistart, readsize, uio); + status = uiomove((caddr_t)bktr->vbibuffer + bktr->vbistart, readsize, uio); } /* Update the number of bytes left to read */ |