__find_resource_space() currently uses resource_contains() but for tentative resources that are not yet crafted into the resource tree. As resource_contains() checks that IORESOURCE_UNSET is not set for either of the resources, the caller has to hack around this problem by clearing the IORESOURCE_UNSET flag (essentially lying to resource_contains()). Instead of the hack, introduce __resource_contains_unbound() for cases like this.
Showing the changes to kernel (1 of 2 files). Show all
Unified · Split
| @@ -754,7 +754,7 @@ static int __find_resource_space(struct resource *root, struct resource *old, · 753 unmodified lines | ||
| 754 | 754 | /* Check for overflow after ALIGN() */ |
| 755 | 755 | avail.start = ALIGN(tmp.start, constraint->align); |
| 756 | 756 | avail.end = tmp.end; |
| 757 | − avail.flags = new->flags & ~IORESOURCE_UNSET; | |
| 757 | + avail.flags = new->flags; | |
| 758 | 758 | if (avail.start >= tmp.start) { |
| 759 | 759 | alloc.flags = avail.flags; |
| 760 | 760 | if (alignf) { |
| @@ -765,7 +765,7 @@ static int __find_resource_space(struct resource *root, struct resource *old, · 4 unmodified lines | ||
| 765 | 765 | } |
| 766 | 766 | alloc.end = alloc.start + size - 1; |
| 767 | 767 | if (alloc.start <= alloc.end && |
| 768 | − resource_contains(&avail, &alloc)) { | |
| 768 | + __resource_contains_unbound(&avail, &alloc)) { | |
| 769 | 769 | new->start = alloc.start; |
| 770 | 770 | new->end = alloc.end; |
| 771 | 771 | return 0; |