@@ -336,8 +336,11 @@ static inline void iosys_map_memset(struct iosys_map *dst, size_t offset,
#ifdef CONFIG_64BIT
#define __iosys_map_rd_io_u64_case(val_, vaddr_iomem_) \
u64: val_ = readq(vaddr_iomem_),
+#define __iosys_map_wr_io_u64_case(val_, vaddr_iomem_) \
+ u64: writeq(val_, vaddr_iomem_),
#else
#define __iosys_map_rd_io_u64_case(val_, vaddr_iomem_)
+#define __iosys_map_wr_io_u64_case(val_, vaddr_iomem_)
#endif
#define __iosys_map_rd_io(val__, vaddr_iomem__, type__) _Generic(val__, \
@@ -347,6 +350,13 @@ static inline void iosys_map_memset(struct iosys_map *dst, size_t offset,
__iosys_map_rd_io_u64_case(val__, vaddr_iomem__) \
default: memcpy_fromio(&(val__), vaddr_iomem__, sizeof(val__)))
+#define __iosys_map_wr_io(val__, vaddr_iomem__, type__) _Generic(val__, \
+ u8: writeb(val__, vaddr_iomem__), \
+ u16: writew(val__, vaddr_iomem__), \
+ u32: writel(val__, vaddr_iomem__), \
+ __iosys_map_wr_io_u64_case(val__, vaddr_iomem__) \
+ default: memcpy_toio(vaddr_iomem__, &val, sizeof(val)))
+
/**
* iosys_map_rd - Read a C-type value from the iosys_map
*
@@ -381,9 +391,13 @@ static inline void iosys_map_memset(struct iosys_map *dst, size_t offset,
* Write a C-type value to the iosys_map, handling possible un-aligned accesses
* to the mapping.
*/
-#define iosys_map_wr(map__, offset__, type__, val__) ({ \
- type__ val = (val__); \
- iosys_map_memcpy_to(map__, offset__, &val, sizeof(val)); \
+#define iosys_map_wr(map__, offset__, type__, val__) ({ \
+ type__ val = (val__); \
+ if ((map__)->is_iomem) { \
+ __iosys_map_wr_io(val, (map__)->vaddr_iomem + offset__, type__);\
+ } else { \
+ memcpy((map__)->vaddr + offset__, &val, sizeof(val)); \
+ } \
})
/**
Like was done for read, provide the equivalent for write. Even if current users are not in the hot path, this should future-proof it. Signed-off-by: Lucas De Marchi <lucas.demarchi@intel.com> --- include/linux/iosys-map.h | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-)