Re: [PATCH v2 1/3] resource: Introduce a new helper resource_contains_addr()

From: Andy Shevchenko
Date: Wed Jul 02 2025 - 04:16:52 EST


On Wed, Jul 02, 2025 at 03:20:06PM +0800, Li Ming wrote:
> In CXL subsystem, many functions need to check an address availability
> by checking if the resource range contains the address. Providing a new
> helper function resource_contains_addr() to check if the resource range
> contains the input address.

resources are about ranges and not addresses. At bare minimum naming sucks
here. Also there is no symmetry with the intersection API. But I would argue
to use resource_contains() and just provide necessary parameter with both
start and end to be set at the same value.

struct resource r = DEFINE_RES...(addr);

if (resource_contains, res, &r)
...do stuff...

--
With Best Regards,
Andy Shevchenko