/*
- * $Id: mtdchar.c,v 1.65 2004/09/23 23:45:47 gleixner 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;
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;
size = (cmd & IOCSIZE_MASK) >> IOCSIZE_SHIFT;
if (cmd & IOC_IN) {
- ret = verify_area(VERIFY_READ, argp, size);
- if (ret) return ret;
+ if (!access_ok(VERIFY_READ, argp, size))
+ return -EFAULT;
}
if (cmd & IOC_OUT) {
- ret = verify_area(VERIFY_WRITE, argp, size);
- if (ret) return ret;
+ if (!access_ok(VERIFY_WRITE, argp, size))
+ return -EFAULT;
}
switch (cmd) {
if (!mtd->write_oob)
ret = -EOPNOTSUPP;
else
- ret = verify_area(VERIFY_READ, buf.ptr, buf.length);
+ ret = access_ok(VERIFY_READ, buf.ptr,
+ buf.length) ? 0 : EFAULT;
if (ret)
return ret;
if (!mtd->read_oob)
ret = -EOPNOTSUPP;
else
- ret = verify_area(VERIFY_WRITE, buf.ptr, buf.length);
+ ret = access_ok(VERIFY_WRITE, buf.ptr,
+ buf.length) ? 0 : -EFAULT;
if (ret)
return ret;