All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 1/3] resource: Introduce a new helper resource_contains_addr()
@ 2025-07-02  7:20 Li Ming
  2025-07-02  7:20 ` [PATCH v2 2/3] cxl/edac: Fix wrong dpa checking for PPR operation Li Ming
                   ` (4 more replies)
  0 siblings, 5 replies; 15+ messages in thread
From: Li Ming @ 2025-07-02  7:20 UTC (permalink / raw)
  To: akpm, andriy.shevchenko, bhelgaas, ilpo.jarvinen, dave,
	jonathan.cameron, dave.jiang, alison.schofield, vishal.l.verma,
	ira.weiny, dan.j.williams, shiju.jose
  Cc: linux-cxl, linux-kernel, Li Ming

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.

Suggested-by: Alison Schofield <alison.schofield@intel.com>
Signed-off-by: Li Ming <ming.li@zohomail.com>
---
v2:
* Implement a general helper resource_contains_addr(). (Alison)

base-commit: 0a46f60a9fe16f5596b6b4b3ee1a483ea7854136 cxl/fixes
---
 include/linux/ioport.h | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/include/linux/ioport.h b/include/linux/ioport.h
index e8b2d6aa4013..75f5e9ccd549 100644
--- a/include/linux/ioport.h
+++ b/include/linux/ioport.h
@@ -308,6 +308,14 @@ static inline bool resource_contains(const struct resource *r1, const struct res
 	return r1->start <= r2->start && r1->end >= r2->end;
 }
 
+/* True if res contains addr */
+static inline bool resource_contains_addr(const struct resource *res, const resource_size_t addr)
+{
+	if (res->flags & IORESOURCE_UNSET)
+		return false;
+	return res->start <= addr && addr <= res->end;
+}
+
 /* True if any part of r1 overlaps r2 */
 static inline bool resource_overlaps(const struct resource *r1, const struct resource *r2)
 {
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2025-07-07  4:19 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-07-02  7:20 [PATCH v2 1/3] resource: Introduce a new helper resource_contains_addr() Li Ming
2025-07-02  7:20 ` [PATCH v2 2/3] cxl/edac: Fix wrong dpa checking for PPR operation Li Ming
2025-07-02  8:24   ` Andy Shevchenko
2025-07-02 19:38   ` Alison Schofield
2025-07-03  9:57     ` Li Ming
2025-07-03  9:52   ` Shiju Jose
2025-07-02  7:20 ` [PATCH v2 3/3] cxl/core: Using resource_contains_addr() to check address availability Li Ming
2025-07-02  8:16 ` [PATCH v2 1/3] resource: Introduce a new helper resource_contains_addr() Andy Shevchenko
2025-07-02  8:18   ` Andy Shevchenko
2025-07-02 19:16   ` Alison Schofield
2025-07-03  9:31     ` Andy Shevchenko
2025-07-07  4:19       ` Li Ming
2025-07-02  8:21 ` Andy Shevchenko
2025-07-03  5:33   ` Li Ming
2025-07-03  9:52 ` Shiju Jose

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.