Fedora kernel-2.6.17-1.2142_FC4 patched with stable patch-2.6.17.4-vs2.0.2-rc26.diff
[linux-2.6.git] / arch / ppc / lib / rheap.c
index 4d938a0..31e5118 100644 (file)
@@ -1,6 +1,4 @@
 /*
- * arch/ppc/syslib/rheap.c
- *
  * A Remote Heap.  Remote means that we don't touch the memory that the
  * heap points to. Normal heap implementations use the memory they manage
  * to place their list. We cannot do that because the memory we manage may
@@ -216,7 +214,7 @@ static void attach_free_block(rh_info_t * info, rh_block_t * blkn)
 
        /* Grow the after block backwards */
        if (before == NULL && after != NULL) {
-               (int8_t *) after->start -= size;
+               after->start = (int8_t *)after->start - size;
                after->size += size;
                return;
        }
@@ -254,11 +252,11 @@ rh_info_t *rh_create(unsigned int alignment)
 
        /* Alignment must be a power of two */
        if ((alignment & (alignment - 1)) != 0)
-               return NULL;
+               return ERR_PTR(-EINVAL);
 
        info = kmalloc(sizeof(*info), GFP_KERNEL);
        if (info == NULL)
-               return NULL;
+               return ERR_PTR(-ENOMEM);
 
        info->alignment = alignment;
 
@@ -366,7 +364,7 @@ void *rh_detach_region(rh_info_t * info, void *start, int size)
 
        /* Validate size */
        if (size <= 0)
-               return NULL;
+               return ERR_PTR(-EINVAL);
 
        /* The region must be aligned */
        s = (unsigned long)start;
@@ -380,7 +378,7 @@ void *rh_detach_region(rh_info_t * info, void *start, int size)
        e = e & ~m;
 
        if (assure_empty(info, 1) < 0)
-               return NULL;
+               return ERR_PTR(-ENOMEM);
 
        blk = NULL;
        list_for_each(l, &info->free_list) {
@@ -394,7 +392,7 @@ void *rh_detach_region(rh_info_t * info, void *start, int size)
        }
 
        if (blk == NULL)
-               return NULL;
+               return ERR_PTR(-ENOMEM);
 
        /* Perfect fit */
        if (bs == s && be == e) {
@@ -407,7 +405,7 @@ void *rh_detach_region(rh_info_t * info, void *start, int size)
        /* blk still in free list, with updated start and/or size */
        if (bs == s || be == e) {
                if (bs == s)
-                       (int8_t *) blk->start += size;
+                       blk->start = (int8_t *)blk->start + size;
                blk->size -= size;
 
        } else {
@@ -434,13 +432,13 @@ void *rh_alloc(rh_info_t * info, int size, const char *owner)
 
        /* Validate size */
        if (size <= 0)
-               return NULL;
+               return ERR_PTR(-EINVAL);
 
        /* Align to configured alignment */
        size = (size + (info->alignment - 1)) & ~(info->alignment - 1);
 
        if (assure_empty(info, 1) < 0)
-               return NULL;
+               return ERR_PTR(-ENOMEM);
 
        blk = NULL;
        list_for_each(l, &info->free_list) {
@@ -451,7 +449,7 @@ void *rh_alloc(rh_info_t * info, int size, const char *owner)
        }
 
        if (blk == NULL)
-               return NULL;
+               return ERR_PTR(-ENOMEM);
 
        /* Just fits */
        if (blk->size == size) {
@@ -471,7 +469,7 @@ void *rh_alloc(rh_info_t * info, int size, const char *owner)
        newblk->owner = owner;
 
        /* blk still in free list, with updated start, size */
-       (int8_t *) blk->start += size;
+       blk->start = (int8_t *)blk->start + size;
        blk->size -= size;
 
        start = newblk->start;
@@ -490,7 +488,7 @@ void *rh_alloc_fixed(rh_info_t * info, void *start, int size, const char *owner)
 
        /* Validate size */
        if (size <= 0)
-               return NULL;
+               return ERR_PTR(-EINVAL);
 
        /* The region must be aligned */
        s = (unsigned long)start;
@@ -504,7 +502,7 @@ void *rh_alloc_fixed(rh_info_t * info, void *start, int size, const char *owner)
        e = e & ~m;
 
        if (assure_empty(info, 2) < 0)
-               return NULL;
+               return ERR_PTR(-ENOMEM);
 
        blk = NULL;
        list_for_each(l, &info->free_list) {
@@ -517,7 +515,7 @@ void *rh_alloc_fixed(rh_info_t * info, void *start, int size, const char *owner)
        }
 
        if (blk == NULL)
-               return NULL;
+               return ERR_PTR(-ENOMEM);
 
        /* Perfect fit */
        if (bs == s && be == e) {
@@ -535,7 +533,7 @@ void *rh_alloc_fixed(rh_info_t * info, void *start, int size, const char *owner)
        /* blk still in free list, with updated start and/or size */
        if (bs == s || be == e) {
                if (bs == s)
-                       (int8_t *) blk->start += size;
+                       blk->start = (int8_t *)blk->start + size;
                blk->size -= size;
 
        } else {
@@ -645,6 +643,7 @@ int rh_set_owner(rh_info_t * info, void *start, const char *owner)
                return -EINVAL;
 
        blk->owner = owner;
+       size = blk->size;
 
        return size;
 }