[Yaffs] Eh.... Patch enclosed...

Ladislav Michl ladis at linux-mips.org
Thu Jul 28 06:14:31 BST 2005


On Thu, Jul 28, 2005 at 08:27:58AM +1200, Charles Manning wrote:
> Sergey's patch would not stick so I did the next best and  did it quickly to 
> get compiling again.
> 
> I have applied this patch and CVS now looks sweet.

Heh :). Yet another no-op removing trailing white space.
vim & let c_space_errors=1 is your friend :). I'm not sure if adding
more noise to CVS is actually good idea, but here is patch anyway.

Index: yaffs_fs.c
===================================================================
RCS file: /home/aleph1/cvs/yaffs2/yaffs_fs.c,v
retrieving revision 1.12
diff -u -r1.12 yaffs_fs.c
--- yaffs_fs.c	27 Jul 2005 20:23:15 -0000	1.12
+++ yaffs_fs.c	28 Jul 2005 05:10:29 -0000
@@ -14,7 +14,7 @@
  * This is the file system front-end to YAFFS that hooks it up to
  * the VFS.
  *
- * Special notes: 
+ * Special notes:
  * >> 2.4: sb->u.generic_sbp points to the yaffs_Device associated with this superblock
  * >> 2.6: sb->s_fs_info  points to the yaffs_Device associated with this superblock
  * >> inode->u.generic_ip points to the associated yaffs_Object.
@@ -79,7 +79,7 @@
 
 
 #ifdef CONFIG_YAFFS_RAM_ENABLED
-#include "yaffs_nandemul.h" 
+#include "yaffs_nandemul.h"
 // 2 MB of RAM for emulation
 #define YAFFS_RAM_EMULATION_SIZE  0x200000
 #endif //CONFIG_YAFFS_RAM_ENABLED
@@ -198,7 +198,7 @@
 	.setattr	= yaffs_setattr,
 };
 
-struct inode_operations yaffs_symlink_inode_operations = {	
+struct inode_operations yaffs_symlink_inode_operations = {
 	.readlink	= yaffs_readlink,
 	.follow_link	= yaffs_follow_link,
 	.setattr	= yaffs_setattr,
@@ -208,7 +208,7 @@
 	.create		= yaffs_create,
 	.lookup		= yaffs_lookup,
 	.link		= yaffs_link,
-	.unlink		= yaffs_unlink,	
+	.unlink		= yaffs_unlink,
 	.symlink	= yaffs_symlink,
 	.mkdir		= yaffs_mkdir,
 	.rmdir		= yaffs_unlink,
@@ -257,11 +257,11 @@
 
 
 	yaffs_GrossLock(dev);
-	
+
 	alias = yaffs_GetSymlinkAlias(yaffs_DentryToObject(dentry));
-	
+
 	yaffs_GrossUnlock(dev);
-	
+
 	if(!alias)
 		return -ENOMEM;
 
@@ -280,9 +280,9 @@
 	yaffs_GrossLock(dev);
 
 	alias = yaffs_GetSymlinkAlias(yaffs_DentryToObject(dentry));
-	
+
 	yaffs_GrossUnlock(dev);
-	
+
 	if(!alias)
 		return -ENOMEM;
 
@@ -307,35 +307,35 @@
 {
 	yaffs_Object *obj;
 	struct inode *inode = NULL; // NCB 2.5/2.6 needs NULL here
-	
+
 	yaffs_Device *dev = yaffs_InodeToObject(dir)->myDev;
 
 
 	yaffs_GrossLock(dev);
 
-	
+
 	T(YAFFS_TRACE_OS,(KERN_DEBUG"yaffs_lookup for %d:%s\n",yaffs_InodeToObject(dir)->objectId,dentry->d_name.name));
-	
+
 	obj = yaffs_FindObjectByName(yaffs_InodeToObject(dir),dentry->d_name.name);
-	
+
 	obj = yaffs_GetEquivalentObject(obj); // in case it was a hardlink
-	
 
-	
+
+
 	if(obj)
 	{
 		T(YAFFS_TRACE_OS,(KERN_DEBUG"yaffs_lookup found %d\n",obj->objectId));
-		
+
 		inode = yaffs_get_inode(dir->i_sb, obj->yst_mode,0,obj);
-		
+
 		if(inode)
 		{
 			T(YAFFS_TRACE_OS,(KERN_DEBUG"yaffs_loookup dentry \n"));
-/* #if 0 asserted by NCB for 2.5/6 compatability - falls through to d_add even if NULL inode */	
+/* #if 0 asserted by NCB for 2.5/6 compatability - falls through to d_add even if NULL inode */
 #if 0
 			//dget(dentry); // try to solve directory bug
 			d_add(dentry,inode);
-			
+
 			yaffs_GrossUnlock(dev);
 
 			// return dentry;
@@ -347,16 +347,16 @@
 	else
 	{
 		T(YAFFS_TRACE_OS,(KERN_DEBUG"yaffs_lookup not found\n"));
-		
+
 	}
 	yaffs_GrossUnlock(dev);
 
-/* added NCB for 2.5/6 compatability - forces add even if inode is NULL which creates dentry hash*/	
+/* added NCB for 2.5/6 compatability - forces add even if inode is NULL which creates dentry hash*/
 	d_add(dentry,inode);
-	
+
 	return NULL;
 	//	return (ERR_PTR(-EIO));
-	
+
 }
 
 // For now put inode is just for debugging
@@ -364,7 +364,7 @@
 static void yaffs_put_inode(struct inode *inode)
 {
 	T(YAFFS_TRACE_OS,("yaffs_put_inode: ino %d, count %d\n",(int)inode->i_ino, atomic_read(&inode->i_count)));
-	
+
 }
 
 // clear is called to tell the fs to release any per-inode data it holds
@@ -372,30 +372,30 @@
 {
 	yaffs_Object *obj;
 	yaffs_Device *dev;
-	
+
 	obj = yaffs_InodeToObject(inode);
-	
+
 	T(YAFFS_TRACE_OS,("yaffs_clear_inode: ino %d, count %d %s\n",(int)inode->i_ino, atomic_read(&inode->i_count),
-		obj ? "object exists" : "null object"));	
+		obj ? "object exists" : "null object"));
 
 	if(obj)
 	{
 		dev = obj->myDev;
 		yaffs_GrossLock(dev);
-		
+
 		// Clear the association between the inode ant the yaffs_Object.
 		obj->myInode = NULL;
 		inode->u.generic_ip = NULL;
-		
+
 		// If the object freeing was deferred, then the real free happens now.
 		// This should fix the inode inconsistency problem.
-		
+
 		yaffs_HandleDeferedFree(obj);
-		
+
 		yaffs_GrossUnlock(dev);
 	}
-	
-	
+
+
 }
 
 // delete is called when the link count is zero and the inode
@@ -409,10 +409,10 @@
 
 	T(YAFFS_TRACE_OS,("yaffs_delete_inode: ino %d, count %d %s\n",(int)inode->i_ino, atomic_read(&inode->i_count),
 		obj ? "object exists" : "null object"));
-	
+
 	if(obj)
 	{
-	 	dev = obj->myDev;
+		dev = obj->myDev;
 		yaffs_GrossLock(dev);
 		yaffs_DeleteFile(obj);
 		yaffs_GrossUnlock(dev);
@@ -424,15 +424,15 @@
 static int yaffs_file_flush(struct file* file)
 {
 	yaffs_Object *obj = yaffs_DentryToObject(file->f_dentry);
-	
+
 	yaffs_Device *dev = obj->myDev;
-	
+
 	T(YAFFS_TRACE_OS,(KERN_DEBUG"yaffs_file_flush object %d (%s)\n",obj->objectId,
 				obj->dirty ? "dirty" : "clean"));
 
 	yaffs_GrossLock(dev);
-	
-    yaffs_FlushFile(obj,1);
+
+	yaffs_FlushFile(obj,1);
 
 	yaffs_GrossUnlock(dev);
 
@@ -444,7 +444,7 @@
 static int yaffs_readpage_nolock(struct file *f, struct page * pg)
 {
 	// Lifted from jffs2
-	
+
 	yaffs_Object *obj;
 	unsigned char *pg_buf;
 	int ret;
@@ -457,8 +457,8 @@
 	obj  = yaffs_DentryToObject(f->f_dentry);
 
 	dev = obj->myDev;
-	
-	
+
+
 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0))
         BUG_ON(!PageLocked(pg));
 #else
@@ -470,11 +470,11 @@
 	/* FIXME: Can kmap fail? */
 
 	yaffs_GrossLock(dev);
-	
+
 	ret = yaffs_ReadDataFromFile(obj, pg_buf, pg->index << PAGE_CACHE_SHIFT, PAGE_CACHE_SIZE);
 
 	yaffs_GrossUnlock(dev);
-	
+
 	if(ret >= 0) ret = 0;
 
 	if (ret) {
@@ -556,7 +556,7 @@
 	nWritten = yaffs_WriteDataToFile(obj,buffer,page->index << PAGE_CACHE_SHIFT,nBytes,0);
 
 	yaffs_GrossUnlock(obj->myDev);
-	
+
 	kunmap(page);
 	SetPageUptodate(page);
 	UnlockPage(page);
@@ -572,10 +572,10 @@
 
 	T(YAFFS_TRACE_OS,(KERN_DEBUG"yaffs_prepair_write\n"));
 	if(!Page_Uptodate(pg) && (offset || to < PAGE_CACHE_SIZE))
-		return  yaffs_readpage_nolock(f,pg);    
+		return  yaffs_readpage_nolock(f,pg);
 
 	return 0;
-	
+
 }
 
 static int yaffs_commit_write(struct file *f, struct page *pg, unsigned offset, unsigned to)
@@ -585,14 +585,14 @@
 	loff_t pos = (((loff_t)pg->index) << PAGE_CACHE_SHIFT) + offset;
 	int nBytes = to - offset;
 	int nWritten;
-	
+
 	unsigned spos = pos;
 	unsigned saddr = (unsigned)addr;
 
 	T(YAFFS_TRACE_OS,(KERN_DEBUG"yaffs_commit_write addr %x pos %x nBytes %d\n",saddr,spos,nBytes));
-	
+
 	nWritten = yaffs_file_write(f,addr, nBytes, &pos);
-	
+
 	if(nWritten != nBytes)
 	{
 		T(YAFFS_TRACE_OS,(KERN_DEBUG"yaffs_commit_write not same size nWritten %d  nBytes %d\n",nWritten,nBytes));
@@ -605,7 +605,7 @@
 	}
 
 	T(YAFFS_TRACE_OS,(KERN_DEBUG"yaffs_commit_write returning %d\n",nWritten));
-	
+
 	return nWritten;
 
 }
@@ -614,7 +614,7 @@
 
 static void yaffs_FillInodeFromObject(struct inode *inode, yaffs_Object *obj)
 {
-	if (inode && obj) 
+	if (inode && obj)
 	{
 		inode->i_ino = obj->objectId;
 		inode->i_mode = obj->yst_mode;
@@ -641,20 +641,20 @@
 		inode->i_blocks = (inode->i_size + 511) >> 9;
 
 		inode->i_nlink = yaffs_GetObjectLinkCount(obj);
-		
+
 		T(YAFFS_TRACE_OS,(KERN_DEBUG"yaffs_FillInode mode %x uid %d gid %d size %d count %d\n",
 				inode->i_mode, inode->i_uid, inode->i_gid, (int)inode->i_size, atomic_read(&inode->i_count)));
-		
-		switch (obj->yst_mode & S_IFMT) 
+
+		switch (obj->yst_mode & S_IFMT)
 		{
 			default: // fifo, device or socket
 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0))
                                init_special_inode(inode, obj->yst_mode,old_decode_dev(obj->yst_rdev));
 #else
                                  init_special_inode(inode, obj->yst_mode,(dev_t)(obj->yst_rdev));
-#endif				
+#endif
                         break;
-			case S_IFREG:	// file		
+			case S_IFREG:	// file
 				inode->i_op = &yaffs_file_inode_operations;
 				inode->i_fop = &yaffs_file_operations;
 				inode->i_mapping->a_ops = &yaffs_file_address_operations;
@@ -667,11 +667,10 @@
 				inode->i_op = &yaffs_symlink_inode_operations;
 				break;
 		}
-		
-		
+
 		inode->u.generic_ip = obj;
 		obj->myInode = inode;
-		
+
 	}
 	else
 	{
@@ -683,28 +682,25 @@
 struct inode *yaffs_get_inode(struct super_block *sb, int mode, int dev,yaffs_Object *obj)
 {
 	struct inode * inode;
-	
+
 	if(!sb)
 	{
 	  T(YAFFS_TRACE_OS,(KERN_DEBUG"yaffs_get_inode for NULL super_block!!\n"));
 	  return NULL;
-	  
 	}
-	
 	if(!obj)
 	{
 	  T(YAFFS_TRACE_OS,(KERN_DEBUG"yaffs_get_inode for NULL object!!\n"));
 	  return NULL;
-	  
 	}
-	
+
 	T(YAFFS_TRACE_OS,(KERN_DEBUG"yaffs_get_inode for object %d\n",obj->objectId));
 
 	inode = iget(sb,obj->objectId);
 
 	// NB Side effect: iget calls back to yaffs_read_inode().
 	// iget also increments the inode's i_count
-	
+
 	return inode;
 }
 
@@ -717,18 +713,18 @@
 	int nRead,ipos;
 	struct inode *inode;
 	yaffs_Device *dev;
-	
+
 	T(YAFFS_TRACE_OS,(KERN_DEBUG"yaffs_file_read\n"));
 
 	obj  = yaffs_DentryToObject(f->f_dentry);
-	
+
 	dev = obj->myDev;
-	
+
 	yaffs_GrossLock(dev);
-	
+
 	inode = f->f_dentry->d_inode;
-	
-	if (*pos < inode->i_size) 
+
+	if (*pos < inode->i_size)
 	{
 			if (*pos + n > inode->i_size)
 			{
@@ -739,20 +735,20 @@
 	{
 		n = 0;
 	}
-	
+
 	nRead = yaffs_ReadDataFromFile(obj,buf,*pos,n);
 	if(nRead > 0)
 	{
 		f->f_pos += nRead;
 	}
-	
+
 	yaffs_GrossUnlock(dev);
-	
+
 	ipos = *pos;
-	
+
 	T(YAFFS_TRACE_OS,(KERN_DEBUG"yaffs_file_read read %d bytes, %d read at %d\n",n,nRead,ipos));
 	return nRead;
-	
+
 }
 
 #endif
@@ -763,12 +759,12 @@
 	int nWritten,ipos;
 	struct inode *inode;
 	yaffs_Device *dev;
-	
-	
+
+
 	obj  = yaffs_DentryToObject(f->f_dentry);
-	
+
 	dev = obj->myDev;
-	
+
 	yaffs_GrossLock(dev);
 
 	inode = f->f_dentry->d_inode;
@@ -781,8 +777,8 @@
 	{
 		ipos = *pos;
 	}
-	
-	
+
+
 	if(!obj)
 	{
 		T(YAFFS_TRACE_OS,(KERN_DEBUG"yaffs_file_write: hey obj is null!\n"));
@@ -803,13 +799,13 @@
 		{
 			inode->i_size = ipos;
 			inode->i_blocks = (ipos + 511)>>9;
-			
+
 			T(YAFFS_TRACE_OS,(KERN_DEBUG"yaffs_file_write size updated to %d bytes, %d blocks\n",ipos,(int)(inode->i_blocks)));
 		}
-		
+
 	}
 	yaffs_GrossUnlock(dev);
-	
+
 	return nWritten != n ? -ENOSPC : nWritten;
 }
 
@@ -821,20 +817,20 @@
 	yaffs_Device *dev;
 	struct inode *inode = f->f_dentry->d_inode;
 	unsigned long offset, curoffs;
-	struct list_head *i;	
+	struct list_head *i;
 	yaffs_Object *l;
-	
+
 	char name[YAFFS_MAX_NAME_LENGTH	+1];
-		
+
 	obj =  yaffs_DentryToObject(f->f_dentry);
 	dev = obj->myDev;
-	
+
 	yaffs_GrossLock(dev);
-	
+
 	offset = f->f_pos;
-	
+
 	T(YAFFS_TRACE_OS,("yaffs_readdir: starting at %d\n",(int)offset));
-	
+
 	if(offset == 0)
 	{
         T(YAFFS_TRACE_OS,(KERN_DEBUG"yaffs_readdir: entry . ino %d \n",(int)inode->i_ino));
@@ -855,19 +851,19 @@
 		offset++;
 		f->f_pos++;
 	}
-	
+
 	curoffs = 1;
-	
+
 	list_for_each(i,&obj->variant.directoryVariant.children)
 	{
 		curoffs++;
 		if(curoffs >= offset)
-		{		
+		{
 			l = list_entry(i, yaffs_Object,siblings);
-			
-			yaffs_GetObjectName(l,name,YAFFS_MAX_NAME_LENGTH+1); 
+
+			yaffs_GetObjectName(l,name,YAFFS_MAX_NAME_LENGTH+1);
 			T(YAFFS_TRACE_OS,(KERN_DEBUG"yaffs_readdir: %s inode %d\n",name,yaffs_GetObjectInode(l)));
-			
+
 			if(filldir(dirent,
 					   name,
 					   strlen(name),
@@ -878,17 +874,17 @@
 			{
 				goto up_and_out;
 			}
-			
+
 			offset++;
-			f->f_pos++;	   
+			f->f_pos++;
 		}
 	}
 
   up_and_out:
   out:
-  
-    yaffs_GrossUnlock(dev);
-    
+
+	yaffs_GrossUnlock(dev);
+
 	return 0;
 }
 
@@ -904,12 +900,12 @@
 #endif
 {
 	struct inode *inode;
-	
+
 	yaffs_Object *obj = NULL;
 	yaffs_Device *dev;
-	
+
 	yaffs_Object *parent = yaffs_InodeToObject(dir);
-	
+
 	int error = -ENOSPC;
 
 	if(parent)
@@ -922,15 +918,15 @@
 		T(YAFFS_TRACE_OS,(KERN_DEBUG"yaffs_mknod: could not get parent object\n"));
 		return -EPERM;
 	}
-	
+
 	T(YAFFS_TRACE_OS,("yaffs_mknod: making oject for %s, mode %x dev %x\n",
 					dentry->d_name.name, mode,rdev));
 
 	dev = parent->myDev;
-	
+
 	yaffs_GrossLock(dev);
 
-	switch (mode & S_IFMT) 
+	switch (mode & S_IFMT)
 	{
 		default:
 			// Special (socket, fifo, device...)
@@ -939,9 +935,9 @@
                         obj = yaffs_MknodSpecial(parent,dentry->d_name.name,mode,current->uid, current->gid,old_encode_dev(rdev));
 #else
                         obj = yaffs_MknodSpecial(parent,dentry->d_name.name,mode,current->uid, current->gid,rdev);
-#endif			
+#endif
                 break;
-		case S_IFREG:	// file		
+		case S_IFREG:	// file
 			T(YAFFS_TRACE_OS,(KERN_DEBUG"yaffs_mknod: making file\n"));
 			obj = yaffs_MknodFile(parent,dentry->d_name.name,mode,current->uid, current->gid);
 			break;
@@ -954,7 +950,7 @@
 			obj = NULL; // Do we ever get here?
 			break;
 	}
-	
+
 	if(obj)
 	{
 		inode = yaffs_get_inode(dir->i_sb, mode, rdev, obj);
@@ -1003,22 +999,21 @@
 static int yaffs_unlink(struct inode * dir, struct dentry *dentry)
 {
 	int retVal;
-	
 	yaffs_Device *dev;
-	
-	
+
+
 	T(YAFFS_TRACE_OS,(KERN_DEBUG"yaffs_unlink %d:%s\n",(int)(dir->i_ino),dentry->d_name.name));
-	
+
 	dev = yaffs_InodeToObject(dir)->myDev;
-	
+
 	yaffs_GrossLock(dev);
-	
-	
+
+
 	retVal = yaffs_Unlink(yaffs_InodeToObject(dir),dentry->d_name.name);
-	
-	
+
+
 	yaffs_GrossUnlock(dev);
-	
+
 	if( retVal == YAFFS_OK)
 	{
 		dentry->d_inode->i_nlink--;
@@ -1041,40 +1036,36 @@
 	yaffs_Object *obj = NULL;
 	yaffs_Object *link=NULL;
 	yaffs_Device *dev;
-	
+
 	T(YAFFS_TRACE_OS,(KERN_DEBUG"yaffs_link\n"));
-	
+
 	obj = yaffs_InodeToObject(inode);
 	dev = obj->myDev;
-	
+
 	yaffs_GrossLock(dev);
 
 	if (!S_ISDIR(inode->i_mode))	// Don't link directories
 	{
 		link = yaffs_Link(yaffs_InodeToObject(dir),dentry->d_name.name,obj);
 	}
-	
+
 
 	if(link)
 	{
 		old_dentry->d_inode->i_nlink =  yaffs_GetObjectLinkCount(obj);
 		d_instantiate(dentry, old_dentry->d_inode);
 		atomic_inc(&old_dentry->d_inode->i_count);
-		T(YAFFS_TRACE_OS,(KERN_DEBUG"yaffs_link link count %d i_count %d\n",	
+		T(YAFFS_TRACE_OS,(KERN_DEBUG"yaffs_link link count %d i_count %d\n",
 			old_dentry->d_inode->i_nlink,atomic_read(&old_dentry->d_inode->i_count)));
-	
+
 	}
-	
+
 	yaffs_GrossUnlock(dev);
-	
+
 
 	if(link)
-	{
-	
 		return 0;
-	}
-	
-	
+
 	return -EPERM; 
 }
 
@@ -1083,21 +1074,20 @@
 {
 	yaffs_Object *obj;
 	yaffs_Device *dev;
-	
+
 	T(YAFFS_TRACE_OS,(KERN_DEBUG"yaffs_symlink\n"));
-	
+
 	dev = yaffs_InodeToObject(dir)->myDev;
 	yaffs_GrossLock(dev);
-	obj = yaffs_MknodSymLink(yaffs_InodeToObject(dir), dentry->d_name.name, 
+	obj = yaffs_MknodSymLink(yaffs_InodeToObject(dir), dentry->d_name.name,
 							 S_IFLNK | S_IRWXUGO, current->uid, current->gid,
 							 symname);
 	yaffs_GrossUnlock(dev);
 
 	if(obj)
 	{
-
 		struct inode* inode;
-	
+
 		inode = yaffs_get_inode(dir->i_sb, obj->yst_mode, 0, obj);
 		d_instantiate(dentry, inode);
 		T(YAFFS_TRACE_OS,(KERN_DEBUG"symlink created OK\n"));
@@ -1108,7 +1098,7 @@
 		T(YAFFS_TRACE_OS,(KERN_DEBUG"symlink not created\n"));
 
 	}
-	
+
 	return -ENOMEM;
 }
 
@@ -1117,11 +1107,11 @@
 
 	yaffs_Object *obj;
 	yaffs_Device *dev;
-	
+
 	obj = yaffs_DentryToObject(dentry);
 
 	dev = obj->myDev;
-	
+
 	T(YAFFS_TRACE_OS,(KERN_DEBUG"yaffs_sync_object\n"));
 	yaffs_GrossLock(dev);
 	yaffs_FlushFile(obj,1);
@@ -1140,14 +1130,14 @@
 	int retVal = YAFFS_FAIL;
 	int removed = 0;
 	yaffs_Object *target;
-	
+
 	dev = yaffs_InodeToObject(old_dir)->myDev;
 
 	yaffs_GrossLock(dev);
-	
+
 	// Check if the target is an existing directory that is not empty.
 	target = yaffs_FindObjectByName(yaffs_InodeToObject(new_dir),new_dentry->d_name.name);
-	
+
 	if(target &&
 	   target->variantType == YAFFS_OBJECT_TYPE_DIRECTORY &&
 	   !list_empty(&target->variant.directoryVariant.children))
@@ -1156,17 +1146,16 @@
 	}
 	else
 	{
-	   
 		// Unlink the target if it exists
 		removed = yaffs_Unlink(yaffs_InodeToObject(new_dir),new_dentry->d_name.name);
 
-	
+
 		retVal =  yaffs_RenameObject(yaffs_InodeToObject(old_dir),old_dentry->d_name.name,
 									yaffs_InodeToObject(new_dir),new_dentry->d_name.name);
-									
+
 	}
 	yaffs_GrossUnlock(dev);
-	
+
 	if(retVal == YAFFS_OK)
 	{
 		if(removed == YAFFS_OK)
@@ -1174,14 +1163,14 @@
 			new_dentry->d_inode->i_nlink--;
 			mark_inode_dirty(new_dentry->d_inode);
 		}
-		
+
 		return 0;
 	}
 	else
 	{
 		return -ENOTEMPTY;
 	}
-	
+
 
 }
 
@@ -1190,12 +1179,12 @@
 	struct inode *inode = dentry->d_inode;
 	int error;
 	yaffs_Device *dev;
-	
+
 	T(YAFFS_TRACE_OS,(KERN_DEBUG"yaffs_setattr of object %d\n",yaffs_InodeToObject(inode)->objectId));
-	
+
 	if((error = inode_change_ok(inode,attr)) == 0)
 	{
-	
+
 		dev = yaffs_InodeToObject(inode)->myDev;
 		yaffs_GrossLock(dev);
 		if(yaffs_SetAttributes(yaffs_InodeToObject(inode),attr) == YAFFS_OK)
@@ -1221,19 +1210,18 @@
 #endif
 {
 
-	
 	yaffs_Device *dev = yaffs_SuperToDevice(sb);
 	T(YAFFS_TRACE_OS,(KERN_DEBUG"yaffs_statfs\n"));
 
 	yaffs_GrossLock(dev);
-	
-	
+
+
 	buf->f_type = YAFFS_MAGIC;
 	buf->f_bsize = sb->s_blocksize;
 	buf->f_namelen = 255;
 	if(sb->s_blocksize > dev->nBytesPerChunk)
 	{
-		
+
 		buf->f_blocks = (dev->endBlock - dev->startBlock + 1) * dev->nChunksPerBlock/
 						(sb->s_blocksize/dev->nBytesPerChunk);
 		buf->f_bfree = yaffs_GetNumberOfFreeChunks(dev)/
@@ -1241,7 +1229,7 @@
 	}
 	else
 	{
-		
+
 		buf->f_blocks = (dev->endBlock - dev->startBlock + 1) * dev->nChunksPerBlock *
 						(dev->nBytesPerChunk/sb->s_blocksize);
 		buf->f_bfree = yaffs_GetNumberOfFreeChunks(dev) *
@@ -1250,7 +1238,7 @@
 	buf->f_files = 0;
 	buf->f_ffree = 0;
 	buf->f_bavail =  buf->f_bfree;
-	
+
 	yaffs_GrossUnlock(dev);
 	return 0;
 }
@@ -1259,14 +1247,14 @@
 {
 	// NB This is called as a side effect of other functions and
 	// thus gross locking should always be in place already.
-	
-	yaffs_Object *obj ; 
+
+	yaffs_Object *obj ;
 	yaffs_Device *dev = yaffs_SuperToDevice(inode->i_sb);
-	
+
 	T(YAFFS_TRACE_OS,(KERN_DEBUG"yaffs_read_inode for %d\n",(int)inode->i_ino));
 
 	obj  = yaffs_FindObjectByNumber(dev,inode->i_ino);
-	
+
 	yaffs_FillInodeFromObject(inode,obj);
 
 }
@@ -1276,7 +1264,7 @@
 static void yaffs_put_super(struct super_block *sb)
 {
 	yaffs_Device *dev = yaffs_SuperToDevice(sb);
-	
+
 	yaffs_GrossLock(dev);
 	if(dev->putSuperFunc)
 	{
@@ -1296,14 +1284,14 @@
 
 static void  yaffs_MTDPutSuper(struct super_block *sb)
 {
-	
+
 	struct mtd_info *mtd = yaffs_SuperToDevice(sb)->genericDevice;
-	
+
 	if(mtd->sync)
 	{
 		mtd->sync(mtd);
 	}
-	
+
 	put_mtd_device(mtd);
 }
 
@@ -1317,10 +1305,10 @@
 	struct dentry * root;
 	yaffs_Device *dev = 0;
 	int err;
-	
+
 	sb->s_magic = YAFFS_MAGIC;
 	sb->s_op = &yaffs_super_ops;
-	
+
 	if(!sb)
 		printk(KERN_INFO"yaffs: sb is NULL\n");
 	else if(!sb->s_dev)
@@ -1330,7 +1318,7 @@
 	else
 		printk(KERN_INFO"yaffs: dev is %d name is \"%s\"\n", sb->s_dev, kdevname(sb->s_dev));
 
-	
+
 
 #ifdef CONFIG_YAFFS_USE_CHUNK_SIZE
 	sb->s_blocksize = YAFFS_BYTES_PER_CHUNK;
@@ -1347,14 +1335,12 @@
 #endif
 
 
-	
 	if(useRam)
 	{
 
 #ifdef CONFIG_YAFFS_RAM_ENABLED
 		// Set the yaffs_Device up for ram emulation
 
-		
 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0))
 		sb->s_fs_info =	dev = kmalloc(sizeof(yaffs_Device),GFP_KERNEL);
 #else
@@ -1373,12 +1359,12 @@
 		dev->name = sb->s_type->name;
 
 		nBlocks = YAFFS_RAM_EMULATION_SIZE / (YAFFS_CHUNKS_PER_BLOCK * YAFFS_BYTES_PER_CHUNK);
-		dev->startBlock = 0;  
+		dev->startBlock = 0;
 		dev->endBlock = nBlocks - 1;
 		dev->nChunksPerBlock = YAFFS_CHUNKS_PER_BLOCK;
 		dev->nBytesPerChunk = YAFFS_BYTES_PER_CHUNK;
 		dev->nReservedBlocks = 5;
-		
+
 		if(yaffsVersion == 2)
 		{
 			dev->writeChunkWithTagsToNAND  = nandemul2k_WriteChunkWithTagsToNAND;
@@ -1406,27 +1392,27 @@
 
 	}
 	else
-	{	
+	{
 #ifdef CONFIG_YAFFS_MTD_ENABLED
 		struct mtd_info *mtd;
-		
+
 		T(YAFFS_TRACE_ALWAYS,("yaffs: Attempting MTD mount on %u.%u, \"%s\"\n",
 		 MAJOR(sb->s_dev),MINOR(sb->s_dev),kdevname(sb->s_dev)));
-			
+
 		// Check it's an mtd device.....
 		if(MAJOR(sb->s_dev) != MTD_BLOCK_MAJOR)
 		{
 			return NULL; // This isn't an mtd device
-		} 
-		
+		}
+
 		// Get the device
 		mtd = get_mtd_device(NULL, MINOR(sb->s_dev));
-		if (!mtd) 
+		if (!mtd)
 		{
 			T(YAFFS_TRACE_ALWAYS,("yaffs: MTD device #%u doesn't appear to exist\n", MINOR(sb->s_dev)));
 			return NULL;
 		}
-		
+
 		// Check it's NAND
 		if(mtd->type != MTD_NANDFLASH)
 		{
@@ -1464,7 +1450,7 @@
 				T(YAFFS_TRACE_ALWAYS,("yaffs: MTD device does not support required functions\n"));;
 				return NULL;
 			}
-		
+
 			if(mtd->oobblock < YAFFS_MIN_YAFFS2_CHUNK_SIZE ||
 			   mtd->oobsize < YAFFS_MIN_YAFFS2_SPARE_SIZE)
 			{
@@ -1487,7 +1473,7 @@
 				T(YAFFS_TRACE_ALWAYS,("yaffs: MTD device does not support required functions\n"));;
 				return NULL;
 			}
-		
+
 			if(mtd->oobblock != YAFFS_BYTES_PER_CHUNK ||
 			   mtd->oobsize != YAFFS_BYTES_PER_SPARE)
 			{
@@ -1495,9 +1481,9 @@
 				return NULL;
 			}
 		}
-		   
 
-			// OK, so if we got here, we have an MTD that's NAND and looks 
+
+			// OK, so if we got here, we have an MTD that's NAND and looks
 			// like it has the right capabilities
 			// Set the yaffs_Device up for mtd
 
@@ -1515,11 +1501,11 @@
 		}
 
 		memset(dev,0,sizeof(yaffs_Device));
-		dev->genericDevice = mtd; 
+		dev->genericDevice = mtd;
 		dev->name = mtd->name;
 
 		// Set up the memory size parameters....
-		
+
 		nBlocks = mtd->size / (YAFFS_CHUNKS_PER_BLOCK * YAFFS_BYTES_PER_CHUNK);
 		dev->startBlock = 0;
 		dev->endBlock = nBlocks - 1;
@@ -1527,7 +1513,6 @@
 		dev->nBytesPerChunk = YAFFS_BYTES_PER_CHUNK;
 		dev->nReservedBlocks = 5;
 		dev->nShortOpCaches = 10; // Enable short op caching
-		
 
 		// ... and the functions.
 		if(yaffsVersion == 2)
@@ -1553,9 +1538,9 @@
 		// ... and common functions
 		dev->eraseBlockInNAND = nandmtd_EraseBlockInNAND;
 		dev->initialiseNAND = nandmtd_InitialiseNAND;
-		
+
 		dev->putSuperFunc = yaffs_MTDPutSuper;
-		
+
 #ifdef CONFIG_YAFFS_USE_NANDECC
 		dev->useNANDECC = 1;
 #endif
@@ -1566,10 +1551,10 @@
 	list_add_tail(&dev->devList, &yaffs_dev_list);
 
 	init_MUTEX(&dev->grossLock);
-	
-	
+
+
 	yaffs_GrossLock(dev);
-	
+
 	err = yaffs_GutsInitialise(dev);
 
 	T(YAFFS_TRACE_OS,("yaffs_read_super: guts initialised %s\n", (err == YAFFS_OK) ? "OK" : "FAILED"));
@@ -1582,13 +1567,13 @@
 
 	if (!inode)
 		return NULL;
-		
+
 // added NCB
 	inode->i_op = & yaffs_dir_inode_operations;
 	inode->i_fop = & yaffs_dir_operations;
 
 	T(YAFFS_TRACE_OS,("yaffs_read_super: got root inode\n"));
-		
+
 
 	root = d_alloc_root(inode);
 
@@ -1778,7 +1763,7 @@
 	buf +=sprintf(buf,"useNANDECC......... %d\n",dev->useNANDECC);
 	buf +=sprintf(buf,"isYaffs2........... %d\n",dev->isYaffs2);
 
-	return buf;	
+	return buf;
 }
 
 static int  yaffs_proc_read(
@@ -1871,86 +1856,75 @@
 static int __init init_yaffs_fs(void)
 {
 	int error = 0;
-	struct file_system_to_install *fsinst;	
-	
-   T(YAFFS_TRACE_ALWAYS,("yaffs " __DATE__ " " __TIME__ " Installing. \n"));
+	struct file_system_to_install *fsinst;
 
+	T(YAFFS_TRACE_ALWAYS,("yaffs " __DATE__ " " __TIME__ " Installing. \n"));
 
 
-    /* Install the proc_fs entry */
-    my_proc_entry = create_proc_read_entry("yaffs",
-                                           S_IRUGO | S_IFREG,
-					   &proc_root,
-					   yaffs_proc_read,
-					   NULL);
-    if(!my_proc_entry)
-    {
-       return -ENOMEM;
-    }
-    
-    
-
-    // Now add the file system entries
-    
-    fsinst = fs_to_install;
-    
-    while(fsinst->fst && !error)
-    {
-      error = register_filesystem(fsinst->fst);
-      if(!error)
-      {
-          fsinst->installed = 1;
-      }
-      fsinst++;
-    }
-   
-    // Any errors? uninstall 
-    if(error)
-    {
-    	    fsinst = fs_to_install;
-    	    
-	    while(fsinst->fst)
-	    {
-	      if(fsinst->installed)
-	      {
-	        unregister_filesystem(fsinst->fst);
-	        fsinst->installed = 0;
-	      }
-	      fsinst++;
-	    }
-    }
-    
-    return error;
+	/* Install the proc_fs entry */
+	my_proc_entry = create_proc_read_entry("yaffs", S_IRUGO | S_IFREG,
+					       &proc_root, yaffs_proc_read,
+					       NULL);
+	if(!my_proc_entry)
+		return -ENOMEM;
+
+	/* Now add the file system entries */
+	fsinst = fs_to_install;
+
+	while(fsinst->fst && !error)
+	{
+		error = register_filesystem(fsinst->fst);
+		if(!error)
+			fsinst->installed = 1;
+
+		fsinst++;
+	}
+
+	/* Any errors? uninstall */
+	if(error)
+	{
+		fsinst = fs_to_install;
+
+		while(fsinst->fst)
+		{
+			if(fsinst->installed)
+			{
+				unregister_filesystem(fsinst->fst);
+				fsinst->installed = 0;
+			}
+		fsinst++;
+		}
+	}
+
+	return error;
 }
 
 static void __exit exit_yaffs_fs(void)
 {
+	struct file_system_to_install *fsinst;
 
-   struct file_system_to_install *fsinst;
-   
-   T(YAFFS_TRACE_ALWAYS,("yaffs " __DATE__ " " __TIME__ " removing. \n"));
-
-   remove_proc_entry("yaffs",&proc_root);
-    
-    fsinst = fs_to_install;
-    
-    while(fsinst->fst)
-    {
-      if(fsinst->installed)
-      {
-        unregister_filesystem(fsinst->fst);
-        fsinst->installed = 0;
-      }
-      fsinst++;
-    }
+	T(YAFFS_TRACE_ALWAYS,("yaffs " __DATE__ " " __TIME__ " removing. \n"));
+
+	remove_proc_entry("yaffs",&proc_root);
+
+	fsinst = fs_to_install;
+
+	while(fsinst->fst)
+	{
+		if(fsinst->installed)
+		{
+			unregister_filesystem(fsinst->fst);
+			fsinst->installed = 0;
+		}
+		fsinst++;
+	}
 
 }
 
-module_init(init_yaffs_fs)
-module_exit(exit_yaffs_fs)
+module_init(init_yaffs_fs);
+module_exit(exit_yaffs_fs);
 
 MODULE_DESCRIPTION("YAFFS2 - a NAND specific flash file system");
 MODULE_AUTHOR("Charles Manning, Aleph One Ltd., 2002,2003,2004");
 MODULE_LICENSE("GPL");
 
-



More information about the yaffs mailing list