diff options
Diffstat (limited to 'kernel/resource.c')
-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 7797dae85b50..4089d12af6e0 100644 --- a/kernel/resource.c +++ b/kernel/resource.c | |||
@@ -626,33 +626,34 @@ struct resource * __request_region(struct resource *parent, | |||
626 | { | 626 | { |
627 | struct resource *res = kzalloc(sizeof(*res), GFP_KERNEL); | 627 | struct resource *res = kzalloc(sizeof(*res), GFP_KERNEL); |
628 | 628 | ||
629 | if (res) { | 629 | if (!res) |
630 | res->name = name; | 630 | return NULL; |
631 | res->start = start; | ||
632 | res->end = start + n - 1; | ||
633 | res->flags = IORESOURCE_BUSY; | ||
634 | 631 | ||
635 | write_lock(&resource_lock); | 632 | res->name = name; |
633 | res->start = start; | ||
634 | res->end = start + n - 1; | ||
635 | res->flags = IORESOURCE_BUSY; | ||
636 | 636 | ||
637 | for (;;) { | 637 | write_lock(&resource_lock); |
638 | struct resource *conflict; | ||
639 | 638 | ||
640 | conflict = __request_resource(parent, res); | 639 | for (;;) { |
641 | if (!conflict) | 640 | struct resource *conflict; |
642 | break; | ||
643 | if (conflict != parent) { | ||
644 | parent = conflict; | ||
645 | if (!(conflict->flags & IORESOURCE_BUSY)) | ||
646 | continue; | ||
647 | } | ||
648 | 641 | ||
649 | /* Uhhuh, that didn't work out.. */ | 642 | conflict = __request_resource(parent, res); |
650 | kfree(res); | 643 | if (!conflict) |
651 | res = NULL; | ||
652 | break; | 644 | break; |
645 | if (conflict != parent) { | ||
646 | parent = conflict; | ||
647 | if (!(conflict->flags & IORESOURCE_BUSY)) | ||
648 | continue; | ||
653 | } | 649 | } |
654 | write_unlock(&resource_lock); | 650 | |
651 | /* Uhhuh, that didn't work out.. */ | ||
652 | kfree(res); | ||
653 | res = NULL; | ||
654 | break; | ||
655 | } | 655 | } |
656 | write_unlock(&resource_lock); | ||
656 | return res; | 657 | return res; |
657 | } | 658 | } |
658 | EXPORT_SYMBOL(__request_region); | 659 | EXPORT_SYMBOL(__request_region); |