1 --- a/fs/yaffs2/yaffs_vfs_glue.c
2 +++ b/fs/yaffs2/yaffs_vfs_glue.c
3 @@ -220,11 +220,34 @@ static struct inode *yaffs_iget(struct s
4 #define yaffs_SuperToDevice(sb) ((yaffs_dev_t *)sb->u.generic_sbp)
7 +#if (LINUX_VERSION_CODE > KERNEL_VERSION(3, 2, 0))
8 +static inline void yaffs_set_nlink(struct inode *inode, unsigned int nlink)
10 + set_nlink(inode, nlink);
13 +static inline void yaffs_dec_link_count(struct inode *inode)
15 + inode_dec_link_count(inode);
18 +static inline void yaffs_set_nlink(struct inode *inode, unsigned int nlink)
20 + inode->i_nlink = nlink;
23 +static inline void yaffs_dec_link_count(struct inode *inode)
26 + mark_inode_dirty(inode)
31 #define update_dir_time(dir) do {\
32 (dir)->i_ctime = (dir)->i_mtime = CURRENT_TIME; \
36 static void yaffs_put_super(struct super_block *sb);
38 static ssize_t yaffs_file_write(struct file *f, const char *buf, size_t n,
39 @@ -238,7 +261,10 @@ static int yaffs_file_flush(struct file
40 static int yaffs_file_flush(struct file *file);
43 -#if (LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 34))
44 +#if (LINUX_VERSION_CODE > KERNEL_VERSION(3, 2, 0))
45 +static int yaffs_sync_object(struct file *file, loff_t start, loff_t end,
47 +#elif (LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 34))
48 static int yaffs_sync_object(struct file *file, int datasync);
50 static int yaffs_sync_object(struct file *file, struct dentry *dentry,
51 @@ -513,7 +539,7 @@ static unsigned yaffs_gc_control_callbac
53 return yaffs_gc_control;
57 static void yaffs_gross_lock(yaffs_dev_t *dev)
59 T(YAFFS_TRACE_LOCK, (TSTR("yaffs locking %p\n"), current));
60 @@ -1362,7 +1388,7 @@ static void yaffs_fill_inode_from_obj(st
61 inode->i_size = yaffs_get_obj_length(obj);
62 inode->i_blocks = (inode->i_size + 511) >> 9;
64 - inode->i_nlink = yaffs_get_obj_link_count(obj);
65 + yaffs_set_nlink(inode, yaffs_get_obj_link_count(obj));
68 (TSTR("yaffs_fill_inode mode %x uid %d gid %d size %d count %d\n"),
69 @@ -1810,10 +1836,9 @@ static int yaffs_unlink(struct inode *di
70 retVal = yaffs_unlinker(obj, dentry->d_name.name);
72 if (retVal == YAFFS_OK) {
73 - dentry->d_inode->i_nlink--;
74 + yaffs_dec_link_count(dentry->d_inode);
76 yaffs_gross_unlock(dev);
77 - mark_inode_dirty(dentry->d_inode);
81 @@ -1844,7 +1869,8 @@ static int yaffs_link(struct dentry *old
85 - old_dentry->d_inode->i_nlink = yaffs_get_obj_link_count(obj);
86 + yaffs_set_nlink(old_dentry->d_inode,
87 + yaffs_get_obj_link_count(obj));
88 d_instantiate(dentry, old_dentry->d_inode);
89 atomic_inc(&old_dentry->d_inode->i_count);
91 @@ -1894,7 +1920,10 @@ static int yaffs_symlink(struct inode *d
95 -#if (LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 34))
96 +#if (LINUX_VERSION_CODE > KERNEL_VERSION(3, 2, 0))
97 +static int yaffs_sync_object(struct file *file, loff_t start, loff_t end,
99 +#elif (LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 34))
100 static int yaffs_sync_object(struct file *file, int datasync)
102 static int yaffs_sync_object(struct file *file, struct dentry *dentry,
103 @@ -1961,11 +1990,9 @@ static int yaffs_rename(struct inode *ol
104 yaffs_gross_unlock(dev);
106 if (retVal == YAFFS_OK) {
108 - new_dentry->d_inode->i_nlink--;
109 - mark_inode_dirty(new_dentry->d_inode);
113 + yaffs_dec_link_count(new_dentry->d_inode);
115 update_dir_time(old_dir);
116 if(old_dir != new_dir)
117 update_dir_time(new_dir);
118 @@ -1985,7 +2012,7 @@ static int yaffs_setattr(struct dentry *
119 (TSTR("yaffs_setattr of object %d\n"),
120 yaffs_InodeToObject(inode)->obj_id));
122 - /* Fail if a requested resize >= 2GB */
123 + /* Fail if a requested resize >= 2GB */
124 if (attr->ia_valid & ATTR_SIZE &&
125 (attr->ia_size >> 31))
127 @@ -2216,7 +2243,7 @@ static void yaffs_flush_inodes(struct su
133 list_for_each_entry(iptr,&sb->s_inodes, i_sb_list){
134 obj = yaffs_InodeToObject(iptr);
136 @@ -2230,10 +2257,10 @@ static void yaffs_flush_inodes(struct su
138 static void yaffs_flush_super(struct super_block *sb, int do_checkpoint)
140 - yaffs_dev_t *dev = yaffs_SuperToDevice(sb);
141 + yaffs_dev_t *dev = yaffs_SuperToDevice(sb);
146 yaffs_flush_inodes(sb);
147 yaffs_update_dirty_dirs(dev);
148 yaffs_flush_whole_cache(dev);
149 @@ -2301,7 +2328,7 @@ static int yaffs_do_sync_fs(struct super
150 * yaffs_bg_start() launches the background thread.
151 * yaffs_bg_stop() cleans up the background thread.
155 * The thread should only run after the yaffs is initialised
156 * The thread should be stopped before yaffs is unmounted.
157 * The thread should not do any writing while the fs is in read only.
158 @@ -2872,7 +2899,7 @@ static struct super_block *yaffs_interna
160 dev = kmalloc(sizeof(yaffs_dev_t), GFP_KERNEL);
161 context = kmalloc(sizeof(struct yaffs_LinuxContext),GFP_KERNEL);
164 if(!dev || !context ){
167 @@ -2905,7 +2932,7 @@ static struct super_block *yaffs_interna
169 sb->u.generic_sbp = dev;
173 dev->driver_context = mtd;
174 param->name = mtd->name;
176 @@ -3005,7 +3032,7 @@ static struct super_block *yaffs_interna
177 param->gc_control = yaffs_gc_control_callback;
179 yaffs_dev_to_lc(dev)->superBlock= sb;
183 #ifndef CONFIG_YAFFS_DOES_ECC
184 param->use_nand_ecc = 1;
185 @@ -3047,10 +3074,10 @@ static struct super_block *yaffs_interna
187 (TSTR("yaffs_read_super: guts initialised %s\n"),
188 (err == YAFFS_OK) ? "OK" : "FAILED"));
195 if(!context->bgThread)
196 param->defered_dir_update = 0;
198 @@ -3125,7 +3152,7 @@ static struct dentry *yaffs2_read_super(
201 return mount_bdev(fs, flags, dev_name, data,
202 - yaffs_internal_read_super_mtd);
203 + yaffs2_internal_read_super_mtd);
206 static struct file_system_type yaffs2_fs_type = {
207 @@ -3223,7 +3250,7 @@ static int yaffs_proc_read(char *page,
208 buf += sprintf(buf,"\n");
213 down(&yaffs_context_lock);
215 /* Locate and print the Nth entry. Order N-squared but N is small. */
216 @@ -3240,7 +3267,7 @@ static int yaffs_proc_read(char *page,
217 buf = yaffs_dump_dev_part0(buf, dev);
219 buf = yaffs_dump_dev_part1(buf, dev);
224 up(&yaffs_context_lock);
225 @@ -3267,7 +3294,7 @@ static int yaffs_stats_proc_read(char *p
228 erasedChunks = dev->n_erased_blocks * dev->param.chunks_per_block;
231 buf += sprintf(buf,"%d, %d, %d, %u, %u, %u, %u\n",
232 n, dev->n_free_chunks, erasedChunks,
233 dev->bg_gcs, dev->oldest_dirty_gc_count,
234 --- a/fs/yaffs2/yaffs_mtdif1.c
235 +++ b/fs/yaffs2/yaffs_mtdif1.c
237 #include "linux/version.h"
238 #include "linux/types.h"
239 #include "linux/mtd/mtd.h"
240 +#include "mtd/mtd-abi.h"
242 /* Don't compile this module if we don't have MTD's mtd_oob_ops interface */
243 #if (MTD_VERSION_CODE > MTD_VERSION(2, 6, 17))
244 @@ -127,7 +128,7 @@ int nandmtd1_WriteChunkWithTagsToNAND(ya
247 memset(&ops, 0, sizeof(ops));
248 - ops.mode = MTD_OOB_AUTO;
249 + ops.mode = MTD_OPS_AUTO_OOB;
250 ops.len = (data) ? chunkBytes : 0;
251 ops.ooblen = YTAG1_SIZE;
252 ops.datbuf = (__u8 *)data;
253 @@ -179,7 +180,7 @@ int nandmtd1_ReadChunkWithTagsFromNAND(y
256 memset(&ops, 0, sizeof(ops));
257 - ops.mode = MTD_OOB_AUTO;
258 + ops.mode = MTD_OPS_AUTO_OOB;
259 ops.len = (data) ? chunkBytes : 0;
260 ops.ooblen = YTAG1_SIZE;
262 --- a/fs/yaffs2/yaffs_mtdif2.c
263 +++ b/fs/yaffs2/yaffs_mtdif2.c
265 #include "linux/mtd/mtd.h"
266 #include "linux/types.h"
267 #include "linux/time.h"
268 +#include "mtd/mtd-abi.h"
270 #include "yaffs_packedtags2.h"
272 @@ -71,7 +72,7 @@ int nandmtd2_WriteChunkWithTagsToNAND(ya
273 yaffs_PackTags2(&pt, tags, !dev->param.no_tags_ecc);
275 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 17))
276 - ops.mode = MTD_OOB_AUTO;
277 + ops.mode = MTD_OPS_AUTO_OOB;
278 ops.ooblen = (dev->param.inband_tags) ? 0 : packed_tags_size;
279 ops.len = dev->param.total_bytes_per_chunk;
281 @@ -136,7 +137,7 @@ int nandmtd2_ReadChunkWithTagsFromNAND(y
282 retval = mtd->read(mtd, addr, dev->param.total_bytes_per_chunk,
285 - ops.mode = MTD_OOB_AUTO;
286 + ops.mode = MTD_OPS_AUTO_OOB;
287 ops.ooblen = packed_tags_size;
288 ops.len = data ? dev->data_bytes_per_chunk : packed_tags_size;