aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorBrian Norris <computersforpeace@gmail.com>2011-08-30 21:45:41 -0400
committerArtem Bityutskiy <artem.bityutskiy@intel.com>2011-09-11 08:29:36 -0400
commitbeb133fc165e1289c858d8f952b982b7d0b313cd (patch)
treed247b021d3e28f16cfaf74e08404a304f554882c /drivers
parent0612b9ddc2eeda014dd805c87c752b342d8f80f0 (diff)
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: Brian Norris <computersforpeace@gmail.com> Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/mtd/mtdchar.c36
1 files changed, 18 insertions, 18 deletions
diff --git a/drivers/mtd/mtdchar.c b/drivers/mtd/mtdchar.c
index 9b76438a3c27..4004f2b2f403 100644
--- a/drivers/mtd/mtdchar.c
+++ b/drivers/mtd/mtdchar.c
@@ -211,13 +211,13 @@ static ssize_t mtd_read(struct file *file, char __user *buf, size_t count,loff_t
211 len = min_t(size_t, count, size); 211 len = min_t(size_t, count, size);
212 212
213 switch (mfi->mode) { 213 switch (mfi->mode) {
214 case MTD_MODE_OTP_FACTORY: 214 case MTD_FILE_MODE_OTP_FACTORY:
215 ret = mtd->read_fact_prot_reg(mtd, *ppos, len, &retlen, kbuf); 215 ret = mtd->read_fact_prot_reg(mtd, *ppos, len, &retlen, kbuf);
216 break; 216 break;
217 case MTD_MODE_OTP_USER: 217 case MTD_FILE_MODE_OTP_USER:
218 ret = mtd->read_user_prot_reg(mtd, *ppos, len, &retlen, kbuf); 218 ret = mtd->read_user_prot_reg(mtd, *ppos, len, &retlen, kbuf);
219 break; 219 break;
220 case MTD_MODE_RAW: 220 case MTD_FILE_MODE_RAW:
221 { 221 {
222 struct mtd_oob_ops ops; 222 struct mtd_oob_ops ops;
223 223
@@ -302,10 +302,10 @@ static ssize_t mtd_write(struct file *file, const char __user *buf, size_t count
302 } 302 }
303 303
304 switch (mfi->mode) { 304 switch (mfi->mode) {
305 case MTD_MODE_OTP_FACTORY: 305 case MTD_FILE_MODE_OTP_FACTORY:
306 ret = -EROFS; 306 ret = -EROFS;
307 break; 307 break;
308 case MTD_MODE_OTP_USER: 308 case MTD_FILE_MODE_OTP_USER:
309 if (!mtd->write_user_prot_reg) { 309 if (!mtd->write_user_prot_reg) {
310 ret = -EOPNOTSUPP; 310 ret = -EOPNOTSUPP;
311 break; 311 break;
@@ -313,7 +313,7 @@ static ssize_t mtd_write(struct file *file, const char __user *buf, size_t count
313 ret = mtd->write_user_prot_reg(mtd, *ppos, len, &retlen, kbuf); 313 ret = mtd->write_user_prot_reg(mtd, *ppos, len, &retlen, kbuf);
314 break; 314 break;
315 315
316 case MTD_MODE_RAW: 316 case MTD_FILE_MODE_RAW:
317 { 317 {
318 struct mtd_oob_ops ops; 318 struct mtd_oob_ops ops;
319 319
@@ -368,13 +368,13 @@ static int otp_select_filemode(struct mtd_file_info *mfi, int mode)
368 if (!mtd->read_fact_prot_reg) 368 if (!mtd->read_fact_prot_reg)
369 ret = -EOPNOTSUPP; 369 ret = -EOPNOTSUPP;
370 else 370 else
371 mfi->mode = MTD_MODE_OTP_FACTORY; 371 mfi->mode = MTD_FILE_MODE_OTP_FACTORY;
372 break; 372 break;
373 case MTD_OTP_USER: 373 case MTD_OTP_USER:
374 if (!mtd->read_fact_prot_reg) 374 if (!mtd->read_fact_prot_reg)
375 ret = -EOPNOTSUPP; 375 ret = -EOPNOTSUPP;
376 else 376 else
377 mfi->mode = MTD_MODE_OTP_USER; 377 mfi->mode = MTD_FILE_MODE_OTP_USER;
378 break; 378 break;
379 default: 379 default:
380 ret = -EINVAL; 380 ret = -EINVAL;
@@ -413,7 +413,7 @@ static int mtd_do_writeoob(struct file *file, struct mtd_info *mtd,
413 ops.ooblen = length; 413 ops.ooblen = length;
414 ops.ooboffs = start & (mtd->writesize - 1); 414 ops.ooboffs = start & (mtd->writesize - 1);
415 ops.datbuf = NULL; 415 ops.datbuf = NULL;
416 ops.mode = (mfi->mode == MTD_MODE_RAW) ? MTD_OPS_RAW : 416 ops.mode = (mfi->mode == MTD_FILE_MODE_RAW) ? MTD_OPS_RAW :
417 MTD_OPS_PLACE_OOB; 417 MTD_OPS_PLACE_OOB;
418 418
419 if (ops.ooboffs && ops.ooblen > (mtd->oobsize - ops.ooboffs)) 419 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 ops.ooblen = length; 458 ops.ooblen = length;
459 ops.ooboffs = start & (mtd->writesize - 1); 459 ops.ooboffs = start & (mtd->writesize - 1);
460 ops.datbuf = NULL; 460 ops.datbuf = NULL;
461 ops.mode = (mfi->mode == MTD_MODE_RAW) ? MTD_OPS_RAW : 461 ops.mode = (mfi->mode == MTD_FILE_MODE_RAW) ? MTD_OPS_RAW :
462 MTD_OPS_PLACE_OOB; 462 MTD_OPS_PLACE_OOB;
463 463
464 if (ops.ooboffs && ops.ooblen > (mtd->oobsize - ops.ooboffs)) 464 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 if (copy_from_user(&mode, argp, sizeof(int))) 849 if (copy_from_user(&mode, argp, sizeof(int)))
850 return -EFAULT; 850 return -EFAULT;
851 851
852 mfi->mode = MTD_MODE_NORMAL; 852 mfi->mode = MTD_FILE_MODE_NORMAL;
853 853
854 ret = otp_select_filemode(mfi, mode); 854 ret = otp_select_filemode(mfi, mode);
855 855
@@ -865,11 +865,11 @@ static int mtd_ioctl(struct file *file, u_int cmd, u_long arg)
865 return -ENOMEM; 865 return -ENOMEM;
866 ret = -EOPNOTSUPP; 866 ret = -EOPNOTSUPP;
867 switch (mfi->mode) { 867 switch (mfi->mode) {
868 case MTD_MODE_OTP_FACTORY: 868 case MTD_FILE_MODE_OTP_FACTORY:
869 if (mtd->get_fact_prot_info) 869 if (mtd->get_fact_prot_info)
870 ret = mtd->get_fact_prot_info(mtd, buf, 4096); 870 ret = mtd->get_fact_prot_info(mtd, buf, 4096);
871 break; 871 break;
872 case MTD_MODE_OTP_USER: 872 case MTD_FILE_MODE_OTP_USER:
873 if (mtd->get_user_prot_info) 873 if (mtd->get_user_prot_info)
874 ret = mtd->get_user_prot_info(mtd, buf, 4096); 874 ret = mtd->get_user_prot_info(mtd, buf, 4096);
875 break; 875 break;
@@ -893,7 +893,7 @@ static int mtd_ioctl(struct file *file, u_int cmd, u_long arg)
893 { 893 {
894 struct otp_info oinfo; 894 struct otp_info oinfo;
895 895
896 if (mfi->mode != MTD_MODE_OTP_USER) 896 if (mfi->mode != MTD_FILE_MODE_OTP_USER)
897 return -EINVAL; 897 return -EINVAL;
898 if (copy_from_user(&oinfo, argp, sizeof(oinfo))) 898 if (copy_from_user(&oinfo, argp, sizeof(oinfo)))
899 return -EFAULT; 899 return -EFAULT;
@@ -937,17 +937,17 @@ static int mtd_ioctl(struct file *file, u_int cmd, u_long arg)
937 mfi->mode = 0; 937 mfi->mode = 0;
938 938
939 switch(arg) { 939 switch(arg) {
940 case MTD_MODE_OTP_FACTORY: 940 case MTD_FILE_MODE_OTP_FACTORY:
941 case MTD_MODE_OTP_USER: 941 case MTD_FILE_MODE_OTP_USER:
942 ret = otp_select_filemode(mfi, arg); 942 ret = otp_select_filemode(mfi, arg);
943 break; 943 break;
944 944
945 case MTD_MODE_RAW: 945 case MTD_FILE_MODE_RAW:
946 if (!mtd->read_oob || !mtd->write_oob) 946 if (!mtd->read_oob || !mtd->write_oob)
947 return -EOPNOTSUPP; 947 return -EOPNOTSUPP;
948 mfi->mode = arg; 948 mfi->mode = arg;
949 949
950 case MTD_MODE_NORMAL: 950 case MTD_FILE_MODE_NORMAL:
951 break; 951 break;
952 default: 952 default:
953 ret = -EINVAL; 953 ret = -EINVAL;