patch-2.4.27 linux-2.4.27/drivers/char/nwflash.c

Next file: linux-2.4.27/drivers/char/parport_serial.c
Previous file: linux-2.4.27/drivers/char/nvram.c
Back to the patch index
Back to the overall index

diff -urN linux-2.4.26/drivers/char/nwflash.c linux-2.4.27/drivers/char/nwflash.c
@@ -133,7 +133,8 @@
 
 static ssize_t flash_read(struct file *file, char *buf, size_t size, loff_t * ppos)
 {
-	unsigned long p = *ppos;
+	loff_t n = *ppos;
+	unsigned long p = n;
 	unsigned int count = size;
 	int ret = 0;
 
@@ -144,7 +145,7 @@
 	if (count)
 		ret = -ENXIO;
 
-	if (p < gbFlashSize) {
+	if (n == p && p < gbFlashSize) {
 		if (count > gbFlashSize - p)
 			count = gbFlashSize - p;
 
@@ -157,7 +158,7 @@
 		ret = copy_to_user(buf, (void *)(FLASH_BASE + p), count);
 		if (ret == 0) {
 			ret = count;
-			*ppos += count;
+			*ppos = p + count;
 		}
 		up(&nwflash_sem);
 	}
@@ -166,7 +167,8 @@
 
 static ssize_t flash_write(struct file *file, const char *buf, size_t size, loff_t * ppos)
 {
-	unsigned long p = *ppos;
+	loff_t n = *ppos;
+	unsigned long p = n;
 	unsigned int count = size;
 	int written;
 	int nBlock, temp, rc;
@@ -185,7 +187,7 @@
 	/*
 	 * check for out of range pos or count
 	 */
-	if (p >= gbFlashSize)
+	if (p != n || p >= gbFlashSize)
 		return count ? -ENXIO : 0;
 
 	if (count > gbFlashSize - p)
@@ -274,7 +276,7 @@
 		p += rc;
 		buf += rc;
 		written += rc;
-		*ppos += rc;
+		*ppos = p;
 
 		if (flashdebug)
 			printk(KERN_DEBUG "flash_write: written 0x%X bytes OK.\n", written);

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)