History

resource: Add __resource_contains_unbound() for internal contains checks

__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.

Ilpo Järvinen committed 7 months ago

Commit edfaa811 parent 1ee47162 files · +19 −5Browse files

Showing the changes to kernel (1 of 2 files). Show all

Unified · Split

kernel/resource.c+2−2
@@ -754,7 +754,7 @@ static int __find_resource_space(struct resource *root, struct resource *old, · 753 unmodified lines
754 /* Check for overflow after ALIGN() */754 /* Check for overflow after ALIGN() */
755 avail.start = ALIGN(tmp.start, constraint->align);755 avail.start = ALIGN(tmp.start, constraint->align);
756 avail.end = tmp.end;756 avail.end = tmp.end;
757 avail.flags = new->flags & ~IORESOURCE_UNSET;757 avail.flags = new->flags;
758 if (avail.start >= tmp.start) {758 if (avail.start >= tmp.start) {
759 alloc.flags = avail.flags;759 alloc.flags = avail.flags;
760 if (alignf) {760 if (alignf) {
@@ -765,7 +765,7 @@ static int __find_resource_space(struct resource *root, struct resource *old, · 4 unmodified lines
765 }765 }
766 alloc.end = alloc.start + size - 1;766 alloc.end = alloc.start + size - 1;
767 if (alloc.start <= alloc.end &&767 if (alloc.start <= alloc.end &&
768 resource_contains(&avail, &alloc)) {768 __resource_contains_unbound(&avail, &alloc)) {
769 new->start = alloc.start;769 new->start = alloc.start;
770 new->end = alloc.end;770 new->end = alloc.end;
771 return 0;771 return 0;