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