[Intel-gfx] [PATCH 1/2] iosys-map: Add a helper for pointer difference

Lucas De Marchi lucas.demarchi at intel.com
Wed Mar 9 01:13:09 UTC 2022


On Tue, Mar 08, 2022 at 03:08:04PM +0530, Mullati Siva wrote:
>From: Siva Mullati <siva.mullati at intel.com>
>
>iosys_map_ptrdiff to get the difference in address of
>same memory type.
>
>Signed-off-by: Siva Mullati <siva.mullati at intel.com>
>---
> include/linux/iosys-map.h | 21 +++++++++++++++++++++
> 1 file changed, 21 insertions(+)
>
>diff --git a/include/linux/iosys-map.h b/include/linux/iosys-map.h
>index e69a002d5aa4..8987f69ec1e9 100644
>--- a/include/linux/iosys-map.h
>+++ b/include/linux/iosys-map.h
>@@ -8,6 +8,7 @@
>
> #include <linux/io.h>
> #include <linux/string.h>
>+#include <linux/types.h>
>
> /**
>  * DOC: overview
>@@ -208,6 +209,26 @@ static inline bool iosys_map_is_equal(const struct iosys_map *lhs,
> 		return lhs->vaddr == rhs->vaddr;
> }
>
>+/**
>+ * iosys_map_ptrdiff - Difference of two iosys mapping addresses of same memory type
>+ * @lhs:       The iosys_map structure
>+ * @rhs:       A iosys_map structure to compare with
>+ *
>+ * Two iosys mapping structures of same memory type with the differences
>+ * in address within that memory.
>+ *
>+ * Returns:
>+ * Address difference of two memory locations with same memory type.
>+ */
>+static inline ptrdiff_t iosys_map_ptrdiff(const struct iosys_map *lhs,
>+					  const struct iosys_map *rhs)
>+{
>+	if (lhs->is_iomem)

the other interfaces always check both arguments to make sure they are
both iomem. So if we want this interface we will want to check like
that.

I'm not sure this is really needed, but will depend on the secon patch,
let's wait to settle this discussion there.


thanks
Lucas De Marchi


More information about the Intel-gfx mailing list