kernel: add missing config symbol
[15.05/openwrt.git] / target / linux / generic / patches-3.18 / 503-yaffs-add-tags-9bytes-mount-option.patch
1 Subject: yaffs: add support for tags-9bytes mount option
2
3 Signed-off-by: Gabor Juhos <juhosg@openwrt.org>
4 ---
5 --- a/fs/yaffs2/yaffs_vfs.c
6 +++ b/fs/yaffs2/yaffs_vfs.c
7 @@ -2605,6 +2605,7 @@ static const struct super_operations yaf
8  
9  struct yaffs_options {
10         int inband_tags;
11 +       int tags_9bytes;
12         int skip_checkpoint_read;
13         int skip_checkpoint_write;
14         int no_cache;
15 @@ -2644,6 +2645,8 @@ static int yaffs_parse_options(struct ya
16  
17                 if (!strcmp(cur_opt, "inband-tags")) {
18                         options->inband_tags = 1;
19 +               } else if (!strcmp(cur_opt, "tags-9bytes")) {
20 +                       options->tags_9bytes = 1;
21                 } else if (!strcmp(cur_opt, "tags-ecc-off")) {
22                         options->tags_ecc_on = 0;
23                         options->tags_ecc_overridden = 1;
24 @@ -2717,7 +2720,6 @@ static struct super_block *yaffs_interna
25         struct yaffs_param *param;
26  
27         int read_only = 0;
28 -       int inband_tags = 0;
29  
30         struct yaffs_options options;
31  
32 @@ -2757,6 +2759,9 @@ static struct super_block *yaffs_interna
33  
34         memset(&options, 0, sizeof(options));
35  
36 +       if (IS_ENABLED(CONFIG_YAFFS_9BYTE_TAGS))
37 +               options.tags_9bytes = 1;
38 +
39         if (yaffs_parse_options(&options, data_str)) {
40                 /* Option parsing failed */
41                 return NULL;
42 @@ -2790,17 +2795,22 @@ static struct super_block *yaffs_interna
43         }
44  
45         /* Added NCB 26/5/2006 for completeness */
46 -       if (yaffs_version == 2 && !options.inband_tags
47 -           && WRITE_SIZE(mtd) == 512) {
48 +       if (yaffs_version == 2 &&
49 +           (!options.inband_tags || options.tags_9bytes) &&
50 +           WRITE_SIZE(mtd) == 512) {
51                 yaffs_trace(YAFFS_TRACE_ALWAYS, "auto selecting yaffs1");
52                 yaffs_version = 1;
53         }
54  
55 -       if (mtd->oobavail < sizeof(struct yaffs_packed_tags2) ||
56 -           options.inband_tags)
57 -               inband_tags = 1;
58 +       if (yaffs_version == 2 &&
59 +           mtd->oobavail < sizeof(struct yaffs_packed_tags2)) {
60 +               yaffs_trace(YAFFS_TRACE_ALWAYS, "auto selecting inband tags");
61 +               options.inband_tags = 1;
62 +       }
63  
64 -       if(yaffs_verify_mtd(mtd, yaffs_version, inband_tags) < 0)
65 +       err = yaffs_verify_mtd(mtd, yaffs_version, options.inband_tags,
66 +                              options.tags_9bytes);
67 +       if (err < 0)
68                 return NULL;
69  
70         /* OK, so if we got here, we have an MTD that's NAND and looks
71 @@ -2857,7 +2867,8 @@ static struct super_block *yaffs_interna
72  
73         param->n_reserved_blocks = 5;
74         param->n_caches = (options.no_cache) ? 0 : 10;
75 -       param->inband_tags = inband_tags;
76 +       param->inband_tags = options.inband_tags;
77 +       param->tags_9bytes = options.tags_9bytes;
78  
79         param->enable_xattr = 1;
80         if (options.lazy_loading_overridden)
81 --- a/fs/yaffs2/yaffs_mtdif.c
82 +++ b/fs/yaffs2/yaffs_mtdif.c
83 @@ -278,7 +278,8 @@ struct mtd_info * yaffs_get_mtd_device(d
84         return mtd;
85  }
86  
87 -int yaffs_verify_mtd(struct mtd_info *mtd, int yaffs_version, int inband_tags)
88 +int yaffs_verify_mtd(struct mtd_info *mtd, int yaffs_version, int inband_tags,
89 +                    int tags_9bytes)
90  {
91         if (yaffs_version == 2) {
92                 if ((WRITE_SIZE(mtd) < YAFFS_MIN_YAFFS2_CHUNK_SIZE ||
93 @@ -297,6 +298,12 @@ int yaffs_verify_mtd(struct mtd_info *mt
94                         );
95                         return -1;
96                 }
97 +
98 +               if (tags_9bytes && mtd->oobavail < 9) {
99 +                       yaffs_trace(YAFFS_TRACE_ALWAYS,
100 +                                   "MTD device does not support 9-byte tags");
101 +                       return -1;
102 +               }
103         }
104  
105         return 0;
106 --- a/fs/yaffs2/yaffs_mtdif.h
107 +++ b/fs/yaffs2/yaffs_mtdif.h
108 @@ -21,5 +21,6 @@
109  void yaffs_mtd_drv_install(struct yaffs_dev *dev);
110  struct mtd_info * yaffs_get_mtd_device(dev_t sdev);
111  void yaffs_put_mtd_device(struct mtd_info *mtd);
112 -int yaffs_verify_mtd(struct mtd_info *mtd, int yaffs_version, int inband_tags);
113 +int yaffs_verify_mtd(struct mtd_info *mtd, int yaffs_version, int inband_tags,
114 +                    int tags_9bytes);
115  #endif