diff --git a/include/linux/media/v4l2-isp.h b/include/linux/media/v4l2-isp.h
index fed89b5678585a3565d33cf873d0313dc089524f..ea23dfdeeab9e69959cd8fa3c4853e931f36198a 100644
--- a/include/linux/media/v4l2-isp.h
+++ b/include/linux/media/v4l2-isp.h
@@ -12,6 +12,24 @@
 #include <linux/stddef.h>
 #include <linux/types.h>
 
+/*
+ * Provide __counted_by() if not available in linux/stddef.h
+ *
+ * The Linux macro __counted_by() has been introduced in kernel v6.5 and
+ * is not available in older kernel version.
+ *
+ * See commit dd06e72e68bc ("Compiler Attributes: Add __counted_by macro")
+ *
+ * Provide it here if not available.
+ */
+#if not defined(__counted_by)
+#if __has_attribute(__counted_by__)
+# define __counted_by(member)		__attribute__((__counted_by__(member)))
+#else
+# define __counted_by(member)
+#endif
+#endif
+
 #define V4L2_PARAMS_FL_BLOCK_DISABLE	(1U << 0)
 #define V4L2_PARAMS_FL_BLOCK_ENABLE	(1U << 1)
 
