/*
- * $Id: mtdchar.c,v 1.64 2004/08/09 13:59:46 dwmw2 Exp $
+ * $Id: mtdchar.c,v 1.66 2005/01/05 18:05:11 dwmw2 Exp $
*
* Character-device access to raw MTD devices.
*
static loff_t mtd_lseek (struct file *file, loff_t offset, int orig)
{
- struct mtd_info *mtd=(struct mtd_info *)file->private_data;
+ struct mtd_info *mtd = file->private_data;
switch (orig) {
case 0:
DEBUG(MTD_DEBUG_LEVEL0, "MTD_close\n");
- mtd = (struct mtd_info *)file->private_data;
+ mtd = file->private_data;
if (mtd->sync)
mtd->sync(mtd);
static ssize_t mtd_read(struct file *file, char __user *buf, size_t count,loff_t *ppos)
{
- struct mtd_info *mtd = (struct mtd_info *)file->private_data;
+ struct mtd_info *mtd = file->private_data;
size_t retlen=0;
size_t total_retlen=0;
int ret=0;
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);
kfree(kbuf);
}
-
+
return total_retlen;
} /* mtd_read */
static ssize_t mtd_write(struct file *file, const char __user *buf, size_t count,loff_t *ppos)
{
- struct mtd_info *mtd = (struct mtd_info *)file->private_data;
+ struct mtd_info *mtd = file->private_data;
char *kbuf;
size_t retlen;
size_t total_retlen=0;
static int mtd_ioctl(struct inode *inode, struct file *file,
u_int cmd, u_long arg)
{
- struct mtd_info *mtd = (struct mtd_info *)file->private_data;
+ struct mtd_info *mtd = file->private_data;
void __user *argp = (void __user *)arg;
int ret = 0;
u_long size;