mtd: mtd->write_user_prot_reg directly
authorArtem Bityutskiy <artem.bityutskiy@linux.intel.com>
Thu, 29 Dec 2011 08:39:20 +0000 (10:39 +0200)
committerDavid Woodhouse <David.Woodhouse@intel.com>
Mon, 9 Jan 2012 18:26:17 +0000 (18:26 +0000)
Instead, just call 'mtd_write_user_prot_reg()' and check the '-EOPNOTSUPP' return
code.

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 4e8e5fbc1e132c4934e95f8504f5d1eab7db5d84..25bbbc3aa665fb778385e8a89b426322cce23edf 100644 (file)
@@ -310,10 +310,6 @@ static ssize_t mtdchar_write(struct file *file, const char __user *buf, size_t c
                        ret = -EROFS;
                        break;
                case MTD_FILE_MODE_OTP_USER:
-                       if (!mtd->write_user_prot_reg) {
-                               ret = -EOPNOTSUPP;
-                               break;
-                       }
                        ret = mtd_write_user_prot_reg(mtd, *ppos, len,
                                                      &retlen, kbuf);
                        break;
index e488cf9109148eebef66686c7ad450ddf0421628..7cd56d2b9419a6e55538919953e3d67a817b4320 100644 (file)
@@ -381,6 +381,8 @@ static inline int mtd_write_user_prot_reg(struct mtd_info *mtd, loff_t to,
                                          u_char *buf)
 {
        *retlen = 0;
+       if (!mtd->write_user_prot_reg)
+               return -EOPNOTSUPP;
        return mtd->write_user_prot_reg(mtd, to, len, retlen, buf);
 }