*/
#define MAX_KMALLOC_SIZE 0x20000
-static ssize_t mtd_read(struct file *file, char *buf, size_t count,loff_t *ppos)
+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;
size_t retlen=0;
return total_retlen;
} /* mtd_read */
-static ssize_t mtd_write(struct file *file, const char *buf, size_t count,loff_t *ppos)
+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;
char *kbuf;
u_int cmd, u_long arg)
{
struct mtd_info *mtd = (struct mtd_info *)file->private_data;
+ void __user *argp = (void __user *)arg;
int ret = 0;
u_long size;
size = (cmd & IOCSIZE_MASK) >> IOCSIZE_SHIFT;
if (cmd & IOC_IN) {
- ret = verify_area(VERIFY_READ, (char *)arg, size);
+ ret = verify_area(VERIFY_READ, argp, size);
if (ret) return ret;
}
if (cmd & IOC_OUT) {
- ret = verify_area(VERIFY_WRITE, (char *)arg, size);
+ ret = verify_area(VERIFY_WRITE, argp, size);
if (ret) return ret;
}
switch (cmd) {
case MEMGETREGIONCOUNT:
- if (copy_to_user((int *) arg, &(mtd->numeraseregions), sizeof(int)))
+ if (copy_to_user(argp, &(mtd->numeraseregions), sizeof(int)))
return -EFAULT;
break;
{
struct region_info_user ur;
- if (copy_from_user( &ur,
- (struct region_info_user *)arg,
- sizeof(struct region_info_user))) {
+ if (copy_from_user(&ur, argp, sizeof(struct region_info_user)))
return -EFAULT;
- }
if (ur.regionindex >= mtd->numeraseregions)
return -EINVAL;
- if (copy_to_user((struct mtd_erase_region_info *) arg,
- &(mtd->eraseregions[ur.regionindex]),
+ if (copy_to_user(argp, &(mtd->eraseregions[ur.regionindex]),
sizeof(struct mtd_erase_region_info)))
return -EFAULT;
break;
}
case MEMGETINFO:
- if (copy_to_user((struct mtd_info *)arg, mtd,
- sizeof(struct mtd_info_user)))
+ if (copy_to_user(argp, mtd, sizeof(struct mtd_info_user)))
return -EFAULT;
break;
init_waitqueue_head(&waitq);
memset (erase,0,sizeof(struct erase_info));
- if (copy_from_user(&erase->addr, (u_long *)arg,
+ if (copy_from_user(&erase->addr, argp,
2 * sizeof(u_long))) {
kfree(erase);
return -EFAULT;
if(!(file->f_mode & 2))
return -EPERM;
- if (copy_from_user(&buf, (struct mtd_oob_buf *)arg, sizeof(struct mtd_oob_buf)))
+ if (copy_from_user(&buf, argp, sizeof(struct mtd_oob_buf)))
return -EFAULT;
if (buf.length > 0x4096)
if (!mtd->write_oob)
ret = -EOPNOTSUPP;
else
- ret = verify_area(VERIFY_READ, (char *)buf.ptr, buf.length);
+ ret = verify_area(VERIFY_READ, buf.ptr, buf.length);
if (ret)
return ret;
ret = (mtd->write_oob)(mtd, buf.start, buf.length, &retlen, databuf);
- if (copy_to_user((void *)arg + sizeof(u_int32_t), &retlen, sizeof(u_int32_t)))
+ if (copy_to_user(argp + sizeof(u_int32_t), &retlen, sizeof(u_int32_t)))
ret = -EFAULT;
kfree(databuf);
void *databuf;
ssize_t retlen;
- if (copy_from_user(&buf, (struct mtd_oob_buf *)arg, sizeof(struct mtd_oob_buf)))
+ if (copy_from_user(&buf, argp, sizeof(struct mtd_oob_buf)))
return -EFAULT;
if (buf.length > 0x4096)
if (!mtd->read_oob)
ret = -EOPNOTSUPP;
else
- ret = verify_area(VERIFY_WRITE, (char *)buf.ptr, buf.length);
+ ret = verify_area(VERIFY_WRITE, buf.ptr, buf.length);
if (ret)
return ret;
ret = (mtd->read_oob)(mtd, buf.start, buf.length, &retlen, databuf);
- if (copy_to_user((void *)arg + sizeof(u_int32_t), &retlen, sizeof(u_int32_t)))
+ if (copy_to_user(argp + sizeof(u_int32_t), &retlen, sizeof(u_int32_t)))
ret = -EFAULT;
else if (retlen && copy_to_user(buf.ptr, databuf, retlen))
ret = -EFAULT;
{
unsigned long adrs[2];
- if (copy_from_user(adrs ,(void *)arg, 2* sizeof(unsigned long)))
+ if (copy_from_user(adrs, argp, 2* sizeof(unsigned long)))
return -EFAULT;
if (!mtd->lock)
{
unsigned long adrs[2];
- if (copy_from_user(adrs, (void *)arg, 2* sizeof(unsigned long)))
+ if (copy_from_user(adrs, argp, 2* sizeof(unsigned long)))
return -EFAULT;
if (!mtd->unlock)
case MEMSETOOBSEL:
{
- if (copy_from_user(&mtd->oobinfo ,(void *)arg, sizeof(struct nand_oobinfo)))
+ if (copy_from_user(&mtd->oobinfo, argp, sizeof(struct nand_oobinfo)))
return -EFAULT;
break;
}