diff options
-rw-r--r-- | kernel/resource.c | 41 |
1 files changed, 21 insertions, 20 deletions
diff --git a/kernel/resource.c b/kernel/resource.c index 414d6fc9131e..f193d6e3ded2 100644 --- a/kernel/resource.c +++ b/kernel/resource.c | |||
@@ -630,33 +630,34 @@ struct resource * __request_region(struct resource *parent, | |||
630 | { | 630 | { |
631 | struct resource *res = kzalloc(sizeof(*res), GFP_KERNEL); | 631 | struct resource *res = kzalloc(sizeof(*res), GFP_KERNEL); |
632 | 632 | ||
633 | if (res) { | 633 | if (!res) |
634 | res->name = name; | 634 | return NULL; |
635 | res->start = start; | ||
636 | res->end = start + n - 1; | ||
637 | res->flags = IORESOURCE_BUSY; | ||
638 | 635 | ||
639 | write_lock(&resource_lock); | 636 | res->name = name; |
637 | res->start = start; | ||
638 | res->end = start + n - 1; | ||
639 | res->flags = IORESOURCE_BUSY; | ||
640 | 640 | ||
641 | for (;;) { | 641 | write_lock(&resource_lock); |
642 | struct resource *conflict; | ||
643 | 642 | ||
644 | conflict = __request_resource(parent, res); | 643 | for (;;) { |
645 | if (!conflict) | 644 | struct resource *conflict; |
646 | break; | ||
647 | if (conflict != parent) { | ||
648 | parent = conflict; | ||
649 | if (!(conflict->flags & IORESOURCE_BUSY)) | ||
650 | continue; | ||
651 | } | ||
652 | 645 | ||
653 | /* Uhhuh, that didn't work out.. */ | 646 | conflict = __request_resource(parent, res); |
654 | kfree(res); | 647 | if (!conflict) |
655 | res = NULL; | ||
656 | break; | 648 | break; |
649 | if (conflict != parent) { | ||
650 | parent = conflict; | ||
651 | if (!(conflict->flags & IORESOURCE_BUSY)) | ||
652 | continue; | ||
657 | } | 653 | } |
658 | write_unlock(&resource_lock); | 654 | |
655 | /* Uhhuh, that didn't work out.. */ | ||
656 | kfree(res); | ||
657 | res = NULL; | ||
658 | break; | ||
659 | } | 659 | } |
660 | write_unlock(&resource_lock); | ||
660 | return res; | 661 | return res; |
661 | } | 662 | } |
662 | EXPORT_SYMBOL(__request_region); | 663 | EXPORT_SYMBOL(__request_region); |