@@ -216,6 +216,38 @@ struct resource *lookup_resource(struct resource *root, resource_size_t start);
int adjust_resource(struct resource *res, resource_size_t start,
resource_size_t size);
resource_size_t resource_alignment(struct resource *res);
+
+/**
+ * resource_set_size - Calculates resource end address from size and start address
+ * @res: The resource descriptor
+ * @size: The size of the resource
+ *
+ * Calculates the end address for @res based on @size.
+ *
+ * Note: The start address of @res must be set when calling this function.
+ * Use 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 - Sets resource start and end addresses
+ * @res: The resource descriptor
+ * @start: The start address for the resource
+ * @size: The size of the resource
+ *
+ * Sets @res start address and calculates 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);
+}
+
static inline resource_size_t resource_size(const struct resource *res)
{
return res->end - res->start + 1;