Commit beb133fc authored by Brian Norris's avatar Brian Norris Committed by Artem Bityutskiy

mtd: rename MTD_MODE_* to MTD_FILE_MODE_*

These modes hold their state only for the life of their file descriptor,
and they overlap functionality with the MTD_OPS_* modes. Particularly,
MTD_MODE_RAW and MTD_OPS_RAW cover the same function: to provide raw
(i.e., without ECC) access to the flash. In fact, although it may not be
clear, MTD_MODE_RAW implied that operations should enable the
MTD_OPS_RAW mode.

Thus, we should be specific on what each mode means. This is a start,
where MTD_FILE_MODE_* actually represents a "file mode," not necessarily
a true global MTD mode.
Signed-off-by: default avatarBrian Norris <computersforpeace@gmail.com>
Signed-off-by: default avatarArtem Bityutskiy <artem.bityutskiy@intel.com>
parent 0612b9dd
...@@ -211,13 +211,13 @@ static ssize_t mtd_read(struct file *file, char __user *buf, size_t count,loff_t ...@@ -211,13 +211,13 @@ static ssize_t mtd_read(struct file *file, char __user *buf, size_t count,loff_t
len = min_t(size_t, count, size); len = min_t(size_t, count, size);
switch (mfi->mode) { switch (mfi->mode) {
case MTD_MODE_OTP_FACTORY: case MTD_FILE_MODE_OTP_FACTORY:
ret = mtd->read_fact_prot_reg(mtd, *ppos, len, &retlen, kbuf); ret = mtd->read_fact_prot_reg(mtd, *ppos, len, &retlen, kbuf);
break; break;
case MTD_MODE_OTP_USER: case MTD_FILE_MODE_OTP_USER:
ret = mtd->read_user_prot_reg(mtd, *ppos, len, &retlen, kbuf); ret = mtd->read_user_prot_reg(mtd, *ppos, len, &retlen, kbuf);
break; break;
case MTD_MODE_RAW: case MTD_FILE_MODE_RAW:
{ {
struct mtd_oob_ops ops; struct mtd_oob_ops ops;
...@@ -302,10 +302,10 @@ static ssize_t mtd_write(struct file *file, const char __user *buf, size_t count ...@@ -302,10 +302,10 @@ static ssize_t mtd_write(struct file *file, const char __user *buf, size_t count
} }
switch (mfi->mode) { switch (mfi->mode) {
case MTD_MODE_OTP_FACTORY: case MTD_FILE_MODE_OTP_FACTORY:
ret = -EROFS; ret = -EROFS;
break; break;
case MTD_MODE_OTP_USER: case MTD_FILE_MODE_OTP_USER:
if (!mtd->write_user_prot_reg) { if (!mtd->write_user_prot_reg) {
ret = -EOPNOTSUPP; ret = -EOPNOTSUPP;
break; break;
...@@ -313,7 +313,7 @@ static ssize_t mtd_write(struct file *file, const char __user *buf, size_t count ...@@ -313,7 +313,7 @@ static ssize_t mtd_write(struct file *file, const char __user *buf, size_t count
ret = mtd->write_user_prot_reg(mtd, *ppos, len, &retlen, kbuf); ret = mtd->write_user_prot_reg(mtd, *ppos, len, &retlen, kbuf);
break; break;
case MTD_MODE_RAW: case MTD_FILE_MODE_RAW:
{ {
struct mtd_oob_ops ops; struct mtd_oob_ops ops;
...@@ -368,13 +368,13 @@ static int otp_select_filemode(struct mtd_file_info *mfi, int mode) ...@@ -368,13 +368,13 @@ static int otp_select_filemode(struct mtd_file_info *mfi, int mode)
if (!mtd->read_fact_prot_reg) if (!mtd->read_fact_prot_reg)
ret = -EOPNOTSUPP; ret = -EOPNOTSUPP;
else else
mfi->mode = MTD_MODE_OTP_FACTORY; mfi->mode = MTD_FILE_MODE_OTP_FACTORY;
break; break;
case MTD_OTP_USER: case MTD_OTP_USER:
if (!mtd->read_fact_prot_reg) if (!mtd->read_fact_prot_reg)
ret = -EOPNOTSUPP; ret = -EOPNOTSUPP;
else else
mfi->mode = MTD_MODE_OTP_USER; mfi->mode = MTD_FILE_MODE_OTP_USER;
break; break;
default: default:
ret = -EINVAL; ret = -EINVAL;
...@@ -413,7 +413,7 @@ static int mtd_do_writeoob(struct file *file, struct mtd_info *mtd, ...@@ -413,7 +413,7 @@ static int mtd_do_writeoob(struct file *file, struct mtd_info *mtd,
ops.ooblen = length; ops.ooblen = length;
ops.ooboffs = start & (mtd->writesize - 1); ops.ooboffs = start & (mtd->writesize - 1);
ops.datbuf = NULL; ops.datbuf = NULL;
ops.mode = (mfi->mode == MTD_MODE_RAW) ? MTD_OPS_RAW : ops.mode = (mfi->mode == MTD_FILE_MODE_RAW) ? MTD_OPS_RAW :
MTD_OPS_PLACE_OOB; MTD_OPS_PLACE_OOB;
if (ops.ooboffs && ops.ooblen > (mtd->oobsize - ops.ooboffs)) if (ops.ooboffs && ops.ooblen > (mtd->oobsize - ops.ooboffs))
...@@ -458,7 +458,7 @@ static int mtd_do_readoob(struct file *file, struct mtd_info *mtd, ...@@ -458,7 +458,7 @@ static int mtd_do_readoob(struct file *file, struct mtd_info *mtd,
ops.ooblen = length; ops.ooblen = length;
ops.ooboffs = start & (mtd->writesize - 1); ops.ooboffs = start & (mtd->writesize - 1);
ops.datbuf = NULL; ops.datbuf = NULL;
ops.mode = (mfi->mode == MTD_MODE_RAW) ? MTD_OPS_RAW : ops.mode = (mfi->mode == MTD_FILE_MODE_RAW) ? MTD_OPS_RAW :
MTD_OPS_PLACE_OOB; MTD_OPS_PLACE_OOB;
if (ops.ooboffs && ops.ooblen > (mtd->oobsize - ops.ooboffs)) if (ops.ooboffs && ops.ooblen > (mtd->oobsize - ops.ooboffs))
...@@ -849,7 +849,7 @@ static int mtd_ioctl(struct file *file, u_int cmd, u_long arg) ...@@ -849,7 +849,7 @@ static int mtd_ioctl(struct file *file, u_int cmd, u_long arg)
if (copy_from_user(&mode, argp, sizeof(int))) if (copy_from_user(&mode, argp, sizeof(int)))
return -EFAULT; return -EFAULT;
mfi->mode = MTD_MODE_NORMAL; mfi->mode = MTD_FILE_MODE_NORMAL;
ret = otp_select_filemode(mfi, mode); ret = otp_select_filemode(mfi, mode);
...@@ -865,11 +865,11 @@ static int mtd_ioctl(struct file *file, u_int cmd, u_long arg) ...@@ -865,11 +865,11 @@ static int mtd_ioctl(struct file *file, u_int cmd, u_long arg)
return -ENOMEM; return -ENOMEM;
ret = -EOPNOTSUPP; ret = -EOPNOTSUPP;
switch (mfi->mode) { switch (mfi->mode) {
case MTD_MODE_OTP_FACTORY: case MTD_FILE_MODE_OTP_FACTORY:
if (mtd->get_fact_prot_info) if (mtd->get_fact_prot_info)
ret = mtd->get_fact_prot_info(mtd, buf, 4096); ret = mtd->get_fact_prot_info(mtd, buf, 4096);
break; break;
case MTD_MODE_OTP_USER: case MTD_FILE_MODE_OTP_USER:
if (mtd->get_user_prot_info) if (mtd->get_user_prot_info)
ret = mtd->get_user_prot_info(mtd, buf, 4096); ret = mtd->get_user_prot_info(mtd, buf, 4096);
break; break;
...@@ -893,7 +893,7 @@ static int mtd_ioctl(struct file *file, u_int cmd, u_long arg) ...@@ -893,7 +893,7 @@ static int mtd_ioctl(struct file *file, u_int cmd, u_long arg)
{ {
struct otp_info oinfo; struct otp_info oinfo;
if (mfi->mode != MTD_MODE_OTP_USER) if (mfi->mode != MTD_FILE_MODE_OTP_USER)
return -EINVAL; return -EINVAL;
if (copy_from_user(&oinfo, argp, sizeof(oinfo))) if (copy_from_user(&oinfo, argp, sizeof(oinfo)))
return -EFAULT; return -EFAULT;
...@@ -937,17 +937,17 @@ static int mtd_ioctl(struct file *file, u_int cmd, u_long arg) ...@@ -937,17 +937,17 @@ static int mtd_ioctl(struct file *file, u_int cmd, u_long arg)
mfi->mode = 0; mfi->mode = 0;
switch(arg) { switch(arg) {
case MTD_MODE_OTP_FACTORY: case MTD_FILE_MODE_OTP_FACTORY:
case MTD_MODE_OTP_USER: case MTD_FILE_MODE_OTP_USER:
ret = otp_select_filemode(mfi, arg); ret = otp_select_filemode(mfi, arg);
break; break;
case MTD_MODE_RAW: case MTD_FILE_MODE_RAW:
if (!mtd->read_oob || !mtd->write_oob) if (!mtd->read_oob || !mtd->write_oob)
return -EOPNOTSUPP; return -EOPNOTSUPP;
mfi->mode = arg; mfi->mode = arg;
case MTD_MODE_NORMAL: case MTD_FILE_MODE_NORMAL:
break; break;
default: default:
ret = -EINVAL; ret = -EINVAL;
......
...@@ -200,10 +200,10 @@ struct mtd_ecc_stats { ...@@ -200,10 +200,10 @@ struct mtd_ecc_stats {
* Read/write file modes for access to MTD * Read/write file modes for access to MTD
*/ */
enum mtd_file_modes { enum mtd_file_modes {
MTD_MODE_NORMAL = MTD_OTP_OFF, MTD_FILE_MODE_NORMAL = MTD_OTP_OFF,
MTD_MODE_OTP_FACTORY = MTD_OTP_FACTORY, MTD_FILE_MODE_OTP_FACTORY = MTD_OTP_FACTORY,
MTD_MODE_OTP_USER = MTD_OTP_USER, MTD_FILE_MODE_OTP_USER = MTD_OTP_USER,
MTD_MODE_RAW, MTD_FILE_MODE_RAW,
}; };
#endif /* __MTD_ABI_H__ */ #endif /* __MTD_ABI_H__ */
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment