[PATCH 2/4] iosys-map: add iosys_map_read_from() helper

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



It allows to copy data from iosys_map into the user memory,
regardless whether iosys_map points to memory or I/O memory.

Signed-off-by: Michal Wajdeczko <michal.wajdeczko@xxxxxxxxx>
---
Cc: linux-fsdevel@xxxxxxxxxxxxxxx
Cc: dri-devel@xxxxxxxxxxxxxxxxxxxxx
Cc: Lucas De Marchi <lucas.demarchi@xxxxxxxxx>
---
 include/linux/iosys-map.h | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)

diff --git a/include/linux/iosys-map.h b/include/linux/iosys-map.h
index 4696abfd311c..eb79da976211 100644
--- a/include/linux/iosys-map.h
+++ b/include/linux/iosys-map.h
@@ -7,6 +7,7 @@
 #define __IOSYS_MAP_H__
 
 #include <linux/compiler_types.h>
+#include <linux/fs.h>
 #include <linux/io.h>
 #include <linux/string.h>
 
@@ -312,6 +313,29 @@ static inline void iosys_map_memcpy_from(void *dst, const struct iosys_map *src,
 		memcpy(dst, src->vaddr + src_offset, len);
 }
 
+/**
+ * iosys_map_read_from - Copy data from iosys_map into user memory
+ * @to: the user space buffer to read to
+ * @count: the maximum number of bytes to read
+ * @ppos: the current position in the buffer
+ * @map: the iosys_map structure to read from
+ * @available: the size of the data in iosys_map
+ *
+ * Copies up to @count bytes from a iosys_map @map at offset @ppos into the user
+ * space address starting at @to.
+ *
+ * Return: On success, the number of bytes read is returned and the offset
+ * @ppos is advanced by this number, or negative value is returned on error.
+ */
+static inline ssize_t iosys_map_read_from(void __user *to, size_t count, loff_t *ppos,
+					  const struct iosys_map *map, size_t available)
+{
+	if (map->is_iomem)
+		return simple_read_from_iomem(to, count, ppos, map->vaddr_iomem, available);
+	else
+		return simple_read_from_buffer(to, count, ppos, map->vaddr, available);
+}
+
 /**
  * iosys_map_incr - Increments the address stored in a iosys mapping
  * @map:	The iosys_map structure
-- 
2.43.0





[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [NTFS 3]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [NTFS 3]     [Samba]     [Device Mapper]     [CEPH Development]

  Powered by Linux