Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 219562
b: refs/heads/master
c: 6909ba1
h: refs/heads/master
v: v3
  • Loading branch information
Bjorn Helgaas authored and Jesse Barnes committed Oct 26, 2010
1 parent f2bb4d1 commit 577d2c6
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 5d6b1fa301b13cc651ee717a9b518124dea2f814
refs/heads/master: 6909ba14c25b4db6be2ff89f4fa0fac2d70151a0
16 changes: 11 additions & 5 deletions trunk/kernel/resource.c
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,11 @@ static void resource_clip(struct resource *res, resource_size_t min,
res->end = max;
}

static bool resource_contains(struct resource *res1, struct resource *res2)
{
return res1->start <= res2->start && res1->end >= res2->end;
}

/*
* Find empty slot in the resource tree given range and alignment.
*/
Expand All @@ -387,7 +392,7 @@ static int find_resource(struct resource *root, struct resource *new,
void *alignf_data)
{
struct resource *this = root->child;
struct resource tmp = *new;
struct resource tmp = *new, alloc;

tmp.start = root->start;
/*
Expand All @@ -407,10 +412,11 @@ static int find_resource(struct resource *root, struct resource *new,
resource_clip(&tmp, min, max);
tmp.start = ALIGN(tmp.start, align);

tmp.start = alignf(alignf_data, &tmp, size, align);
if (tmp.start < tmp.end && tmp.end - tmp.start >= size - 1) {
new->start = tmp.start;
new->end = tmp.start + size - 1;
alloc.start = alignf(alignf_data, &tmp, size, align);
alloc.end = alloc.start + size - 1;
if (resource_contains(&tmp, &alloc)) {
new->start = alloc.start;
new->end = alloc.end;
return 0;
}
if (!this)
Expand Down

0 comments on commit 577d2c6

Please sign in to comment.