mtd: mtd->write_user_prot_reg directly

Linux-MTD Mailing List linux-mtd at lists.infradead.org
Mon Jan 9 13:59:16 EST 2012


Gitweb:     http://git.infradead.org/?p=mtd-2.6.git;a=commit;h=27c151a5e52efaa46d0938984f2ef591bdcb6d5b
Commit:     27c151a5e52efaa46d0938984f2ef591bdcb6d5b
Parent:     b6de3d6cb63427178c4f1df88b81d1ceee637e6f
Author:     Artem Bityutskiy <artem.bityutskiy at linux.intel.com>
AuthorDate: Thu Dec 29 10:39:20 2011 +0200
Committer:  David Woodhouse <David.Woodhouse at intel.com>
CommitDate: Mon Jan 9 18:26:17 2012 +0000

    mtd: mtd->write_user_prot_reg directly
    
    Instead, just call 'mtd_write_user_prot_reg()' and check the '-EOPNOTSUPP' return
    code.
    
    Signed-off-by: Artem Bityutskiy <artem.bityutskiy at linux.intel.com>
    Signed-off-by: David Woodhouse <David.Woodhouse at intel.com>
---
 drivers/mtd/mtdchar.c   |    4 ----
 include/linux/mtd/mtd.h |    2 ++
 2 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/mtd/mtdchar.c b/drivers/mtd/mtdchar.c
index 4e8e5fb..25bbbc3 100644
--- a/drivers/mtd/mtdchar.c
+++ b/drivers/mtd/mtdchar.c
@@ -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;
diff --git a/include/linux/mtd/mtd.h b/include/linux/mtd/mtd.h
index e488cf9..7cd56d2 100644
--- a/include/linux/mtd/mtd.h
+++ b/include/linux/mtd/mtd.h
@@ -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);
 }
 



More information about the linux-mtd-cvs mailing list