kernel/3.6: remove yaffs support
[openwrt.git] / target / linux / generic / patches-3.9 / 508-yaffs-3.3-use-mtd_-helpers.patch
1 --- a/fs/yaffs2/yaffs_mtdif1.c
2 +++ b/fs/yaffs2/yaffs_mtdif1.c
3 @@ -133,7 +133,7 @@ int nandmtd1_WriteChunkWithTagsToNAND(ya
4         ops.datbuf = (__u8 *)data;
5         ops.oobbuf = (__u8 *)&pt1;
6  
7 -       retval = mtd->write_oob(mtd, addr, &ops);
8 +       retval = mtd_write_oob(mtd, addr, &ops);
9         if (retval) {
10                 T(YAFFS_TRACE_MTD,
11                         (TSTR("write_oob failed, chunk %d, mtd error %d"TENDSTR),
12 @@ -194,7 +194,7 @@ int nandmtd1_ReadChunkWithTagsFromNAND(y
13         /* Read page and oob using MTD.
14          * Check status and determine ECC result.
15          */
16 -       retval = mtd->read_oob(mtd, addr, &ops);
17 +       retval = mtd_read_oob(mtd, addr, &ops);
18         if (retval) {
19                 T(YAFFS_TRACE_MTD,
20                         (TSTR("read_oob failed, chunk %d, mtd error %d"TENDSTR),
21 @@ -218,7 +218,7 @@ int nandmtd1_ReadChunkWithTagsFromNAND(y
22                 /* fall into... */
23         default:
24                 rettags(etags, YAFFS_ECC_RESULT_UNFIXED, 0);
25 -               etags->block_bad = (mtd->block_isbad)(mtd, addr);
26 +               etags->block_bad = mtd_block_isbad(mtd, addr);
27                 return YAFFS_FAIL;
28         }
29  
30 @@ -286,7 +286,7 @@ int nandmtd1_MarkNANDBlockBad(struct yaf
31  
32         T(YAFFS_TRACE_BAD_BLOCKS,(TSTR("marking block %d bad"TENDSTR), block_no));
33  
34 -       retval = mtd->block_markbad(mtd, (loff_t)blocksize * block_no);
35 +       retval = mtd_block_markbad(mtd, (loff_t)blocksize * block_no);
36         return (retval) ? YAFFS_FAIL : YAFFS_OK;
37  }
38  
39 @@ -336,7 +336,7 @@ int nandmtd1_QueryNANDBlock(struct yaffs
40                 return YAFFS_FAIL;
41  
42         retval = nandmtd1_ReadChunkWithTagsFromNAND(dev, chunkNo, NULL, &etags);
43 -       etags.block_bad = (mtd->block_isbad)(mtd, addr);
44 +       etags.block_bad = mtd_block_isbad(mtd, addr);
45         if (etags.block_bad) {
46                 T(YAFFS_TRACE_BAD_BLOCKS,
47                         (TSTR("block %d is marked bad"TENDSTR), block_no));
48 --- a/fs/yaffs2/yaffs_vfs_glue.c
49 +++ b/fs/yaffs2/yaffs_vfs_glue.c
50 @@ -2607,8 +2607,8 @@ static void yaffs_MTDPutSuper(struct sup
51  {
52         struct mtd_info *mtd = yaffs_dev_to_mtd(yaffs_SuperToDevice(sb));
53  
54 -       if (mtd->sync)
55 -               mtd->sync(mtd);
56 +       if (mtd)
57 +               mtd_sync(mtd);
58  
59         put_mtd_device(mtd);
60  }
61 --- a/fs/yaffs2/yaffs_mtdif2.c
62 +++ b/fs/yaffs2/yaffs_mtdif2.c
63 @@ -77,7 +77,7 @@ int nandmtd2_WriteChunkWithTagsToNAND(ya
64         ops.ooboffs = 0;
65         ops.datbuf = (__u8 *)data;
66         ops.oobbuf = (dev->param.inband_tags) ? NULL : packed_tags_ptr;
67 -       retval = mtd->write_oob(mtd, addr, &ops);
68 +       retval = mtd_write_oob(mtd, addr, &ops);
69  
70  #else
71         if (!dev->param.inband_tags) {
72 @@ -133,7 +133,7 @@ int nandmtd2_ReadChunkWithTagsFromNAND(y
73  
74  #if (LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 17))
75         if (dev->param.inband_tags || (data && !tags))
76 -               retval = mtd->read(mtd, addr, dev->param.total_bytes_per_chunk,
77 +               retval = mtd_read(mtd, addr, dev->param.total_bytes_per_chunk,
78                                 &dummy, data);
79         else if (tags) {
80                 ops.mode = MTD_OPS_AUTO_OOB;
81 @@ -142,7 +142,7 @@ int nandmtd2_ReadChunkWithTagsFromNAND(y
82                 ops.ooboffs = 0;
83                 ops.datbuf = data;
84                 ops.oobbuf = yaffs_dev_to_lc(dev)->spareBuffer;
85 -               retval = mtd->read_oob(mtd, addr, &ops);
86 +               retval = mtd_read_oob(mtd, addr, &ops);
87         }
88  #else
89         if (!dev->param.inband_tags && data && tags) {
90 @@ -201,7 +201,7 @@ int nandmtd2_MarkNANDBlockBad(struct yaf
91           (TSTR("nandmtd2_MarkNANDBlockBad %d" TENDSTR), block_no));
92  
93         retval =
94 -           mtd->block_markbad(mtd,
95 +           mtd_block_markbad(mtd,
96                                block_no * dev->param.chunks_per_block *
97                                dev->param.total_bytes_per_chunk);
98  
99 @@ -221,7 +221,7 @@ int nandmtd2_QueryNANDBlock(struct yaffs
100         T(YAFFS_TRACE_MTD,
101           (TSTR("nandmtd2_QueryNANDBlock %d" TENDSTR), block_no));
102         retval =
103 -           mtd->block_isbad(mtd,
104 +           mtd_block_isbad(mtd,
105                              block_no * dev->param.chunks_per_block *
106                              dev->param.total_bytes_per_chunk);
107  
108 --- a/fs/yaffs2/yaffs_mtdif.h
109 +++ b/fs/yaffs2/yaffs_mtdif.h
110 @@ -31,4 +31,39 @@ int nandmtd_InitialiseNAND(yaffs_dev_t *
111  #define MTD_OPS_AUTO_OOB       MTD_OOB_AUTO
112  #endif
113  
114 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(3, 3, 0))
115 +static inline int mtd_erase(struct mdt_info *mtd, struct erase_info *ei)
116 +{
117 +       return mtd->erase(mtd, ei);
118 +}
119 +
120 +static inline int mtd_block_markbad(struct mtd_info *mtd, loff_t ofs)
121 +{
122 +       return mtd->block_mark_bad(mtd, ofs);
123 +}
124 +
125 +static inline int mtd_block_isbad(struct mtd_info *mtd, loff_t ofs)
126 +{
127 +       return mtd->block_is_bad(mtd, ofs);
128 +}
129 +
130 +static inline int mtd_read_oob(struct mtd_info *mtd, loff_t from,
131 +                              struct mtd_oob_ops *ops)
132 +{
133 +       return mtd->read_oob(mtd, from, ops);
134 +}
135 +
136 +static inline int mtd_write_oob(struct mtd_info *mtd, loff_t to,
137 +                               struct mtd_oob_ops *ops)
138 +{
139 +       return mtd->write_oob(mtd, to, ops);
140 +}
141 +
142 +static inline void mtd_sync(struct mtd_info *mtd)
143 +{
144 +       if (mtd->sync)
145 +               mtd->sync(mtd);
146 +}
147 +#endif
148 +
149  #endif
150 --- a/fs/yaffs2/yaffs_mtdif.c
151 +++ b/fs/yaffs2/yaffs_mtdif.c
152 @@ -41,7 +41,7 @@ int nandmtd_EraseBlockInNAND(yaffs_dev_t
153         ei.callback = NULL;
154         ei.priv = (u_long) dev;
155  
156 -       retval = mtd->erase(mtd, &ei);
157 +       retval = mtd_erase(mtd, &ei);
158  
159         if (retval == 0)
160                 return YAFFS_OK;