[v3,2/5] include: linux: v4l2-isp: Provide __counted_by()
diff mbox series

Message ID 20250926-v4l2-params-v3-2-ee114782c1be@ideasonboard.com
State New
Headers show
Series
  • ipa: libipa: Introduce V4L2Params
Related show

Commit Message

Jacopo Mondi Sept. 26, 2025, 2:39 p.m. UTC
The v4l2-isp.h header exported from version
https://lore.kernel.org/all/20250915-extensible-parameters-validation-v5-0-e6db94468af3@ideasonboard.com/

includes the __counted_by() macro, which is not availale in Linux
uAPI headers older than version v6.5.

Provide the macro here, to support older kernel versions.

Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
---
 include/linux/media/v4l2-isp.h | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

Patch
diff mbox series

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)