mtd: do not use mtd->lock_user_prot_reg directly
authorArtem Bityutskiy <artem.bityutskiy@linux.intel.com>
Thu, 29 Dec 2011 08:45:04 +0000 (10:45 +0200)
committerDavid Woodhouse <David.Woodhouse@intel.com>
Mon, 9 Jan 2012 18:26:18 +0000 (18:26 +0000)
Instead, check the -EOPNOTSUPP return code of 'mtd_lock_user_prot_reg()'.

Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
drivers/mtd/mtdchar.c
include/linux/mtd/mtd.h

index 25bbbc3aa665fb778385e8a89b426322cce23edf..2020a169ed9c79098467c0815bfbdd56eae35497 100644 (file)
@@ -949,8 +949,6 @@ static int mtdchar_ioctl(struct file *file, u_int cmd, u_long arg)
                        return -EINVAL;
                if (copy_from_user(&oinfo, argp, sizeof(oinfo)))
                        return -EFAULT;
-               if (!mtd->lock_user_prot_reg)
-                       return -EOPNOTSUPP;
                ret = mtd_lock_user_prot_reg(mtd, oinfo.start, oinfo.length);
                break;
        }
index 7cd56d2b9419a6e55538919953e3d67a817b4320..a994129ede55ea77057b5f6bd016aea1a4b69380 100644 (file)
@@ -389,6 +389,8 @@ static inline int mtd_write_user_prot_reg(struct mtd_info *mtd, loff_t to,
 static inline int mtd_lock_user_prot_reg(struct mtd_info *mtd, loff_t from,
                                         size_t len)
 {
+       if (!mtd->lock_user_prot_reg)
+               return -EOPNOTSUPP;
        return mtd->lock_user_prot_reg(mtd, from, len);
 }