Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

resource: replace open coded resource_intersection()

Patch series "resource: A couple of cleanups".

A couple of ad-hoc cleanups since there was a recent development of
the code in question. No functional changes intended.


This patch (of 2):

__region_intersects() uses open coded resource_intersection(). Replace it
with existing API which also make more clear what we are checking.

Link: https://lkml.kernel.org/r/20240925154355.1170859-1-andriy.shevchenko@linux.intel.com
Link: https://lkml.kernel.org/r/20240925154355.1170859-2-andriy.shevchenko@linux.intel.com
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Cc: Rasmus Villemoes <linux@rasmusvillemoes.dk>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

authored by

Andy Shevchenko and committed by
Andrew Morton
5c1edea7 83801018

+6 -9
+6 -9
kernel/resource.c
··· 537 537 size_t size, unsigned long flags, 538 538 unsigned long desc) 539 539 { 540 - resource_size_t ostart, oend; 541 540 int type = 0; int other = 0; 542 541 struct resource *p, *dp; 542 + struct resource res, o; 543 543 bool is_type, covered; 544 - struct resource res; 545 544 546 545 res.start = start; 547 546 res.end = start + size - 1; 548 547 549 548 for (p = parent->child; p ; p = p->sibling) { 550 - if (!resource_overlaps(p, &res)) 549 + if (!resource_intersection(p, &res, &o)) 551 550 continue; 552 551 is_type = (p->flags & flags) == flags && 553 552 (desc == IORES_DESC_NONE || desc == p->desc); ··· 567 568 * |-- "System RAM" --||-- "CXL Window 0a" --| 568 569 */ 569 570 covered = false; 570 - ostart = max(res.start, p->start); 571 - oend = min(res.end, p->end); 572 571 for_each_resource(p, dp, false) { 573 572 if (!resource_overlaps(dp, &res)) 574 573 continue; ··· 575 578 if (is_type) { 576 579 type++; 577 580 /* 578 - * Range from 'ostart' to 'dp->start' 581 + * Range from 'o.start' to 'dp->start' 579 582 * isn't covered by matched resource. 580 583 */ 581 - if (dp->start > ostart) 584 + if (dp->start > o.start) 582 585 break; 583 - if (dp->end >= oend) { 586 + if (dp->end >= o.end) { 584 587 covered = true; 585 588 break; 586 589 } 587 590 /* Remove covered range */ 588 - ostart = max(ostart, dp->end + 1); 591 + o.start = max(o.start, dp->end + 1); 589 592 } 590 593 } 591 594 if (!covered)