[PATCH 1/3] include: linux: ioport.h: port resource_set_range from linux
Michael Grzeschik
m.grzeschik at pengutronix.de
Mon Nov 17 13:29:26 PST 2025
This is a preparation patch for potential users to follow.
Signed-off-by: Michael Grzeschik <m.grzeschik at pengutronix.de>
---
include/linux/ioport.h | 31 +++++++++++++++++++++++++++++++
1 file changed, 31 insertions(+)
diff --git a/include/linux/ioport.h b/include/linux/ioport.h
index 290f9feddcb900d92b61169acc46d7e1ead62c91..e24984f7f722eae5466a4e198457adda6601bf77 100644
--- a/include/linux/ioport.h
+++ b/include/linux/ioport.h
@@ -234,5 +234,36 @@ static inline bool is_reserved_resource(const struct resource *res)
return false;
}
+/**
+ * resource_set_size - Calculate resource end address from size and start
+ * @res: Resource descriptor
+ * @size: Size of the resource
+ *
+ * Calculate the end address for @res based on @size.
+ *
+ * Note: The start address of @res must be set when calling this function.
+ * Prefer resource_set_range() if setting both the start address and @size.
+ */
+static inline void resource_set_size(struct resource *res, resource_size_t size)
+{
+ res->end = res->start + size - 1;
+}
+
+/**
+ * resource_set_range - Set resource start and end addresses
+ * @res: Resource descriptor
+ * @start: Start address for the resource
+ * @size: Size of the resource
+ *
+ * Set @res start address and calculate the end address based on @size.
+ */
+static inline void resource_set_range(struct resource *res,
+ resource_size_t start,
+ resource_size_t size)
+{
+ res->start = start;
+ resource_set_size(res, size);
+}
+
#endif /* __ASSEMBLY__ */
#endif /* _LINUX_IOPORT_H */
--
2.47.3
More information about the barebox
mailing list