Skip to content

Commit

Permalink
Remove 'recurse into child resources' logic from 'reserve_region_with…
Browse files Browse the repository at this point in the history
…_split()'

This function is not actually used right now, since the original use
case for it was done with insert_resource_expand_to_fit() instead.

However, we now have another usage case that wants to basically do a
"reserve IO resource, splitting around existing resources", however that
one doesn't actually want the "recurse into the conflicting resource"
logic at all.

And since recursing into the conflicting resource was the most complex
part, and isn't wanted, just remove it.  Maybe we'll some day want both
versions, but we can just resurrect the logic then.

Tested-by: Yinghai Lu <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
torvalds committed Apr 19, 2009
1 parent 8d4ab5d commit ff54250
Showing 1 changed file with 12 additions and 34 deletions.
46 changes: 12 additions & 34 deletions kernel/resource.c
Original file line number Diff line number Diff line change
Expand Up @@ -533,43 +533,21 @@ static void __init __reserve_region_with_split(struct resource *root,
res->end = end;
res->flags = IORESOURCE_BUSY;

for (;;) {
conflict = __request_resource(parent, res);
if (!conflict)
break;
if (conflict != parent) {
parent = conflict;
if (!(conflict->flags & IORESOURCE_BUSY))
continue;
}

/* Uhhuh, that didn't work out.. */
kfree(res);
res = NULL;
break;
}

if (!res) {
/* failed, split and try again */

/* conflict covered whole area */
if (conflict->start <= start && conflict->end >= end)
return;
conflict = __request_resource(parent, res);
if (!conflict)
return;

if (conflict->start > start)
__reserve_region_with_split(root, start, conflict->start-1, name);
if (!(conflict->flags & IORESOURCE_BUSY)) {
resource_size_t common_start, common_end;
/* failed, split and try again */
kfree(res);

common_start = max(conflict->start, start);
common_end = min(conflict->end, end);
if (common_start < common_end)
__reserve_region_with_split(root, common_start, common_end, name);
}
if (conflict->end < end)
__reserve_region_with_split(root, conflict->end+1, end, name);
}
/* conflict covered whole area */
if (conflict->start <= start && conflict->end >= end)
return;

if (conflict->start > start)
__reserve_region_with_split(root, start, conflict->start-1, name);
if (conflict->end < end)
__reserve_region_with_split(root, conflict->end+1, end, name);
}

void __init reserve_region_with_split(struct resource *root,
Expand Down

0 comments on commit ff54250

Please sign in to comment.