summaryrefslogtreecommitdiffstats
path: root/target/linux/generic-2.6/patches-2.6.28/514-yaffs_2.6.28_fixes.patch
blob: 012ba04f07551130eb48e02827edd84e01f3f482 (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
--- a/fs/yaffs2/yaffs_fs.c
+++ b/fs/yaffs2/yaffs_fs.c
@@ -207,10 +207,20 @@ static int yaffs_writepage(struct page *
 #else
 static int yaffs_writepage(struct page *page);
 #endif
+
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,28))
+static int yaffs_write_begin(struct file *f, struct address_space *mapping,
+                            loff_t pos, unsigned len, unsigned flags,
+                            struct page **pagep, void **fsdata);
+static int yaffs_write_end(struct file *f, struct address_space *mapping,
+                          loff_t pos, unsigned len, unsigned copied,
+                          struct page *pg, void *fsdata);
+#else
 static int yaffs_prepare_write(struct file *f, struct page *pg,
 			       unsigned offset, unsigned to);
 static int yaffs_commit_write(struct file *f, struct page *pg, unsigned offset,
 			      unsigned to);
+#endif
 
 static int yaffs_readlink(struct dentry *dentry, char __user * buffer,
 			  int buflen);
@@ -223,8 +233,13 @@ static int yaffs_follow_link(struct dent
 static struct address_space_operations yaffs_file_address_operations = {
 	.readpage = yaffs_readpage,
 	.writepage = yaffs_writepage,
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,28))
+	.write_begin = yaffs_write_begin,
+	.write_end = yaffs_write_end,
+#else
 	.prepare_write = yaffs_prepare_write,
 	.commit_write = yaffs_commit_write,
+#endif
 };
 
 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,22))
@@ -687,6 +702,74 @@ static int yaffs_writepage(struct page *
 	return (nWritten == nBytes) ? 0 : -ENOSPC;
 }
 
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,28))
+static int yaffs_write_begin(struct file *f, struct address_space *mapping,
+                            loff_t pos, unsigned len, unsigned flags,
+                            struct page **pagep, void **fsdata)
+{
+	struct page *pg;
+	pgoff_t index = pos >> PAGE_CACHE_SHIFT;
+	int ret = 0;
+
+	pg = __grab_cache_page(mapping, index);
+	if (!pg)
+		return -ENOMEM;
+
+	*pagep = pg;
+
+	T(YAFFS_TRACE_OS, (KERN_DEBUG "yaffs_write_begin\n"));
+	if (!Page_Uptodate(pg)) {
+		ret = yaffs_readpage_nolock(f, pg);
+		if (ret)
+			goto err_unlock;
+	}
+
+	T(YAFFS_TRACE_OS, (KERN_DEBUG "yaffs_write_begin\n"));
+	return 0;
+
+ err_unlock:
+	unlock_page(pg);
+	page_cache_release(pg);
+	return ret;
+}
+
+static int yaffs_write_end(struct file *f, struct address_space *mapping,
+                          loff_t pos, unsigned len, unsigned copied,
+                          struct page *pg, void *fsdata)
+{
+	void *addr = page_address(pg) + (pos & (PAGE_CACHE_SIZE - 1));
+	loff_t pos2;
+	int nBytes = copied;
+	int nWritten;
+
+	T(YAFFS_TRACE_OS,
+	 (KERN_DEBUG "yaffs_write_end addr %x pos %x nBytes %d\n", (unsigned)addr,
+	 (unsigned)pos, nBytes));
+
+	pos2 = pos;
+	nWritten = yaffs_file_write(f, addr, nBytes, &pos2);
+
+	if (nWritten != nBytes) {
+		T(YAFFS_TRACE_OS,
+		 (KERN_DEBUG
+		 "yaffs_write_end not same size nWritten %d  nBytes %d\n",
+		  nWritten, nBytes));
+		SetPageError(pg);
+		ClearPageUptodate(pg);
+	} else {
+		SetPageUptodate(pg);
+	}
+
+	T(YAFFS_TRACE_OS,
+	 (KERN_DEBUG "yaffs_write_end returning %d\n",
+	 nWritten == nBytes ? nWritten : 0));
+
+	unlock_page(pg);
+	page_cache_release(pg);
+
+	return (nWritten == nBytes) ? nWritten : 0;
+}
+#else
 static int yaffs_prepare_write(struct file *f, struct page *pg,
 			       unsigned offset, unsigned to)
 {
@@ -735,6 +818,7 @@ static int yaffs_commit_write(struct fil
 	return nWritten == nBytes ? 0 : nWritten;
 
 }
+#endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,28)) */
 
 static void yaffs_FillInodeFromObject(struct inode *inode, yaffs_Object * obj)
 {