X-Git-Url: http://aleph1.co.uk/gitweb/?a=blobdiff_plain;f=yaffs_allocator.c;h=a284439cfa62e070b959cd65d49f3a6a385c93ba;hb=refs%2Fheads%2Faleph1-release-branch;hp=b181dd54893642530e7ba2bee46b26f0e987510e;hpb=299791ad6d378fae30d50560097a7633cde3aab2;p=yaffs2.git diff --git a/yaffs_allocator.c b/yaffs_allocator.c index b181dd5..a284439 100644 --- a/yaffs_allocator.c +++ b/yaffs_allocator.c @@ -1,5 +1,5 @@ /* - * YAFFS: Yet another Flash File System . A NAND-flash specific file system. + * YAFFS: Yet Another Flash File System. A NAND-flash specific file system. * * Copyright (C) 2002-2010 Aleph One Ltd. * for Toby Churchill Ltd and Brightstar Engineering @@ -7,13 +7,12 @@ * Created by Charles Manning * * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 2.1 as + * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. - * - * Note: Only YAFFS headers are LGPL, YAFFS C code is covered by GPL. */ + #include "yaffs_allocator.h" #include "yaffs_guts.h" #include "yaffs_trace.h" @@ -62,7 +61,7 @@ yaffs_Object *yaffs_AllocateRawObject(yaffs_Device *dev) void yaffs_FreeRawObject(yaffs_Device *dev, yaffs_Object *obj) { - dev = dev; + dev = dev; YFREE(obj); } @@ -82,7 +81,7 @@ struct yaffs_ObjectList_struct { typedef struct yaffs_ObjectList_struct yaffs_ObjectList; - + struct yaffs_AllocatorStruct { int nTnodesCreated; yaffs_Tnode *freeTnodes; @@ -92,7 +91,7 @@ struct yaffs_AllocatorStruct { int nObjectsCreated; yaffs_Object *freeObjects; int nFreeObjects; - + yaffs_ObjectList *allocatedObjectList; }; @@ -105,7 +104,7 @@ static void yaffs_DeinitialiseRawTnodes(yaffs_Device *dev) yaffs_Allocator *allocator = (yaffs_Allocator *)dev->allocator; yaffs_TnodeList *tmp; - + if(!allocator){ YBUG(); return; @@ -147,7 +146,7 @@ static int yaffs_CreateTnodes(yaffs_Device *dev, int nTnodes) yaffs_Tnode *curr; yaffs_Tnode *next; yaffs_TnodeList *tnl; - + if(!allocator){ YBUG(); return YAFFS_FAIL; @@ -168,21 +167,6 @@ static int yaffs_CreateTnodes(yaffs_Device *dev, int nTnodes) return YAFFS_FAIL; } - /* Hook them into the free list */ -#if 0 - for (i = 0; i < nTnodes - 1; i++) { - newTnodes[i].internal[0] = &newTnodes[i + 1]; -#ifdef CONFIG_YAFFS_TNODE_LIST_DEBUG - newTnodes[i].internal[YAFFS_NTNODES_INTERNAL] = (void *)1; -#endif - } - - newTnodes[nTnodes - 1].internal[0] = allocator->freeTnodes; -#ifdef CONFIG_YAFFS_TNODE_LIST_DEBUG - newTnodes[nTnodes - 1].internal[YAFFS_NTNODES_INTERNAL] = (void *)1; -#endif - allocator->freeTnodes = newTnodes; -#else /* New hookup for wide tnodes */ for (i = 0; i < nTnodes - 1; i++) { curr = (yaffs_Tnode *) &mem[i * dev->tnodeSize]; @@ -194,9 +178,6 @@ static int yaffs_CreateTnodes(yaffs_Device *dev, int nTnodes) curr->internal[0] = allocator->freeTnodes; allocator->freeTnodes = (yaffs_Tnode *)mem; -#endif - - allocator->nFreeTnodes += nTnodes; allocator->nTnodesCreated += nTnodes; @@ -227,7 +208,7 @@ yaffs_Tnode *yaffs_AllocateRawTnode(yaffs_Device *dev) { yaffs_Allocator *allocator = (yaffs_Allocator *)dev->allocator; yaffs_Tnode *tn = NULL; - + if(!allocator){ YBUG(); return NULL; @@ -239,13 +220,6 @@ yaffs_Tnode *yaffs_AllocateRawTnode(yaffs_Device *dev) if (allocator->freeTnodes) { tn = allocator->freeTnodes; -#ifdef CONFIG_YAFFS_TNODE_LIST_DEBUG - if (tn->internal[YAFFS_NTNODES_INTERNAL] != (void *)1) { - /* Hoosterman, this thing looks like it isn't in the list */ - T(YAFFS_TRACE_ALWAYS, - (TSTR("yaffs: Tnode list bug 1" TENDSTR))); - } -#endif allocator->freeTnodes = allocator->freeTnodes->internal[0]; allocator->nFreeTnodes--; } @@ -264,14 +238,6 @@ void yaffs_FreeRawTnode(yaffs_Device *dev, yaffs_Tnode *tn) } if (tn) { -#ifdef CONFIG_YAFFS_TNODE_LIST_DEBUG - if (tn->internal[YAFFS_NTNODES_INTERNAL] != 0) { - /* Hoosterman, this thing looks like it is already in the list */ - T(YAFFS_TRACE_ALWAYS, - (TSTR("yaffs: Tnode list bug 2" TENDSTR))); - } - tn->internal[YAFFS_NTNODES_INTERNAL] = (void *)1; -#endif tn->internal[0] = allocator->freeTnodes; allocator->freeTnodes = tn; allocator->nFreeTnodes++; @@ -403,7 +369,7 @@ void yaffs_FreeRawObject(yaffs_Device *dev, yaffs_Object *obj) if(!allocator) YBUG(); - else { + else { /* Link into the free list. */ obj->siblings.next = (struct ylist_head *)(allocator->freeObjects); allocator->freeObjects = obj; @@ -416,7 +382,7 @@ void yaffs_DeinitialiseRawTnodesAndObjects(yaffs_Device *dev) if(dev->allocator){ yaffs_DeinitialiseRawTnodes(dev); yaffs_DeinitialiseRawObjects(dev); - + YFREE(dev->allocator); dev->allocator=NULL; } else @@ -426,7 +392,7 @@ void yaffs_DeinitialiseRawTnodesAndObjects(yaffs_Device *dev) void yaffs_InitialiseRawTnodesAndObjects(yaffs_Device *dev) { yaffs_Allocator *allocator; - + if(!dev->allocator){ allocator = YMALLOC(sizeof(yaffs_Allocator)); if(allocator){