generic-2.6/2.6.28: sync yaffs code with the current CVS version
SVN-Revision: 14158
This commit is contained in:
		
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							@@ -1,92 +0,0 @@
 | 
				
			|||||||
--- a/fs/yaffs2/yaffs_fs.c
 | 
					 | 
				
			||||||
+++ b/fs/yaffs2/yaffs_fs.c
 | 
					 | 
				
			||||||
@@ -181,7 +181,13 @@ static int yaffs_statfs(struct super_blo
 | 
					 | 
				
			||||||
 #else
 | 
					 | 
				
			||||||
 static int yaffs_statfs(struct super_block *sb, struct statfs *buf);
 | 
					 | 
				
			||||||
 #endif
 | 
					 | 
				
			||||||
+
 | 
					 | 
				
			||||||
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,25))
 | 
					 | 
				
			||||||
+static struct inode *yaffs_iget(struct super_block *sb, unsigned long ino);
 | 
					 | 
				
			||||||
+#else
 | 
					 | 
				
			||||||
 static void yaffs_read_inode(struct inode *inode);
 | 
					 | 
				
			||||||
+#endif
 | 
					 | 
				
			||||||
+
 | 
					 | 
				
			||||||
 
 | 
					 | 
				
			||||||
 static void yaffs_put_inode(struct inode *inode);
 | 
					 | 
				
			||||||
 static void yaffs_delete_inode(struct inode *);
 | 
					 | 
				
			||||||
@@ -284,7 +290,9 @@ static struct file_operations yaffs_dir_
 | 
					 | 
				
			||||||
 
 | 
					 | 
				
			||||||
 static struct super_operations yaffs_super_ops = {
 | 
					 | 
				
			||||||
 	.statfs = yaffs_statfs,
 | 
					 | 
				
			||||||
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,25))
 | 
					 | 
				
			||||||
 	.read_inode = yaffs_read_inode,
 | 
					 | 
				
			||||||
+#endif
 | 
					 | 
				
			||||||
 	.put_inode = yaffs_put_inode,
 | 
					 | 
				
			||||||
 	.put_super = yaffs_put_super,
 | 
					 | 
				
			||||||
 	.delete_inode = yaffs_delete_inode,
 | 
					 | 
				
			||||||
@@ -844,11 +852,17 @@ struct inode *yaffs_get_inode(struct sup
 | 
					 | 
				
			||||||
 	T(YAFFS_TRACE_OS,
 | 
					 | 
				
			||||||
 	  (KERN_DEBUG "yaffs_get_inode for object %d\n", obj->objectId));
 | 
					 | 
				
			||||||
 
 | 
					 | 
				
			||||||
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,25))
 | 
					 | 
				
			||||||
+	inode = yaffs_iget(sb, obj->objectId);
 | 
					 | 
				
			||||||
+	if (IS_ERR(inode))
 | 
					 | 
				
			||||||
+		return NULL;
 | 
					 | 
				
			||||||
+#else
 | 
					 | 
				
			||||||
 	inode = iget(sb, obj->objectId);
 | 
					 | 
				
			||||||
 
 | 
					 | 
				
			||||||
 	/* NB Side effect: iget calls back to yaffs_read_inode(). */
 | 
					 | 
				
			||||||
 	/* iget also increments the inode's i_count */
 | 
					 | 
				
			||||||
 	/* NB You can't be holding grossLock or deadlock will happen! */
 | 
					 | 
				
			||||||
+#endif
 | 
					 | 
				
			||||||
 
 | 
					 | 
				
			||||||
 	return inode;
 | 
					 | 
				
			||||||
 }
 | 
					 | 
				
			||||||
@@ -1427,6 +1441,39 @@ static int yaffs_sync_fs(struct super_bl
 | 
					 | 
				
			||||||
 }
 | 
					 | 
				
			||||||
 
 | 
					 | 
				
			||||||
 
 | 
					 | 
				
			||||||
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,25))
 | 
					 | 
				
			||||||
+static struct inode *yaffs_iget(struct super_block *sb, unsigned long ino)
 | 
					 | 
				
			||||||
+{
 | 
					 | 
				
			||||||
+	yaffs_Object *obj;
 | 
					 | 
				
			||||||
+	yaffs_Device *dev = yaffs_SuperToDevice(sb);
 | 
					 | 
				
			||||||
+	struct inode *inode;
 | 
					 | 
				
			||||||
+
 | 
					 | 
				
			||||||
+	T(YAFFS_TRACE_OS,
 | 
					 | 
				
			||||||
+	  (KERN_DEBUG "yaffs_iget for %lu\n", ino));
 | 
					 | 
				
			||||||
+
 | 
					 | 
				
			||||||
+	inode = iget_locked(sb, ino);
 | 
					 | 
				
			||||||
+	if (!inode)
 | 
					 | 
				
			||||||
+		return ERR_PTR(-ENOMEM);
 | 
					 | 
				
			||||||
+	if (!(inode->i_state & I_NEW))
 | 
					 | 
				
			||||||
+		return inode;
 | 
					 | 
				
			||||||
+
 | 
					 | 
				
			||||||
+	/* NB This is called as a side effect of other functions, but
 | 
					 | 
				
			||||||
+	 * we had to release the lock to prevent deadlocks, so
 | 
					 | 
				
			||||||
+	 * need to lock again.
 | 
					 | 
				
			||||||
+	 */
 | 
					 | 
				
			||||||
+
 | 
					 | 
				
			||||||
+	yaffs_GrossLock(dev);
 | 
					 | 
				
			||||||
+
 | 
					 | 
				
			||||||
+	obj = yaffs_FindObjectByNumber(dev, inode->i_ino);
 | 
					 | 
				
			||||||
+
 | 
					 | 
				
			||||||
+	yaffs_FillInodeFromObject(inode, obj);
 | 
					 | 
				
			||||||
+
 | 
					 | 
				
			||||||
+	yaffs_GrossUnlock(dev);
 | 
					 | 
				
			||||||
+
 | 
					 | 
				
			||||||
+	unlock_new_inode(inode);
 | 
					 | 
				
			||||||
+	return inode;
 | 
					 | 
				
			||||||
+}
 | 
					 | 
				
			||||||
+#else
 | 
					 | 
				
			||||||
 static void yaffs_read_inode(struct inode *inode)
 | 
					 | 
				
			||||||
 {
 | 
					 | 
				
			||||||
 	/* NB This is called as a side effect of other functions, but
 | 
					 | 
				
			||||||
@@ -1448,6 +1495,7 @@ static void yaffs_read_inode(struct inod
 | 
					 | 
				
			||||||
 
 | 
					 | 
				
			||||||
 	yaffs_GrossUnlock(dev);
 | 
					 | 
				
			||||||
 }
 | 
					 | 
				
			||||||
+#endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,25)) */
 | 
					 | 
				
			||||||
 
 | 
					 | 
				
			||||||
 static LIST_HEAD(yaffs_dev_list);
 | 
					 | 
				
			||||||
 
 | 
					 | 
				
			||||||
@@ -1,69 +0,0 @@
 | 
				
			|||||||
--- a/fs/yaffs2/yaffs_fs.c
 | 
					 | 
				
			||||||
+++ b/fs/yaffs2/yaffs_fs.c
 | 
					 | 
				
			||||||
@@ -76,6 +76,12 @@ extern const char *yaffs_guts_c_version;
 | 
					 | 
				
			||||||
 
 | 
					 | 
				
			||||||
 #endif
 | 
					 | 
				
			||||||
 
 | 
					 | 
				
			||||||
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,26))
 | 
					 | 
				
			||||||
+#define YPROC_ROOT	&proc_root
 | 
					 | 
				
			||||||
+#else
 | 
					 | 
				
			||||||
+#define YPROC_ROOT	NULL
 | 
					 | 
				
			||||||
+#endif
 | 
					 | 
				
			||||||
+
 | 
					 | 
				
			||||||
 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,17))
 | 
					 | 
				
			||||||
 #define WRITE_SIZE_STR "writesize"
 | 
					 | 
				
			||||||
 #define WRITE_SIZE(mtd) (mtd)->writesize
 | 
					 | 
				
			||||||
@@ -189,7 +195,9 @@ static void yaffs_read_inode(struct inod
 | 
					 | 
				
			||||||
 #endif
 | 
					 | 
				
			||||||
 
 | 
					 | 
				
			||||||
 
 | 
					 | 
				
			||||||
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,26))
 | 
					 | 
				
			||||||
 static void yaffs_put_inode(struct inode *inode);
 | 
					 | 
				
			||||||
+#endif
 | 
					 | 
				
			||||||
 static void yaffs_delete_inode(struct inode *);
 | 
					 | 
				
			||||||
 static void yaffs_clear_inode(struct inode *);
 | 
					 | 
				
			||||||
 
 | 
					 | 
				
			||||||
@@ -293,7 +301,9 @@ static struct super_operations yaffs_sup
 | 
					 | 
				
			||||||
 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,25))
 | 
					 | 
				
			||||||
 	.read_inode = yaffs_read_inode,
 | 
					 | 
				
			||||||
 #endif
 | 
					 | 
				
			||||||
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,26))
 | 
					 | 
				
			||||||
 	.put_inode = yaffs_put_inode,
 | 
					 | 
				
			||||||
+#endif
 | 
					 | 
				
			||||||
 	.put_super = yaffs_put_super,
 | 
					 | 
				
			||||||
 	.delete_inode = yaffs_delete_inode,
 | 
					 | 
				
			||||||
 	.clear_inode = yaffs_clear_inode,
 | 
					 | 
				
			||||||
@@ -437,6 +447,7 @@ static struct dentry *yaffs_lookup(struc
 | 
					 | 
				
			||||||
 
 | 
					 | 
				
			||||||
 }
 | 
					 | 
				
			||||||
 
 | 
					 | 
				
			||||||
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,26))
 | 
					 | 
				
			||||||
 /* For now put inode is just for debugging
 | 
					 | 
				
			||||||
  * Put inode is called when the inode **structure** is put.
 | 
					 | 
				
			||||||
  */
 | 
					 | 
				
			||||||
@@ -447,6 +458,7 @@ static void yaffs_put_inode(struct inode
 | 
					 | 
				
			||||||
 	   atomic_read(&inode->i_count)));
 | 
					 | 
				
			||||||
 
 | 
					 | 
				
			||||||
 }
 | 
					 | 
				
			||||||
+#endif
 | 
					 | 
				
			||||||
 
 | 
					 | 
				
			||||||
 /* clear is called to tell the fs to release any per-inode data it holds */
 | 
					 | 
				
			||||||
 static void yaffs_clear_inode(struct inode *inode)
 | 
					 | 
				
			||||||
@@ -2279,7 +2291,7 @@ static int __init init_yaffs_fs(void)
 | 
					 | 
				
			||||||
 	/* Install the proc_fs entry */
 | 
					 | 
				
			||||||
 	my_proc_entry = create_proc_entry("yaffs",
 | 
					 | 
				
			||||||
 					       S_IRUGO | S_IFREG,
 | 
					 | 
				
			||||||
-					       &proc_root);
 | 
					 | 
				
			||||||
+					       YPROC_ROOT);
 | 
					 | 
				
			||||||
 
 | 
					 | 
				
			||||||
 	if (my_proc_entry) {
 | 
					 | 
				
			||||||
 		my_proc_entry->write_proc = yaffs_proc_write;
 | 
					 | 
				
			||||||
@@ -2325,7 +2337,7 @@ static void __exit exit_yaffs_fs(void)
 | 
					 | 
				
			||||||
 	T(YAFFS_TRACE_ALWAYS, ("yaffs " __DATE__ " " __TIME__
 | 
					 | 
				
			||||||
 			       " removing. \n"));
 | 
					 | 
				
			||||||
 
 | 
					 | 
				
			||||||
-	remove_proc_entry("yaffs", &proc_root);
 | 
					 | 
				
			||||||
+	remove_proc_entry("yaffs", YPROC_ROOT);
 | 
					 | 
				
			||||||
 
 | 
					 | 
				
			||||||
 	fsinst = fs_to_install;
 | 
					 | 
				
			||||||
 
 | 
					 | 
				
			||||||
@@ -1,120 +0,0 @@
 | 
				
			|||||||
--- 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)
 | 
					 | 
				
			||||||
 {
 | 
					 | 
				
			||||||
		Reference in New Issue
	
	Block a user