b0555789f3b1ff62e6df4473a5f6b51e934bfe3e
[openwrt/openwrt.git] / target / linux / generic-2.6 / patches-2.6.26 / 512-yaffs_2.6.25_fix.patch
1 --- a/fs/yaffs2/yaffs_fs.c
2 +++ b/fs/yaffs2/yaffs_fs.c
3 @@ -183,7 +183,13 @@
4 #else
5 static int yaffs_statfs(struct super_block *sb, struct statfs *buf);
6 #endif
7 +
8 +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,25))
9 +static struct inode *yaffs_iget(struct super_block *sb, unsigned long ino);
10 +#else
11 static void yaffs_read_inode(struct inode *inode);
12 +#endif
13 +
14
15 static void yaffs_put_inode(struct inode *inode);
16 static void yaffs_delete_inode(struct inode *);
17 @@ -286,7 +292,9 @@
18
19 static struct super_operations yaffs_super_ops = {
20 .statfs = yaffs_statfs,
21 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,25))
22 .read_inode = yaffs_read_inode,
23 +#endif
24 .put_inode = yaffs_put_inode,
25 .put_super = yaffs_put_super,
26 .delete_inode = yaffs_delete_inode,
27 @@ -848,11 +856,17 @@
28 T(YAFFS_TRACE_OS,
29 (KERN_DEBUG "yaffs_get_inode for object %d\n", obj->objectId));
30
31 +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,25))
32 + inode = yaffs_iget(sb, obj->objectId);
33 + if (IS_ERR(inode))
34 + return NULL;
35 +#else
36 inode = iget(sb, obj->objectId);
37
38 /* NB Side effect: iget calls back to yaffs_read_inode(). */
39 /* iget also increments the inode's i_count */
40 /* NB You can't be holding grossLock or deadlock will happen! */
41 +#endif
42
43 return inode;
44 }
45 @@ -1453,6 +1467,39 @@
46 }
47
48
49 +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,25))
50 +static struct inode *yaffs_iget(struct super_block *sb, unsigned long ino)
51 +{
52 + yaffs_Object *obj;
53 + yaffs_Device *dev = yaffs_SuperToDevice(sb);
54 + struct inode *inode;
55 +
56 + T(YAFFS_TRACE_OS,
57 + (KERN_DEBUG "yaffs_iget for %lu\n", ino));
58 +
59 + inode = iget_locked(sb, ino);
60 + if (!inode)
61 + return ERR_PTR(-ENOMEM);
62 + if (!(inode->i_state & I_NEW))
63 + return inode;
64 +
65 + /* NB This is called as a side effect of other functions, but
66 + * we had to release the lock to prevent deadlocks, so
67 + * need to lock again.
68 + */
69 +
70 + yaffs_GrossLock(dev);
71 +
72 + obj = yaffs_FindObjectByNumber(dev, inode->i_ino);
73 +
74 + yaffs_FillInodeFromObject(inode, obj);
75 +
76 + yaffs_GrossUnlock(dev);
77 +
78 + unlock_new_inode(inode);
79 + return inode;
80 +}
81 +#else
82 static void yaffs_read_inode(struct inode *inode)
83 {
84 /* NB This is called as a side effect of other functions, but
85 @@ -1474,6 +1521,7 @@
86
87 yaffs_GrossUnlock(dev);
88 }
89 +#endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,25)) */
90
91 static LIST_HEAD(yaffs_dev_list);
92