mirror of
https://github.com/torvalds/linux.git
synced 2025-12-01 07:26:02 +07:00
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>
This commit is contained in:
committed by
Andrew Morton
parent
8380101802
commit
5c1edea773
@@ -537,17 +537,16 @@ static int __region_intersects(struct resource *parent, resource_size_t start,
|
|||||||
size_t size, unsigned long flags,
|
size_t size, unsigned long flags,
|
||||||
unsigned long desc)
|
unsigned long desc)
|
||||||
{
|
{
|
||||||
resource_size_t ostart, oend;
|
|
||||||
int type = 0; int other = 0;
|
int type = 0; int other = 0;
|
||||||
struct resource *p, *dp;
|
struct resource *p, *dp;
|
||||||
|
struct resource res, o;
|
||||||
bool is_type, covered;
|
bool is_type, covered;
|
||||||
struct resource res;
|
|
||||||
|
|
||||||
res.start = start;
|
res.start = start;
|
||||||
res.end = start + size - 1;
|
res.end = start + size - 1;
|
||||||
|
|
||||||
for (p = parent->child; p ; p = p->sibling) {
|
for (p = parent->child; p ; p = p->sibling) {
|
||||||
if (!resource_overlaps(p, &res))
|
if (!resource_intersection(p, &res, &o))
|
||||||
continue;
|
continue;
|
||||||
is_type = (p->flags & flags) == flags &&
|
is_type = (p->flags & flags) == flags &&
|
||||||
(desc == IORES_DESC_NONE || desc == p->desc);
|
(desc == IORES_DESC_NONE || desc == p->desc);
|
||||||
@@ -568,8 +567,6 @@ static int __region_intersects(struct resource *parent, resource_size_t start,
|
|||||||
* |-- "System RAM" --||-- "CXL Window 0a" --|
|
* |-- "System RAM" --||-- "CXL Window 0a" --|
|
||||||
*/
|
*/
|
||||||
covered = false;
|
covered = false;
|
||||||
ostart = max(res.start, p->start);
|
|
||||||
oend = min(res.end, p->end);
|
|
||||||
for_each_resource(p, dp, false) {
|
for_each_resource(p, dp, false) {
|
||||||
if (!resource_overlaps(dp, &res))
|
if (!resource_overlaps(dp, &res))
|
||||||
continue;
|
continue;
|
||||||
@@ -578,17 +575,17 @@ static int __region_intersects(struct resource *parent, resource_size_t start,
|
|||||||
if (is_type) {
|
if (is_type) {
|
||||||
type++;
|
type++;
|
||||||
/*
|
/*
|
||||||
* Range from 'ostart' to 'dp->start'
|
* Range from 'o.start' to 'dp->start'
|
||||||
* isn't covered by matched resource.
|
* isn't covered by matched resource.
|
||||||
*/
|
*/
|
||||||
if (dp->start > ostart)
|
if (dp->start > o.start)
|
||||||
break;
|
break;
|
||||||
if (dp->end >= oend) {
|
if (dp->end >= o.end) {
|
||||||
covered = true;
|
covered = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
/* Remove covered range */
|
/* Remove covered range */
|
||||||
ostart = max(ostart, dp->end + 1);
|
o.start = max(o.start, dp->end + 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!covered)
|
if (!covered)
|
||||||
|
|||||||
Reference in New Issue
Block a user