aboutsummaryrefslogtreecommitdiff
path: root/sys/dev/cfi
diff options
context:
space:
mode:
authorSam Leffler <sam@FreeBSD.org>2009-02-03 19:07:41 +0000
committerSam Leffler <sam@FreeBSD.org>2009-02-03 19:07:41 +0000
commit3a114d1f9233a14a1b94408c77a02f6633d8e858 (patch)
tree4827bcf177cbbd142145370420aef1be368a76c5 /sys/dev/cfi
parent22f8f5fe925bc0d31c44da2475e396cc9b07779c (diff)
Notes
Diffstat (limited to 'sys/dev/cfi')
-rw-r--r--sys/dev/cfi/cfi_dev.c37
1 files changed, 21 insertions, 16 deletions
diff --git a/sys/dev/cfi/cfi_dev.c b/sys/dev/cfi/cfi_dev.c
index aad1de2923c3..b8db1d2d3300 100644
--- a/sys/dev/cfi/cfi_dev.c
+++ b/sys/dev/cfi/cfi_dev.c
@@ -252,26 +252,31 @@ cfi_devioctl(struct cdev *dev, u_long cmd, caddr_t data, int fflag,
int error;
u_char val;
- if (cmd != CFIOCQRY)
- return (ENOIOCTL);
-
sc = dev->si_drv1;
+ error = 0;
- error = (sc->sc_writing) ? cfi_block_finish(sc) : 0;
- if (error)
- return (error);
-
- rq = (struct cfiocqry *)data;
+ switch(cmd) {
+ case CFIOCQRY:
+ if (sc->sc_writing) {
+ error = cfi_block_finish(sc);
+ if (error)
+ break;
+ }
- if (rq->offset >= sc->sc_size / sc->sc_width)
- return (ESPIPE);
- if (rq->offset + rq->count > sc->sc_size / sc->sc_width)
- return (ENOSPC);
+ rq = (struct cfiocqry *)data;
+ if (rq->offset >= sc->sc_size / sc->sc_width)
+ return (ESPIPE);
+ if (rq->offset + rq->count > sc->sc_size / sc->sc_width)
+ return (ENOSPC);
- while (!error && rq->count--) {
- val = cfi_read_qry(sc, rq->offset++);
- error = copyout(&val, rq->buffer++, 1);
+ while (!error && rq->count--) {
+ val = cfi_read_qry(sc, rq->offset++);
+ error = copyout(&val, rq->buffer++, 1);
+ }
+ break;
+ default:
+ error = ENOIOCTL;
+ break;
}
-
return (error);
}