Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 30 Jan 2009 18:34:03 +0000 (UTC)
From:      Sam Leffler <sam@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-projects@freebsd.org
Subject:   svn commit: r187932 - projects/cambria/sys/dev/cfi
Message-ID:  <200901301834.n0UIY3HR099989@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
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);
 }



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200901301834.n0UIY3HR099989>