]> err.no Git - linux-2.6/blobdiff - drivers/mtd/mtdchar.c
V4L/DVB (4296): Remove stradis MODULE_DEVICE_INFO definition
[linux-2.6] / drivers / mtd / mtdchar.c
index fdc535b22e39a9f3ed0c121d37fe3904babe790d..fb8b4f7e48d3a14a295f5661b9014908f1110dd4 100644 (file)
@@ -5,7 +5,6 @@
  *
  */
 
-#include <linux/config.h>
 #include <linux/device.h>
 #include <linux/fs.h>
 #include <linux/init.h>
@@ -78,7 +77,7 @@ static loff_t mtd_lseek (struct file *file, loff_t offset, int orig)
                return -EINVAL;
        }
 
-       if (offset >= 0 && offset < mtd->size)
+       if (offset >= 0 && offset <= mtd->size)
                return file->f_pos = offset;
 
        return -EINVAL;
@@ -380,6 +379,7 @@ static int mtd_ioctl(struct inode *inode, struct file *file,
        void __user *argp = (void __user *)arg;
        int ret = 0;
        u_long size;
+       struct mtd_info_user info;
 
        DEBUG(MTD_DEBUG_LEVEL0, "MTD_ioctl\n");
 
@@ -415,7 +415,15 @@ static int mtd_ioctl(struct inode *inode, struct file *file,
        }
 
        case MEMGETINFO:
-               if (copy_to_user(argp, mtd, sizeof(struct mtd_info_user)))
+               info.type       = mtd->type;
+               info.flags      = mtd->flags;
+               info.size       = mtd->size;
+               info.erasesize  = mtd->erasesize;
+               info.writesize  = mtd->writesize;
+               info.oobsize    = mtd->oobsize;
+               info.ecctype    = mtd->ecctype;
+               info.eccsize    = mtd->eccsize;
+               if (copy_to_user(argp, &info, sizeof(struct mtd_info_user)))
                        return -EFAULT;
                break;
 
@@ -495,12 +503,12 @@ static int mtd_ioctl(struct inode *inode, struct file *file,
                        return ret;
 
                ops.len = buf.length;
-               ops.ooblen = mtd->oobsize;
+               ops.ooblen = buf.length;
                ops.ooboffs = buf.start & (mtd->oobsize - 1);
                ops.datbuf = NULL;
                ops.mode = MTD_OOB_PLACE;
 
-               if (ops.ooboffs && ops.len > (ops.ooblen - ops.ooboffs))
+               if (ops.ooboffs && ops.len > (mtd->oobsize - ops.ooboffs))
                        return -EINVAL;
 
                ops.oobbuf = kmalloc(buf.length, GFP_KERNEL);
@@ -544,12 +552,12 @@ static int mtd_ioctl(struct inode *inode, struct file *file,
                        return ret;
 
                ops.len = buf.length;
-               ops.ooblen = mtd->oobsize;
+               ops.ooblen = buf.length;
                ops.ooboffs = buf.start & (mtd->oobsize - 1);
                ops.datbuf = NULL;
                ops.mode = MTD_OOB_PLACE;
 
-               if (ops.ooboffs && ops.len > (ops.ooblen - ops.ooboffs))
+               if (ops.ooboffs && ops.len > (mtd->oobsize - ops.ooboffs))
                        return -EINVAL;
 
                ops.oobbuf = kmalloc(buf.length, GFP_KERNEL);