Commit 71255988 authored by Thomas Gleixner's avatar Thomas Gleixner Committed by David Woodhouse

MTD char device access -- return data when ECC errors happen.

This is sane, as the driver returns the real data and the return 
value is for information of NAND aware filesystems. Userspace 
access to raw NAND is usually restricted to debugging tools which 
are aware of the NAND specific problems.
Signed-Off-By: default avatarThomas Gleixner <tglx@linutronix.de>
Signed-Off-By: default avatarDavid Woodhouse <dwmw2@infradead.org>
parent 8eb2a259
/*
* $Id: mtdchar.c,v 1.64 2004/08/09 13:59:46 dwmw2 Exp $
* $Id: mtdchar.c,v 1.65 2004/09/23 23:45:47 gleixner Exp $
*
* Character-device access to raw MTD devices.
*
......@@ -179,7 +179,13 @@ static ssize_t mtd_read(struct file *file, char __user *buf, size_t count,loff_t
return -ENOMEM;
ret = MTD_READ(mtd, *ppos, len, &retlen, kbuf);
if (!ret) {
/* Nand returns -EBADMSG on ecc errors, but it returns
* the data. For our userspace tools it is important
* to dump areas with ecc errors !
* Userspace software which accesses NAND this way
* must be aware of the fact that it deals with NAND
*/
if (!ret || (ret == -EBADMSG)) {
*ppos += retlen;
if (copy_to_user(buf, kbuf, retlen)) {
kfree(kbuf);
......@@ -198,7 +204,7 @@ static ssize_t mtd_read(struct file *file, char __user *buf, size_t count,loff_t
kfree(kbuf);
}
return total_retlen;
} /* mtd_read */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment