yaffs: Remove malloc allocator
[yaffs2.git] / yaffs_allocator.c
index 9af15c705bd1c9899a963e88732a4ef3df079b3a..af61ec0a796583d458034c7d3dd12bfc50fc46c0 100644 (file)
 #include "yaffs_trace.h"
 #include "yportenv.h"
 
 #include "yaffs_trace.h"
 #include "yportenv.h"
 
-#ifdef CONFIG_YAFFS_KMALLOC_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 *)kmalloc(dev->tnode_size, GFP_NOFS);
-}
-
-void yaffs_free_raw_tnode(struct yaffs_dev *dev, struct yaffs_tnode *tn)
-{
-       dev = dev;
-       kfree(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 *)kmalloc(sizeof(struct yaffs_obj));
-}
-
-void yaffs_free_raw_obj(struct yaffs_dev *dev, struct yaffs_obj *obj)
-{
-
-       dev = dev;
-       kfree(obj);
-}
-
-#else
 
 struct yaffs_tnode_list {
        struct yaffs_tnode_list *next;
 
 struct yaffs_tnode_list {
        struct yaffs_tnode_list *next;
@@ -89,10 +42,8 @@ struct yaffs_allocator {
 
 static void yaffs_deinit_raw_tnodes(struct yaffs_dev *dev)
 {
 
 static void yaffs_deinit_raw_tnodes(struct yaffs_dev *dev)
 {
-
        struct yaffs_allocator *allocator =
            (struct yaffs_allocator *)dev->allocator;
        struct yaffs_allocator *allocator =
            (struct yaffs_allocator *)dev->allocator;
-
        struct yaffs_tnode_list *tmp;
 
        if (!allocator) {
        struct yaffs_tnode_list *tmp;
 
        if (!allocator) {
@@ -106,7 +57,6 @@ static void yaffs_deinit_raw_tnodes(struct yaffs_dev *dev)
                kfree(allocator->alloc_tnode_list->tnodes);
                kfree(allocator->alloc_tnode_list);
                allocator->alloc_tnode_list = tmp;
                kfree(allocator->alloc_tnode_list->tnodes);
                kfree(allocator->alloc_tnode_list);
                allocator->alloc_tnode_list = tmp;
-
        }
 
        allocator->free_tnodes = NULL;
        }
 
        allocator->free_tnodes = NULL;
@@ -148,13 +98,12 @@ static int yaffs_create_tnodes(struct yaffs_dev *dev, int n_tnodes)
                return YAFFS_OK;
 
        /* make these things */
                return YAFFS_OK;
 
        /* make these things */
-
        new_tnodes = kmalloc(n_tnodes * dev->tnode_size, GFP_NOFS);
        mem = (u8 *) new_tnodes;
 
        if (!new_tnodes) {
        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;
        }
 
                return YAFFS_FAIL;
        }
 
@@ -176,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.
         */
         * 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 = kmalloc(sizeof(struct yaffs_tnode_list), GFP_NOFS);
        if (!tnl) {
        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;
                return YAFFS_FAIL;
        } else {
                tnl->tnodes = new_tnodes;
@@ -189,7 +136,7 @@ static int yaffs_create_tnodes(struct yaffs_dev *dev, int n_tnodes)
                allocator->alloc_tnode_list = tnl;
        }
 
                allocator->alloc_tnode_list = tnl;
        }
 
-       T(YAFFS_TRACE_ALLOCATE, (TSTR("yaffs: Tnodes added" TENDSTR)));
+       yaffs_trace(YAFFS_TRACE_ALLOCATE, "Tnodes added");
 
        return YAFFS_OK;
 }
 
        return YAFFS_OK;
 }
@@ -275,7 +222,6 @@ 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;
 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;
        int i;
        struct yaffs_obj *new_objs;
        struct yaffs_obj_list *list;
@@ -293,16 +239,12 @@ static int yaffs_create_free_objs(struct yaffs_dev *dev, int n_obj)
        list = kmalloc(sizeof(struct yaffs_obj_list), GFP_NOFS);
 
        if (!new_objs || !list) {
        list = kmalloc(sizeof(struct yaffs_obj_list), GFP_NOFS);
 
        if (!new_objs || !list) {
-               if (new_objs) {
-                       kfree(new_objs);
-                       new_objs = NULL;
-               }
-               if (list) {
-                       kfree(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;
        }
 
                return YAFFS_FAIL;
        }
 
@@ -394,4 +336,3 @@ void yaffs_init_raw_tnodes_and_objs(struct yaffs_dev *dev)
        }
 }
 
        }
 }
 
-#endif