[PATCH 1/2] iosys-map: Add getter functions for virtual addresses
From: oushixiong1025
Date: Fri Jul 24 2026 - 05:43:00 EST
From: Shixiong Ou <oushixiong@xxxxxxxxxx>
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@xxxxxxxxxx>
---
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