svn commit: r187932 - projects/cambria/sys/dev/cfi

Sam Leffler sam at FreeBSD.org
Fri Jan 30 10:34:03 PST 2009


Author: sam
Date: Fri Jan 30 18:34:03 2009
New Revision: 187932
URL: http://svn.freebsd.org/changeset/base/187932

Log:
  setup to add new ioctl cmds

Modified:
  projects/cambria/sys/dev/cfi/cfi_dev.c

Modified: projects/cambria/sys/dev/cfi/cfi_dev.c
==============================================================================
--- projects/cambria/sys/dev/cfi/cfi_dev.c	Fri Jan 30 18:33:05 2009	(r187931)
+++ projects/cambria/sys/dev/cfi/cfi_dev.c	Fri Jan 30 18:34:03 2009	(r187932)
@@ -252,26 +252,31 @@ cfi_devioctl(struct cdev *dev, u_long cm
 	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;
-
-	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);
+	switch(cmd) {
+	case CFIOCQRY:
+		if (sc->sc_writing) {
+			error = cfi_block_finish(sc);
+			if (error)
+				break;
+		}
+
+		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);
+		}
+		break;
+	default:
+		error = ENOIOCTL;
+		break;
 	}
-
 	return (error);
 }


More information about the svn-src-projects mailing list