diff options
author | Artem Bityutskiy <artem.bityutskiy@linux.intel.com> | 2011-12-28 11:47:46 -0500 |
---|---|---|
committer | David Woodhouse <David.Woodhouse@intel.com> | 2012-01-09 13:26:15 -0500 |
commit | 87e858a97e8a7010aedc01db7cd31cc7c02b0b6a (patch) | |
tree | c5ff8b86ef0ae7891224e620916c58241c3e1799 | |
parent | dac2639f9833e858139d7e07f6ee45fb2191a9f2 (diff) |
mtd: do not use mtd->get_*_prot_info directly
Instead, call 'mtd_get_*_prot_info()' and check for '-EOPNOTSUPP'. While
on it, fix the return code from '-EOPNOTSUPP' to '-EINVAL' for the case
when the mode parameter is invalid.
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
-rw-r--r-- | drivers/mtd/mtdchar.c | 8 | ||||
-rw-r--r-- | include/linux/mtd/mtd.h | 4 |
2 files changed, 7 insertions, 5 deletions
diff --git a/drivers/mtd/mtdchar.c b/drivers/mtd/mtdchar.c index 287ff0d3584..49340dc1b10 100644 --- a/drivers/mtd/mtdchar.c +++ b/drivers/mtd/mtdchar.c | |||
@@ -919,17 +919,15 @@ static int mtdchar_ioctl(struct file *file, u_int cmd, u_long arg) | |||
919 | struct otp_info *buf = kmalloc(4096, GFP_KERNEL); | 919 | struct otp_info *buf = kmalloc(4096, GFP_KERNEL); |
920 | if (!buf) | 920 | if (!buf) |
921 | return -ENOMEM; | 921 | return -ENOMEM; |
922 | ret = -EOPNOTSUPP; | ||
923 | switch (mfi->mode) { | 922 | switch (mfi->mode) { |
924 | case MTD_FILE_MODE_OTP_FACTORY: | 923 | case MTD_FILE_MODE_OTP_FACTORY: |
925 | if (mtd->get_fact_prot_info) | 924 | ret = mtd_get_fact_prot_info(mtd, buf, 4096); |
926 | ret = mtd_get_fact_prot_info(mtd, buf, 4096); | ||
927 | break; | 925 | break; |
928 | case MTD_FILE_MODE_OTP_USER: | 926 | case MTD_FILE_MODE_OTP_USER: |
929 | if (mtd->get_user_prot_info) | 927 | ret = mtd_get_user_prot_info(mtd, buf, 4096); |
930 | ret = mtd_get_user_prot_info(mtd, buf, 4096); | ||
931 | break; | 928 | break; |
932 | default: | 929 | default: |
930 | ret = -EINVAL; | ||
933 | break; | 931 | break; |
934 | } | 932 | } |
935 | if (ret >= 0) { | 933 | if (ret >= 0) { |
diff --git a/include/linux/mtd/mtd.h b/include/linux/mtd/mtd.h index 721a63ffeb9..7122efdc6d9 100644 --- a/include/linux/mtd/mtd.h +++ b/include/linux/mtd/mtd.h | |||
@@ -342,6 +342,8 @@ static inline int mtd_write_oob(struct mtd_info *mtd, loff_t to, | |||
342 | static inline int mtd_get_fact_prot_info(struct mtd_info *mtd, | 342 | static inline int mtd_get_fact_prot_info(struct mtd_info *mtd, |
343 | struct otp_info *buf, size_t len) | 343 | struct otp_info *buf, size_t len) |
344 | { | 344 | { |
345 | if (!mtd->get_fact_prot_info) | ||
346 | return -EOPNOTSUPP; | ||
345 | return mtd->get_fact_prot_info(mtd, buf, len); | 347 | return mtd->get_fact_prot_info(mtd, buf, len); |
346 | } | 348 | } |
347 | 349 | ||
@@ -357,6 +359,8 @@ static inline int mtd_get_user_prot_info(struct mtd_info *mtd, | |||
357 | struct otp_info *buf, | 359 | struct otp_info *buf, |
358 | size_t len) | 360 | size_t len) |
359 | { | 361 | { |
362 | if (!mtd->get_user_prot_info) | ||
363 | return -EOPNOTSUPP; | ||
360 | return mtd->get_user_prot_info(mtd, buf, len); | 364 | return mtd->get_user_prot_info(mtd, buf, len); |
361 | } | 365 | } |
362 | 366 | ||