aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/resource.c
diff options
context:
space:
mode:
authorBjorn Helgaas <bjorn.helgaas@hp.com>2010-10-26 17:41:18 -0400
committerJesse Barnes <jbarnes@virtuousgeek.org>2010-10-26 18:33:24 -0400
commit5d6b1fa301b13cc651ee717a9b518124dea2f814 (patch)
tree53958650b23a85cbd1b58ebd9346fe62603c3a0d /kernel/resource.c
parenta9cea017411c95ec789092971f9baaef1f826883 (diff)
resources: factor out resource_clip() to simplify find_resource()
This factors out the min/max clipping to simplify find_resource(). No functional change. Signed-off-by: Bjorn Helgaas <bjorn.helgaas@hp.com> Signed-off-by: Jesse Barnes <jbarnes@virtuousgeek.org>
Diffstat (limited to 'kernel/resource.c')
-rw-r--r--kernel/resource.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/kernel/resource.c b/kernel/resource.c
index 7dc8ad24f915..26e9f2546923 100644
--- a/kernel/resource.c
+++ b/kernel/resource.c
@@ -365,6 +365,15 @@ static resource_size_t simple_align_resource(void *data,
365 return avail->start; 365 return avail->start;
366} 366}
367 367
368static void resource_clip(struct resource *res, resource_size_t min,
369 resource_size_t max)
370{
371 if (res->start < min)
372 res->start = min;
373 if (res->end > max)
374 res->end = max;
375}
376
368/* 377/*
369 * Find empty slot in the resource tree given range and alignment. 378 * Find empty slot in the resource tree given range and alignment.
370 */ 379 */
@@ -394,10 +403,8 @@ static int find_resource(struct resource *root, struct resource *new,
394 tmp.end = this->start - 1; 403 tmp.end = this->start - 1;
395 else 404 else
396 tmp.end = root->end; 405 tmp.end = root->end;
397 if (tmp.start < min) 406
398 tmp.start = min; 407 resource_clip(&tmp, min, max);
399 if (tmp.end > max)
400 tmp.end = max;
401 tmp.start = ALIGN(tmp.start, align); 408 tmp.start = ALIGN(tmp.start, align);
402 409
403 tmp.start = alignf(alignf_data, &tmp, size, align); 410 tmp.start = alignf(alignf_data, &tmp, size, align);