Skip to content

Commit 27c151a

Browse files
dedekindDavid Woodhouse
authored andcommitted
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@linux.intel.com> Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
1 parent b6de3d6 commit 27c151a

2 files changed

Lines changed: 2 additions & 4 deletions

File tree

‎drivers/mtd/mtdchar.c‎

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -310,10 +310,6 @@ static ssize_t mtdchar_write(struct file *file, const char __user *buf, size_t c
310310
ret = -EROFS;
311311
break;
312312
case MTD_FILE_MODE_OTP_USER:
313-
if (!mtd->write_user_prot_reg) {
314-
ret = -EOPNOTSUPP;
315-
break;
316-
}
317313
ret = mtd_write_user_prot_reg(mtd, *ppos, len,
318314
&retlen, kbuf);
319315
break;

‎include/linux/mtd/mtd.h‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -381,6 +381,8 @@ static inline int mtd_write_user_prot_reg(struct mtd_info *mtd, loff_t to,
381381
u_char *buf)
382382
{
383383
*retlen = 0;
384+
if (!mtd->write_user_prot_reg)
385+
return -EOPNOTSUPP;
384386
return mtd->write_user_prot_reg(mtd, to, len, retlen, buf);
385387
}
386388

0 commit comments

Comments
 (0)