mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Michael Grzeschik <m.grzeschik@pengutronix.de>
To: Sascha Hauer <s.hauer@pengutronix.de>,
	 BAREBOX <barebox@lists.infradead.org>
Subject: [PATCH 1/3] include: linux: ioport.h: port resource_set_range from linux
Date: Mon, 17 Nov 2025 22:29:26 +0100	[thread overview]
Message-ID: <20251117-simplefb-fixup-v1-1-7824d99b3fb3@pengutronix.de> (raw)
In-Reply-To: <20251117-simplefb-fixup-v1-0-7824d99b3fb3@pengutronix.de>

This is a preparation patch for potential users to follow.

Signed-off-by: Michael Grzeschik <m.grzeschik@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




  reply	other threads:[~2025-11-17 21:30 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-11-17 21:29 [PATCH 0/3] simplefb-fixup: fixes for 64bit systems Michael Grzeschik
2025-11-17 21:29 ` Michael Grzeschik [this message]
2025-11-17 21:29 ` [PATCH 2/3] simplefb-fixup: depend res fields on root size-cells and addr-cells Michael Grzeschik
2025-11-17 21:29 ` [PATCH 3/3] simplefb-fixup: add reserved memory-region entry for the simple-framebuffer Michael Grzeschik
2025-11-18  7:30 ` [PATCH 0/3] simplefb-fixup: fixes for 64bit systems Sascha Hauer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20251117-simplefb-fixup-v1-1-7824d99b3fb3@pengutronix.de \
    --to=m.grzeschik@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    --cc=s.hauer@pengutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox