提交 5dc63fa2 编写于 作者: U Uwe Kleine-König 提交者: David Woodhouse

mtd: mtdchar: handle chips that have user otp but no factory otp

Before this patch mtd_read_fact_prot_reg was used to check availability
for both MTD_OTP_FACTORY and MTD_OTP_USER access. This made accessing
user otp for chips that don't have a factory otp area impossible. So use
the right wrapper depending on the intended area to be accessed.
Signed-off-by: NUwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: NArtem Bityutskiy <artem.bityutskiy@linux.intel.com>
Signed-off-by: NDavid Woodhouse <David.Woodhouse@intel.com>
上级 6b75152b
...@@ -370,28 +370,30 @@ static int otp_select_filemode(struct mtd_file_info *mfi, int mode) ...@@ -370,28 +370,30 @@ static int otp_select_filemode(struct mtd_file_info *mfi, int mode)
{ {
struct mtd_info *mtd = mfi->mtd; struct mtd_info *mtd = mfi->mtd;
size_t retlen; 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, 0, &retlen, NULL) == -EOPNOTSUPP)
return -EOPNOTSUPP;
switch (mode) { switch (mode) {
case MTD_OTP_FACTORY: case MTD_OTP_FACTORY:
if (mtd_read_fact_prot_reg(mtd, -1, 0, &retlen, NULL) ==
-EOPNOTSUPP)
return -EOPNOTSUPP;
mfi->mode = MTD_FILE_MODE_OTP_FACTORY; mfi->mode = MTD_FILE_MODE_OTP_FACTORY;
break; break;
case MTD_OTP_USER: case MTD_OTP_USER:
if (mtd_read_user_prot_reg(mtd, -1, 0, &retlen, NULL) ==
-EOPNOTSUPP)
return -EOPNOTSUPP;
mfi->mode = MTD_FILE_MODE_OTP_USER; mfi->mode = MTD_FILE_MODE_OTP_USER;
break; break;
default:
ret = -EINVAL;
case MTD_OTP_OFF: case MTD_OTP_OFF:
mfi->mode = MTD_FILE_MODE_NORMAL;
break; break;
default:
return -EINVAL;
} }
return ret;
return 0;
} }
#else #else
# define otp_select_filemode(f,m) -EOPNOTSUPP # define otp_select_filemode(f,m) -EOPNOTSUPP
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册