|
@@ -435,9 +435,11 @@ static int mtd_do_writeoob(struct file *file, struct mtd_info *mtd,
|
|
return ret;
|
|
return ret;
|
|
}
|
|
}
|
|
|
|
|
|
-static int mtd_do_readoob(struct mtd_info *mtd, uint64_t start,
|
|
|
|
- uint32_t length, void __user *ptr, uint32_t __user *retp)
|
|
|
|
|
|
+static int mtd_do_readoob(struct file *file, struct mtd_info *mtd,
|
|
|
|
+ uint64_t start, uint32_t length, void __user *ptr,
|
|
|
|
+ uint32_t __user *retp)
|
|
{
|
|
{
|
|
|
|
+ struct mtd_file_info *mfi = file->private_data;
|
|
struct mtd_oob_ops ops;
|
|
struct mtd_oob_ops ops;
|
|
int ret = 0;
|
|
int ret = 0;
|
|
|
|
|
|
@@ -455,7 +457,7 @@ static int mtd_do_readoob(struct mtd_info *mtd, uint64_t start,
|
|
ops.ooblen = length;
|
|
ops.ooblen = length;
|
|
ops.ooboffs = start & (mtd->writesize - 1);
|
|
ops.ooboffs = start & (mtd->writesize - 1);
|
|
ops.datbuf = NULL;
|
|
ops.datbuf = NULL;
|
|
- ops.mode = MTD_OOB_PLACE;
|
|
|
|
|
|
+ ops.mode = (mfi->mode == MTD_MODE_RAW) ? MTD_OOB_RAW : MTD_OOB_PLACE;
|
|
|
|
|
|
if (ops.ooboffs && ops.ooblen > (mtd->oobsize - ops.ooboffs))
|
|
if (ops.ooboffs && ops.ooblen > (mtd->oobsize - ops.ooboffs))
|
|
return -EINVAL;
|
|
return -EINVAL;
|
|
@@ -716,7 +718,7 @@ static int mtd_ioctl(struct file *file, u_int cmd, u_long arg)
|
|
if (copy_from_user(&buf, argp, sizeof(buf)))
|
|
if (copy_from_user(&buf, argp, sizeof(buf)))
|
|
ret = -EFAULT;
|
|
ret = -EFAULT;
|
|
else
|
|
else
|
|
- ret = mtd_do_readoob(mtd, buf.start, buf.length,
|
|
|
|
|
|
+ ret = mtd_do_readoob(file, mtd, buf.start, buf.length,
|
|
buf.ptr, &buf_user->start);
|
|
buf.ptr, &buf_user->start);
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
@@ -743,7 +745,7 @@ static int mtd_ioctl(struct file *file, u_int cmd, u_long arg)
|
|
if (copy_from_user(&buf, argp, sizeof(buf)))
|
|
if (copy_from_user(&buf, argp, sizeof(buf)))
|
|
ret = -EFAULT;
|
|
ret = -EFAULT;
|
|
else
|
|
else
|
|
- ret = mtd_do_readoob(mtd, buf.start, buf.length,
|
|
|
|
|
|
+ ret = mtd_do_readoob(file, mtd, buf.start, buf.length,
|
|
(void __user *)(uintptr_t)buf.usr_ptr,
|
|
(void __user *)(uintptr_t)buf.usr_ptr,
|
|
&buf_user->length);
|
|
&buf_user->length);
|
|
break;
|
|
break;
|
|
@@ -1029,7 +1031,7 @@ static long mtd_compat_ioctl(struct file *file, unsigned int cmd,
|
|
if (copy_from_user(&buf, argp, sizeof(buf)))
|
|
if (copy_from_user(&buf, argp, sizeof(buf)))
|
|
ret = -EFAULT;
|
|
ret = -EFAULT;
|
|
else
|
|
else
|
|
- ret = mtd_do_readoob(mtd, buf.start,
|
|
|
|
|
|
+ ret = mtd_do_readoob(file, mtd, buf.start,
|
|
buf.length, compat_ptr(buf.ptr),
|
|
buf.length, compat_ptr(buf.ptr),
|
|
&buf_user->start);
|
|
&buf_user->start);
|
|
break;
|
|
break;
|