All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] iosys-map: Add getter functions for virtual addresses
@ 2026-07-24  9:38 oushixiong1025
  2026-07-24  9:38 ` [PATCH 2/2] drm/udl: Use iosys_map getter for virtual address oushixiong1025
  2026-07-24  9:52 ` [PATCH 1/2] iosys-map: Add getter functions for virtual addresses sashiko-bot
  0 siblings, 2 replies; 5+ messages in thread
From: oushixiong1025 @ 2026-07-24  9:38 UTC (permalink / raw)
  To: Thomas Zimmermann; +Cc: dri-devel, linux-kernel, Shixiong Ou

From: Shixiong Ou <oushixiong@kylinos.cn>

Add iosys_map_get_vaddr() and iosys_map_get_vaddr_iomem() as the
counterparts to iosys_map_set_vaddr() and iosys_map_set_vaddr_iomem().

This allows drivers to use the iosys_map abstraction layer properly
instead of directly accessing the structure members, improving code
maintainability and safety.

Signed-off-by: Shixiong Ou <oushixiong@kylinos.cn>
---
 include/linux/iosys-map.h | 36 ++++++++++++++++++++++++++++++++++++
 1 file changed, 36 insertions(+)

diff --git a/include/linux/iosys-map.h b/include/linux/iosys-map.h
index 3e85afe794c0..658d5038498a 100644
--- a/include/linux/iosys-map.h
+++ b/include/linux/iosys-map.h
@@ -200,6 +200,42 @@ static inline void iosys_map_set_vaddr_iomem(struct iosys_map *map,
 	map->is_iomem = true;
 }
 
+/**
+ * iosys_map_get_vaddr - Gets the virtual address of a system-memory mapping
+ * @map:	The iosys_map structure
+ *
+ * Returns the system-memory address. The caller must ensure the mapping
+ * refers to system memory (not I/O memory).
+ *
+ * Returns:
+ * The system-memory address, or NULL if the mapping is not set or refers
+ * to I/O memory.
+ */
+static inline void *iosys_map_get_vaddr(const struct iosys_map *map)
+{
+	if (WARN_ON(map->is_iomem))
+		return NULL;
+	return map->vaddr;
+}
+
+/**
+ * iosys_map_get_vaddr_iomem - Gets the virtual address of an I/O-memory mapping
+ * @map:	The iosys_map structure
+ *
+ * Returns the I/O-memory address. The caller must ensure the mapping
+ * refers to I/O memory (not system memory).
+ *
+ * Returns:
+ * The I/O-memory address, or NULL if the mapping is not set or refers
+ * to system memory.
+ */
+static inline void __iomem *iosys_map_get_vaddr_iomem(const struct iosys_map *map)
+{
+	if (WARN_ON(!map->is_iomem))
+		return NULL;
+	return map->vaddr_iomem;
+}
+
 /**
  * iosys_map_is_equal - Compares two iosys mapping structures for equality
  * @lhs:	The iosys_map structure
-- 
2.25.1


No virus found
		Checked by Hillstone Network AntiVirus


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

end of thread, other threads:[~2026-07-24 11:29 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-24  9:38 [PATCH 1/2] iosys-map: Add getter functions for virtual addresses oushixiong1025
2026-07-24  9:38 ` [PATCH 2/2] drm/udl: Use iosys_map getter for virtual address oushixiong1025
2026-07-24  9:52   ` sashiko-bot
2026-07-24 11:29   ` Thomas Zimmermann
2026-07-24  9:52 ` [PATCH 1/2] iosys-map: Add getter functions for virtual addresses sashiko-bot

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.