diff options
author | Artem Bityutskiy <artem.bityutskiy@linux.intel.com> | 2011-12-29 10:06:32 +0200 |
---|---|---|
committer | David Woodhouse <David.Woodhouse@intel.com> | 2012-01-09 18:26:16 +0000 |
commit | b6de3d6cb63427178c4f1df88b81d1ceee637e6f (patch) | |
tree | 9e84f24ac14305246c6f38e885edbc9f48dfc089 /drivers/mtd | |
parent | 87e858a97e8a7010aedc01db7cd31cc7c02b0b6a (diff) | |
download | linux-b6de3d6cb63427178c4f1df88b81d1ceee637e6f.tar.bz2 |
mtd: do not use mtd->read_*_prot_reg directly
Instead, call 'mtd_read_*_prot_info()' and check for -EOPNOTSUPP.
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
Diffstat (limited to 'drivers/mtd')
-rw-r--r-- | drivers/mtd/mtdchar.c | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/drivers/mtd/mtdchar.c b/drivers/mtd/mtdchar.c index 49340dc1b107..4e8e5fbc1e13 100644 --- a/drivers/mtd/mtdchar.c +++ b/drivers/mtd/mtdchar.c @@ -366,20 +366,22 @@ static void mtdchar_erase_callback (struct erase_info *instr) static int otp_select_filemode(struct mtd_file_info *mfi, int mode) { struct mtd_info *mtd = mfi->mtd; + size_t retlen; int ret = 0; + /* + * Make a fake call to mtd_read_fact_prot_reg() to check if OTP + * operations are supported. + */ + if (mtd_read_fact_prot_reg(mtd, -1, -1, &retlen, NULL) == -EOPNOTSUPP) + return -EOPNOTSUPP; + switch (mode) { case MTD_OTP_FACTORY: - if (!mtd->read_fact_prot_reg) - ret = -EOPNOTSUPP; - else - mfi->mode = MTD_FILE_MODE_OTP_FACTORY; + mfi->mode = MTD_FILE_MODE_OTP_FACTORY; break; case MTD_OTP_USER: - if (!mtd->read_fact_prot_reg) - ret = -EOPNOTSUPP; - else - mfi->mode = MTD_FILE_MODE_OTP_USER; + mfi->mode = MTD_FILE_MODE_OTP_USER; break; default: ret = -EINVAL; |