X-Git-Url: http://www.aleph1.co.uk/gitweb/?p=yaffs2.git;a=blobdiff_plain;f=yaffs_allocator.c;h=1dd0c27b91682b8cd274d8d4a67d9ddf019566d2;hp=03ede863744809989918ac984065a29abb7fb699;hb=6120ba5a0a029e945f4a2e7e5955896f112d4adc;hpb=3ecea787c3d99a5e13bf3b826dd3ad772fbad810 diff --git a/yaffs_allocator.c b/yaffs_allocator.c index 03ede86..1dd0c27 100644 --- a/yaffs_allocator.c +++ b/yaffs_allocator.c @@ -16,53 +16,6 @@ #include "yaffs_trace.h" #include "yportenv.h" -#ifdef CONFIG_YAFFS_YMALLOC_ALLOCATOR - -void yaffs_deinit_raw_tnodes_and_objs(struct yaffs_dev *dev) -{ - dev = dev; -} - -void yaffs_init_raw_tnodes_and_objs(struct yaffs_dev *dev) -{ - dev = dev; -} - -struct yaffs_tnode *yaffs_alloc_raw_tnode(struct yaffs_dev *dev) -{ - return (struct yaffs_tnode *)YMALLOC(dev->tnode_size); -} - -void yaffs_free_raw_tnode(struct yaffs_dev *dev, struct yaffs_tnode *tn) -{ - dev = dev; - YFREE(tn); -} - -void yaffs_init_raw_objs(struct yaffs_dev *dev) -{ - dev = dev; -} - -void yaffs_deinit_raw_objs(struct yaffs_dev *dev) -{ - dev = dev; -} - -struct yaffs_obj *yaffs_alloc_raw_obj(struct yaffs_dev *dev) -{ - dev = dev; - return (struct yaffs_obj *)YMALLOC(sizeof(struct yaffs_obj)); -} - -void yaffs_free_raw_obj(struct yaffs_dev *dev, struct yaffs_obj *obj) -{ - - dev = dev; - YFREE(obj); -} - -#else struct yaffs_tnode_list { struct yaffs_tnode_list *next; @@ -89,24 +42,21 @@ struct yaffs_allocator { static void yaffs_deinit_raw_tnodes(struct yaffs_dev *dev) { - struct yaffs_allocator *allocator = (struct yaffs_allocator *)dev->allocator; - struct yaffs_tnode_list *tmp; if (!allocator) { - YBUG(); + BUG(); return; } while (allocator->alloc_tnode_list) { tmp = allocator->alloc_tnode_list->next; - YFREE(allocator->alloc_tnode_list->tnodes); - YFREE(allocator->alloc_tnode_list); + kfree(allocator->alloc_tnode_list->tnodes); + kfree(allocator->alloc_tnode_list); allocator->alloc_tnode_list = tmp; - } allocator->free_tnodes = NULL; @@ -123,8 +73,9 @@ static void yaffs_init_raw_tnodes(struct yaffs_dev *dev) allocator->free_tnodes = NULL; allocator->n_free_tnodes = 0; allocator->n_tnodes_created = 0; - } else - YBUG(); + } else { + BUG(); + } } static int yaffs_create_tnodes(struct yaffs_dev *dev, int n_tnodes) @@ -139,7 +90,7 @@ static int yaffs_create_tnodes(struct yaffs_dev *dev, int n_tnodes) struct yaffs_tnode_list *tnl; if (!allocator) { - YBUG(); + BUG(); return YAFFS_FAIL; } @@ -147,13 +98,12 @@ static int yaffs_create_tnodes(struct yaffs_dev *dev, int n_tnodes) return YAFFS_OK; /* make these things */ - - new_tnodes = YMALLOC(n_tnodes * dev->tnode_size); + new_tnodes = kmalloc(n_tnodes * dev->tnode_size, GFP_NOFS); mem = (u8 *) new_tnodes; if (!new_tnodes) { - T(YAFFS_TRACE_ERROR, - (TSTR("yaffs: Could not allocate Tnodes" TENDSTR))); + yaffs_trace(YAFFS_TRACE_ERROR, + "yaffs: Could not allocate Tnodes"); return YAFFS_FAIL; } @@ -175,12 +125,10 @@ static int yaffs_create_tnodes(struct yaffs_dev *dev, int n_tnodes) * NB If we can't add this to the management list it isn't fatal * but it just means we can't free this bunch of tnodes later. */ - - tnl = YMALLOC(sizeof(struct yaffs_tnode_list)); + tnl = kmalloc(sizeof(struct yaffs_tnode_list), GFP_NOFS); if (!tnl) { - T(YAFFS_TRACE_ERROR, - (TSTR - ("yaffs: Could not add tnodes to management list" TENDSTR))); + yaffs_trace(YAFFS_TRACE_ERROR, + "Could not add tnodes to management list"); return YAFFS_FAIL; } else { tnl->tnodes = new_tnodes; @@ -188,7 +136,7 @@ static int yaffs_create_tnodes(struct yaffs_dev *dev, int n_tnodes) allocator->alloc_tnode_list = tnl; } - T(YAFFS_TRACE_ALLOCATE, (TSTR("yaffs: Tnodes added" TENDSTR))); + yaffs_trace(YAFFS_TRACE_ALLOCATE, "Tnodes added"); return YAFFS_OK; } @@ -200,7 +148,7 @@ struct yaffs_tnode *yaffs_alloc_raw_tnode(struct yaffs_dev *dev) struct yaffs_tnode *tn = NULL; if (!allocator) { - YBUG(); + BUG(); return NULL; } @@ -223,7 +171,7 @@ void yaffs_free_raw_tnode(struct yaffs_dev *dev, struct yaffs_tnode *tn) struct yaffs_allocator *allocator = dev->allocator; if (!allocator) { - YBUG(); + BUG(); return; } @@ -243,8 +191,9 @@ static void yaffs_init_raw_objs(struct yaffs_dev *dev) allocator->allocated_obj_list = NULL; allocator->free_objs = NULL; allocator->n_free_objects = 0; - } else - YBUG(); + } else { + BUG(); + } } static void yaffs_deinit_raw_objs(struct yaffs_dev *dev) @@ -253,14 +202,14 @@ static void yaffs_deinit_raw_objs(struct yaffs_dev *dev) struct yaffs_obj_list *tmp; if (!allocator) { - YBUG(); + BUG(); return; } while (allocator->allocated_obj_list) { tmp = allocator->allocated_obj_list->next; - YFREE(allocator->allocated_obj_list->objects); - YFREE(allocator->allocated_obj_list); + kfree(allocator->allocated_obj_list->objects); + kfree(allocator->allocated_obj_list); allocator->allocated_obj_list = tmp; } @@ -273,13 +222,12 @@ static void yaffs_deinit_raw_objs(struct yaffs_dev *dev) static int yaffs_create_free_objs(struct yaffs_dev *dev, int n_obj) { struct yaffs_allocator *allocator = dev->allocator; - int i; struct yaffs_obj *new_objs; struct yaffs_obj_list *list; if (!allocator) { - YBUG(); + BUG(); return YAFFS_FAIL; } @@ -287,20 +235,16 @@ static int yaffs_create_free_objs(struct yaffs_dev *dev, int n_obj) return YAFFS_OK; /* make these things */ - new_objs = YMALLOC(n_obj * sizeof(struct yaffs_obj)); - list = YMALLOC(sizeof(struct yaffs_obj_list)); + new_objs = kmalloc(n_obj * sizeof(struct yaffs_obj), GFP_NOFS); + list = kmalloc(sizeof(struct yaffs_obj_list), GFP_NOFS); if (!new_objs || !list) { - if (new_objs) { - YFREE(new_objs); - new_objs = NULL; - } - if (list) { - YFREE(list); - list = NULL; - } - T(YAFFS_TRACE_ALLOCATE, - (TSTR("yaffs: Could not allocate more objects" TENDSTR))); + kfree(new_objs); + new_objs = NULL; + kfree(list); + list = NULL; + yaffs_trace(YAFFS_TRACE_ALLOCATE, + "Could not allocate more objects"); return YAFFS_FAIL; } @@ -330,7 +274,7 @@ struct yaffs_obj *yaffs_alloc_raw_obj(struct yaffs_dev *dev) struct yaffs_allocator *allocator = dev->allocator; if (!allocator) { - YBUG(); + BUG(); return obj; } @@ -354,7 +298,7 @@ void yaffs_free_raw_obj(struct yaffs_dev *dev, struct yaffs_obj *obj) struct yaffs_allocator *allocator = dev->allocator; if (!allocator) - YBUG(); + BUG(); else { /* Link into the free list. */ obj->siblings.next = (struct list_head *)(allocator->free_objs); @@ -369,10 +313,11 @@ void yaffs_deinit_raw_tnodes_and_objs(struct yaffs_dev *dev) yaffs_deinit_raw_tnodes(dev); yaffs_deinit_raw_objs(dev); - YFREE(dev->allocator); + kfree(dev->allocator); dev->allocator = NULL; - } else - YBUG(); + } else { + BUG(); + } } void yaffs_init_raw_tnodes_and_objs(struct yaffs_dev *dev) @@ -380,14 +325,14 @@ void yaffs_init_raw_tnodes_and_objs(struct yaffs_dev *dev) struct yaffs_allocator *allocator; if (!dev->allocator) { - allocator = YMALLOC(sizeof(struct yaffs_allocator)); + allocator = kmalloc(sizeof(struct yaffs_allocator), GFP_NOFS); if (allocator) { dev->allocator = allocator; yaffs_init_raw_tnodes(dev); yaffs_init_raw_objs(dev); } - } else - YBUG(); + } else { + BUG(); + } } -#endif