Skip to content

Commit

Permalink
resources: allow adjust_resource() for resources with no parent
Browse files Browse the repository at this point in the history
If a resource has no parent, allow its start/end to be set arbitrarily
as long as any children are still contained within the new range.

[bhelgaas: changelog]
Signed-off-by: Yinghai Lu <[email protected]>
Signed-off-by: Bjorn Helgaas <[email protected]>
  • Loading branch information
Yinghai Lu authored and bjorn-helgaas committed Jun 13, 2012
1 parent 5cc62c2 commit 82ec90e
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions kernel/resource.c
Original file line number Diff line number Diff line change
Expand Up @@ -722,14 +722,12 @@ int adjust_resource(struct resource *res, resource_size_t start, resource_size_t

write_lock(&resource_lock);

if (!parent)
goto skip;

if ((start < parent->start) || (end > parent->end))
goto out;

for (tmp = res->child; tmp; tmp = tmp->sibling) {
if ((tmp->start < start) || (tmp->end > end))
goto out;
}

if (res->sibling && (res->sibling->start <= end))
goto out;

Expand All @@ -741,6 +739,11 @@ int adjust_resource(struct resource *res, resource_size_t start, resource_size_t
goto out;
}

skip:
for (tmp = res->child; tmp; tmp = tmp->sibling)
if ((tmp->start < start) || (tmp->end > end))
goto out;

res->start = start;
res->end = end;
result = 0;
Expand Down

0 comments on commit 82ec90e

Please sign in to comment.